Sha256: 401be12382ec7a942410ed40078419eb0fbd941304bf435e3db40ce91347721c
Contents?: true
Size: 1005 Bytes
Versions: 2
Compression:
Stored size: 1005 Bytes
Contents
module Macaco class Sendgrid < Sender def docs 'http://sendgrid.com/docs/API_Reference/Web_API/mail.html' end def api_root 'api.sendgrid.com' end def api_path '/api/mail.send.json' end def content_type 'application/x-www-form-urlencoded' end def to_hash { from: @from, to: @to, subject: @subject, html: @body_html, text: @body_text } end def to(val = nil) return @to unless val @to << val end 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 private def convert_data_params(data) addr = Addressable::URI.new addr.query_values = data addr.query end def api_key Macaco.config.api_key || ENV['MACACO_API_KEY'] end def api_user Macaco.config.api_user || ENV['MACACO_USER'] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
macaco-0.0.4 | lib/macaco/senders/sendgrid.rb |
macaco-0.0.3 | lib/macaco/senders/sendgrid.rb |