Class: BGS::SubmitForm674Job
- Includes:
- SentryLogging, Sidekiq::Job
- Defined in:
- app/sidekiq/bgs/submit_form674_job.rb
Defined Under Namespace
Classes: Invalid674Claim
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(encrypted_user_struct, vet_info) ⇒ Object
- .send_backup_submission(encrypted_user_struct_hash, vet_info, saved_claim_id, user_uuid) ⇒ Object
Instance Method Summary collapse
- #handle_filtered_errors!(e:, encrypted_user_struct_hash:, encrypted_vet_info:) ⇒ Object
- #instance_params(encrypted_vet_info, icn, encrypted_user_struct_hash, user_uuid, saved_claim_id) ⇒ Object
- #perform(user_uuid, icn, saved_claim_id, encrypted_vet_info, encrypted_user_struct_hash = nil) ⇒ Object
- #send_confirmation_email ⇒ Object private
- #submit_form ⇒ 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_form674_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_form674_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_form674_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_form674_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_form674_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_form674_job.rb', line 12 def vet_info @vet_info end |
Class Method Details
.generate_user_struct(encrypted_user_struct, vet_info) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/sidekiq/bgs/submit_form674_job.rb', line 65 def self.generate_user_struct(encrypted_user_struct, vet_info) if encrypted_user_struct.present? return OpenStruct.new(JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_user_struct))) end 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(encrypted_user_struct_hash, vet_info, saved_claim_id, user_uuid) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/sidekiq/bgs/submit_form674_job.rb', line 86 def self.send_backup_submission(encrypted_user_struct_hash, vet_info, saved_claim_id, user_uuid) user = generate_user_struct(encrypted_user_struct_hash, 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::SubmitForm674Job 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_user_struct_hash:, encrypted_vet_info:) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/sidekiq/bgs/submit_form674_job.rb', line 44 def handle_filtered_errors!(e:, encrypted_user_struct_hash:, encrypted_vet_info:) filter = FILTERED_ERRORS.any? { |filtered| e..include?(filtered) || e.cause&.&.include?(filtered) } return unless filter Rails.logger.warn('BGS::SubmitForm674Job 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(encrypted_user_struct_hash, vet_info, saved_claim_id, user_uuid) raise Sidekiq::JobRetry::Skip end |
#instance_params(encrypted_vet_info, icn, encrypted_user_struct_hash, user_uuid, saved_claim_id) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/sidekiq/bgs/submit_form674_job.rb', line 56 def instance_params(encrypted_vet_info, icn, encrypted_user_struct_hash, user_uuid, saved_claim_id) @vet_info = JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_vet_info)) @user = BGS::SubmitForm674Job.generate_user_struct(encrypted_user_struct_hash, @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, encrypted_user_struct_hash = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/sidekiq/bgs/submit_form674_job.rb', line 27 def perform(user_uuid, icn, saved_claim_id, encrypted_vet_info, encrypted_user_struct_hash = nil) Rails.logger.info('BGS::SubmitForm674Job running!', { user_uuid:, saved_claim_id:, icn: }) instance_params(encrypted_vet_info, icn, encrypted_user_struct_hash, user_uuid, saved_claim_id) submit_form send_confirmation_email Rails.logger.info('BGS::SubmitForm674Job succeeded!', { user_uuid:, saved_claim_id:, icn: }) InProgressForm.destroy_by(form_id: FORM_ID, user_uuid:) rescue => e handle_filtered_errors!(e:, encrypted_user_struct_hash:, encrypted_vet_info:) Rails.logger.warn('BGS::SubmitForm674Job received error, retrying...', { user_uuid:, saved_claim_id:, icn:, error: e., nested_error: e.cause&. }) raise end |
#send_confirmation_email ⇒ Object (private)
110 111 112 113 114 115 116 117 118 119 |
# File 'app/sidekiq/bgs/submit_form674_job.rb', line 110 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_form ⇒ Object (private)
100 101 102 103 104 105 106 107 108 |
# File 'app/sidekiq/bgs/submit_form674_job.rb', line 100 def submit_form claim.add_veteran_info(vet_info) raise Invalid674Claim unless claim.valid?(:run_686_form_jobs) claim_data = normalize_names_and_addresses!(claim.formatted_674_data(vet_info)) BGS::Form674.new(user, claim).submit(claim_data) end |