Skip to content

Commit

Permalink
[Automated] Merged master into target k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot authored Apr 17, 2024
2 parents e3599d1 + 475ed89 commit bdd6a82
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 66 deletions.
46 changes: 19 additions & 27 deletions modules/claims_api/lib/bgs_service/local_bgs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,14 @@ def find_intent_to_file_by_ptcpnt_id_itf_type_cd(id, type)
itf_type_cd = body.at 'itfTypeCd'
itf_type_cd.content = type.to_s

make_request(endpoint: 'IntentToFileWebServiceBean/IntentToFileWebService',
action: 'findIntentToFileByPtcpntIdItfTypeCd', body:, key: 'IntentToFileDTO')
response =
make_request(
endpoint: 'IntentToFileWebServiceBean/IntentToFileWebService',
action: 'findIntentToFileByPtcpntIdItfTypeCd',
body:
)

Array.wrap(response[:intent_to_file_dto])
end

# BEGIN: switching v1 from evss to bgs. Delete after EVSS is no longer available. Fix controller first.
Expand Down Expand Up @@ -261,35 +267,21 @@ def full_body(action:, body:, namespace:, namespaces:)
body.to_s
end

def parsed_response(res, action, key = nil)
parsed = Hash.from_xml(res.body)
if action == 'findIntentToFileByPtcpntIdItfTypeCd'
itf_response = []
[parsed.dig('Envelope', 'Body', "#{action}Response", key)].flatten.each do |itf|
return itf_response if itf.nil?
def parsed_response(response, action:, key:, transform:)
body = Hash.from_xml(response.body)
keys = ['Envelope', 'Body', "#{action}Response"]
keys << key if key.present?

temp = itf.deep_transform_keys(&:underscore)
&.deep_symbolize_keys
itf_response.push(temp)
body.dig(*keys).to_h.tap do |value|
if transform
value.deep_transform_keys! do |key|
key.underscore.to_sym
end
end
return itf_response
end
if key.nil?
parsed.dig('Envelope', 'Body', "#{action}Response")
&.deep_transform_keys(&:underscore)
&.deep_symbolize_keys || {}
else
parsed.dig('Envelope', 'Body', "#{action}Response", key)
&.deep_transform_keys(&:underscore)
&.deep_symbolize_keys || {}
end
end

def namespaces
{}
end

def make_request(endpoint:, action:, body:, key: nil) # rubocop:disable Metrics/MethodLength
def make_request(endpoint:, action:, body:, key: nil, namespaces: {}, transform_response: true) # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
connection = log_duration event: 'establish_ssl_connection' do
Faraday::Connection.new(ssl: { verify_mode: @ssl_verify_mode }) do |f|
f.use :breakers
Expand Down Expand Up @@ -324,7 +316,7 @@ def make_request(endpoint:, action:, body:, key: nil) # rubocop:disable Metrics/
soap_error_handler.handle_errors(response) if response

log_duration(event: 'parsed_response', key:) do
parsed_response(response, action, key)
parsed_response(response, action:, key:, transform: transform_response)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

module ClaimsApi
class ManageRepresentativeService < ClaimsApi::LocalBGS
def endpoint
'VDC/ManageRepresentativeService'
end
private

def namespaces
{
'data' => '/data'
}
def make_request(**args)
super(
endpoint: 'VDC/ManageRepresentativeService',
namespaces: { 'data' => '/data' },
transform_response: false,
**args
)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def read_poa_request(poa_codes: nil, statuses: nil)
end

make_request(
endpoint:,
action: 'readPOARequest',
body: builder.doc.at('root').children.to_xml,
key: 'POARequestRespondReturnVO'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def update_poa_request(representative:, proc_id:)
EOXML

make_request(
endpoint:,
action: 'updatePOARequest',
body: body.to_s,
key: 'POARequestUpdate'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,30 @@

let(:expected) do
{
poa_request_respond_return_vo_list: {
vso_user_email: nil,
vso_user_first_name: 'VDC USER',
vso_user_last_name: nil,
change_address_auth: 'Y',
claimant_city: 'SEASIDE',
claimant_country: 'USA',
claimant_military_po: nil,
claimant_military_postal_code: nil,
claimant_state: 'MT',
claimant_zip: '95102',
date_request_actioned: '2015-08-05T11:33:20-05:00',
date_request_received: '2015-08-05T11:33:20-05:00',
declined_reason: nil,
health_info_auth: 'N',
poa_code: '091',
proc_id: '52095',
secondary_status: 'New',
vet_first_name: 'Wallace',
vet_last_name: 'Webb',
vet_middle_name: 'R',
vet_ptcpnt_id: '600043200'
'poaRequestRespondReturnVOList' => {
'VSOUserEmail' => nil,
'VSOUserFirstName' => 'VDC USER',
'VSOUserLastName' => nil,
'changeAddressAuth' => 'Y',
'claimantCity' => 'SEASIDE',
'claimantCountry' => 'USA',
'claimantMilitaryPO' => nil,
'claimantMilitaryPostalCode' => nil,
'claimantState' => 'MT',
'claimantZip' => '95102',
'dateRequestActioned' => '2015-08-05T11:33:20-05:00',
'dateRequestReceived' => '2015-08-05T11:33:20-05:00',
'declinedReason' => nil,
'healthInfoAuth' => 'N',
'poaCode' => '091',
'procID' => '52095',
'secondaryStatus' => 'New',
'vetFirstName' => 'Wallace',
'vetLastName' => 'Webb',
'vetMiddleName' => 'R',
'vetPtcpntID' => '600043200'
},
total_nbr_of_records: '1'
'totalNbrOfRecords' => '1'
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
use_bgs_cassette('happy_path') do
expect(subject).to eq(
{
vso_user_email: nil,
vso_user_first_name: params[:representative].first_name,
vso_user_last_name: params[:representative].last_name,
declined_reason: nil,
proc_id: params[:proc_id],
secondary_status: 'OBS',
date_request_actioned:
'VSOUserEmail' => nil,
'VSOUserFirstName' => params[:representative].first_name,
'VSOUserLastName' => params[:representative].last_name,
'declinedReason' => nil,
'procId' => params[:proc_id],
'secondaryStatus' => 'OBS',
'dateRequestActioned' =>
# Formatting this to show the difference between the date returned
# in response and the date sent in request.
Time.current.in_time_zone('America/Chicago').iso8601
Expand Down

0 comments on commit bdd6a82

Please sign in to comment.