diff --git a/app/controllers/v0/benefits_claims_controller.rb b/app/controllers/v0/benefits_claims_controller.rb index 10fbbed3f69..7622dfe4af9 100644 --- a/app/controllers/v0/benefits_claims_controller.rb +++ b/app/controllers/v0/benefits_claims_controller.rb @@ -51,7 +51,13 @@ def submit5103 # for file number here ::Rails.logger.info('[5103 Submission] No file number') if @current_user.birls_id.nil? - res = service.submit5103(params[:id]) + json_payload = request.body.read + + data = JSON.parse(json_payload) + + tracked_item_id = data['trackedItemId'] || nil + + res = service.submit5103(params[:id], tracked_item_id) render json: res end diff --git a/lib/lighthouse/benefits_claims/service.rb b/lib/lighthouse/benefits_claims/service.rb index 7ff2334563a..b09625329eb 100644 --- a/lib/lighthouse/benefits_claims/service.rb +++ b/lib/lighthouse/benefits_claims/service.rb @@ -22,8 +22,6 @@ def initialize(icn) end def get_claims(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) - Rails.logger.info("Get claims - icn: #{@icn.present?}, client_id: #{lighthouse_client_id.present?}, - lighthouse_rsa: #{lighthouse_rsa_key_path.present?}") claims = config.get("#{@icn}/claims", lighthouse_client_id, lighthouse_rsa_key_path, options).body claims['data'] = filter_by_status(claims['data']) claims @@ -34,9 +32,6 @@ def get_claims(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, option end def get_claim(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) - Rails.logger.info("Get claim - icn: #{@icn.present?}, get_claim: #{id.present?}, - client_id: #{lighthouse_client_id.present?}, - lighthouse_rsa: #{lighthouse_rsa_key_path.present?}") config.get("#{@icn}/claims/#{id}", lighthouse_client_id, lighthouse_rsa_key_path, options).body rescue Faraday::TimeoutError raise BenefitsClaims::ServiceException.new({ status: 504 }), 'Lighthouse Error' @@ -52,8 +47,17 @@ def get_power_of_attorney(lighthouse_client_id = nil, lighthouse_rsa_key_path = raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error' end - def submit5103(id, options = {}) - config.post("#{@icn}/claims/#{id}/5103", {}, nil, nil, options).body + def submit5103(id, tracked_item_id, options = {}) + config.post("#{@icn}/claims/#{id}/5103", { + data: { + type: 'form/5103', + attributes: { + trackedItemIds: [ + tracked_item_id + ] + } + } + }, nil, nil, options).body rescue Faraday::TimeoutError raise BenefitsClaims::ServiceException.new({ status: 504 }), 'Lighthouse Error' rescue Faraday::ClientError, Faraday::ServerError => e diff --git a/spec/controllers/v0/benefits_claims_controller_spec.rb b/spec/controllers/v0/benefits_claims_controller_spec.rb index 42276a69720..59a0eb2de18 100644 --- a/spec/controllers/v0/benefits_claims_controller_spec.rb +++ b/spec/controllers/v0/benefits_claims_controller_spec.rb @@ -218,7 +218,7 @@ describe '#submit5103' do it 'returns a status of 200' do VCR.use_cassette('lighthouse/benefits_claims/submit5103/200_response') do - post(:submit5103, params: { id: '600397108' }) + post(:submit5103, params: { id: '600397108', trackedItemId: 12_345 }, as: :json) end expect(response).to have_http_status(:ok) @@ -226,7 +226,7 @@ it 'returns a status of 404' do VCR.use_cassette('lighthouse/benefits_claims/submit5103/404_response') do - post(:submit5103, params: { id: '600397108' }) + post(:submit5103, params: { id: '600397108', trackedItemId: 12_345 }, as: :json) end expect(response).to have_http_status(:not_found) @@ -235,7 +235,7 @@ context 'when LH takes too long to respond' do it 'returns a status of 504' do allow_any_instance_of(BenefitsClaims::Configuration).to receive(:post).and_raise(Faraday::TimeoutError) - post(:submit5103, params: { id: '60038334' }) + post(:submit5103, params: { id: '600397108', trackedItemId: 12_345 }, as: :json) expect(response).to have_http_status(:gateway_timeout) end diff --git a/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/200_response.yml b/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/200_response.yml index c9b2b369b44..849745ccb42 100644 --- a/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/200_response.yml +++ b/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/200_response.yml @@ -5,7 +5,14 @@ http_interactions: uri: https://sandbox-api.va.gov/services/claims/v2/veterans/123498767V234859/claims/600397108/5103 body: encoding: UTF-8 - string: "{}" + string: "{ + \"data\": { + \"type\": 'form/5103', + \"attributes\": { + \"trackedItemIds\": [12345] + } + } + }" headers: Accept: - application/json diff --git a/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/404_response.yml b/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/404_response.yml index 05ebe3abc66..7026207b159 100644 --- a/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/404_response.yml +++ b/spec/support/vcr_cassettes/lighthouse/benefits_claims/submit5103/404_response.yml @@ -5,7 +5,14 @@ http_interactions: uri: https://sandbox-api.va.gov/services/claims/v2/veterans/123498767V234859/claims/600397108/5103 body: encoding: UTF-8 - string: "{}" + string: "{ + \"data\": { + \"type\": 'form/5103', + \"attributes\": { + \"trackedItemIds\": [12345] + } + } + }" headers: Accept: - application/json