Class: SavedClaim::EducationBenefits::VA1995

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

Constant Summary collapse

BENEFIT_TITLE_FOR_1995 =
{
  'chapter30' => 'Montgomery GI Bill (MGIB, Chapter 30)',
  'chapter33Post911' => 'Post-9/11 GI Bill (Chapter 33)',
  'chapter33FryScholarship' => 'Fry Scholarship (Chapter 33)',
  'chapter1606' => 'Montgomery GI Bill Selected Reserve (MGIB-SR, Chapter 1606)',
  'chapter32' => 'Post-Vietnam Era Veterans’ Educational Assistance Program (VEAP, chapter 32)',
  'transferOfEntitlement' => 'Transfer of Entitlement Program (TOE)'
}.freeze

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



17
18
19
20
21
22
23
24
25
# File 'app/models/saved_claim/education_benefits/va_1995.rb', line 17

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

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

  send_confirmation_email(parsed_form_data, email)
end

#send_confirmation_email(parsed_form_data, email) ⇒ Object (private)



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/saved_claim/education_benefits/va_1995.rb', line 29

def send_confirmation_email(parsed_form_data, email)
  benefit_claimed = BENEFIT_TITLE_FOR_1995[parsed_form_data['benefit']] || ''

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