Skip to content

Commit dbf8521

Browse files
Api 44280 country code translation (#20596)
* API-44280-country-code-translation * Adds country code list to BRD modified: modules/claims_api/lib/brd/brd.rb * API-44280-country-code-translation * Updates Schema to accept countryCode in lace of country * Updates related JSON files * Updates related tests * Compiles Dev Docs to reflect the change (this endpoint is not in production yet) modified: modules/claims_api/app/controllers/claims_api/v2/blueprints/power_of_attorney_request_blueprint.rb modified: modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json modified: modules/claims_api/config/schemas/v2/poa_request.json modified: modules/claims_api/spec/controllers/v2/veterans/power_of_attorney/request_controller_spec.rb modified: modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/request_representative/invalid_claimant_schema.json modified: modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/request_representative/invalid_poa.json modified: modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/request_representative/invalid_schema.json modified: modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/request_representative/valid.json modified: modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/request_representative/valid_no_claimant.json modified: modules/claims_api/spec/requests/v2/veterans/power_of_attorney/power_of_attorney_request_spec.rb modified: spec/support/schemas/claims_api/v2/veterans/power_of_attorney/request_representative/submit.json * API-44280-country-code-translation * Adds validation check for create method * Adds tests for scenario * Updates countries list * Adds countryCode handling in * `vnp_ptcpnt_addrs_create` in create_request.rb * validation method in request_controller.rb modified: modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/request_controller.rb modified: modules/claims_api/app/services/claims_api/power_of_attorney_request_service/create_request.rb modified: modules/claims_api/lib/brd/brd.rb modified: modules/claims_api/spec/controllers/v2/veterans/power_of_attorney/request_controller_spec.rb modified: modules/claims_api/spec/requests/v2/veterans/power_of_attorney/power_of_attorney_request_spec.rb * Removes comment * Fixes comments in BTD list, merges in master branch and fixes conflicts * Adds regex for character limit on countryCode, fixes missed example text * Reverts unnecessary v1 and production swagger changes * Revert prod swagger take 2 * Revert prod swagger take 3 * API-44280-country-code-translation * upates REGEX to allow for numbers and dashes * Adds test for character patterns * character types * upper/lowercase * Updates swagger docs for DEV * Adds some normalization by uppercasing when checking the BRD list modified: modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/request_controller.rb modified: modules/claims_api/app/services/claims_api/power_of_attorney_request_service/create_request.rb modified: modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json modified: modules/claims_api/config/schemas/v2/poa_request.json modified: modules/claims_api/spec/controllers/v2/veterans/power_of_attorney/request_controller_spec.rb modified: spec/support/schemas/claims_api/v2/veterans/power_of_attorney/request_representative/submit.json * API-44280-country-code-translation * Fixes REGEX for lowercase acceptance modified: modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json modified: modules/claims_api/config/schemas/v2/poa_request.json modified: spec/support/schemas/claims_api/v2/veterans/power_of_attorney/request_representative/submit.json * Reverts Gemfile.lock changes * Revert production swagger change
1 parent 4ba678b commit dbf8521

File tree

14 files changed

+414
-67
lines changed

14 files changed

+414
-67
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PowerOfAttorneyRequestBlueprint < Blueprinter::Base
6666
address_line_2: request.dig('veteran', 'address', 'addressLine2'),
6767
city: request.dig('veteran', 'address', 'city'),
6868
state_code: request.dig('veteran', 'address', 'stateCode'),
69-
country: request.dig('veteran', 'address', 'country'),
69+
countryCode: request.dig('veteran', 'address', 'countryCode'),
7070
zip_code: request.dig('veteran', 'address', 'zipCode'),
7171
zip_code_suffix: request.dig('veteran', 'address', 'zipCodeSuffix')
7272
},
@@ -84,7 +84,7 @@ class PowerOfAttorneyRequestBlueprint < Blueprinter::Base
8484
address_line_2: request.dig('claimant', 'address', 'addressLine2'),
8585
city: request.dig('claimant', 'address', 'city'),
8686
state_code: request.dig('claimant', 'address', 'stateCode'),
87-
country: request.dig('claimant', 'address', 'country'),
87+
countryCode: request.dig('claimant', 'address', 'countryCode'),
8888
zip_code: request.dig('claimant', 'address', 'zipCode'),
8989
zip_code_suffix: request.dig('claimant', 'address', 'zipCodeSuffix')
9090
},

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

+19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'claims_api/common/exceptions/lighthouse/bad_gateway'
55
require 'claims_api/v2/error/lighthouse_error_handler'
66
require 'claims_api/v2/json_format_validation'
7+
require 'brd/brd'
78

