Class: SavedClaim::EducationBenefits::VA1990e

Inherits:
SavedClaim::EducationBenefits show all
Defined in:
app/models/saved_claim/education_benefits/va_1990e.rb

Instance Method Summary collapse

Methods inherited from SavedClaim::EducationBenefits

#add_education_benefits_claim, form_class, #in_progress_form_id, #regional_office_address

Methods inherited from SavedClaim

add_form_and_validation, #after_create_metrics, #after_destroy_metrics, #attachment_keys, #business_line, #confirmation_number, #email, #form_is_string, #form_matches_schema, #form_must_be_string, #insert_notification, #open_struct_form, #parsed_form, #process_attachments!, #submitted_at, #to_pdf, #update_form, #va_notification?, #validate_form, #validate_schema

Methods inherited from ApplicationRecord

descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?

Instance Method Details

#after_submit(_user) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'app/models/saved_claim/education_benefits/va_1990e.rb', line 6

def after_submit(_user)
  return unless Flipper.enabled?(:form1990e_confirmation_email)

  parsed_form_data ||= JSON.parse(form)
  email = parsed_form_data['email']
  return if email.blank?

  send_confirmation_email(email)
end

#send_confirmation_email(email) ⇒ Object (private)



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/saved_claim/education_benefits/va_1990e.rb', line 18

def send_confirmation_email(email)
  VANotify::EmailJob.perform_async(
    email,
    Settings.vanotify.services.va_gov.template_id.form1990e_confirmation_email,
    {
      'first_name' => parsed_form.dig('relativeFullName', 'first')&.upcase.presence,
      'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
      'confirmation_number' => education_benefits_claim.confirmation_number,
      'regional_office_address' => regional_office_address
    }
  )
end