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 34938 poa v2 create veteran rep #16212

Merged
merged 20 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d9679fc
WPI:Adds start of service
rockwellwindsor-va Apr 1, 2024
2cb5576
Merge branch 'master' into API-34938-poa-v2-create-veteran-rep
rockwellwindsor-va Apr 2, 2024
fe82797
WIP
rockwellwindsor-va Apr 3, 2024
6cbce4f
Merge branch 'master' into API-34938-poa-v2-create-veteran-rep
rockwellwindsor-va Apr 3, 2024
73ce760
WIP
rockwellwindsor-va Apr 3, 2024
81db461
Merge branch 'master' into API-34938-poa-v2-create-veteran-rep
rockwellwindsor-va Apr 3, 2024
5b3b329
WIP:Updates structure to be more in line with manage rep structure to…
rockwellwindsor-va Apr 3, 2024
ac705f7
WIP:Updates params
rockwellwindsor-va Apr 3, 2024
1902125
Merge branch 'master' into API-34938-poa-v2-create-veteran-rep
rockwellwindsor-va Apr 4, 2024
1b6c0a4
Merge branch 'master' into API-34938-poa-v2-create-veteran-rep
rockwellwindsor-va Apr 5, 2024
b534b49
Merge branch 'master' into API-34938-poa-v2-create-veteran-rep
rockwellwindsor-va Apr 16, 2024
6175903
Updates to take in options as the params for create_veteran_represent…
rockwellwindsor-va Apr 16, 2024
7eb6204
Merge branch 'master' into API-34938-poa-v2-create-veteran-rep
rockwellwindsor-va Apr 22, 2024
2bc58e0
Merges in master, updates namespace
rockwellwindsor-va Apr 22, 2024
5f25bc4
Revert Gemfile.lock change because of conflict
rockwellwindsor-va Apr 22, 2024
27a75b8
Removes comment
rockwellwindsor-va Apr 22, 2024
b07b47d
Adds tests for valid request and incorrect ptcpnt_id being used
rockwellwindsor-va Apr 23, 2024
1b7933b
Removes uneeded value from test file
rockwellwindsor-va Apr 23, 2024
7ea9605
Revert Gemfile.lock change
rockwellwindsor-va Apr 23, 2024
c1b08a2
Fixes typo in cassette
rockwellwindsor-va Apr 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading