Skip to content

Commit

Permalink
EDM-372/sob dgib client and rake task (#19582)
Browse files Browse the repository at this point in the history
* 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
jefftmarks authored Nov 25, 2024
1 parent e100bdf commit bbe1eab
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/initializers/breakers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require 'mhv_ac/configuration'
require 'mpi/configuration'
require 'pagerduty/configuration'
require 'post911_sob/dgib/configuration'
require 'preneeds/configuration'
require 'rx/configuration'
require 'sm/configuration'
Expand Down Expand Up @@ -62,6 +63,7 @@
HCA::Configuration.instance.breakers_service,
MHVAC::Configuration.instance.breakers_service,
MPI::Configuration.instance.breakers_service,
Post911SOB::DGIB::Configuration.instance.breakers_service,
Preneeds::Configuration.instance.breakers_service,
SM::Configuration.instance.breakers_service,
VAProfile::AddressValidation::Configuration.instance.breakers_service,
Expand Down
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,9 @@ dgi:
jwt:
public_key_path: spec/fixtures/post911_sob/dgib/public_test.pem
private_key_path: spec/fixtures/post911_sob/dgib/private_test.pem
claimants:
url: ~
mock: false

# Settings for the VEText integration (mobile push notifications)
vetext_push:
Expand Down
42 changes: 42 additions & 0 deletions lib/post911_sob/dgib/client.rb
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
40 changes: 40 additions & 0 deletions lib/post911_sob/dgib/configuration.rb
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
18 changes: 18 additions & 0 deletions rakelib/post911_sob.rake
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

0 comments on commit bbe1eab

Please sign in to comment.