-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ip/1429-v2
- Loading branch information
Showing
43 changed files
with
711 additions
and
175 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddPathToBanners < ActiveRecord::Migration[7.2] | ||
def change | ||
add_column :banners, :path, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddIndexToBannersPath < ActiveRecord::Migration[7.2] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
add_index :banners, :path, algorithm: :concurrently | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
lib/disability_compensation/providers/brd/lighthouse_staging_brd_provider.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'disability_compensation/providers/brd/lighthouse_brd_provider' | ||
require 'lighthouse/benefits_reference_data_staging/service' | ||
|
||
class LighthouseStagingBRDProvider < LighthouseBRDProvider | ||
def initialize(_current_user) | ||
super | ||
@service = BenefitsReferenceData::Staging::Service.new | ||
end | ||
end |
68 changes: 68 additions & 0 deletions
68
lib/lighthouse/benefits_reference_data_staging/configuration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'common/client/configuration/rest' | ||
require 'faraday/multipart' | ||
|
||
module BenefitsReferenceData | ||
## | ||
# HTTP client configuration for the {BenefitsReferenceData::Service}, | ||
# sets the base path, the base request headers, and a service name for breakers and metrics. | ||
|
||
module Staging | ||
class Configuration < Common::Client::Configuration::REST | ||
self.read_timeout = Settings.lighthouse.benefits_reference_data.timeout || 20 | ||
|
||
## | ||
# @return [String] Base path for benefits_reference_data URLs. | ||
# | ||
def base_path | ||
settings = Settings.lighthouse.benefits_reference_data | ||
url = settings.staging_url | ||
path = settings.path | ||
version = settings.version | ||
safe_slash_merge(url, path, version) | ||
end | ||
|
||
## | ||
# @return [String] Service name to use in breakers and metrics. | ||
# | ||
def service_name | ||
'BenefitsReferenceDataStaging' | ||
end | ||
|
||
## | ||
# @return [Hash] The basic headers required for any benefits_reference_data API call. | ||
# | ||
def self.base_request_headers | ||
key = Settings.lighthouse.staging_api_key | ||
message = "No api_key set for LH benefits_reference_data_staging. Please set 'lighthouse.staging_api_key'" | ||
raise message if key.nil? | ||
|
||
super.merge('apiKey' => key) | ||
end | ||
|
||
## | ||
# Creates the a connection with parsing json and adding breakers functionality. | ||
# | ||
# @return [Faraday::Connection] a Faraday connection instance. | ||
# | ||
def connection | ||
@conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday| | ||
faraday.use :breakers | ||
faraday.use Faraday::Response::RaiseError | ||
|
||
faraday.request :multipart | ||
faraday.request :json | ||
faraday.response :json | ||
faraday.adapter Faraday.default_adapter | ||
end | ||
end | ||
|
||
private | ||
|
||
def safe_slash_merge(*url_segments) | ||
url_segments.map { |segment| segment.sub(%r{^/}, '').chomp('/') }.join('/') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'common/client/base' | ||
require 'common/client/concerns/monitoring' | ||
require 'common/client/errors' | ||
require 'common/exceptions/forbidden' | ||
require 'common/exceptions/schema_validation_errors' | ||
require 'lighthouse/benefits_reference_data_staging/configuration' | ||
require 'lighthouse/benefits_reference_data/service_exception' | ||
|
||
module BenefitsReferenceData | ||
## | ||
# Proxy Service for the Lighthouse Benefits Reference Data API. | ||
|
||
module Staging | ||
class Service < Common::Client::Base | ||
include SentryLogging | ||
include Common::Client::Concerns::Monitoring | ||
|
||
configuration BenefitsReferenceData::Staging::Configuration | ||
|
||
# ap @configuration.base_request_headers; exit | ||
|
||
STATSD_KEY_PREFIX = 'api.benefits_reference_data_staging' | ||
|
||
## | ||
# Hit a Benefits Reference Data End-point | ||
# | ||
# @path end-point [string|symbol] a string or symbol of the end-point you wish to hit. | ||
# @params params hash [Hash] a hash of key-value pairs of parameters | ||
# | ||
# @return [Faraday::Response] | ||
# | ||
def get_data(path:, params: {}) | ||
headers = config.base_request_headers | ||
begin | ||
response = perform :get, path, params, headers | ||
rescue => e | ||
raise BenefitsReferenceData::ServiceException.new(e), 'Lighthouse Error' | ||
end | ||
response | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.