-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EDM-372/sob dgib client and rake task (#19582)
* create auth service * Update settings and create test keys * Update test settings * spec test for auth token service * Update codeowners * Linting * fix codeowners * Add url to settings * Client and config * Update breakers * Client and configuration * Update service name * Update client to use MEB claimant service * Remove call to meb * Build rake task to test connection * Fix comment * Fix linting
- Loading branch information
1 parent
e100bdf
commit bbe1eab
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
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,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'common/client/base' | ||
require 'post911_sob/dgib/configuration' | ||
require 'post911_sob/dgib/authentication_token_service' | ||
|
||
module Post911SOB | ||
module DGIB | ||
class Client < Common::Client::Base | ||
include Common::Client::Concerns::Monitoring | ||
|
||
configuration Post911SOB::DGIB::Configuration | ||
|
||
BENEFIT_TYPE = 'Chapter33' | ||
|
||
def initialize(claimant_id) | ||
@claimant_id = claimant_id | ||
|
||
super() | ||
end | ||
|
||
def get_entitlement_transferred_out | ||
# TO-DO add monitoring and serialized response | ||
# TO-DO Filter response by chapter33 benefit type | ||
options = { timeout: 60 } | ||
perform(:get, end_point, {}, request_headers, options) | ||
end | ||
|
||
private | ||
|
||
def end_point | ||
"transferees/#{@claimant_id}/toe" | ||
end | ||
|
||
def request_headers | ||
{ | ||
Authorization: "Bearer #{Post911SOB::DGIB::AuthenticationTokenService.call}" | ||
} | ||
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,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'common/client/configuration/rest' | ||
|
||
module Post911SOB | ||
module DGIB | ||
class Configuration < Common::Client::Configuration::REST | ||
SETTINGS = Settings.dgi.post911_sob.claimants | ||
|
||
# TO-DO: Datadog | ||
|
||
def base_path | ||
SETTINGS.url.to_s | ||
end | ||
|
||
def service_name | ||
'Post911SOB/DGIB' | ||
end | ||
|
||
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 :json | ||
|
||
faraday.response :betamocks if mock_enabled? | ||
faraday.response :snakecase, symbolize: false | ||
faraday.response :json, content_type: /\bjson/ # ensures only json content types parsed | ||
faraday.adapter Faraday.default_adapter | ||
end | ||
end | ||
|
||
private | ||
|
||
def mock_enabled? | ||
SETTINGS.mock || false | ||
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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'post911_sob/dgib/client' | ||
|
||
namespace :post911_sob do | ||
namespace :dgib do | ||
desc 'Test connection between vets-api and DGIB claimant-service' | ||
task :connect, %i[claimant_id base_url] => :environment do |_cmd, args| | ||
args.with_defaults(base_url: Settings.dgi.post911_sob.claimants.url) | ||
|
||
# Allow for base url to be overridden for testing purposes | ||
Settings.dgi.post911_sob.claimants.url = args[:base_url] | ||
|
||
client = Post911SOB::DGIB::Client.new(args[:claimant_id]) | ||
client.get_entitlement_transferred_out | ||
end | ||
end | ||
end |