require 'httparty' ### Usage # MailEngine::Sendgrid::RestApi.stats module MailEngine module Sendgrid class RestApiError < StandardError; end class RestApi include HTTParty base_uri "https://sendgrid.com/api" default_params :api_key => MailEngine::Base.current_config["sendgrid"]["sendgrid_key"], :api_user => MailEngine::Base.current_config["sendgrid"]["sendgrid_user"] format :xml class << self # # # 2009-06-20 # 12342 # 12 # 10223 # 9992 # 5 # 3 # 6 # 7 # # def stats options = {} response = get "/stats.get.xml", :query => options response["stats"].try(:send, :[], "day") end # # # email1@domain.com # 5.1.1 # host [127.0.0.1] said: 550 5.1.1 unknown or illegal user: email1@domain.com # 2009-06-10 12:40:30 # # def bounces options = {} response = get "/bounces.get.xml", :query => options response["bounces"].try(:send, :[], "bounce") end # # # email1@domain.com # 2009-06-10 12:40:30 # # def spamreports options = {} response = get "/spamreports.get.xml", :query => options response["spamreports"].try(:send, :[], "spamreport") end # # # isaac@hotmail.comm # Mail domain mentioned in email address is unknown # 2009-06-10 12:40:30 # # def invalidemails options = {} response = get "/invalidemails.get.xml", :query => options response["invalidemails"].try(:send, :[], "invalidemail") end # # # exp_block_0466@sendgrid.com # # Some random block reason # 2010-11-08 20:39:29 # # def blocks options = {} response = get "/blocks.get.xml", :query => options response["blocks"].try(:send, :[], "block") end end end # end of rest api class end # end of sendgrid module end # end of mail engine module