Class: Mail::Notify::DeliveryMethod
- Inherits:
-
Object
- Object
- Mail::Notify::DeliveryMethod
- Defined in:
- lib/mail/notify/delivery_method.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(message) ⇒ Object
-
#initialize(settings) ⇒ DeliveryMethod
constructor
A new instance of DeliveryMethod.
- #preview(message) ⇒ Object
Constructor Details
#initialize(settings) ⇒ DeliveryMethod
Returns a new instance of DeliveryMethod.
8 9 10 11 12 |
# File 'lib/mail/notify/delivery_method.rb', line 8 def initialize(settings) raise ArgumentError, "You must specify a Notify API key" if settings[:api_key].blank? @settings = settings end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/mail/notify/delivery_method.rb', line 6 def response @response end |
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/mail/notify/delivery_method.rb', line 6 def settings @settings end |
Instance Method Details
#deliver!(message) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mail/notify/delivery_method.rb', line 14 def deliver!() params = { template_id: .template_id, email_address: .to.first, personalisation: .personalisation, email_reply_to_id: .reply_to_id, reference: .reference } client.send_email(params.compact) end |
#preview(message) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/mail/notify/delivery_method.rb', line 26 def preview() template_id = .template_id personalisation = .personalisation Rails.logger.info("Getting Notify preview for template id #{template_id}") client.generate_template_preview(template_id, personalisation: personalisation) end |