Module: Mailgun
- Defined in:
- lib/mailgun/secure.rb,
lib/mailgun/log.rb,
lib/mailgun/base.rb,
lib/mailgun/list.rb,
lib/mailgun/route.rb,
lib/mailgun/bounce.rb,
lib/mailgun/client.rb,
lib/mailgun/client.rb,
lib/mailgun/domain.rb,
lib/mailgun/address.rb,
lib/mailgun/mailbox.rb,
lib/mailgun/message.rb,
lib/mailgun/webhook.rb,
lib/mailgun/complaint.rb,
lib/mailgun/list/member.rb,
lib/mailgun/unsubscribe.rb,
lib/mailgun/mailgun_error.rb
Overview
verifySignature: function(timestamp, token, signature, minutes_offset)
var offset = Math.round((new Date()).getTime() / 1000) - (minutes_offset || 5) * 60;
if(timestamp < offset)
return false;
var hmac = crypto.createHmac('sha256', api_key);
hmac.update(timestamp + token);
return signature == hmac.digest('hex');
,
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
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.api_version ⇒ Object
Returns the value of attribute api_version.
-
.domain ⇒ Object
Returns the value of attribute domain.
-
.mailgun_host ⇒ Object
Returns the value of attribute mailgun_host.
-
.protocol ⇒ Object
Returns the value of attribute protocol.
-
.public_api_key ⇒ Object
Returns the value of attribute public_api_key.
-
.test_mode ⇒ Object
Returns the value of attribute test_mode.
-
.webhook_url ⇒ Object
Returns the value of attribute webhook_url.
Class Method Summary collapse
- .configure {|_self| ... } ⇒ Object (also: config)
-
.submit(method, url, parameters = {}) ⇒ Object
Submits the API call to the Mailgun server.
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def api_key @api_key end |
.api_version ⇒ Object
Returns the value of attribute api_version.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def api_version @api_version end |
.domain ⇒ Object
Returns the value of attribute domain.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def domain @domain end |
.mailgun_host ⇒ Object
Returns the value of attribute mailgun_host.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def mailgun_host @mailgun_host end |
.protocol ⇒ Object
Returns the value of attribute protocol.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def protocol @protocol end |
.public_api_key ⇒ Object
Returns the value of attribute public_api_key.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def public_api_key @public_api_key end |
.test_mode ⇒ Object
Returns the value of attribute test_mode.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def test_mode @test_mode end |
.webhook_url ⇒ Object
Returns the value of attribute webhook_url.
117 118 119 |
# File 'lib/mailgun/base.rb', line 117 def webhook_url @webhook_url end |
Class Method Details
.configure {|_self| ... } ⇒ Object Also known as: config
126 127 128 129 |
# File 'lib/mailgun/base.rb', line 126 def configure yield self true end |
.submit(method, url, parameters = {}) ⇒ Object
Submits the API call to the Mailgun server
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/mailgun/base.rb', line 91 def self.submit(method, url, parameters={}) begin JSON.parse(Client.new(url).send(method, parameters)) rescue => e error_code = e.http_code = begin JSON(e.http_body)["message"] rescue JSON::ParserError '' end error = Mailgun::Error.new( :code => error_code || nil, :message => || nil ) if error.handle.kind_of? Mailgun::ErrorBase raise error.handle else raise error end end end |