Sha256: 686740dcd710350a3880058c015d0ac677fae1aacdcfe93f5e93bbe6b51b3545

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

Mailgun - Events
====================

This is the Mailgun Ruby *Events* utility.

The below assumes you've already installed the Mailgun Ruby SDK in your project.
If not, go back to the master README for a few quick install steps.

Events: Provides methods for traversing the Mailgun Events API.


Usage - Events
-----------------------------------------------------
Here's how to use the Events Handler to pull events.

```ruby
# First, instantiate the SDK with your API credentials, domain, and required parameters for example.
mg_client = Mailgun::Client.new("your-api-key")
mg_events = Mailgun::Events.new(mg_client, "your-domain")

result = mg_events.get({'limit' => 25,
                        'recipient' => 'joe@example.com'})

result.to_h['items'].each do | item |
    # outputs "Delivered - 20140509184016.12571.48844@example.com"
    puts "#{item['event']} - #{item['message']['headers']['message-id']}"
end

# Want more results?
result = mg_events.next

# Go backwards?
result = mg_events.previous
```

A few notes:  
1. Next will use the pagination links to advance the result set.
Retain the mg_events object to query forward, or reverse, at any time.  
2. If the result set is less than your limit, do not worry. A
second query against "next" will return the next 25 results since the
last time you called "next".

More Documentation
------------------
See the official [Mailgun Docs](https://documentation.mailgun.com/en/latest/api-events.html)
for more information.

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailgun-ruby-1.2.16 docs/Events.md
mailgun-ruby-1.2.15 docs/Events.md
mailgun-ruby-1.2.14 docs/Events.md