-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Api 34938 poa v2 create veteran rep (#16212)
* WPI:Adds start of service * WIP * WIP * WIP:Updates structure to be more in line with manage rep structure to maintain uniformity * WIP:Updates params * Updates to take in options as the params for create_veteran_representative * Revert Gemfile.lock change because of conflict * Removes comment * Adds tests for valid request and incorrect ptcpnt_id being used * Removes uneeded value from test file * Revert Gemfile.lock change * Fixes typo in cassette
- Loading branch information
1 parent
1e50563
commit 8aebcd6
Showing
7 changed files
with
721 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
modules/claims_api/lib/bgs_service/veteran_representative_service.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...i/lib/bgs_service/veteran_representative_service/create_veteran_representative_request.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
...aims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
36 changes: 36 additions & 0 deletions
36
.../lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.