Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api 45134 remove reg number job title #20876

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ class PowerOfAttorneyRequestBlueprint < Blueprinter::Base
email: request.dig('claimant', 'email'),
relationship: request.dig('claimant', 'relationship')
},
poa: {
poa_code: request.dig('poa', 'poaCode'),
registration_number: request.dig('poa', 'registrationNumber'),
job_title: request.dig('poa', 'jobTitle')
representative: {
poa_code: request.dig('representative', 'poaCode')
},
record_consent: request['recordConsent'],
consent_limits: request['consentLimits'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ def create # rubocop:disable Metrics/MethodLength
# validate target veteran exists
target_veteran

poa_code = form_attributes.dig('poa', 'poaCode')
poa_code = form_attributes.dig('representative', 'poaCode')
@claims_api_forms_validation_errors = validate_form_2122_and_2122a_submission_values(user_profile:)

validate_json_schema(FORM_NUMBER)
validate_accredited_representative(form_attributes.dig('poa', 'registrationNumber'),
poa_code)
validate_accredited_representative(poa_code)
validate_accredited_organization(poa_code)

# if we get here, the only errors not raised are form value validation errors
Expand Down Expand Up @@ -221,16 +220,14 @@ def validate_ptcpnt_id!(ptcpnt_id:, proc_id:, representative_id:, service:)
matching_request
end

def validate_accredited_representative(registration_number, poa_code)
@representative = ::Veteran::Service::Representative.where('? = ANY(poa_codes) AND representative_id = ?',
poa_code,
registration_number).order(created_at: :desc).first
def validate_accredited_representative(poa_code)
@representative = ::Veteran::Service::Representative.where('? = ANY(poa_codes)',
poa_code).order(created_at: :desc).first
# there must be a representative to appoint. This representative can be an accredited attorney, claims agent,
# or representative.
if @representative.nil?
raise ::Common::Exceptions::ResourceNotFound.new(
detail: "Could not find an Accredited Representative with registration number: #{registration_number} " \
"and poa code: #{poa_code}"
detail: "Could not find an Accredited Representative with poa code: #{poa_code}"
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PoaFormBuilderJob < ClaimsApi::ServiceBase
# it queues a job to update the POA code in BGS, as well.
#
# @param power_of_attorney_id [String] Unique identifier of the submitted POA
def perform(power_of_attorney_id, form_number, rep_id, action) # rubocop:disable Metrics/MethodLength
def perform(power_of_attorney_id, form_number, action, rep_id = nil) # rubocop:disable Metrics/MethodLength
power_of_attorney = ClaimsApi::PowerOfAttorney.find(power_of_attorney_id)

process = ClaimsApi::Process.find_or_create_by(processable: power_of_attorney,
Expand Down
52 changes: 13 additions & 39 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9468,10 +9468,8 @@
"email": null,
"relationship": null
},
"poa": {
"poaCode": "067",
"registrationNumber": "999999999999",
"jobTitle": "MyJob"
"representative": {
"poaCode": "067"
},
"recordConsent": true,
"consentLimits": [
Expand Down Expand Up @@ -9516,7 +9514,7 @@
"additionalProperties": false,
"required": [
"veteran",
"poa",
"representative",
"recordConsent",
"consentAddressChange"
],
Expand Down Expand Up @@ -9729,29 +9727,18 @@
}
}
},
"poa": {
"representative": {
"description": "Details of the requested Power of Attorney representing the veteran.",
"type": "object",
"additionalProperties": false,
"required": [
"poaCode",
"registrationNumber"
"poaCode"
],
"properties": {
"poaCode": {
"description": "The POA code of the accredited representative or organization.",
"type": "string",
"example": "A1Q"
},
"registrationNumber": {
"description": "Registration Number of the accredited representative.",
"type": "string",
"example": "12345"
},
"jobTitle": {
"description": "Job title of the accredited representative.",
"type": "string",
"example": "Veteran Service Representative"
}
}
},
Expand Down Expand Up @@ -9852,10 +9839,10 @@
"errors": [
{
"title": "Unprocessable entity",
"detail": "The property /poa did not contain the required key poaCode",
"detail": "The property /representative did not contain the required key poaCode",
"status": "422",
"source": {
"pointer": "data/attributes/poa"
"pointer": "data/attributes/representative"
}
}
]
Expand Down Expand Up @@ -9914,7 +9901,7 @@
{
"status": "404",
"title": "Resource not found",
"detail": "Could not find an Accredited Representative with registration number: 999999999999 and poa code: 067"
"detail": "Could not find an Accredited Representative with poa code: 067"
}
]
},
Expand Down Expand Up @@ -9987,7 +9974,7 @@
"additionalProperties": false,
"required": [
"veteran",
"poa",
"representative",
"recordConsent",
"consentAddressChange"
],
Expand Down Expand Up @@ -10200,29 +10187,18 @@
}
}
},
"poa": {
"representative": {
"description": "Details of the requested Power of Attorney representing the veteran.",
"type": "object",
"additionalProperties": false,
"required": [
"poaCode",
"registrationNumber"
"poaCode"
],
"properties": {
"poaCode": {
"description": "The POA code of the accredited representative or organization.",
"type": "string",
"example": "A1Q"
},
"registrationNumber": {
"description": "Registration Number of the accredited representative.",
"type": "string",
"example": "12345"
},
"jobTitle": {
"description": "Job title of the accredited representative.",
"type": "string",
"example": "Veteran Service Representative"
}
}
},
Expand Down Expand Up @@ -10275,10 +10251,8 @@
"email": "[email protected]",
"insuranceNumber": "1234567890"
},
"poa": {
"poaCode": "067",
"registrationNumber": "999999999999",
"jobTitle": "MyJob"
"representative": {
"poaCode": "067"
},
"recordConsent": true,
"consentAddressChange": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9331,7 +9331,7 @@
"status": "422",
"detail": "Could not retrieve Power of Attorney due to multiple representatives with code: A1Q",
"source": {
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb:164:in `representative'"
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb:163:in `representative'"
}
}
]
Expand Down Expand Up @@ -9787,7 +9787,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down Expand Up @@ -9927,7 +9927,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down Expand Up @@ -10476,7 +10476,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down Expand Up @@ -10616,7 +10616,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down Expand Up @@ -11228,7 +11228,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down Expand Up @@ -11354,7 +11354,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down Expand Up @@ -11983,7 +11983,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down Expand Up @@ -12109,7 +12109,7 @@
"pattern": "^\\d(?:[- ]?\\d){0,13}$",
"example": "555-5555",
"minLength": 1,
"maxLength": 14
"maxLength": 23
}
},
"if": {
Expand Down
17 changes: 3 additions & 14 deletions modules/claims_api/config/schemas/v2/poa_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"additionalProperties": false,
"required": [
"veteran",
"poa",
"representative",
"recordConsent",
"consentAddressChange"
],
Expand Down Expand Up @@ -214,29 +214,18 @@
}
}
},
"poa": {
"representative": {
"description": "Details of the requested Power of Attorney representing the veteran.",
"type": "object",
"additionalProperties": false,
"required": [
"poaCode",
"registrationNumber"
"poaCode"
],
"properties": {
"poaCode": {
"description": "The POA code of the accredited representative or organization.",
"type": "string",
"example": "A1Q"
},
"registrationNumber": {
"description": "Registration Number of the accredited representative.",
"type": "string",
"example": "12345"
},
"jobTitle": {
"description": "Job title of the accredited representative.",
"type": "string",
"example": "Veteran Service Representative"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
"email": "[email protected]",
"relationship": "Spouse"
},
"poa": {
"poaCode": "067",
"registrationNumber": "999999999999",
"jobTitle": "Best Rep Ever"
"representative": {
"poaCode": "067"
},
"recordConsent": true,
"consentAddressChange": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
"email": "[email protected]",
"insuranceNumber": "678678987"
},
"poa": {
"poaCode": "AG3",
"registrationNumber": "999999999999",
"jobTitle": "Best Rep Ever"
"representative": {
"poaCode": "AG3"
},
"recordConsent": true,
"consentAddressChange": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
"email": "[email protected]",
"insuranceNumber": "678678987"
},
"poa": {
"registrationNumber": "999999999999",
"jobTitle": "Best Rep Ever"
"representative": {
},
"recordConsent": true,
"consentAddressChange": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
"email": "[email protected]",
"relationship": "Spouse"
},
"poa": {
"poaCode": "067",
"registrationNumber": "999999999999",
"jobTitle": "MyJob"
"representative": {
"poaCode": "067"
},
"recordConsent": true,
"consentAddressChange": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
"email": "[email protected]",
"insuranceNumber": "1234567890"
},
"poa": {
"poaCode": "067",
"registrationNumber": "999999999999",
"jobTitle": "MyJob"
"representative": {
"poaCode": "067"
},
"recordConsent": true,
"consentAddressChange": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
it 'returns a meaningful 422' do
VCR.use_cassette('claims_api/mpi/find_candidate/valid_icn_full') do
mock_ccg(scopes) do |auth_header|
detail = 'The property /poa did not contain the required key poaCode'
detail = 'The property /representative did not contain the required key poaCode'

post request_path, params: request_body, headers: auth_header

Expand Down Expand Up @@ -123,8 +123,7 @@

it 'returns a meaningful 404' do
mock_ccg(scopes) do |auth_header|
detail = 'Could not find an Accredited Representative with registration number: 999999999999 ' \
'and poa code: AG3'
detail = 'Could not find an Accredited Representative with poa code: AG3'

post request_path, params: request_body, headers: auth_header

Expand Down
Loading
Loading