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 committed Apr 24, 2024
2 parents 853e4a3 + 8aebcd6 commit 6d1ec77
Show file tree
Hide file tree
Showing 7 changed files with 721 additions and 3 deletions.
@@ -1,15 +1,16 @@
# frozen_string_literal: true

require_relative 'veteran_representative_service/create_veteran_representative_request'
require_relative 'veteran_representative_service/read_all_veteran_representatives'

module ClaimsApi
class VeteranRepresentativeService < ClaimsApi::LocalBGS
private

def make_request(**args)
def make_request(namespace:, **args)
super(
endpoint: 'VDC/VeteranRepresentativeService',
namespaces: { 'ns0' => '/data' },
namespaces: { namespace => '/data' },
transform_response: false,
**args
)
Expand Down
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module ClaimsApi
class VeteranRepresentativeService < ClaimsApi::LocalBGS
def create_veteran_representative(options)
injected = convert_nil_values(options)
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<data:VeteranRepresentative>
#{injected}
</data:VeteranRepresentative>
EOXML

make_request(
namespace: 'data',
action: 'createVeteranRepresentative',
body: body.to_s,
key: 'VeteranRepresentativeReturn'
)
end
end
end
Expand Up @@ -13,7 +13,7 @@ def read_all_veteran_representatives(type_code:, ptcpnt_id:)
<formTypeCode>#{type_code}</formTypeCode>
</ns0:CorpPtcpntIdFormTypeCode>
EOXML
ret = make_request(action: 'readAllVeteranRepresentatives', body:)
ret = make_request(namespace: 'ns0', action: 'readAllVeteranRepresentatives', body:)
&.dig('VeteranRepresentativeReturnList') || []
[ret].flatten
end
Expand Down
@@ -0,0 +1,147 @@
# frozen_string_literal: true

require 'rails_helper'
require 'bgs_service/veteran_representative_service'
require Rails.root.join('modules', 'claims_api', 'spec', 'support', 'bgs_client_helpers.rb')

metadata = {
bgs: {
service: 'veteran_representative_service',
operation: 'create_veteran_representative'
}
}

describe ClaimsApi::VeteranRepresentativeService, metadata do
describe '#create_veteran_representative' do
subject do
service = described_class.new(**header_params)
service.create_veteran_representative(**params)
end

let(:header_params) do
{
external_uid: 'keyHere',
external_key: 'keyHere'
}
end

describe 'with valid request params' do
let(:params) do
{
form_type_code: '21-22',
proc_id: '3854909',
veteran_ptcpnt_id: '182359',
poa_code: '074',
section_7332_auth: false,
limitation_drug_abuse: false,
limitation_alcohol: false,
limitation_hiv: false,
limitation_s_c_a: false,
limitation_h_i_v: false,
change_address_auth: true,
vdc_status: 'Submitted',
representative_type: 'Recognized Veterans Service Organization',
claimant_ptcpnt_id: '182358',
# rubocop:disable Naming/VariableNumber
address_line_1: '76 Crowther Ave',
# rubocop:enable Naming/VariableNumber
city: 'Bridgeport',
postal_code: '06605',
state: 'CT',
submitted_date: '2024-04-22T19:27:37Z'
}
end

let(:expected_response) do
{
'addressLine1' => '76 Crowther Ave',
'addressLine2' => nil,
'addressLine3' => nil,
'changeAddressAuth' => 'true',
'city' => 'Bridgeport',
'claimantPtcpntId' => '182358',
'claimantRelationship' => nil,
'formTypeCode' => '21-22',
'insuranceNumbers' => nil,
'limitationAlcohol' => 'false',
'limitationDrugAbuse' => 'false',
'limitationHIV' => 'false',
'limitationSCA' => 'false',
'organizationName' => nil,
'otherServiceBranch' => nil,
'phoneNumber' => nil,
'poaCode' => '074',
'postalCode' => '06605',
'procId' => '3854909',
'representativeFirstName' => nil,
'representativeLastName' => nil,
'representativeLawFirmOrAgencyName' => nil,
'representativeTitle' => nil,
'representativeType' => 'Recognized Veterans Service Organization',
'section7332Auth' => 'false',
'serviceBranch' => nil,
'serviceNumber' => nil,
'state' => 'CT',
'vdcStatus' => 'Submitted',
'veteranPtcpntId' => '182359',
'acceptedBy' => nil,
'claimantFirstName' => 'VERNON',
'claimantLastName' => 'WAGNER',
'claimantMiddleName' => nil,
'declinedBy' => nil,
'declinedReason' => nil,
'secondaryStatus' => nil,
'veteranFirstName' => 'VERNON',
'veteranLastName' => 'WAGNER',
'veteranMiddleName' => nil,
'veteranSSN' => nil,
'veteranVAFileNumber' => nil
}
end

it 'returns a response with expected body' do
use_bgs_cassette('valid_params') do
expect(subject).to eq(expected_response)
end
end
end

describe 'with invalid params' do
describe 'with the MPI participant ID being used instead of the VNP participant ID' do
let(:params) do
{
form_type_code: '21-22',
proc_id: '3854909',
veteran_ptcpnt_id: '600043284',
poa_code: '074',
section_7332_auth: false,
limitation_drug_abuse: false,
limitation_alcohol: false,
limitation_hiv: false,
limitation_s_c_a: false,
limitation_h_i_v: false,
change_address_auth: true,
vdc_status: 'Submitted',
representative_type: 'Recognized Veterans Service Organization',
claimant_ptcpnt_id: '182358',
# rubocop:disable Naming/VariableNumber
address_line_1: '76 Crowther Ave',
# rubocop:enable Naming/VariableNumber
city: 'Bridgeport',
postal_code: '06605',
state: 'CT',
submitted_date: '2024-04-22T19:27:37Z'
}
end

it 'raises Common::Exceptions::ServiceError' do
use_bgs_cassette('mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id') do
expect { subject }.to raise_error(
Common::Exceptions::ServiceError
)
end
end
end
end
end
end
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require 'rails_helper'
require 'bgs_service/veteran_representative_service'
require Rails.root.join('modules', 'claims_api', 'spec', 'support', 'bgs_client_helpers.rb')

describe ClaimsApi::VeteranRepresentativeService do
let(:header_params) do
{
external_uid: 'xUid',
external_key: 'xKey'
}
end

describe 'with a namespace param' do
it 'does not raise ArgumentError' do
service = described_class.new(**header_params)
expect do
service.send(:make_request, namespace: 'testspace', action: 'testAction', body: 'this is the body',
key: 'ThisIsTheKey')
end.not_to raise_error(ArgumentError)
end
end

describe 'without the namespace param' do
let(:params) { { ptcpnt_id: '123456' } }

it 'raises ArgumentError' do
service = described_class.new(**header_params)
expect do
service.send(:make_request, action: 'testAction', body: 'this is the body',
key: 'ThisIsTheKey')
end.to raise_error(ArgumentError)
end
end
end

0 comments on commit 6d1ec77

Please sign in to comment.