Skip to content

Commit

Permalink
Add 5103 endpoint to benefits_claims controller (#12862)
Browse files Browse the repository at this point in the history
* Adding 5103 endpoint to benefits_claims controller
  • Loading branch information
jerekshoe authored Jun 2, 2023
1 parent 0cecb24 commit 3a80303
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 21 deletions.
6 changes: 6 additions & 0 deletions app/controllers/v0/benefits_claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def show
render json: claim
end

def submit5103
res = service.submit5103(params[:id])

render json: res
end

private

def service
Expand Down
2 changes: 1 addition & 1 deletion config/betamocks/services_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -852,5 +852,5 @@
:file_path: "/lighthouse/benefits_claims/submit_5103"
:cache_multiple_responses:
:uid_location: "url"
:uid_locator: "\/services/claims/v2/veterans\/(?:.+)\/claims\/(?:.+)/5103"
:uid_locator: "\/services/claims/v2/veterans\/(?:.+)\/claims\/(.+)/5103"

4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@
resources :burial_claims, only: %i[create show]
end

resources :benefits_claims, only: %i[index show]
resources :benefits_claims, only: %i[index show] do
post :submit5103, on: :member
end

get 'claim_letters', to: 'claim_letters#index'
get 'claim_letters/:document_id', to: 'claim_letters#show'
Expand Down
2 changes: 1 addition & 1 deletion lib/lighthouse/benefits_claims/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get(path, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options
##
# @return [Faraday::Response] response from POST request
#
def post(path, body, lighthouse_client_id, lighthouse_rsa_key_path, options = {})
def post(path, body, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {})
connection.post(path, body, { Authorization: "Bearer #{
access_token(
lighthouse_client_id,
Expand Down
6 changes: 6 additions & 0 deletions lib/lighthouse/benefits_claims/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def get_claim(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, opt
raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error'
end

def submit5103(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {})
config.post("#{@icn}/claims/#{id}/5103", {}, lighthouse_client_id, lighthouse_rsa_key_path, options).body
rescue Faraday::ClientError => e
raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error'
end

def get_intent_to_file(type, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {})
endpoint = 'benefits_claims/intent_to_file'
path = "#{@icn}/intent-to-file/#{type}"
Expand Down
2 changes: 2 additions & 0 deletions lib/lighthouse/benefits_claims/service_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def initialize(e)
raise Common::Exceptions::Forbidden
when 401
raise Common::Exceptions::Unauthorized
when 400
raise Common::Exceptions::BadRequest
else
raise e
end
Expand Down
18 changes: 18 additions & 0 deletions spec/controllers/v0/benefits_claims_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,22 @@
end
end
end

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' })
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' })
end

expect(response).to have_http_status(:not_found)
end
end
end

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.

0 comments on commit 3a80303

Please sign in to comment.