Class: Eco::API::Common::Session::Mailer::SendgridProvider

Inherits:
ProviderBase show all
Defined in:
lib/eco/api/common/session/mailer/sendgrid_provider.rb

Instance Attribute Summary

Attributes inherited from ProviderBase

#config

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods inherited from ProviderBase

#initialize, to_desc

Methods included from Language::AuxiliarLogger

#log

Constructor Details

This class inherits a constructor from Eco::API::Common::Session::Mailer::ProviderBase

Instance Method Details

#configured?Boolean

Returns whether or not the mailer is configured for usage.

Returns:

  • (Boolean)

    whether or not the mailer is configured for usage.



28
29
30
# File 'lib/eco/api/common/session/mailer/sendgrid_provider.rb', line 28

def configured?
  fetch_secret_access_key
end

#fetch_to(value = nil) ⇒ Object



22
23
24
25
# File 'lib/eco/api/common/session/mailer/sendgrid_provider.rb', line 22

def fetch_to(value = nil)
  emails = [super].flatten.compact
  to_email_model(emails)
end

#send_mail(subject:, body:, to: nil, cc: nil, bcc: nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/eco/api/common/session/mailer/sendgrid_provider.rb', line 8

def send_mail(subject:, body:, to: nil, cc: nil, bcc: nil)
  return false unless sendgrid

  data = to_data(
    subject: subject,
    body:    body,
    to:      to,
    cc:      cc,
    bcc:     bcc
  )

  mailer._("send").post(request_body: data)
end