Class: Form526ConfirmationEmailJob

Inherits:
Object
  • Object
show all
Includes:
SentryLogging, Sidekiq::Job
Defined in:
app/sidekiq/form526_confirmation_email_job.rb

Constant Summary collapse

STATSD_ERROR_NAME =
'worker.form526_confirmation_email.error'
STATSD_SUCCESS_NAME =
'worker.form526_confirmation_email.success'

Instance Method Summary collapse

Methods included from SentryLogging

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

Instance Method Details

#handle_errors(ex) ⇒ Object



31
32
33
34
35
36
# File 'app/sidekiq/form526_confirmation_email_job.rb', line 31

def handle_errors(ex)
  log_exception_to_sentry(ex)
  StatsD.increment(STATSD_ERROR_NAME)

  raise ex if ex.status_code.between?(500, 599)
end

#perform(personalization_parameters) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/sidekiq/form526_confirmation_email_job.rb', line 14

def perform(personalization_parameters)
  @notify_client ||= VaNotify::Service.new(Settings.vanotify.services.va_gov.api_key)
  @template_id ||= Settings.vanotify.services.va_gov.template_id.form526_confirmation_email
  @notify_client.send_email(
    email_address: personalization_parameters['email'],
    template_id: @template_id,
    personalisation: {
      'claim_id' => personalization_parameters['submitted_claim_id'],
      'date_submitted' => personalization_parameters['date_submitted'],
      'first_name' => personalization_parameters['first_name']
    }
  )
  StatsD.increment(STATSD_SUCCESS_NAME)
rescue => e
  handle_errors(e)
end