Class: EcoRake::Utils::Mailer::SendgridProvider

Inherits:
ProviderBase
  • Object
show all
Defined in:
lib/eco-rake/utils/mailer/sendgrid_provider.rb

Instance Method Summary collapse

Methods inherited from ProviderBase

to_desc

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.



26
27
28
# File 'lib/eco-rake/utils/mailer/sendgrid_provider.rb', line 26

def configured?
  fetch_secret_access_key
end

#fetch_to(value = nil) ⇒ Object



20
21
22
23
# File 'lib/eco-rake/utils/mailer/sendgrid_provider.rb', line 20

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



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/eco-rake/utils/mailer/sendgrid_provider.rb', line 6

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