Skip to content

Commit

Permalink
Merge pull request #381 from mailgun/incorrect-example-documentation-…
Browse files Browse the repository at this point in the history
…for-events

other: Update readme for events
  • Loading branch information
olexandr-mazepa authored Aug 15, 2023
2 parents 077eb69 + 83996c9 commit 42768e5
Show file tree
Hide file tree
Showing 4 changed files with 23,825 additions and 18 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ The following service methods are available to instantiated clients. The example
- [assignIp](#assignip)
- [events](#events)
- [get](#get-1)
- [Example with Date and *Filter field*](#example-with-date-and-filter-field)
- [stats](#stats)
- [getDomain](#getdomain)
- [getAccount](#getaccount)
Expand Down Expand Up @@ -898,13 +899,15 @@ Method naming conventions:

- #### get

`mg.events.get(domain, query)`
`mg.events.get(domain, data)`

Example:

```js
mg.events.get('foobar.example.com', { page: 'mypageid' })
.then(data => console.log(data.items)) // logs array of event objects
mg.events.get('foobar.example.com', {
page: 'mypageid',
event: 'opened'
}).then(data => console.log(data.items)) // logs array of event objects
.catch(err => console.error(err)); // logs any error
```

Expand All @@ -918,8 +921,17 @@ Method naming conventions:
| end | The end of the search time range. It can be specified as a string (see Date Format) or linux epoch seconds. Refer to Time Range for details. |
| ascending | Defines the direction of the search time range if the range end time is not specified. Can be either yes or no. Refer to Time Range for details. |
| limit | Number of entries to return. (300 max) |
| <field> | <field> is the name of the Filter Field. The value of the parameter should be a valid Filter Expression. Several field filters can be specified in one request. If the same field is mentioned, more then once, then all its filter expressions are combined with AND operator. |

| **field** | **field** is the name of the *[Filter Field](https://documentation.mailgun.com/en/latest/api-events.html#filter-field)*. The value of the parameter should be a valid Filter Expression. Several field filters can be specified in one request. If the same field is mentioned, more then once, then all its filter expressions are combined with AND operator. |
- #### Example with Date and *Filter field*
```js
const date = new Date(2023, 7, 2, 0, 0, 0, 0); // Wed Aug 02 2023 00:00:00 GMT+0300
const events = await mg.events.get('foobar.example.com', {
begin: date.toUTCString(), // 'Tue, 01 Aug 2023 21:00:00 GMT'
ascending: 'yes',
limit: 5,
event: 'delivered'
});
```
Promise returns: items (array of event objects), pages (paging keys grouped by id)

```JS
Expand Down Expand Up @@ -1477,7 +1489,7 @@ Method naming conventions:

Promise returns: response body

```JS
```js
{
actions: [ 'forward("http://myhost.com/messages/")', 'stop()' ],
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',
Expand Down
24 changes: 18 additions & 6 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ The following service methods are available to instantiated clients. The example
- [assignIp](#assignip)
- [events](#events)
- [get](#get-1)
- [Example with Date and *Filter field*](#example-with-date-and-filter-field)
- [stats](#stats)
- [getDomain](#getdomain)
- [getAccount](#getaccount)
Expand Down Expand Up @@ -898,13 +899,15 @@ Method naming conventions:

- #### get

`mg.events.get(domain, query)`
`mg.events.get(domain, data)`

Example:

```js
mg.events.get('foobar.example.com', { page: 'mypageid' })
.then(data => console.log(data.items)) // logs array of event objects
mg.events.get('foobar.example.com', {
page: 'mypageid',
event: 'opened'
}).then(data => console.log(data.items)) // logs array of event objects
.catch(err => console.error(err)); // logs any error
```

Expand All @@ -918,8 +921,17 @@ Method naming conventions:
| end | The end of the search time range. It can be specified as a string (see Date Format) or linux epoch seconds. Refer to Time Range for details. |
| ascending | Defines the direction of the search time range if the range end time is not specified. Can be either yes or no. Refer to Time Range for details. |
| limit | Number of entries to return. (300 max) |
| <field> | <field> is the name of the Filter Field. The value of the parameter should be a valid Filter Expression. Several field filters can be specified in one request. If the same field is mentioned, more then once, then all its filter expressions are combined with AND operator. |

| **field** | **field** is the name of the *[Filter Field](https://documentation.mailgun.com/en/latest/api-events.html#filter-field)*. The value of the parameter should be a valid Filter Expression. Several field filters can be specified in one request. If the same field is mentioned, more then once, then all its filter expressions are combined with AND operator. |
- #### Example with Date and *Filter field*
```js
const date = new Date(2023, 7, 2, 0, 0, 0, 0); // Wed Aug 02 2023 00:00:00 GMT+0300
const events = await mg.events.get('foobar.example.com', {
begin: date.toUTCString(), // 'Tue, 01 Aug 2023 21:00:00 GMT'
ascending: 'yes',
limit: 5,
event: 'delivered'
});
```
Promise returns: items (array of event objects), pages (paging keys grouped by id)

```JS
Expand Down Expand Up @@ -1477,7 +1489,7 @@ Method naming conventions:

Promise returns: response body

```JS
```js
{
actions: [ 'forward("http://myhost.com/messages/")', 'stop()' ],
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',
Expand Down
14,243 changes: 14,240 additions & 3 deletions dist/mailgun.node.js

Large diffs are not rendered by default.

9,552 changes: 9,549 additions & 3 deletions dist/mailgun.web.js

Large diffs are not rendered by default.

0 comments on commit 42768e5

Please sign in to comment.