Module: Mailgun

Defined in:
lib/mailgun/log.rb,
lib/mailgun/base.rb,
lib/mailgun/list.rb,
lib/mailgun/mail.rb,
lib/mailgun/route.rb,
lib/mailgun/bounce.rb,
lib/mailgun/mailbox.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, Error, List, Log, Mail, Mailbox, Route, Unsubscribe

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



79
80
81
# File 'lib/mailgun/base.rb', line 79

def api_key
  @api_key
end

.api_versionObject

Returns the value of attribute api_version.



79
80
81
# File 'lib/mailgun/base.rb', line 79

def api_version
  @api_version
end

.domainObject

Returns the value of attribute domain.



79
80
81
# File 'lib/mailgun/base.rb', line 79

def domain
  @domain
end

.mailgun_hostObject

Returns the value of attribute mailgun_host.



79
80
81
# File 'lib/mailgun/base.rb', line 79

def mailgun_host
  @mailgun_host
end

.protocolObject

Returns the value of attribute protocol.



79
80
81
# File 'lib/mailgun/base.rb', line 79

def protocol
  @protocol
end

.test_modeObject

Returns the value of attribute test_mode.



79
80
81
# File 'lib/mailgun/base.rb', line 79

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



86
87
88
89
# File 'lib/mailgun/base.rb', line 86

def configure
  yield self
  true
end

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

Submits the API call to the Mailgun server



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/mailgun/base.rb', line 58

def self.submit(method, url, parameters={})
  begin
    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