Module: Rubymail

Defined in:
lib/rubymail/log.rb,
lib/rubymail/base.rb,
lib/rubymail/list.rb,
lib/rubymail/route.rb,
lib/rubymail/bounce.rb,
lib/rubymail/client.rb,
lib/rubymail/client.rb,
lib/rubymail/domain.rb,
lib/rubymail/secure.rb,
lib/rubymail/address.rb,
lib/rubymail/mailbox.rb,
lib/rubymail/message.rb,
lib/rubymail/webhook.rb,
lib/rubymail/complaint.rb,
lib/rubymail/unsubscribe.rb,
lib/rubymail/rubymail_error.rb

Defined Under Namespace

Classes: Address, BadRequest, Base, Bounce, Client, ClientError, Complaint, Domain, Error, ErrorBase, Log, Mailbox, MailingList, Message, NotFound, ResquestFailed, Route, Secure, ServerError, Unauthorized, Unsubscribe, Webhook

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def api_key
  @api_key
end

.api_versionObject

Returns the value of attribute api_version.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def api_version
  @api_version
end

.domainObject

Returns the value of attribute domain.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def domain
  @domain
end

.protocolObject

Returns the value of attribute protocol.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def protocol
  @protocol
end

.public_api_keyObject

Returns the value of attribute public_api_key.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def public_api_key
  @public_api_key
end

.rubymail_hostObject

Returns the value of attribute rubymail_host.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def rubymail_host
  @rubymail_host
end

.test_modeObject

Returns the value of attribute test_mode.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def test_mode
  @test_mode
end

.webhook_urlObject

Returns the value of attribute webhook_url.



103
104
105
# File 'lib/rubymail/base.rb', line 103

def webhook_url
  @webhook_url
end

Class Method Details

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

Yields:

  • (_self)

Yield Parameters:

  • _self (Rubymail)

    the object that the method was called on



112
113
114
115
# File 'lib/rubymail/base.rb', line 112

def configure
  yield self
  true
end

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



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rubymail/base.rb', line 80

def self.submit(method, url, parameters={})
  begin
    JSON.parse(Client.new(url).send(method, parameters))
  rescue => e
    error_code = e.http_code
    error_message = begin
      JSON(e.http_body)["message"]
    rescue JSON::ParserError
      ''
    end
    error = Rubymail::Error.new(
      :code => error_code || nil,
      :message => error_message || nil
    )
    if error.handle.kind_of? Rubymail::ErrorBase
      raise error.handle
    else
      raise error
    end
  end
end