Class: SendgridNotification::SendmailJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/sendgrid_notification/sendmail_job.rb

Defined Under Namespace

Classes: HTTPException

Constant Summary collapse

MailerClass =
Rails.application.config.sendgrid_notification.mailer.constantize

Instance Method Summary collapse

Instance Method Details

#perform(to, notification_mail, params, hash_attachments = []) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
# File 'app/jobs/sendgrid_notification/sendmail_job.rb', line 9

def perform(to, notification_mail, params, hash_attachments = [])

  mailer = MailerClass.new(params)
  obj_attachments = hash_attachments.map{|hash| SendgridNotification::Attachment.wrap(hash.symbolize_keys) }
  mailer.sendmail(to, notification_mail, params, obj_attachments)
  raise HTTPException, mailer.last_result.body unless mailer.last_result_success?

  mailer.last_result.body
end