Module: Mailgun

Defined in:
lib/mailgun/log.rb,
lib/mailgun/base.rb,
lib/mailgun/list.rb,
lib/mailgun/route.rb,
lib/mailgun/bounce.rb,
lib/mailgun/domain.rb,
lib/mailgun/mailbox.rb,
lib/mailgun/message.rb,
lib/mailgun/complaint.rb,
lib/mailgun/list/member.rb,
lib/mailgun/unsubscribe.rb,
lib/mailgun/mailgun_error.rb

Defined Under Namespace

Classes: Base, Bounce, Complaint, Domain, Error, Log, Mailbox, MailingList, Message, Route, Unsubscribe

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



90
91
92
# File 'lib/mailgun/base.rb', line 90

def api_key
  @api_key
end

.api_versionObject

Returns the value of attribute api_version.



90
91
92
# File 'lib/mailgun/base.rb', line 90

def api_version
  @api_version
end

.domainObject

Returns the value of attribute domain.



90
91
92
# File 'lib/mailgun/base.rb', line 90

def domain
  @domain
end

.mailgun_hostObject

Returns the value of attribute mailgun_host.



90
91
92
# File 'lib/mailgun/base.rb', line 90

def mailgun_host
  @mailgun_host
end

.protocolObject

Returns the value of attribute protocol.



90
91
92
# File 'lib/mailgun/base.rb', line 90

def protocol
  @protocol
end

.test_modeObject

Returns the value of attribute test_mode.



90
91
92
# File 'lib/mailgun/base.rb', line 90

def test_mode
  @test_mode
end

Class Method Details

.configure {|_self| ... } ⇒ Object Also known as: config

Yields:

  • (_self)

Yield Parameters:

  • _self (Mailgun)

    the object that the method was called on



97
98
99
100
# File 'lib/mailgun/base.rb', line 97

def configure
  yield self
  true
end

.submit(method, url, parameters = {}) ⇒ Object

Submits the API call to the Mailgun server



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/mailgun/base.rb', line 68

def self.submit(method, url, parameters={})
  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 Mailgun::Error.new(error_message)
    end
    raise e
  end
end