Class: MonkeyMail::Clients::MandrillClient
- Inherits:
-
Object
- Object
- MonkeyMail::Clients::MandrillClient
- Defined in:
- lib/monkey_mail/clients/mandrill_client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ MandrillClient
constructor
A new instance of MandrillClient.
- #render_template(template_name:, vars:) ⇒ Object
- #send_template(template_name:, subject:, from_email:, from_name:, to:, vars:) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ MandrillClient
Returns a new instance of MandrillClient.
8 9 10 |
# File 'lib/monkey_mail/clients/mandrill_client.rb', line 8 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/monkey_mail/clients/mandrill_client.rb', line 6 def api_key @api_key end |
Instance Method Details
#render_template(template_name:, vars:) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/monkey_mail/clients/mandrill_client.rb', line 25 def render_template(template_name:, vars:) RestClient::Request.execute(method: :post, url: template_render_url, payload: { key: api_key, template_name: template_name, template_content: [], merge_vars: prepate_vars(vars) }) end |
#send_template(template_name:, subject:, from_email:, from_name:, to:, vars:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/monkey_mail/clients/mandrill_client.rb', line 12 def send_template(template_name:, subject:, from_email:, from_name:, to:, vars:) = { from_email: from_email, from_name: from_name, to: prepare_to(to), subject: subject, global_merge_vars: prepate_vars(vars) } RestClient::Request.execute(method: :post, url: , payload: { key: api_key, template_name: template_name, template_content: [], message: }) end |