Class: SilentBob::EmailSender

Inherits:
Object
  • Object
show all
Defined in:
lib/silent_bob/email_sender.rb

Constant Summary collapse

MESSAGE_TYPE =
'email'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject:, to:, body:, attachments: [], from: nil, configuration: ConfigurationKeeper.default_config) ⇒ EmailSender

Pass initialization params

  • configuration: ‘SilentBob::Configuration` object

  • to: Recipients email address

  • body: Email body in html format

  • subject: Email subject

  • attachments: Email attachments

  • from: Author’s email address



14
15
16
17
18
19
20
21
22
# File 'lib/silent_bob/email_sender.rb', line 14

def initialize(subject:, to:, body:, attachments: [], from: nil,
               configuration: ConfigurationKeeper.default_config)
  @configuration = configuration
  @subject = subject
  @to = to
  @body = body
  @attachments = attachments
  @from = from
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



5
6
7
# File 'lib/silent_bob/email_sender.rb', line 5

def attachments
  @attachments
end

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/silent_bob/email_sender.rb', line 5

def body
  @body
end

#configurationObject (readonly)

Returns the value of attribute configuration.



5
6
7
# File 'lib/silent_bob/email_sender.rb', line 5

def configuration
  @configuration
end

#fromObject (readonly)

Returns the value of attribute from.



5
6
7
# File 'lib/silent_bob/email_sender.rb', line 5

def from
  @from
end

#subjectObject (readonly)

Returns the value of attribute subject.



5
6
7
# File 'lib/silent_bob/email_sender.rb', line 5

def subject
  @subject
end

#toObject (readonly)

Returns the value of attribute to.



5
6
7
# File 'lib/silent_bob/email_sender.rb', line 5

def to
  @to
end

Instance Method Details

#callObject



24
25
26
27
28
# File 'lib/silent_bob/email_sender.rb', line 24

def call
  raise ConfigurationNotFound unless configuration

  Client.new(configuration: configuration, params: email_params).call
end