Class: MnoEnterprise::MailAdapters::SparkpostAdapter
- Defined in:
- lib/mno_enterprise/mail_adapters/sparkpost_adapter.rb
Overview
SparkPost Adapter for MnoEnterprise::MailClient
Class Method Summary collapse
-
.client ⇒ SparkPost::Client
Return a sparkpost client configured with the right API key api key is set in ENV through ENV.
-
.deliver(template, from, to, vars = {}, opts = {}) ⇒ Object
Send a template.
-
.send_template(template_name, _, message) ⇒ Object
Send the provided template with options SparkpostClient.send_template(template_name(string), template_content(array), message(hash)).
Methods inherited from Adapter
Class Method Details
.client ⇒ SparkPost::Client
Return a sparkpost client configured with the right API key api key is set in ENV through ENV
12 13 14 |
# File 'lib/mno_enterprise/mail_adapters/sparkpost_adapter.rb', line 12 def client @client ||= SparkPost::Client.new end |
.deliver(template, from, to, vars = {}, opts = {}) ⇒ Object
Send a template
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mno_enterprise/mail_adapters/sparkpost_adapter.rb', line 18 def deliver(template, from, to, vars={}, opts={}) # Prepare message from args = { recipients: prepare_recipients(to), content: { from: from, template_id: template }, substitution_data: vars } # Merge additional options .merge!(opts) # Send send_template(template,[],) end |
.send_template(template_name, _, message) ⇒ Object
Send the provided template with options SparkpostClient.send_template(template_name(string), template_content(array), message(hash))
38 39 40 41 42 43 44 45 |
# File 'lib/mno_enterprise/mail_adapters/sparkpost_adapter.rb', line 38 def send_template(template_name, _, ) if test? base_deliveries.push([template_name, ]) else [:content][:template_id] = template_name client.transmission.send_payload() end end |