Skip to content

Instantly share code, notes, and snippets.

@tawheed
tawheed / tout_mailer.rb
Created December 29, 2011 07:13
Tout Mailer
class ToutMailer
include HTTParty
format :json
base_uri 'www.toutapp.com:443'
API_KEY = "X"
def deliver(name, email, template_id)
template = self.class.get("/pitch_templates/#{template_id}.json", :query => {:api_key => API_KEY, :name => name, :address => email}).parsed_response
pitch = {:pitch => {:name => name, :email => email, :body => template['body'] + "<br/>--<br/>" + default_signature, :subject => template['subject'], :cc => template['cc'], :bcc => template['bcc']}}
result = self.class.post("/iphone.json?api_key=#{API_KEY}", :body => pitch.to_json, :headers => { 'Content-Type' => 'application/json' })