Access Mailjet API from ruby with mailjetter
Add mailjetter in your Gemfile
gem 'mailjetter', :git => 'git:https://github.com/holinnn/mailjetter.git'
Mailjetter.configure do |config| config.use_https = true config.api_key = 'Your api key' config.secret_key = 'Your secret key' end
api = Mailjetter::Api.new api.user_infos => {"infos"=>{"username"=>"", "firstname"=>"", "lastname"=>"", "company_name"=>"", "locale"=>"fr_FR", "contact_phone"=>nil}} api.lists_contacts(:id => 639) => {"status"=>"OK", "total_cnt"=>"1", "result"=>[{"id"=>"8225160", "last_activity"=>"0", "sent"=>"0", "email"=>"[email protected]"}]}
Or (if not configured)
api = Mailjetter::Api.new('Your api key', 'Your secret key') api.user_infos => {"infos"=>{"username"=>"", "firstname"=>"", "lastname"=>"", "company_name"=>"", "locale"=>"fr_FR", "contact_phone"=>nil}}
It tries to guess the HTTP method to use based on the name of the method you call, if you want to force the request type just add it after the parameters :
api.lists_contacts({:id => 639}, 'Get')
Copyright © 2011 Holinnn. See LICENSE.txt for further details.