Class: MonkeyMail::Clients::MailgunClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- MonkeyMail::Clients::MailgunClient
- Defined in:
- lib/monkey_mail/clients/mailgun_client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Instance Method Summary collapse
-
#initialize(api_key, domain) ⇒ MailgunClient
constructor
A new instance of MailgunClient.
- #send_template(template_name:, subject:, from_email:, from_name:, to:, vars:, attachment: nil) ⇒ Object
Methods inherited from BaseClient
Constructor Details
#initialize(api_key, domain) ⇒ MailgunClient
Returns a new instance of MailgunClient.
9 10 11 12 |
# File 'lib/monkey_mail/clients/mailgun_client.rb', line 9 def initialize(api_key, domain) @api_key = api_key @domain = domain end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/monkey_mail/clients/mailgun_client.rb', line 7 def api_key @api_key end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/monkey_mail/clients/mailgun_client.rb', line 7 def domain @domain end |
Instance Method Details
#send_template(template_name:, subject:, from_email:, from_name:, to:, vars:, attachment: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/monkey_mail/clients/mailgun_client.rb', line 14 def send_template(template_name:, subject:, from_email:, from_name:, to:, vars:, attachment: nil) payload = { :from => "#{from_name} <#{from_email}>", :to => to.join(', '), :subject => subject, :template => template_name, :attachment => , 't:variables' => vars.to_json } RestClient::Request.execute(method: :post, url: , payload: payload) end |