Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API-34934-request-vpn-participant-create #16081

Merged
merged 13 commits into from
Mar 28, 2024
Merged
9 changes: 9 additions & 0 deletions modules/claims_api/lib/bgs_service/local_bgs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,14 @@ def transform_bgs_claims_to_evss(claims)
def to_camelcase(claim:)
claim.deep_transform_keys { |k| k.to_s.camelize(:lower) }
end

def convert_nil_values(options)
arg_strg = ''
options.each do |option|
arg = option[0].to_s.camelize(:lower)
arg_strg += (option[1].nil? ? "<#{arg} xsi:nil='true'/>" : "<#{arg}>#{option[1]}</#{arg}>")
end
arg_strg
end
end
end
18 changes: 18 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,18 @@
# 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)
arg_strg = convert_nil_values(options)
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<arg0>
#{arg_strg}
</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 @@ -15,9 +15,10 @@ def handle_errors(response)
end

def get_fault_info
stiehlrod marked this conversation as resolved.
Show resolved Hide resolved
@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 = @hash&.dig('Envelope', 'Body', 'Fault')
@fault_code = fault&.dig('faultcode')&.split(':')&.dig(1)
@fault_string = fault&.dig('faultstring')
@fault_message = fault&.dig('detail', 'MessageException') || fault&.dig('detail', 'MessageFaultException')
return {} if @fault_string.include?('IntentToFileWebService') && @fault_string.include?('not found')

get_exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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] = '3854437'
options[:vnp_ptcpnt_id] = nil
options[:fraud_ind] = nil
options[:jrn_dt] = '2020-07-16T18:20:17Z'
options[:jrn_lctn_id] = 281
options[:jrn_obj_id] = 'VAgovAPI'
options[:jrn_status_type_cd] = 'U'
options[:jrn_user_id] = 'VAgovAPI'
options[:legacy_poa_cd] = nil
options[:misc_vendor_ind] = nil
options[:ptcpnt_short_nm] = nil
options[:ptcpnt_type_nm] = 'Person'
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_ptcpnt_id: '181913',
vnp_proc_id: '3854437',
jrn_dt: '2020-07-16T18:20:17Z',
jrn_lctn_id: '281',
jrn_obj_id: 'VAgovAPI',
jrn_status_type_cd: 'U',
jrn_user_id: 'VAgovAPI',
ptcpnt_type_nm: 'Person' }
)
end
end
end
end

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

Loading