Class: V0::Preneeds::BurialFormsController

Inherits:
PreneedsController show all
Includes:
SentryLogging
Defined in:
app/controllers/v0/preneeds/burial_forms_controller.rb

Constant Summary collapse

FORM =
'40-10007'

Constants inherited from ApplicationController

ApplicationController::VERSION_STATUS

Constants included from SignIn::Authentication

SignIn::Authentication::BEARER_PATTERN

Constants included from ExceptionHandling

ExceptionHandling::SKIP_SENTRY_EXCEPTION_TYPES

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 PreneedsController

#client

Methods inherited from ApplicationController

#clear_saved_form, #cors_preflight, #routing_error

Methods included from Traceable

#set_trace_tags

Methods included from SignIn::Authentication

#authenticate, #authenticate_service_account, #load_user

Methods included from Headers

#block_unknown_hosts, #set_app_info_headers

Methods included from AuthenticationAndSSOConcerns

#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_session_expiration_header, #sso_logging_info, #validate_inbound_login_params, #validate_session

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/v0/preneeds/burial_forms_controller.rb', line 10

def create
  @form = ::Preneeds::BurialForm.new(burial_form_params)
  validate!(Common::HashHelpers.deep_transform_parameters!(burial_form_params) { |k| k.camelize(:lower) })

  @resource = client.receive_pre_need_application(@form)
  ::Preneeds::PreneedSubmission.create!(
    tracking_number: @resource.tracking_number,
    application_uuid: @resource.application_uuid,
    return_description: @resource.return_description,
    return_code: @resource.return_code
  )

  send_confirmation_email

  clear_saved_form(FORM)
  render json: @resource, serializer: ReceiveApplicationSerializer
end

#send_confirmation_emailObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/v0/preneeds/burial_forms_controller.rb', line 28

def send_confirmation_email
  email = @form.claimant.email
  claimant = @form.applicant.name.first
  first_name = @form.applicant.name.first
  last_initial = @form.applicant.name.last.first

  if @form.applicant.applicant_relationship_to_claimant != 'Self'
    first_name = @form.claimant.name.first
    last_initial = @form.claimant.name.last.first
  end

  VANotify::EmailJob.perform_async(
    email,
    Settings.vanotify.services.va_gov.template_id.preneeds_burial_form_email,
    {
      'form_name' => 'Burial Pre-Need (Form 40-10007)',
      'first_name' => claimant&.upcase.presence,
      'applicant_1_first_name_last_initial' => "#{first_name} #{last_initial}",
      'confirmation_number' => @resource.application_uuid,
      'date_submitted' => Time.zone.today.strftime('%B %d, %Y')
    }
  )
end