Class: Macaco::Mandrill

Inherits:
Sender
  • Object
show all
Defined in:
lib/macaco/senders/mandrill.rb

Instance Method Summary collapse

Methods inherited from Sender

#body_html, #body_text, #from, #hash_attributes, #initialize, #subject, #to, #to_json

Constructor Details

This class inherits a constructor from Macaco::Sender

Instance Method Details

#api_keyObject



4
5
6
# File 'lib/macaco/senders/mandrill.rb', line 4

def api_key
  Macaco.config.api_key || ENV['MACACO_API_KEY']
end

#api_pathObject



12
13
14
# File 'lib/macaco/senders/mandrill.rb', line 12

def api_path
  '/api/1.0/messages/send.json'
end

#api_rootObject



8
9
10
# File 'lib/macaco/senders/mandrill.rb', line 8

def api_root
  'mandrillapp.com'
end

#sendObject



28
29
30
31
# File 'lib/macaco/senders/mandrill.rb', line 28

def send
  data = to_hash.merge!({ key: api_key })
  Macaco::Api.post({ mail: self, data: data })
end

#to_hashObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/macaco/senders/mandrill.rb', line 16

def to_hash
  {
    message: {
      from_email: @from,
      to: @to,
      subject: @subject,
      html: @body_html,
      text: @body_text
    }
  }
end