lib/macaco/senders/mandrill.rb in macaco-0.0.2 vs lib/macaco/senders/mandrill.rb in macaco-0.0.3

- old
+ new

@@ -1,20 +1,24 @@ module Macaco class Mandrill < Sender - def api_key - Macaco.config.api_key || ENV['MACACO_API_KEY'] + def docs + 'https://mandrillapp.com/api/docs/messages.JSON.html#method-send' end def api_root 'mandrillapp.com' end def api_path '/api/1.0/messages/send.json' end + def content_type + 'application/json' + end + def to_hash { message: { from_email: @from, to: @to, @@ -25,10 +29,20 @@ } end def send data = to_hash.merge!({ key: api_key }) - Macaco::Api.post({ mail: self, data: data }) + Macaco::Api.post({ mail: self, data: convert_data_params(data) }) + end + + private + + def convert_data_params(data) + data.to_json + end + + def api_key + Macaco.config.api_key || ENV['MACACO_API_KEY'] end end end