diff --git a/modules/claims_api/lib/bgs_service/veteran_representative_service.rb b/modules/claims_api/lib/bgs_service/veteran_representative_service.rb
index 7b798d89e24..2ef438d9482 100644
--- a/modules/claims_api/lib/bgs_service/veteran_representative_service.rb
+++ b/modules/claims_api/lib/bgs_service/veteran_representative_service.rb
@@ -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
)
diff --git a/modules/claims_api/lib/bgs_service/veteran_representative_service/create_veteran_representative_request.rb b/modules/claims_api/lib/bgs_service/veteran_representative_service/create_veteran_representative_request.rb
new file mode 100644
index 00000000000..69823f7f0c7
--- /dev/null
+++ b/modules/claims_api/lib/bgs_service/veteran_representative_service/create_veteran_representative_request.rb
@@ -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
+
+ #{injected}
+
+ EOXML
+
+ make_request(
+ namespace: 'data',
+ action: 'createVeteranRepresentative',
+ body: body.to_s,
+ key: 'VeteranRepresentativeReturn'
+ )
+ end
+ end
+end
diff --git a/modules/claims_api/lib/bgs_service/veteran_representative_service/read_all_veteran_representatives.rb b/modules/claims_api/lib/bgs_service/veteran_representative_service/read_all_veteran_representatives.rb
index b9de1f6f373..9dfeb0e3c69 100644
--- a/modules/claims_api/lib/bgs_service/veteran_representative_service/read_all_veteran_representatives.rb
+++ b/modules/claims_api/lib/bgs_service/veteran_representative_service/read_all_veteran_representatives.rb
@@ -13,7 +13,7 @@ def read_all_veteran_representatives(type_code:, ptcpnt_id:)
#{type_code}
EOXML
- ret = make_request(action: 'readAllVeteranRepresentatives', body:)
+ ret = make_request(namespace: 'ns0', action: 'readAllVeteranRepresentatives', body:)
&.dig('VeteranRepresentativeReturnList') || []
[ret].flatten
end
diff --git a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb
new file mode 100644
index 00000000000..ebcf7905201
--- /dev/null
+++ b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb
@@ -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
diff --git a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb
new file mode 100644
index 00000000000..c2db3c02fd1
--- /dev/null
+++ b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb
@@ -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
diff --git a/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id.yml b/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id.yml
new file mode 100644
index 00000000000..9314758c514
--- /dev/null
+++ b/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id.yml
@@ -0,0 +1,233 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: "/VDC/VeteranRepresentativeService?WSDL"
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ User-Agent:
+ - Faraday v2.9.0
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Date:
+ - Tue, 23 Apr 2024 19:25:26 GMT
+ Server:
+ - Apache
+ X-Frame-Options:
+ - SAMEORIGIN
+ Transfer-Encoding:
+ - chunked
+ Content-Type:
+ - text/xml;charset=utf-8
+ Strict-Transport-Security:
+ - max-age=16000000; includeSubDomains; preload;
+ body:
+ encoding: UTF-8
+ string: |-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ recorded_at: Mon, 22 Apr 2024 19:27:00 GMT
+- request:
+ method: post
+ uri: "/VDC/VeteranRepresentativeService"
+ body:
+ encoding: UTF-8
+ string: |
+
+
+
+
+
+ VAgovAPI
+
+
+ 127.0.0.1
+ 281
+ VAgovAPI
+ keyHere
+ keyHere
+
+
+
+
+
+
+ 21-223854909600043284074falsefalsefalsefalsefalsefalsetrueSubmittedRecognized Veterans Service Organization18235876 Crowther AveBridgeport06605CT2024-04-22T19:27:37Z
+
+
+
+
+ headers:
+ User-Agent:
+ - Faraday v2.9.0
+ Content-Type:
+ - text/xml;charset=UTF-8
+ Host:
+ - ".vba.va.gov"
+ Soapaction:
+ - '"createVeteranRepresentative"'
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ response:
+ status:
+ code: 500
+ message: Internal Server Error
+ headers:
+ Date:
+ - Tue, 23 Apr 2024 19:25:27 GMT
+ Server:
+ - Apache
+ X-Frame-Options:
+ - SAMEORIGIN
+ Transfer-Encoding:
+ - chunked
+ Content-Type:
+ - text/xml; charset=utf-8
+ Strict-Transport-Security:
+ - max-age=16000000; includeSubDomains; preload;
+ body:
+ encoding: UTF-8
+ string: 'ns0:Servergov.va.vba.benefits.exceptions.MessageFault
+
+ 3
+ :
+ ORA-02291: integrity constraint (CORPPROD.FK1_VNP_PTCPNT_RLNSHP) violated - parent key
+ not found - Input: Proc ID: 3854909, poa code = 074, formTypeCode = 21-22,
+ submittedDate: 2024-04-22T14:27:37-05:00
+
+
+ 3
+ :
+ ORA-02291: integrity constraint (CORPPROD.FK1_VNP_PTCPNT_RLNSHP) violated - parent key
+ not found - Input: Proc ID: 3854909, poa code = 074, formTypeCode = 21-22,
+ submittedDate: 2024-04-22T14:27:37-05:00
+
+
+
+
+
+ '
+ recorded_at: Mon, 22 Apr 2024 19:27:00 GMT
+recorded_with: VCR 6.2.0
diff --git a/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params.yml b/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params.yml
new file mode 100644
index 00000000000..767a27d1269
--- /dev/null
+++ b/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params.yml
@@ -0,0 +1,280 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: "/VDC/VeteranRepresentativeService?WSDL"
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ User-Agent:
+ - Faraday v2.9.0
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Date:
+ - Tue, 23 Apr 2024 19:07:13 GMT
+ Server:
+ - Apache
+ X-Frame-Options:
+ - SAMEORIGIN
+ Transfer-Encoding:
+ - chunked
+ Content-Type:
+ - text/xml;charset=utf-8
+ Strict-Transport-Security:
+ - max-age=16000000; includeSubDomains; preload;
+ body:
+ encoding: UTF-8
+ string: |-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ recorded_at: Mon, 22 Apr 2024 19:27:37 GMT
+- request:
+ method: post
+ uri: "/VDC/VeteranRepresentativeService"
+ body:
+ encoding: UTF-8
+ string: |
+
+
+
+
+
+ VAgovAPI
+
+
+ 127.0.0.1
+ 281
+ VAgovAPI
+ keyHere
+ keyHere
+
+
+
+
+
+
+
+ 21-22
+ 3854909
+ 182359
+ 074
+ false
+ false
+ false
+ false
+ false
+ false
+ true
+ Submitted
+ Recognized Veterans Service Organization
+ 182358
+ 76 Crowther Ave
+ Bridgeport
+ 06605
+ CT
+ 2024-04-22T19:27:37Z
+
+
+
+
+ headers:
+ User-Agent:
+ - Faraday v2.9.0
+ Content-Type:
+ - text/xml;charset=UTF-8
+ Host:
+ - ".vba.va.gov"
+ Soapaction:
+ - '"createVeteranRepresentative"'
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Date:
+ - Tue, 23 Apr 2024 19:07:14 GMT
+ Server:
+ - Apache
+ X-Frame-Options:
+ - SAMEORIGIN
+ Transfer-Encoding:
+ - chunked
+ Content-Type:
+ - text/xml; charset=utf-8
+ Strict-Transport-Security:
+ - max-age=16000000; includeSubDomains; preload;
+ body:
+ encoding: UTF-8
+ string:
+
+ 76 Crowther Ave
+
+
+ true
+ Bridgeport
+ 182358
+
+ 21-22
+
+ false
+ false
+ false
+ false
+
+
+
+ 074
+ 06605
+ 3854909
+
+
+
+
+ Recognized Veterans Service Organization
+ false
+
+
+ CT
+ Submitted
+ 182359
+
+ VERNON
+ WAGNER
+
+
+
+
+ VERNON
+ WAGNER
+
+
+
+
+
+
+
+ recorded_at: Mon, 22 Apr 2024 19:27:37 GMT
+recorded_with: VCR 6.2.0