Class: VANotifyEmailJob

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

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

#perform(email, template_id, personalisation = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/sidekiq/va_notify_email_job.rb', line 8

def perform(email, template_id, personalisation = nil)
  notify_client = VaNotify::Service.new(Settings.vanotify.services.va_gov.api_key)

  notify_client.send_email(
    **{
      email_address: email,
      template_id:,
      personalisation:
    }.compact
  )
rescue Common::Exceptions::BackendServiceException => e
  if e.status_code == 400
    log_exception_to_sentry(
      e,
      {
        args: { template_id:, personalisation: }
      },
      { error: :va_notify_email_job }
    )
  else
    raise e
  end
end