Skip to content

Commit ec00f49

Browse files
authored
[ARP PoA submission] (#2) Lighthouse 2122 submission (#99310) (#20641)
* Add LH methods for 2122 submit (#99310) - Added LH methods for 2122 submit (#99310) - Testing for LH submit2122 - Added VCR files, rubocop - allow pass-thru of all attributes * Changes per Oren review
1 parent 37487ed commit ec00f49

File tree

4 files changed

+227
-0
lines changed

4 files changed

+227
-0
lines changed

lib/lighthouse/benefits_claims/service.rb

+12
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ def get_2122_submission(
6464
raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error'
6565
end
6666

67+
def submit2122(attributes, lighthouse_client_id = nil,
68+
lighthouse_rsa_key_path = nil, options = {})
69+
data = { data: { attributes: } }
70+
config.post(
71+
"#{@icn}/2122", data, lighthouse_client_id, lighthouse_rsa_key_path, options
72+
)
73+
rescue Faraday::TimeoutError
74+
raise BenefitsClaims::ServiceException.new({ status: 504 }), 'Lighthouse Error'
75+
rescue Faraday::ClientError, Faraday::ServerError => e
76+
raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error'
77+
end
78+
6779
def submit5103(id, tracked_item_id = nil, options = {})
6880
config.post("#{@icn}/claims/#{id}/5103", {
6981
data: {

spec/lib/lighthouse/benefits_claims/service_spec.rb

+62
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,68 @@
266266
end
267267
end
268268
end
269+
270+
describe 'when submitting a 2122' do
271+
let(:lh_config) { double }
272+
let(:attributes) do
273+
{
274+
veteran: {
275+
address: {
276+
addressLine1: '936 Gus Points',
277+
city: 'Watersborough',
278+
countryCode: 'US',
279+
stateCode: 'CO',
280+
zipCode: '36090'
281+
}
282+
},
283+
recordConsent: true,
284+
consentLimits: %w[DRUG_ABUSE ALCOHOLISM HIV SICKLE_CELL],
285+
serviceOrganization: {
286+
poaCode: '095',
287+
registrationNumber: '999999999999'
288+
}
289+
}
290+
end
291+
let(:expected_data) { { data: { attributes: } } }
292+
let(:expected_response) do
293+
{
294+
'data' => {
295+
'id' => '12beb731-3440-44d2-84ba-473bd75201aa',
296+
'type' => 'organization',
297+
'attributes' => {
298+
'code' => '095',
299+
'name' => 'Italian American War Veterans of the US, Inc.',
300+
'phoneNumber' => '440-233-6527'
301+
}
302+
}
303+
}
304+
end
305+
306+
context 'successful submit' do
307+
it 'submits the correct data to lighthouse' do
308+
@service = BenefitsClaims::Service.new('1012666183V089914')
309+
VCR.use_cassette(
310+
'lighthouse/benefits_claims/power_of_attorney_decision/202_response',
311+
match_requests_on: %i[method uri headers body]
312+
) do
313+
expect(
314+
@service.submit2122(attributes, 'lh_client_id', 'key_path').body
315+
).to eq expected_response
316+
end
317+
end
318+
end
319+
320+
context 'rep does not have poa for veteran' do
321+
it 'returns a not_found response' do
322+
@service = BenefitsClaims::Service.new('1012666183V089914')
323+
VCR.use_cassette('lighthouse/benefits_claims/power_of_attorney_decision/404_response') do
324+
expect do
325+
@service.submit2122(attributes, 'lh_client_id', 'key_path')
326+
end.to raise_error(Common::Exceptions::ResourceNotFound)
327+
end
328+
end
329+
end
330+
end
269331
end
270332
end
271333
end

spec/support/vcr_cassettes/lighthouse/benefits_claims/power_of_attorney_decision/202_response.yml

+77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/support/vcr_cassettes/lighthouse/benefits_claims/power_of_attorney_decision/404_response.yml

+76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)