89
module ClaimsApi
910
module V2
@@ -105,6 +106,7 @@ def decide # rubocop:disable Metrics/MethodLength
105106
end
106107

107108
def create # rubocop:disable Metrics/MethodLength
109+
validate_country_code
108110
# validate target veteran exists
109111
target_veteran
110112

@@ -153,6 +155,23 @@ def create # rubocop:disable Metrics/MethodLength
153155

154156
private
155157

158+
def validate_country_code
159+
vet_cc = form_attributes.dig('veteran', 'address', 'countryCode')
160+
claimant_cc = form_attributes.dig('claimant', 'address', 'countryCode')
161+
162+
if ClaimsApi::BRD::COUNTRY_CODES[vet_cc.to_s.upcase].blank?
163+
raise ::Common::Exceptions::UnprocessableEntity.new(
164+
detail: 'The country provided is not valid.'
165+
)
166+
end
167+
168+
if claimant_cc.present? && ClaimsApi::BRD::COUNTRY_CODES[claimant_cc.to_s.upcase].blank?
169+
raise ::Common::Exceptions::UnprocessableEntity.new(
170+
detail: 'The country provided is not valid.'
171+
)
172+
end
173+
end
174+
156175
def validate_decide_params!(proc_id:, decision:)
157176
if proc_id.blank?
158177
raise ::Common::Exceptions::ParameterMissing.new('procId',

modules/claims_api/app/services/claims_api/power_of_attorney_request_service/create_request.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
require 'bgs_service/vnp_ptcpnt_phone_service'
99
require 'bgs_service/vnp_ptcpnt_service'
1010
require 'concurrent-ruby'
11+
require 'brd/brd'
1112

1213
module ClaimsApi
1314
module PowerOfAttorneyRequestService
@@ -169,7 +170,7 @@ def create_vnp_mailing_address(address, vnp_ptcpnt_id)
169170
addrs_two_txt: address[:addressLine2],
170171
bad_addrs_ind: nil,
171172
city_nm: address[:city],
172-
cntry_nm: address[:country],
173+
cntry_nm: ClaimsApi::BRD::COUNTRY_CODES[(address[:countryCode]).to_s.upcase],
173174
county_nm: nil,
174175
eft_waiver_type_nm: nil,
175176
email_addrs_txt: nil,

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

+44-40
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
"202 without a transactionId": {
336336
"value": {
337337
"data": {
338-
"id": "8e482717-0388-4018-9199-4c34b479840f",
338+
"id": "cb5b9c1d-5a9b-4a56-902d-ebd7f666efec",
339339
"type": "forms/526",
340340
"attributes": {
341341
"claimId": "600442191",
@@ -520,7 +520,7 @@
520520
},
521521
"federalActivation": {
522522
"activationDate": "2023-10-01",
523-
"anticipatedSeparationDate": "2025-02-07"
523+
"anticipatedSeparationDate": "2025-02-12"
524524
},
525525
"confinements": [
526526
{
@@ -566,7 +566,7 @@
566566
"202 with a transactionId": {
567567
"value": {
568568
"data": {
569-
"id": "25bb7925-d6a2-4087-8b84-4940b5bcf2fa",
569+
"id": "91a467ee-c984-4f74-9dcf-33e0522090ae",
570570
"type": "forms/526",
571571
"attributes": {
572572
"claimId": "600442191",
@@ -730,7 +730,7 @@
730730
"serviceBranch": "Public Health Service",
731731
"serviceComponent": "Active",
732732
"activeDutyBeginDate": "2008-11-14",
733-
"activeDutyEndDate": "2025-02-07",
733+
"activeDutyEndDate": "2025-02-12",
734734
"separationLocationCode": "98282"
735735
}
736736
],
@@ -751,7 +751,7 @@
751751
},
752752
"federalActivation": {
753753
"activationDate": "2023-10-01",
754-
"anticipatedSeparationDate": "2025-02-07"
754+
"anticipatedSeparationDate": "2025-02-12"
755755
},
756756
"confinements": [
757757
{
@@ -3994,7 +3994,7 @@
39943994
"serviceBranch": "Public Health Service",
39953995
"serviceComponent": "Active",
39963996
"activeDutyBeginDate": "2008-11-14",
3997-
"activeDutyEndDate": "2025-02-07",
3997+
"activeDutyEndDate": "2025-02-12",
39983998
"separationLocationCode": "98282"
39993999
}
40004000
],
@@ -4015,7 +4015,7 @@
40154015
},
40164016
"federalActivation": {
40174017
"activationDate": "2023-10-01",
4018-
"anticipatedSeparationDate": "2025-02-07"
4018+
"anticipatedSeparationDate": "2025-02-12"
40194019
},
40204020
"confinements": [
40214021
{
@@ -8537,8 +8537,8 @@
85378537
"id": "1",
85388538
"type": "intent_to_file",
85398539
"attributes": {
8540-
"creationDate": "2025-02-05",
8541-
"expirationDate": "2026-02-05",
8540+
"creationDate": "2025-02-10",
8541+
"expirationDate": "2026-02-10",
85428542
"type": "compensation",
85438543
"status": "active"
85448544
}
@@ -9331,7 +9331,7 @@
93319331
"status": "422",
93329332
"detail": "Could not retrieve Power of Attorney due to multiple representatives with code: A1Q",
93339333
"source": {
9334-
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb:164:in `representative'"
9334+
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb:163:in `representative'"
93359335
}
93369336
}
93379337
]
@@ -9428,7 +9428,7 @@
94289428
"application/json": {
94299429
"example": {
94309430
"data": {
9431-
"id": "f748fd99-12a6-4c5c-a533-b87ad954eb37",
9431+
"id": "b4743fc9-02d1-471d-be6f-f087f15c6762",
94329432
"type": "power-of-attorney-request",
94339433
"attributes": {
94349434
"veteran": {
@@ -9439,7 +9439,7 @@
94399439
"addressLine2": "Apt 2",
94409440
"city": "Los Angeles",
94419441
"stateCode": "CA",
9442-
"country": "USA",
9442+
"countryCode": "US",
94439443
"zipCode": "92264",
94449444
"zipCodeSuffix": "0200"
94459445
},
@@ -9457,7 +9457,7 @@
94579457
"addressLine2": null,
94589458
"city": null,
94599459
"stateCode": null,
9460-
"country": null,
9460+
"countryCode": null,
94619461
"zipCode": null,
94629462
"zipCodeSuffix": null
94639463
},
@@ -9554,7 +9554,7 @@
95549554
"addressLine1",
95559555
"city",
95569556
"stateCode",
9557-
"country",
9557+
"countryCode",
95589558
"zipCode"
95599559
],
95609560
"properties": {
@@ -9580,10 +9580,11 @@
95809580
"pattern": "^[a-z,A-Z]{2}$",
95819581
"example": "OR"
95829582
},
9583-
"country": {
9584-
"description": "Country of the address. USA is the value to use for United States based addresses, US will not work.",
9583+
"countryCode": {
9584+
"description": "Country code of the address.",
95859585
"type": "string",
9586-
"example": "USA"
9586+
"example": "US",
9587+
"pattern": "^[A-Za-z0-9-]{2,6}$"
95879588
},
95889589
"zipCode": {
95899590
"description": "Zipcode (First 5 digits) of the address.",
@@ -9671,10 +9672,11 @@
96719672
"pattern": "^[a-z,A-Z]{2}$",
96729673
"example": "OR"
96739674
},
9674-
"country": {
9675-
"description": "Country of the address. Required if claimant information provided.",
9675+
"countryCode": {
9676+
"description": "Country code of the address. Required if claimant information provided.",
96769677
"type": "string",
9677-
"example": "USA"
9678+
"example": "US",
9679+
"pattern": "^[A-Za-z0-9-]{2,6}$"
96789680
},
96799681
"zipCode": {
96809682
"description": "Zipcode (First 5 digits) of the address. Required if claimant information provided.",
@@ -10023,7 +10025,7 @@
1002310025
"addressLine1",
1002410026
"city",
1002510027
"stateCode",
10026-
"country",
10028+
"countryCode",
1002710029
"zipCode"
1002810030
],
1002910031
"properties": {
@@ -10049,10 +10051,11 @@
1004910051
"pattern": "^[a-z,A-Z]{2}$",
1005010052
"example": "OR"
1005110053
},
10052-
"country": {
10053-
"description": "Country of the address. USA is the value to use for United States based addresses, US will not work.",
10054+
"countryCode": {
10055+
"description": "Country code of the address.",
1005410056
"type": "string",
10055-
"example": "USA"
10057+
"example": "US",
10058+
"pattern": "^[A-Za-z0-9-]{2,6}$"
1005610059
},
1005710060
"zipCode": {
1005810061
"description": "Zipcode (First 5 digits) of the address.",
@@ -10140,10 +10143,11 @@
1014010143
"pattern": "^[a-z,A-Z]{2}$",
1014110144
"example": "OR"
1014210145
},
10143-
"country": {
10144-
"description": "Country of the address. Required if claimant information provided.",
10146+
"countryCode": {
10147+
"description": "Country code of the address. Required if claimant information provided.",
1014510148
"type": "string",
10146-
"example": "USA"
10149+
"example": "US",
10150+
"pattern": "^[A-Za-z0-9-]{2,6}$"
1014710151
},
1014810152
"zipCode": {
1014910153
"description": "Zipcode (First 5 digits) of the address. Required if claimant information provided.",
@@ -10259,7 +10263,7 @@
1025910263
"addressLine1": "2719 Hyperion Ave",
1026010264
"addressLine2": "Apt 2",
1026110265
"city": "Los Angeles",
10262-
"country": "USA",
10266+
"countryCode": "US",
1026310267
"stateCode": "CA",
1026410268
"zipCode": "92264",
1026510269
"zipCodeSuffix": "0200"
@@ -11900,7 +11904,7 @@
1190011904
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1190111905
"example": "555-5555",
1190211906
"minLength": 1,
11903-
"maxLength": 14
11907+
"maxLength": 23
1190411908
}
1190511909
},
1190611910
"if": {
@@ -12040,7 +12044,7 @@
1204012044
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1204112045
"example": "555-5555",
1204212046
"minLength": 1,
12043-
"maxLength": 14
12047+
"maxLength": 23
1204412048
}
1204512049
},
1204612050
"if": {
@@ -12221,7 +12225,7 @@
1222112225
"application/json": {
1222212226
"example": {
1222312227
"data": {
12224-
"id": "a2637127-6b5d-4f21-8e8b-7ecd93521f56",
12228+
"id": "e65a310f-43ad-49ac-a51f-c48ce1db4af7",
1222512229
"type": "organization",
1222612230
"attributes": {
1222712231
"code": "083",
@@ -12589,7 +12593,7 @@
1258912593
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1259012594
"example": "555-5555",
1259112595
"minLength": 1,
12592-
"maxLength": 14
12596+
"maxLength": 23
1259312597
}
1259412598
},
1259512599
"if": {
@@ -12729,7 +12733,7 @@
1272912733
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1273012734
"example": "555-5555",
1273112735
"minLength": 1,
12732-
"maxLength": 14
12736+
"maxLength": 23
1273312737
}
1273412738
},
1273512739
"if": {
@@ -13341,7 +13345,7 @@
1334113345
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1334213346
"example": "555-5555",
1334313347
"minLength": 1,
13344-
"maxLength": 14
13348+
"maxLength": 23
1334513349
}
1334613350
},
1334713351
"if": {
@@ -13467,7 +13471,7 @@
1346713471
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1346813472
"example": "555-5555",
1346913473
"minLength": 1,
13470-
"maxLength": 14
13474+
"maxLength": 23
1347113475
}
1347213476
},
1347313477
"if": {
@@ -13711,7 +13715,7 @@
1371113715
"application/json": {
1371213716
"example": {
1371313717
"data": {
13714-
"id": "bce45d99-e99d-4315-9700-bc5a778e2d38",
13718+
"id": "8fd8a8f6-9095-4824-997b-b6f69f435a05",
1371513719
"type": "individual",
1371613720
"attributes": {
1371713721
"code": "067",
@@ -14096,7 +14100,7 @@
1409614100
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1409714101
"example": "555-5555",
1409814102
"minLength": 1,
14099-
"maxLength": 14
14103+
"maxLength": 23
1410014104
}
1410114105
},
1410214106
"if": {
@@ -14222,7 +14226,7 @@
1422214226
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
1422314227
"example": "555-5555",
1422414228
"minLength": 1,
14225-
"maxLength": 14
14229+
"maxLength": 23
1422614230
}
1422714231
},
1422814232
"if": {
@@ -14555,10 +14559,10 @@
1455514559
"application/json": {
1455614560
"example": {
1455714561
"data": {
14558-
"id": "7ea83b6f-d2fa-4370-b1c4-a40c7dc33925",
14562+
"id": "345f4c8d-91c0-4d2e-9ce1-ba64e0b5265c",
1455914563
"type": "claimsApiPowerOfAttorneys",
1456014564
"attributes": {
14561-
"createdAt": "2025-02-05T21:37:11.866Z",
14565+
"createdAt": "2025-02-10 20:57:23 UTC",
1456214566
"representative": {
1456314567
"poaCode": "074"
1456414568
},

0 commit comments

Comments
 (0)