module MarketingConnection
Constants
- VERSION
Attributes
api_key[RW]
api_secret[RW]
api_url[RW]
mode[RW]
Public Class Methods
base_url()
click to toggle source
# File lib/marketing_connection.rb, line 69 def base_url "http://#{self.api_key}:#{self.api_secret}@#{self.api_url}/api/v1/" end
config() { |self| ... }
click to toggle source
# File lib/marketing_connection.rb, line 73 def config yield self true end
submit(method, target_url, parameters={})
click to toggle source
Submits the API call to the Mailgun server
# File lib/marketing_connection.rb, line 49 def submit(method, target_url, parameters={}) url = base_url + target_url puts url begin parameters = {:params => parameters} if method == :get return JSON(RestClient.send(method, url, parameters)) rescue => e error_message = nil if e.respond_to? :http_body begin error_message = JSON(e.http_body)["message"] rescue raise e end raise MarketingConnection::Error.new(error_message) end raise e end end