Class: BGS::SubmitForm686cJob
- Includes:
- SentryLogging, Sidekiq::Job
- Defined in:
- app/sidekiq/bgs/submit_form686c_job.rb
Defined Under Namespace
Classes: Invalid686cClaim
Constant Summary collapse
- FORM_ID =
'686C-674'
Constants inherited from Job
Instance Attribute Summary collapse
-
#claim ⇒ Object
readonly
Returns the value of attribute claim.
-
#icn ⇒ Object
readonly
Returns the value of attribute icn.
-
#saved_claim_id ⇒ Object
readonly
Returns the value of attribute saved_claim_id.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_uuid ⇒ Object
readonly
Returns the value of attribute user_uuid.
-
#vet_info ⇒ Object
readonly
Returns the value of attribute vet_info.
Class Method Summary collapse
- .generate_user_struct(vet_info) ⇒ Object
- .send_backup_submission(vet_info, saved_claim_id, user_uuid) ⇒ Object
Instance Method Summary collapse
- #handle_filtered_errors!(e:, encrypted_vet_info:) ⇒ Object
- #instance_params(encrypted_vet_info, icn, user_uuid, saved_claim_id) ⇒ Object
- #perform(user_uuid, icn, saved_claim_id, encrypted_vet_info) ⇒ Object
- #send_confirmation_email ⇒ Object private
- #submit_forms(encrypted_vet_info) ⇒ Object private
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods inherited from Job
#in_progress_form_copy, #normalize_names_and_addresses!, #salvage_save_in_progress_form
Methods included from Utilities::Helpers
#normalize_composite_characters, #remove_special_characters_from_name
Instance Attribute Details
#claim ⇒ Object (readonly)
Returns the value of attribute claim.
12 13 14 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12 def claim @claim end |
#icn ⇒ Object (readonly)
Returns the value of attribute icn.
12 13 14 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12 def icn @icn end |
#saved_claim_id ⇒ Object (readonly)
Returns the value of attribute saved_claim_id.
12 13 14 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12 def saved_claim_id @saved_claim_id end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
12 13 14 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12 def user @user end |
#user_uuid ⇒ Object (readonly)
Returns the value of attribute user_uuid.
12 13 14 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12 def user_uuid @user_uuid end |
#vet_info ⇒ Object (readonly)
Returns the value of attribute vet_info.
12 13 14 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12 def vet_info @vet_info end |
Class Method Details
.generate_user_struct(vet_info) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 65 def self.generate_user_struct(vet_info) info = vet_info['veteran_information'] full_name = info['full_name'] OpenStruct.new( first_name: full_name['first'], last_name: full_name['last'], middle_name: full_name['middle'], ssn: info['ssn'], email: info['email'], va_profile_email: info['va_profile_email'], participant_id: info['participant_id'], icn: info['icn'], uuid: info['uuid'], common_name: info['common_name'] ) end |
.send_backup_submission(vet_info, saved_claim_id, user_uuid) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 82 def self.send_backup_submission(vet_info, saved_claim_id, user_uuid) user = generate_user_struct(vet_info) CentralMail::SubmitCentralForm686cJob.perform_async(saved_claim_id, KmsEncrypted::Box.new.encrypt(vet_info.to_json), KmsEncrypted::Box.new.encrypt(user.to_h.to_json)) InProgressForm.destroy_by(form_id: FORM_ID, user_uuid:) rescue => e Rails.logger.warn('BGS::SubmitForm686cJob backup submission failed...', { user_uuid:, saved_claim_id:, error: e., nested_error: e.cause&. }) InProgressForm.find_by(form_id: FORM_ID, user_uuid:)&.submission_pending! end |
Instance Method Details
#handle_filtered_errors!(e:, encrypted_vet_info:) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 44 def handle_filtered_errors!(e:, encrypted_vet_info:) filter = FILTERED_ERRORS.any? { |filtered| e..include?(filtered) || e.cause&.&.include?(filtered) } return unless filter Rails.logger.warn('BGS::SubmitForm686cJob received error, skipping retries...', { user_uuid:, saved_claim_id:, icn:, error: e., nested_error: e.cause&. }) vet_info = JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_vet_info)) self.class.send_backup_submission(vet_info, saved_claim_id, user_uuid) raise Sidekiq::JobRetry::Skip end |
#instance_params(encrypted_vet_info, icn, user_uuid, saved_claim_id) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 56 def instance_params(encrypted_vet_info, icn, user_uuid, saved_claim_id) @vet_info = JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_vet_info)) @user = BGS::SubmitForm686cJob.generate_user_struct(@vet_info) @icn = icn @user_uuid = user_uuid @saved_claim_id = saved_claim_id @claim = SavedClaim::DependencyClaim.find(saved_claim_id) end |
#perform(user_uuid, icn, saved_claim_id, encrypted_vet_info) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 27 def perform(user_uuid, icn, saved_claim_id, encrypted_vet_info) Rails.logger.info('BGS::SubmitForm686cJob running!', { user_uuid:, saved_claim_id:, icn: }) instance_params(encrypted_vet_info, icn, user_uuid, saved_claim_id) submit_forms(encrypted_vet_info) send_confirmation_email Rails.logger.info('BGS::SubmitForm686cJob succeeded!', { user_uuid:, saved_claim_id:, icn: }) InProgressForm.destroy_by(form_id: FORM_ID, user_uuid:) unless claim.submittable_674? rescue => e handle_filtered_errors!(e:, encrypted_vet_info:) Rails.logger.warn('BGS::SubmitForm686cJob received error, retrying...', { user_uuid:, saved_claim_id:, icn:, error: e., nested_error: e.cause&. }) raise end |
#send_confirmation_email ⇒ Object (private)
109 110 111 112 113 114 115 116 117 118 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 109 def send_confirmation_email return if user.va_profile_email.blank? VANotify::ConfirmationEmail.send( email_address: user.va_profile_email, template_id: Settings.vanotify.services.va_gov.template_id.form686c_confirmation_email, first_name: user&.first_name&.upcase, user_uuid_and_form_id: "#{user.uuid}_#{FORM_ID}" ) end |
#submit_forms(encrypted_vet_info) ⇒ Object (private)
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 96 def submit_forms(encrypted_vet_info) claim.add_veteran_info(vet_info) raise Invalid686cClaim unless claim.valid?(:run_686_form_jobs) claim_data = normalize_names_and_addresses!(claim.formatted_686_data(vet_info)) BGS::Form686c.new(user, claim).submit(claim_data) # If Form 686c job succeeds, then enqueue 674 job. BGS::SubmitForm674Job.perform_async(user_uuid, icn, saved_claim_id, encrypted_vet_info, KmsEncrypted::Box.new.encrypt(user.to_h.to_json)) if claim.submittable_674? # rubocop:disable Layout/LineLength end |