Skip to content

Commit

Permalink
[API-44056] Update process for poa_vbms_updater (#20375)
Browse files Browse the repository at this point in the history
* add claims_api_processes

* add process model and polymorphic association

* add validation and spec

* add next step

* remove not_started and step_status presence

* update process for poa_vbms_updater

* restore gemfile

* cleanup
  • Loading branch information
tycol7 authored Jan 21, 2025
1 parent 5c2bb88 commit ac8c844
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/claims_api/app/sidekiq/claims_api/poa_vbms_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module ClaimsApi
class PoaVBMSUpdater < ClaimsApi::ServiceBase
def perform(power_of_attorney_id) # rubocop:disable Metrics/MethodLength
poa_form = ClaimsApi::PowerOfAttorney.find(power_of_attorney_id)
process = ClaimsApi::Process.find_or_create_by(processable: poa_form, step_type: 'POA_ACCESS_UPDATE')
process.update!(step_status: 'IN_PROGRESS')
@external_uid = poa_form.external_uid
@external_key = poa_form.external_key
poa_code = extract_poa_code(poa_form.form_data)
Expand All @@ -25,10 +27,12 @@ def perform(power_of_attorney_id) # rubocop:disable Metrics/MethodLength

if response[:return_code] == 'GUIE50000'
poa_form.status = ClaimsApi::PowerOfAttorney::UPDATED
process.update!(step_status: 'SUCCESS')
poa_form.vbms_error_message = nil if poa_form.vbms_error_message.present?
ClaimsApi::Logger.log('poa_vbms_updater', poa_id: power_of_attorney_id, detail: 'VBMS Success')
else
poa_form.status = ClaimsApi::PowerOfAttorney::ERRORED
process.update!(step_status: 'FAILED')
poa_form.vbms_error_message = 'update_poa_access failed with code ' \
"#{response[:return_code]}: #{response[:return_message]}"
ClaimsApi::Logger.log('poa_vbms_updater',
Expand All @@ -40,6 +44,7 @@ def perform(power_of_attorney_id) # rubocop:disable Metrics/MethodLength
poa_form.save
rescue BGS::ShareError => e
poa_form.status = ClaimsApi::PowerOfAttorney::ERRORED
process.update!(step_status: 'FAILED')
poa_form.vbms_error_message = e.respond_to?(:message) ? e.message : 'BGS::ShareError'
poa_form.save
ClaimsApi::Logger.log('poa', poa_id: poa_form.id, detail: 'BGS Error', error: e)
Expand Down
8 changes: 8 additions & 0 deletions modules/claims_api/spec/sidekiq/poa_vbms_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
poa = create_poa(allow_poa_access: true)
create_mock_lighthouse_service
subject.new.perform(poa.id)
process = ClaimsApi::Process.find_by(processable: poa, step_type: 'POA_ACCESS_UPDATE')
expect(process.step_status).to eq('SUCCESS')
end
end

Expand All @@ -48,6 +50,8 @@
poa = create_poa(allow_poa_access: true)
create_mock_lighthouse_service
subject.new.perform(poa.id)
process = ClaimsApi::Process.find_by(processable: poa, step_type: 'POA_ACCESS_UPDATE')
expect(process.step_status).to eq('SUCCESS')
end
end

Expand All @@ -59,6 +63,8 @@
poa = create_poa(allow_poa_access: true)
create_mock_lighthouse_service
subject.new.perform(poa.id)
process = ClaimsApi::Process.find_by(processable: poa, step_type: 'POA_ACCESS_UPDATE')
expect(process.step_status).to eq('SUCCESS')
end
end

Expand All @@ -74,6 +80,8 @@
poa.reload
expect(poa.status).to eq('errored')
expect(poa.vbms_error_message).to eq('updatePoaAccess: No POA found on system of record')
process = ClaimsApi::Process.find_by(processable: poa, step_type: 'POA_ACCESS_UPDATE')
expect(process.step_status).to eq('FAILED')
end
end

Expand Down

0 comments on commit ac8c844

Please sign in to comment.