class Mailgun::Events
A Mailgun::Events
object makes it really simple to consume Mailgun's events from the Events
endpoint.
See the Github documentation for full examples.
Public Class Methods
new(client, domain)
click to toggle source
# File lib/mailgun/events/events.rb, line 15 def initialize(client, domain) @client = client @domain = domain @paging_next = nil @paging_previous = nil end
Public Instance Methods
get(params=nil)
click to toggle source
next()
click to toggle source
Private Instance Methods
_get(params=nil, paging=nil)
click to toggle source
# File lib/mailgun/events/events.rb, line 49 def _get(params=nil, paging=nil) response = @client.get(construct_url(paging), params) extract_paging(response) response end
construct_url(paging=nil)
click to toggle source
# File lib/mailgun/events/events.rb, line 64 def construct_url(paging=nil) if paging "#{@domain}/events/#{paging}" else "#{@domain}/events" end end
extract_paging(response)
click to toggle source
# File lib/mailgun/events/events.rb, line 55 def extract_paging(response) paging_next = response.to_h["paging"]["next"] paging_previous = response.to_h["paging"]["previous"] # This is pretty hackish. But the URL will never change in API v2. @paging_next = paging_next.split("/")[6] @paging_previous = paging_previous.split("/")[6] end