Class: DMCourier::Services::Sendgrid
- Inherits:
-
Object
- Object
- DMCourier::Services::Sendgrid
- Includes:
- MessageHelper
- Defined in:
- lib/dm_courier/services/sendgrid.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#mail ⇒ Object
readonly
Returns the value of attribute mail.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #deliver! ⇒ Object
-
#initialize(mail, options = {}) ⇒ Sendgrid
constructor
A new instance of Sendgrid.
- #name ⇒ Object
- #sendgrid_message ⇒ Object
Methods included from MessageHelper
#attachments, #attachments?, #extract_params, #fallback_options, #from, #from_address, #from_email, #from_name, #html_part, #metadata, #nil_true_false?, #return_string_value, #subject, #text_part
Constructor Details
#initialize(mail, options = {}) ⇒ Sendgrid
Returns a new instance of Sendgrid.
13 14 15 16 17 |
# File 'lib/dm_courier/services/sendgrid.rb', line 13 def initialize(mail, = {}) @mail = mail @api_key = .fetch(:api_key) = end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/dm_courier/services/sendgrid.rb', line 11 def api_key @api_key end |
#mail ⇒ Object (readonly)
Returns the value of attribute mail.
11 12 13 |
# File 'lib/dm_courier/services/sendgrid.rb', line 11 def mail @mail end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/dm_courier/services/sendgrid.rb', line 11 def end |
Instance Method Details
#deliver! ⇒ Object
23 24 25 26 |
# File 'lib/dm_courier/services/sendgrid.rb', line 23 def deliver! sendgrid_api = ::SendGrid::Client.new(api_key) sendgrid_api.send() end |
#name ⇒ Object
19 20 21 |
# File 'lib/dm_courier/services/sendgrid.rb', line 19 def name :sendgrid end |
#sendgrid_message ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dm_courier/services/sendgrid.rb', line 28 def = { to: (mail[:to].formatted if mail[:to]), cc: (mail[:cc].formatted if mail[:cc]), bcc: return_string_value(:bcc_address), from: from_email, from_name: from_name, subject: subject, html: html_part, text: text_part, reply_to: reply_to } [:attachments] = ::SendGrid::Mail.new() do |mail| .each do || mail.contents << end end end |