diff --git a/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb b/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb index 6450d718bb7..3e38c77e71c 100644 --- a/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb +++ b/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb @@ -60,8 +60,6 @@ def shared_form_validation(form_number) end def validate_registration_number!(form_number) - return if form_number != '2122' # Placeholder until API-33481 - base = form_number == '2122' ? 'serviceOrganization' : 'representative' rn = form_attributes.dig(base, 'registrationNumber') poa_code = form_attributes.dig(base, 'poaCode') @@ -70,7 +68,8 @@ def validate_registration_number!(form_number) rn).order(created_at: :desc).first if rep.nil? raise ::Common::Exceptions::ResourceNotFound.new( - detail: "Could not retrieve Power of Attorney with registration number: #{rn} and poa code: #{poa_code}" + detail: "Could not find an Accredited Representative with registration number: #{rn} " \ + "and poa code: #{poa_code}" ) end rep.id diff --git a/modules/claims_api/app/sidekiq/claims_api/v2/poa_form_builder_job.rb b/modules/claims_api/app/sidekiq/claims_api/v2/poa_form_builder_job.rb index 44f4ed78d4a..4564b5b154b 100644 --- a/modules/claims_api/app/sidekiq/claims_api/v2/poa_form_builder_job.rb +++ b/modules/claims_api/app/sidekiq/claims_api/v2/poa_form_builder_job.rb @@ -56,12 +56,12 @@ def data(power_of_attorney, form_number, rep) }) signatures = if form_number == '2122A' - individual_signatures(power_of_attorney) + individual_signatures(power_of_attorney, rep) else organization_signatures(power_of_attorney, rep) end - res.deep_merge!({ 'serviceOrganization' => { + res.deep_merge!({ (form_number == '2122A' ? 'representative' : 'serviceOrganization') => { 'firstName' => rep.first_name, 'lastName' => rep.last_name } }) @@ -88,48 +88,24 @@ def organization_signatures(power_of_attorney, rep) } end - def individual_signatures(power_of_attorney) - first_name = power_of_attorney.form_data['representative']['firstName'] - last_name = power_of_attorney.form_data['representative']['lastName'] + def individual_signatures(power_of_attorney, rep) { - 'page1' => individual_page1_signatures(power_of_attorney, first_name, last_name), - 'page2' => individual_page2_signatures(power_of_attorney, first_name, last_name) + 'page2' => [ + { + 'signature' => "#{power_of_attorney.auth_headers['va_eauth_firstName']} " \ + "#{power_of_attorney.auth_headers['va_eauth_lastName']} - signed via api.va.gov", + 'x' => 35, + 'y' => 306 + }, + { + 'signature' => "#{rep.first_name} #{rep.last_name} - signed via api.va.gov", + 'x' => 35, + 'y' => 200 + } + ] } end - def individual_page1_signatures(power_of_attorney, first_name, last_name) - [ - { - 'signature' => "#{power_of_attorney.auth_headers['va_eauth_firstName']} " \ - "#{power_of_attorney.auth_headers['va_eauth_lastName']} - signed via api.va.gov", - 'x' => 35, - 'y' => 73 - }, - { - 'signature' => "#{first_name} #{last_name} - signed via api.va.gov", - 'x' => 35, - 'y' => 100 - } - ] - end - - def individual_page2_signatures(power_of_attorney, rep_first_name, rep_last_name) - first_name, last_name = veteran_or_claimant_signature(power_of_attorney) - [ - { - 'signature' => "#{first_name} " \ - "#{last_name} - signed via api.va.gov", - 'x' => 35, - 'y' => 306 - }, - { - 'signature' => "#{rep_first_name} #{rep_last_name} - signed via api.va.gov", - 'x' => 35, - 'y' => 200 - } - ] - end - def veteran_or_claimant_signature(power_of_attorney) claimant = power_of_attorney.form_data['claimant'].present? if claimant diff --git a/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json b/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json index 0a94d64e1d7..6e76306fc95 100644 --- a/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json +++ b/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json @@ -8751,6 +8751,14 @@ "pointer": "data/attributes/representative" } }, + { + "title": "Unprocessable entity", + "detail": "The property /representative did not contain the required key registrationNumber", + "status": "422", + "source": { + "pointer": "data/attributes/representative" + } + }, { "title": "Unprocessable entity", "detail": "The property / did not contain the required key veteran", @@ -8815,7 +8823,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not find an Accredited Representative with code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/individual_controller.rb:35:in `validate_individual_poa_code!'" } @@ -9123,8 +9131,7 @@ "additionalProperties": false, "required": [ "poaCode", - "firstName", - "lastName", + "registrationNumber", "type" ], "properties": { @@ -9133,15 +9140,10 @@ "type": "string", "example": "A1Q" }, - "firstName": { - "description": "First Name of the representative.", - "type": "string", - "example": "John" - }, - "lastName": { - "description": "Last Name of the representative", + "registrationNumber": { + "description": "Registration Number of representative.", "type": "string", - "example": "Doe" + "example": "12345" }, "type": { "description": "Type of individual representative", @@ -9254,8 +9256,7 @@ }, "representative": { "poaCode": "083", - "firstName": "my", - "lastName": "name", + "registrationNumber": "67890", "type": "ATTORNEY", "address": { "addressLine1": "123", @@ -9531,7 +9532,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not retrieve Power of Attorney with registration number: 67890 and poa code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/organization_controller.rb:35:in `validate_org_poa_code!'" } @@ -10078,6 +10079,14 @@ "pointer": "data/attributes/representative" } }, + { + "title": "Unprocessable entity", + "detail": "The property /representative did not contain the required key registrationNumber", + "status": "422", + "source": { + "pointer": "data/attributes/representative" + } + }, { "title": "Unprocessable entity", "detail": "The property / did not contain the required key veteran", @@ -10142,7 +10151,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not find an Accredited Representative with code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/individual_controller.rb:35:in `validate_individual_poa_code!'" } @@ -10450,8 +10459,7 @@ "additionalProperties": false, "required": [ "poaCode", - "firstName", - "lastName", + "registrationNumber", "type" ], "properties": { @@ -10460,15 +10468,10 @@ "type": "string", "example": "A1Q" }, - "firstName": { - "description": "First Name of the representative.", - "type": "string", - "example": "John" - }, - "lastName": { - "description": "Last Name of the representative", + "registrationNumber": { + "description": "Registration Number of representative.", "type": "string", - "example": "Doe" + "example": "12345" }, "type": { "description": "Type of individual representative", @@ -10581,8 +10584,7 @@ }, "representative": { "poaCode": "083", - "firstName": "my", - "lastName": "name", + "registrationNumber": "67890", "type": "ATTORNEY", "address": { "addressLine1": "123", @@ -10849,7 +10851,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not retrieve Power of Attorney with registration number: 67890 and poa code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/organization_controller.rb:35:in `validate_org_poa_code!'" } @@ -11527,4 +11529,4 @@ } } ] -} \ No newline at end of file +} diff --git a/modules/claims_api/app/swagger/claims_api/v2/production/swagger.json b/modules/claims_api/app/swagger/claims_api/v2/production/swagger.json index 77631a3752e..5095d8c17b5 100644 --- a/modules/claims_api/app/swagger/claims_api/v2/production/swagger.json +++ b/modules/claims_api/app/swagger/claims_api/v2/production/swagger.json @@ -8751,6 +8751,14 @@ "pointer": "data/attributes/representative" } }, + { + "title": "Unprocessable entity", + "detail": "The property /representative did not contain the required key registrationNumber", + "status": "422", + "source": { + "pointer": "data/attributes/representative" + } + }, { "title": "Unprocessable entity", "detail": "The property / did not contain the required key veteran", @@ -8815,7 +8823,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not find an Accredited Representative with code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/individual_controller.rb:35:in `validate_individual_poa_code!'" } @@ -9123,8 +9131,7 @@ "additionalProperties": false, "required": [ "poaCode", - "firstName", - "lastName", + "registrationNumber", "type" ], "properties": { @@ -9133,15 +9140,10 @@ "type": "string", "example": "A1Q" }, - "firstName": { - "description": "First Name of the representative.", - "type": "string", - "example": "John" - }, - "lastName": { - "description": "Last Name of the representative", + "registrationNumber": { + "description": "Registration Number of representative.", "type": "string", - "example": "Doe" + "example": "12345" }, "type": { "description": "Type of individual representative", @@ -9254,8 +9256,7 @@ }, "representative": { "poaCode": "083", - "firstName": "my", - "lastName": "name", + "registrationNumber": "67890", "type": "ATTORNEY", "address": { "addressLine1": "123", @@ -9531,7 +9532,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not retrieve Power of Attorney with registration number: 67890 and poa code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/organization_controller.rb:35:in `validate_org_poa_code!'" } @@ -10078,6 +10079,14 @@ "pointer": "data/attributes/representative" } }, + { + "title": "Unprocessable entity", + "detail": "The property /representative did not contain the required key registrationNumber", + "status": "422", + "source": { + "pointer": "data/attributes/representative" + } + }, { "title": "Unprocessable entity", "detail": "The property / did not contain the required key veteran", @@ -10142,7 +10151,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not find an Accredited Representative with code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/individual_controller.rb:35:in `validate_individual_poa_code!'" } @@ -10450,8 +10459,7 @@ "additionalProperties": false, "required": [ "poaCode", - "firstName", - "lastName", + "registrationNumber", "type" ], "properties": { @@ -10460,15 +10468,10 @@ "type": "string", "example": "A1Q" }, - "firstName": { - "description": "First Name of the representative.", - "type": "string", - "example": "John" - }, - "lastName": { - "description": "Last Name of the representative", + "registrationNumber": { + "description": "Registration Number of representative.", "type": "string", - "example": "Doe" + "example": "12345" }, "type": { "description": "Type of individual representative", @@ -10581,8 +10584,7 @@ }, "representative": { "poaCode": "083", - "firstName": "my", - "lastName": "name", + "registrationNumber": "67890", "type": "ATTORNEY", "address": { "addressLine1": "123", @@ -10849,7 +10851,7 @@ { "title": "Resource not found", "status": "404", - "detail": "Could not retrieve Power of Attorney with registration number: 67890 and poa code: 083", + "detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083", "source": { "pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/organization_controller.rb:35:in `validate_org_poa_code!'" } @@ -11527,4 +11529,4 @@ } } ] -} \ No newline at end of file +} diff --git a/modules/claims_api/config/schemas/v2/2122a.json b/modules/claims_api/config/schemas/v2/2122a.json index 48d66dfa061..02cfe95b1a9 100644 --- a/modules/claims_api/config/schemas/v2/2122a.json +++ b/modules/claims_api/config/schemas/v2/2122a.json @@ -221,8 +221,7 @@ "additionalProperties": false, "required": [ "poaCode", - "firstName", - "lastName", + "registrationNumber", "type" ], "properties": { @@ -231,15 +230,10 @@ "type": "string", "example": "A1Q" }, - "firstName": { - "description": "First Name of the representative.", + "registrationNumber": { + "description": "Registration Number of representative.", "type": "string", - "example": "John" - }, - "lastName": { - "description": "Last Name of the representative", - "type": "string", - "example": "Doe" + "example": "12345" }, "type": { "description": "Type of individual representative", diff --git a/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_poa.json b/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_poa.json index f36c0e5e464..a93b72d9101 100644 --- a/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_poa.json +++ b/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_poa.json @@ -12,8 +12,7 @@ }, "representative": { "poaCode": "aaa", - "firstName": "my", - "lastName": "name", + "registrationNumber": "67890", "type": "ATTORNEY", "address": { "addressLine1": "123", diff --git a/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_schema.json b/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_schema.json index 6cad91eaee1..f9767e6e69c 100644 --- a/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_schema.json +++ b/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/invalid_schema.json @@ -2,11 +2,9 @@ "data": { "attributes": { "representative": { - "firstName": "my", - "lastName": "name", "type": "ATTORNEY", "address": { - "addressLine1": "123", + "addressLine1": "123", "city": "city", "country": "US", "zipCode": "12345" diff --git a/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/valid.json b/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/valid.json index c73ed3acc6e..ce086b08903 100644 --- a/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/valid.json +++ b/modules/claims_api/spec/fixtures/v2/veterans/power_of_attorney/2122a/valid.json @@ -14,8 +14,7 @@ }, "representative": { "poaCode": "083", - "firstName": "my", - "lastName": "name", + "registrationNumber": "67890", "type": "ATTORNEY", "address": { "addressLine1": "123", diff --git a/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_ind_request_spec.rb b/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_ind_request_spec.rb index 591c9a7f414..33164393062 100644 --- a/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_ind_request_spec.rb +++ b/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_ind_request_spec.rb @@ -39,8 +39,7 @@ }, representative: { poaCode: individual_poa_code, - firstName: 'my', - lastName: 'name', + registrationNumber: '12345', type: 'ATTORNEY', address: { addressLine1: '123', @@ -69,8 +68,7 @@ }, representative: { poaCode: individual_poa_code, - firstName: 'my', - lastName: 'name', + registrationNumber: '12345', type: 'ATTORNEY', address: { addressLine1: '123', @@ -259,8 +257,6 @@ }, representative: { poaCode: individual_poa_code, - firstName: 'my', - lastName: 'name', type: 'ATTORNEY', address: { addressLine1: '123', @@ -350,10 +346,10 @@ it 'returns a meaningful 404' do mock_ccg(%w[claim.write claim.read]) do |auth_header| - detail = 'Could not find an Accredited Representative with code: aaa' + detail = 'Could not find an Accredited Representative with registration number: 67890 ' \ + 'and poa code: aaa' post validate2122a_path, params: request_body, headers: auth_header - response_body = JSON.parse(response.body)['errors'][0] expect(response).to have_http_status(:not_found) diff --git a/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_org_request_spec.rb b/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_org_request_spec.rb index 4733aad6d52..54dceb8d695 100644 --- a/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_org_request_spec.rb +++ b/modules/claims_api/spec/requests/v2/veterans/power_of_attorney_org_request_spec.rb @@ -181,7 +181,8 @@ it 'returns a meaningful 404' do mock_ccg(%w[claim.write claim.read]) do |auth_header| - detail = 'Could not retrieve Power of Attorney with registration number: 67890 and poa code: aaa' + detail = 'Could not find an Accredited Representative with registration number: 67890 ' \ + 'and poa code: aaa' post validate2122_path, params: request_body, headers: auth_header diff --git a/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb b/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb index 05298265cb6..1f3152fe877 100644 --- a/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb +++ b/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb @@ -515,7 +515,7 @@ end before do |example| - Veteran::Service::Representative.new(representative_id: '12345', + Veteran::Service::Representative.new(representative_id: '67890', poa_codes: [poa_code], first_name: 'Firstname', last_name: 'Lastname', diff --git a/modules/claims_api/spec/sidekiq/v2/poa_form_builder_job_spec.rb b/modules/claims_api/spec/sidekiq/v2/poa_form_builder_job_spec.rb index 84bbe1d1968..5e2bee573bb 100644 --- a/modules/claims_api/spec/sidekiq/v2/poa_form_builder_job_spec.rb +++ b/modules/claims_api/spec/sidekiq/v2/poa_form_builder_job_spec.rb @@ -55,8 +55,6 @@ representative: { poaCode: poa_code.to_s, type: 'ATTORNEY', - firstName: 'Bob', - lastName: 'Representative', organizationName: 'I Help Vets LLC', address: { numberAndStreet: '2719 Hyperion Ave', @@ -84,21 +82,9 @@ } } ) - final_data = data.merge( + final_data = data.deep_merge( { 'text_signatures' => { - 'page1' => [ - { - 'signature' => 'JESSE GRAY - signed via api.va.gov', - 'x' => 35, - 'y' => 73 - }, - { - 'signature' => 'Bob Representative - signed via api.va.gov', - 'x' => 35, - 'y' => 100 - } - ], 'page2' => [ { 'signature' => 'JESSE GRAY - signed via api.va.gov', @@ -112,7 +98,7 @@ } ] }, - 'serviceOrganization' => { + 'representative' => { 'firstName' => 'Bob', 'lastName' => 'Representative' } @@ -218,24 +204,12 @@ } } ) - final_data = data.merge( + final_data = data.deep_merge( { 'text_signatures' => { - 'page1' => [ - { - 'signature' => 'JESSE GRAY - signed via api.va.gov', - 'x' => 35, - 'y' => 73 - }, - { - 'signature' => 'Bob Representative - signed via api.va.gov', - 'x' => 35, - 'y' => 100 - } - ], 'page2' => [ { - 'signature' => 'Mitchell Jenkins - signed via api.va.gov', + 'signature' => 'JESSE GRAY - signed via api.va.gov', 'x' => 35, 'y' => 306 }, @@ -246,7 +220,7 @@ } ] }, - 'serviceOrganization' => { + 'representative' => { 'firstName' => 'Bob', 'lastName' => 'Representative' } @@ -330,7 +304,7 @@ } } ) - final_data = data.merge( + final_data = data.deep_merge( { 'text_signatures' => { 'page2' => [ @@ -345,7 +319,8 @@ 'y' => 200 } ] - } + }, + 'serviceOrganization' => { 'firstName' => 'Bob', 'lastName' => 'Representative' } } ) @@ -445,7 +420,7 @@ } } ) - final_data = data.merge( + final_data = data.deep_merge( { 'text_signatures' => { 'page2' => [ @@ -460,7 +435,8 @@ 'y' => 200 } ] - } + }, + 'serviceOrganization' => { 'firstName' => 'Bob', 'lastName' => 'Representative' } } )