Class: Resend::Mailer
- Inherits:
-
Object
- Object
- Resend::Mailer
- Defined in:
- lib/resend/mailer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(config) ⇒ Mailer
constructor
A new instance of Mailer.
- #resend_client ⇒ Object
Constructor Details
#initialize(config) ⇒ Mailer
Returns a new instance of Mailer.
8 9 10 11 12 13 |
# File 'lib/resend/mailer.rb', line 8 def initialize(config) @config = config raise Resend::ResendError.new("Config requires api_key", @config) unless @config.has_key?(:api_key) @settings = { return_response: true } # avoids NilError exception @resend_client = Resend::Client.new config[:api_key] end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/resend/mailer.rb', line 6 def config @config end |
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/resend/mailer.rb', line 6 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/resend/mailer.rb', line 15 def deliver!(mail) params = { from: mail[:from].to_s, to: mail.to, subject: mail.subject, } params[:cc] = mail[:cc] if mail[:cc].present? params[:bcc] = mail[:bcc] if mail[:bcc].present? params[:reply_to] = mail[:reply_to] if mail[:reply_to].present? params[:html] = mail.body.decoded resp = @resend_client.send_email(params) if resp[:error].nil? then mail. = resp[:id] end resp end |
#resend_client ⇒ Object
35 36 37 |
# File 'lib/resend/mailer.rb', line 35 def resend_client @resend_client end |