Skip to content

Commit 968fe28

Browse files
authored
[API-43015] Add power_of_attorney_requests get endpoint (#20167)
* add power_of_attorney_requests get endpoint * add tests and factory * add docs (200 ok) * add docs (401 and 404)
1 parent 6df6adb commit 968fe28

File tree

11 files changed

+685
-2
lines changed

11 files changed

+685
-2
lines changed

modules/claims_api/app/controllers/claims_api/v2/blueprints/power_of_attorney_request_blueprint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ClaimsApi
44
module V2
55
module Blueprints
66
class PowerOfAttorneyRequestBlueprint < Blueprinter::Base
7-
view :index do
7+
view :index_or_show do
88
field :id do |request|
99
request['id']
1010
end

modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/request_controller.rb

+23-1
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,32 @@ def index
3636
raise Common::Exceptions::Lighthouse::BadGateway unless poa_list
3737

3838
render json: ClaimsApi::V2::Blueprints::PowerOfAttorneyRequestBlueprint.render(
39-
poa_list, view: :index, root: :data
39+
poa_list, view: :index_or_show, root: :data
4040
), status: :ok
4141
end
4242

43+
def show
44+
poa_request = ClaimsApi::PowerOfAttorneyRequest.find_by(id: params[:id])
45+
46+
unless poa_request
47+
raise Common::Exceptions::Lighthouse::ResourceNotFound.new(
48+
detail: "Could not find Power of Attorney Request with id: #{params[:id]}"
49+
)
50+
end
51+
52+
params[:veteranId] = poa_request.veteran_icn # needed for target_veteran
53+
participant_id = target_veteran.participant_id
54+
55+
service = ClaimsApi::PowerOfAttorneyRequestService::Show.new(participant_id)
56+
57+
res = service.get_poa_request
58+
res['id'] = poa_request.id
59+
60+
render json: ClaimsApi::V2::Blueprints::PowerOfAttorneyRequestBlueprint.render(res, view: :index_or_show,
61+
root: :data),
62+
status: :ok
63+
end
64+
4365
def decide
4466
proc_id = form_attributes['procId']
4567
ptcpnt_id = form_attributes['participantId']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
module ClaimsApi
4+
module PowerOfAttorneyRequestService
5+
class Show
6+
def initialize(participant_id)
7+
@participant_id = participant_id
8+
end
9+
10+
def get_poa_request
11+
service = ClaimsApi::ManageRepresentativeService.new(external_uid: Settings.bgs.external_uid,
12+
external_key: Settings.bgs.external_key)
13+
14+
res = service.read_poa_request_by_ptcpnt_id(ptcpnt_id: @participant_id)
15+
res['poaRequestRespondReturnVOList']
16+
end
17+
end
18+
end
19+
end

modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json

+307
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,313 @@
843843
}
844844
}
845845
},
846+
"/veterans/power-of-attorney-requests/{id}": {
847+
"get": {
848+
"summary": "Retrieves a Power of Attorney request",
849+
"tags": [
850+
"Power of Attorney"
851+
],
852+
"operationId": "getPowerOfAttorneyRequest",
853+
"security": [
854+
{
855+
"productionOauth": [
856+
"system/claim.read",
857+
"system/claim.write"
858+
]
859+
},
860+
{
861+
"sandboxOauth": [
862+
"system/claim.read",
863+
"system/claim.write"
864+
]
865+
},
866+
{
867+
"bearer_token": []
868+
}
869+
],
870+
"description": "Retrieves a Power of Attorney request.",
871+
"parameters": [
872+
{
873+
"name": "id",
874+
"in": "path",
875+
"required": true,
876+
"example": "12e13134-7229-4e44-90ae-bcea2a4525fa",
877+
"description": "The ID of the Power of Attorney request",
878+
"schema": {
879+
"type": "string"
880+
}
881+
}
882+
],
883+
"responses": {
884+
"200": {
885+
"description": "Successful response with a current Power of Attorney request",
886+
"content": {
887+
"application/json": {
888+
"example": {
889+
"data": {
890+
"id": "12e13134-7229-4e44-90ae-bcea2a4525fa",
891+
"type": "power-of-attorney-request",
892+
"attributes": {
893+
"veteran": {
894+
"firstName": "ANDREA",
895+
"lastName": "MITCHELL",
896+
"middleName": "L"
897+
},
898+
"claimant": {
899+
"city": "Portland",
900+
"country": "USA",
901+
"militaryPo": null,
902+
"militaryPostalCode": null,
903+
"state": "OR",
904+
"zip": "56789"
905+
},
906+
"representative": {
907+
"poaCode": "074",
908+
"vsoUserEmail": null,
909+
"vsoUserFirstName": "vets-api",
910+
"vsoUserLastName": "vets-api"
911+
},
912+
"receivedDate": "2024-10-30T08:22:07-05:00",
913+
"actionedDate": "2025-01-09T10:19:26-06:00",
914+
"status": "Accepted",
915+
"declinedReason": null,
916+
"changeAddressAuthorization": "Y",
917+
"healthInfoAuthorization": "Y"
918+
}
919+
}
920+
},
921+
"schema": {
922+
"type": "object",
923+
"required": [
924+
"data"
925+
],
926+
"properties": {
927+
"data": {
928+
"type": "object",
929+
"required": [
930+
"type",
931+
"attributes"
932+
],
933+
"properties": {
934+
"id": {
935+
"type": "string",
936+
"format": "uuid"
937+
},
938+
"type": {
939+
"type": "string",
940+
"enum": [
941+
"power-of-attorney-request"
942+
]
943+
},
944+
"attributes": {
945+
"type": "object",
946+
"required": [
947+
"veteran",
948+
"claimant",
949+
"representative"
950+
],
951+
"properties": {
952+
"veteran": {
953+
"type": "object",
954+
"properties": {
955+
"firstName": {
956+
"type": "string"
957+
},
958+
"lastName": {
959+
"type": "string"
960+
},
961+
"middleName": {
962+
"type": "string"
963+
}
964+
}
965+
},
966+
"claimant": {
967+
"type": "object",
968+
"properties": {
969+
"city": {
970+
"type": "string"
971+
},
972+
"country": {
973+
"type": "string"
974+
},
975+
"militaryPo": {
976+
"type": "string"
977+
},
978+
"militaryPostalCode": {
979+
"type": "string"
980+
},
981+
"state": {
982+
"type": "string"
983+
},
984+
"zip": {
985+
"type": "string"
986+
}
987+
}
988+
},
989+
"representative": {
990+
"type": "object",
991+
"properties": {
992+
"poaCode": {
993+
"type": "string"
994+
},
995+
"vsoUserEmail": {
996+
"type": "string"
997+
},
998+
"vsoUserFirstName": {
999+
"type": "string"
1000+
},
1001+
"vsoUserLastName": {
1002+
"type": "string"
1003+
}
1004+
}
1005+
},
1006+
"receivedDate": {
1007+
"type": "string",
1008+
"format": "date-time"
1009+
},
1010+
"actionedDate": {
1011+
"type": "string",
1012+
"format": "date-time"
1013+
},
1014+
"status": {
1015+
"type": "string"
1016+
},
1017+
"declinedReason": {
1018+
"type": "string"
1019+
},
1020+
"changeAddressAuthorization": {
1021+
"type": "string",
1022+
"enum": [
1023+
"Y",
1024+
"N"
1025+
]
1026+
},
1027+
"healthInfoAuthorization": {
1028+
"type": "string",
1029+
"enum": [
1030+
"Y",
1031+
"N"
1032+
]
1033+
}
1034+
}
1035+
}
1036+
}
1037+
}
1038+
}
1039+
}
1040+
}
1041+
}
1042+
},
1043+
"401": {
1044+
"description": "Unauthorized",
1045+
"content": {
1046+
"application/json": {
1047+
"example": {
1048+
"errors": [
1049+
{
1050+
"title": "Not authorized",
1051+
"status": "401",
1052+
"detail": "Not authorized"
1053+
}
1054+
]
1055+
},
1056+
"schema": {
1057+
"type": "object",
1058+
"required": [
1059+
"errors"
1060+
],
1061+
"properties": {
1062+
"errors": {
1063+
"type": "array",
1064+
"items": {
1065+
"additionalProperties": false,
1066+
"required": [
1067+
"title",
1068+
"detail",
1069+
"status"
1070+
],
1071+
"properties": {
1072+
"title": {
1073+
"type": "string",
1074+
"enum": [
1075+
"Not authorized"
1076+
]
1077+
},
1078+
"detail": {
1079+
"type": "string",
1080+
"enum": [
1081+
"Not authorized"
1082+
]
1083+
},
1084+
"status": {
1085+
"type": "string",
1086+
"enum": [
1087+
"401"
1088+
]
1089+
}
1090+
}
1091+
}
1092+
}
1093+
}
1094+
}
1095+
}
1096+
}
1097+
},
1098+
"404": {
1099+
"description": "Resource not found",
1100+
"content": {
1101+
"application/json": {
1102+
"example": {
1103+
"errors": [
1104+
{
1105+
"status": "404",
1106+
"title": "Resource not found",
1107+
"detail": "Could not find Power of Attorney Request with id: 12e13134-7229-4e44-90ae-bcea2a4525fa"
1108+
}
1109+
]
1110+
},
1111+
"schema": {
1112+
"type": "object",
1113+
"required": [
1114+
"errors"
1115+
],
1116+
"properties": {
1117+
"errors": {
1118+
"type": "array",
1119+
"items": {
1120+
"additionalProperties": false,
1121+
"required": [
1122+
"title",
1123+
"detail",
1124+
"status"
1125+
],
1126+
"properties": {
1127+
"title": {
1128+
"type": "string",
1129+
"enum": [
1130+
"Resource not found"
1131+
]
1132+
},
1133+
"detail": {
1134+
"type": "string"
1135+
},
1136+
"status": {
1137+
"type": "string",
1138+
"enum": [
1139+
"404"
1140+
]
1141+
}
1142+
}
1143+
}
1144+
}
1145+
}
1146+
}
1147+
}
1148+
}
1149+
}
1150+
}
1151+
}
1152+
},
8461153
"/veterans/{veteranId}/claims/{id}/5103": {
8471154
"post": {
8481155
"summary": "Submit Evidence Waiver 5103",

modules/claims_api/config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
# Power of Attorney Requests
5353
post '/:veteranId/power-of-attorney-request', to: 'request#create'
5454
post '/power-of-attorney-requests', to: 'request#index'
55+
get '/power-of-attorney-requests/:id', to: 'request#show'
5556
post '/power-of-attorney-requests/decide', to: 'request#decide'
5657
end
5758
## 0966 Forms

0 commit comments

Comments
 (0)