Class: BGS::SubmitForm686cJob

Inherits:
Job
  • Object
show all
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'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

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

#claimObject (readonly)

Returns the value of attribute claim.



12
13
14
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12

def claim
  @claim
end

#in_progress_copyObject (readonly)

Returns the value of attribute in_progress_copy.



12
13
14
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 12

def in_progress_copy
  @in_progress_copy
end

#saved_claim_idObject (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

#userObject (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_uuidObject (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_infoObject (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

Instance Method Details

#perform(user_uuid, icn, saved_claim_id, vet_info) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/sidekiq/bgs/submit_form686c_job.rb', line 31

def perform(user_uuid, icn, saved_claim_id, vet_info)
  Rails.logger.info('BGS::SubmitForm686cJob running!', { user_uuid:, saved_claim_id:, icn: })

  @vet_info = vet_info
  @user = generate_user_struct
  @user_uuid = user_uuid
  @saved_claim_id = saved_claim_id

  in_progress_form = InProgressForm.find_by(form_id: FORM_ID, user_uuid:)
  @in_progress_copy = in_progress_form_copy(in_progress_form)

  claim_data = normalize_names_and_addresses!(valid_claim_data)

  BGS::Form686c.new(user, claim).submit(claim_data)

  # If Form 686c job succeeds, then enqueue 674 job.
  user_struct_hash = user.to_h
  BGS::SubmitForm674Job.perform_async(user_uuid, icn, saved_claim_id, vet_info, user_struct_hash) if claim.submittable_674? # rubocop:disable Layout/LineLength

  send_confirmation_email
  in_progress_form&.destroy
  Rails.logger.info('BGS::SubmitForm686cJob succeeded!', { user_uuid:, saved_claim_id:, icn: })
rescue => e
  Rails.logger.warn('BGS::SubmitForm686cJob failed, retrying...',
                    { user_uuid:, saved_claim_id:, icn:, error: e.message })
  log_message_to_sentry(e, :warning, {}, { team: 'vfs-ebenefits' })
  @icn = icn

  raise
end