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

[CST] Pass tracked item id to submit5103 method #18313

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion app/controllers/v0/benefits_claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions lib/lighthouse/benefits_claims/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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 = nil, 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
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/v0/benefits_claims_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@
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)
end

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)
Expand All @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading