Class: Lighthouse::CreateIntentToFileJob
- Inherits:
-
Object
- Object
- Lighthouse::CreateIntentToFileJob
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/lighthouse/create_intent_to_file_job.rb
Defined Under Namespace
Classes: FormNotFoundError, InvalidITFTypeError, MissingICNError, MissingParticipantIDError
Constant Summary collapse
- ITF_FORMS =
Only pension form configured to create async ITFs for now
{ # '21-526EZ' => 'compensation', # '21P-530' => 'survivor', # '21P-530V2' => 'survivor', '21P-527EZ' => 'pension' }.freeze
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#itf_type ⇒ Object
readonly
Returns the value of attribute itf_type.
Instance Method Summary collapse
-
#init(in_progress_form_id, veteran_icn, participant_id) ⇒ Object
private
Instantiate instance variables for this job.
-
#itf_log_monitor ⇒ BenefitsClaims::IntentToFile::Monitor
private
retreive a monitor for tracking.
-
#perform(in_progress_form_id, veteran_icn, participant_id) ⇒ Object
Create an Intent to File using the Lighthouse ITF endpoint for given in progress form, ICN, and PID.
-
#triage_rescued_error(exception) ⇒ Object
private
Track error, prevent retry if will result in known failure, raise again otherwise.
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
10 11 12 |
# File 'app/sidekiq/lighthouse/create_intent_to_file_job.rb', line 10 def form @form end |
#itf_type ⇒ Object (readonly)
Returns the value of attribute itf_type.
10 11 12 |
# File 'app/sidekiq/lighthouse/create_intent_to_file_job.rb', line 10 def itf_type @itf_type end |
Instance Method Details
#init(in_progress_form_id, veteran_icn, participant_id) ⇒ Object (private)
Instantiate instance variables for this job
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/sidekiq/lighthouse/create_intent_to_file_job.rb', line 83 def init(in_progress_form_id, veteran_icn, participant_id) raise MissingICNError, 'Init failed. No veteran ICN provided' if veteran_icn.blank? raise MissingParticipantIDError, 'Init failed. No veteran participant ID provided' if participant_id.blank? @form = InProgressForm.find(in_progress_form_id) raise FormNotFoundError, 'Init failed. Form not found for given ID' if form.blank? @itf_type = ITF_FORMS[form&.form_id] if form.user_account.blank? || form.user_account&.icn != veteran_icn raise ActiveRecord::RecordNotFound, 'Init failed. User account not found for given veteran ICN' end raise InvalidITFTypeError, 'Init failed. Form type not supported for auto ITF' if itf_type.blank? end |
#itf_log_monitor ⇒ BenefitsClaims::IntentToFile::Monitor (private)
retreive a monitor for tracking
123 124 125 |
# File 'app/sidekiq/lighthouse/create_intent_to_file_job.rb', line 123 def itf_log_monitor @itf_log_monitor ||= BenefitsClaims::IntentToFile::Monitor.new end |
#perform(in_progress_form_id, veteran_icn, participant_id) ⇒ Object
Create an Intent to File using the Lighthouse ITF endpoint for given in progress form, ICN, and PID
On success/failure log and increment the respective Datadog counter
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/sidekiq/lighthouse/create_intent_to_file_job.rb', line 63 def perform(in_progress_form_id, veteran_icn, participant_id) init(in_progress_form_id, veteran_icn, participant_id) itf_log_monitor.track_create_itf_begun(itf_type, form&.created_at&.to_s, form&.user_account_id) service = BenefitsClaims::Service.new(veteran_icn) service.create_intent_to_file(itf_type, '') itf_log_monitor.track_create_itf_success(itf_type, form&.created_at&.to_s, form&.user_account_id) rescue => e triage_rescued_error(e) end |
#triage_rescued_error(exception) ⇒ Object (private)
Track error, prevent retry if will result in known failure, raise again otherwise
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/sidekiq/lighthouse/create_intent_to_file_job.rb', line 103 def triage_rescued_error(exception) if exception.instance_of?(MissingICNError) itf_log_monitor.track_missing_user_icn(form, exception) elsif exception.instance_of?(MissingParticipantIDError) itf_log_monitor.track_missing_user_pid(form, exception) elsif exception.instance_of?(InvalidITFTypeError) itf_log_monitor.track_invalid_itf_type(form, exception) elsif exception.instance_of?(FormNotFoundError) itf_log_monitor.track_missing_form(form, exception) else itf_log_monitor.track_create_itf_failure(itf_type, form&.created_at&.to_s, form&.user_account_id, exception) raise exception end end |