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_json

Constructor Details

This class inherits a constructor from Macaco::Sender

Instance Method Details

#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

#content_typeObject



16
17
18
# File 'lib/macaco/senders/mandrill.rb', line 16

def content_type
  'application/json'
end

#docsObject



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

def docs
  'https://mandrillapp.com/api/docs/messages.JSON.html#method-send'
end

#sendObject



37
38
39
40
# File 'lib/macaco/senders/mandrill.rb', line 37

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

#to(val = nil) ⇒ Object



32
33
34
35
# File 'lib/macaco/senders/mandrill.rb', line 32

def to(val = nil)
  return @to unless val
  @to << { email: val }
end

#to_hashObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/macaco/senders/mandrill.rb', line 20

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