Class: Macaco::Sendgrid

Inherits:
Sender
  • Object
show all
Defined in:
lib/macaco/senders/sendgrid.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/sendgrid.rb', line 12

def api_path
  '/api/mail.send.json'
end

#api_rootObject



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

def api_root
  'api.sendgrid.com'
end

#content_typeObject



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

def content_type
  'application/x-www-form-urlencoded'
end

#docsObject



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

def docs
  'http://sendgrid.com/docs/API_Reference/Web_API/mail.html'
end

#sendObject



35
36
37
38
# File 'lib/macaco/senders/sendgrid.rb', line 35

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

#to(val = nil) ⇒ Object



30
31
32
33
# File 'lib/macaco/senders/sendgrid.rb', line 30

def to(val = nil)
  return @to unless val
  @to << val
end

#to_hashObject



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

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