Skip to content

Commit

Permalink
Adds to the get_fault_info method in the soap_error_handler. Changes …
Browse files Browse the repository at this point in the history
…the test url from dev to staging in test.yml. Adds vnp_ptcpnt_service and test, with cassette - WIP. Adds method in local_bgs to check for requreed params once we know what those are.
  • Loading branch information
stiehlrod committed Mar 25, 2024
1 parent 02ff64f commit 68833ac
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/settings/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ bgs:
application: VAgovAPI
client_station_id: 281
client_username: VAgovAPI
url: https://internal-dsva-vagov-dev-fwdproxy-1893365470.us-gov-west-1.elb.amazonaws.com:4447
url: https://internal-dsva-vagov-staging-fwdproxy-1893365470.us-gov-west-1.elb.amazonaws.com:4447
# To create a new VCR cassette:
# 1. Uncomment these lines
# 2. Create an empty cassette file
Expand Down
7 changes: 7 additions & 0 deletions modules/claims_api/lib/bgs_service/local_bgs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,11 @@ def to_camelcase(claim:)
claim.deep_transform_keys { |k| k.to_s.camelize(:lower) }
end
end

def validate_required_keys(required_keys, provided_hash, call)
required_keys.each do |key|
raise(ArgumentError, "#{key} is a required key in #{call}") unless provided_hash.key?(key)
raise(ArgumentError, "#{key} cannot be empty or nil") if provided_hash[key].blank?
end
end
end
36 changes: 36 additions & 0 deletions modules/claims_api/lib/bgs_service/vnp_ptcpnt_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

module ClaimsApi
class VnpPtcpntService < ClaimsApi::LocalBGS
# vnpPtcpntCreate - This service is used to create VONAPP participant information
def vnp_ptcpnt_create(options) # rubocop:disable Metrics/MethodLength
# validate_required_keys(vnp_ptcpnt_create_required_keys, options, __method__.to_s)
options[:ptcpnt_type_nm] = 'Person' if options[:ptcpnt_type_nm].nil?
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<arg0>
<VnpProcDTO>
<ptcpntTypeNm>#{options[:ptcpnt_type_nm]}</ptcpntTypeNm>
<vnpPtcpntId>#{options[:vnp_ptcpnt_id]}</vnpPtcpntId>
<vnpProcId>#{options[:vnp_proc_id]}</vnpProcId>
<fraudInd>#{options[:fraud_ind]}</fraudInd>
<jrnDt>#{options[:jrn_dt]}</jrnDt>
<jrnLctnId>#{options[:vnp_ptcpnt_id]}</jrnLctnId>
<jrnObjId>#{options[:jrn_obj_id]}</jrnObjId>
<jrnStatusTypeCd>#{options[:jrn_status_type_cd]}</jrnStatusTypeCd>
<jrnUserId>#{options[:jrn_user_id]}</jrnUserId>
<legacyPoaCd>#{options[:legacy_poa_cd]}</legacyPoaCd>
<miscVendorInd>#{options[:misc_vendor_ind]}</miscVendorInd>
<ptcpntShortNm>#{options[:ptcpnt_short_nm]}</ptcpntShortNm>
<taxIdfctnNbr>#{options[:tax_idfctn_nbr]}</taxIdfctnNbr>
<tinWaiverReasonTypeCd>#{options[:tin_waiver_reason_type_cd]}</tinWaiverReasonTypeCd>
<ptcpntFkPtcpntId>#{options[:ptcpnt_fk_ptcpnt_id]}</ptcpntFkPtcpntId>
<corpPtcpntId>#{options[:corp_ptcpnt_id]}</corpPtcpntId>
</VnpProcDTO>
</arg0>
EOXML

make_request(endpoint: 'VnpPtcpntWebServiceBean/VnpPtcpntService', action: 'vnpPtcpntCreate', body:,
key: 'return')
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def handle_errors(response)
def get_fault_info
@fault_code = @hash&.dig('Envelope', 'Body', 'Fault', 'faultcode')&.split(':')&.dig(1)
@fault_string = @hash&.dig('Envelope', 'Body', 'Fault', 'faultstring')
@fault_message = @hash&.dig('Envelope', 'Body', 'Fault', 'detail', 'MessageException')
@fault_message = @hash&.dig('Envelope', 'Body', 'Fault', 'detail', 'MessageException') ||
@hash&.dig('Envelope', 'Body', 'Fault', 'detail', 'MessageFaultException')
return {} if @fault_string.include?('IntentToFileWebService') && @fault_string.include?('not found')

get_exception
Expand Down
45 changes: 45 additions & 0 deletions modules/claims_api/spec/lib/claims_api/vnp_ptcpnt_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

require 'rails_helper'
require 'bgs_service/vnp_ptcpnt_service'

describe ClaimsApi::VnpPtcpntService do
subject { described_class.new external_uid: 'xUid', external_key: 'xKey' }

describe 'vnp_ptcpnt_service' do
let(:options) { {} }

it 'responds with attributes' do
options[:vnp_proc_id] = '3830249' # '3830252' # '3854437'
# options[:vnp_ptcpnt_id] = nil
# options[:fraud_ind] = nil
# options[:jrn_dt] = nil
# options[:jrn_lctn_id] = nil
# options[:jrn_obj_id] = nil
# options[:jrn_status_type_cd] = nil
# options[:jrn_user_id] = nil
# options[:legacy_poa_cd] = nil
# options[:misc_vendor_ind] = nil
# options[:ptcpnt_short_nm] = nil
# options[:ptcpnt_type_nm] = nil
# options[:tax_idfctn_nbr] = nil
# options[:tin_waiver_reason_type_cd] = nil
# options[:ptcpnt_fk_ptcpnt_id] = nil
# options[:corp_ptcpnt_id] = nil
VCR.use_cassette('bgs/vnp_proc_service_v2/vnp_ptcpnt_service') do
response = subject.vnp_ptcpnt_create(options)
expect(response).to include(
{
vnp_bnft_claim_id: '426090',
atchms_ind: 'N',
bnft_claim_type_cd: '130DPNEBNADJ',
ptcpnt_clmant_id: '150191',
ptcpnt_mail_addrs_id: '116942',
vnp_ptcpnt_vet_id: '150191',
vnp_proc_id: '29637'
}
)
end
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 68833ac

Please sign in to comment.