Skip to content

Commit

Permalink
add power_of_attorney_requests get endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tycol7 committed Jan 8, 2025
1 parent 66ef6e4 commit 3921006
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,23 @@ class PowerOfAttorneyRequestBlueprint < Blueprinter::Base
end

field :attributes do |request|
{
veteran: {
first_name: request['vetFirstName'],
last_name: request['vetLastName'],
middle_name: request['vetMiddleName']
},
claimant: {
city: request['claimantCity'],
country: request['claimantCountry'],
military_po: request['claimantMilitaryPO'],
military_postal_code: request['claimantMilitaryPostalCode'],
state: request['claimantState'],
zip: request['claimantZip']
},
representative: {
poa_code: request['poaCode'],
vso_user_email: request['VSOUserEmail'],
vso_user_first_name: request['VSOUserFirstName'],
vso_user_last_name: request['VSOUserLastName']
},
received_date: request['dateRequestReceived'],
actioned_date: request['dateRequestActioned'],
status: request['secondaryStatus'],
declined_reason: request['declinedReason'],
change_address_authorization: request['changeAddressAuth'],
health_info_authorization: request['healthInfoAuth']
}
request_attributes(request)
end

transform ClaimsApi::V2::Blueprints::Transformers::LowerCamelTransformer
end

view :show do
field :id do |request|
request['id']
end

field :type do
'power-of-attorney-request'
end

field :attributes do |request|
request_attributes(request)
end

transform ClaimsApi::V2::Blueprints::Transformers::LowerCamelTransformer
Expand All @@ -61,6 +51,36 @@ class PowerOfAttorneyRequestBlueprint < Blueprinter::Base

transform ClaimsApi::V2::Blueprints::Transformers::LowerCamelTransformer
end

private_class_method def self.request_attributes(request) # rubocop:disable Metrics/MethodLength
{
veteran: {
first_name: request['vetFirstName'],
last_name: request['vetLastName'],
middle_name: request['vetMiddleName']
},
claimant: {
city: request['claimantCity'],
country: request['claimantCountry'],
military_po: request['claimantMilitaryPO'],
military_postal_code: request['claimantMilitaryPostalCode'],
state: request['claimantState'],
zip: request['claimantZip']
},
representative: {
poa_code: request['poaCode'],
vso_user_email: request['VSOUserEmail'],
vso_user_first_name: request['VSOUserFirstName'],
vso_user_last_name: request['VSOUserLastName']
},
received_date: request['dateRequestReceived'],
actioned_date: request['dateRequestActioned'],
status: request['secondaryStatus'],
declined_reason: request['declinedReason'],
change_address_authorization: request['changeAddressAuth'],
health_info_authorization: request['healthInfoAuth']
}
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ def index
), status: :ok
end

def show
poa_request = ClaimsApi::PowerOfAttorneyRequest.find(params[:id])

unless poa_request
raise Common::Exceptions::Lighthouse::ResourceNotFound.new(
detail: "Could not find Power of Attorney Request with id: #{params[:id]}"
)
end

params[:veteranId] = poa_request.veteran_icn # needed for target_veteran
participant_id = target_veteran.participant_id

service = ClaimsApi::PowerOfAttorneyRequestService::Show.new(participant_id)

res = service.get_poa_request
res['id'] = poa_request.id

render json: ClaimsApi::V2::Blueprints::PowerOfAttorneyRequestBlueprint.render(res, view: :show,
root: :data),
status: :ok
end

def decide
proc_id = form_attributes['procId']
ptcpnt_id = form_attributes['participantId']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module ClaimsApi
module PowerOfAttorneyRequestService
class Show
def initialize(participant_id)
@participant_id = participant_id
end

def get_poa_request
service = ClaimsApi::ManageRepresentativeService.new(external_uid: Settings.bgs.external_uid,
external_key: Settings.bgs.external_key)

res = service.read_poa_request_by_ptcpnt_id(ptcpnt_id: @participant_id)

res['poaRequestRespondReturnVOList']
end
end
end
end
1 change: 1 addition & 0 deletions modules/claims_api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
# Power of Attorney Requests
post '/:veteranId/power-of-attorney-request', to: 'request#create'
post '/power-of-attorney-requests', to: 'request#index'
get '/power-of-attorney-requests/:id', to: 'request#show'
post '/power-of-attorney-requests/decide', to: 'request#decide'
end
## 0966 Forms
Expand Down

0 comments on commit 3921006

Please sign in to comment.