Class: HttpMailer::MandrillServiceHandler
- Inherits:
-
ServiceHandler
- Object
- ServiceHandler
- HttpMailer::MandrillServiceHandler
- Defined in:
- lib/http_mailer/mandrill/mandrill_service_handler.rb
Instance Attribute Summary collapse
-
#sevice_api ⇒ Object
Returns the value of attribute sevice_api.
Attributes inherited from ServiceHandler
#service_api, #service_configuration
Instance Method Summary collapse
-
#initialize(settings) ⇒ MandrillServiceHandler
constructor
A new instance of MandrillServiceHandler.
- #send_message(from, to, subject, text, from_name = '', to_name = '') ⇒ Object
Methods inherited from ServiceHandler
Constructor Details
#initialize(settings) ⇒ MandrillServiceHandler
Returns a new instance of MandrillServiceHandler.
5 6 7 8 |
# File 'lib/http_mailer/mandrill/mandrill_service_handler.rb', line 5 def initialize(settings) super(settings) @service_api = ::HttpMailer::MandrillServiceApi.new(self.service_configuration.settings.host) end |
Instance Attribute Details
#sevice_api ⇒ Object
Returns the value of attribute sevice_api.
3 4 5 |
# File 'lib/http_mailer/mandrill/mandrill_service_handler.rb', line 3 def sevice_api @sevice_api end |
Instance Method Details
#send_message(from, to, subject, text, from_name = '', to_name = '') ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/http_mailer/mandrill/mandrill_service_handler.rb', line 10 def (from, to, subject, text, from_name='', to_name='') = MandrillMessage.new(from, to, subject, text, nil, from_name, to_name) payload = { :key => self.service_configuration.settings.api_key, :message => .to_h }.to_json ::RestClient.post(self.service_api., payload, :content_type => :json, :accept => :json ) rescue => e puts e.inspect e.response end |