Skip to content

Commit 42768e5

Browse files
Merge pull request #381 from mailgun/incorrect-example-documentation-for-events
other: Update readme for events
2 parents 077eb69 + 83996c9 commit 42768e5

File tree

4 files changed

+23825
-18
lines changed

4 files changed

+23825
-18
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ The following service methods are available to instantiated clients. The example
9797
- [assignIp](#assignip)
9898
- [events](#events)
9999
- [get](#get-1)
100+
- [Example with Date and *Filter field*](#example-with-date-and-filter-field)
100101
- [stats](#stats)
101102
- [getDomain](#getdomain)
102103
- [getAccount](#getaccount)
@@ -898,13 +899,15 @@ Method naming conventions:
898899

899900
- #### get
900901

901-
`mg.events.get(domain, query)`
902+
`mg.events.get(domain, data)`
902903

903904
Example:
904905

905906
```js
906-
mg.events.get('foobar.example.com', { page: 'mypageid' })
907-
.then(data => console.log(data.items)) // logs array of event objects
907+
mg.events.get('foobar.example.com', {
908+
page: 'mypageid',
909+
event: 'opened'
910+
}).then(data => console.log(data.items)) // logs array of event objects
908911
.catch(err => console.error(err)); // logs any error
909912
```
910913

@@ -918,8 +921,17 @@ Method naming conventions:
918921
| 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. |
919922
| 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. |
920923
| limit | Number of entries to return. (300 max) |
921-
| <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. |
922-
924+
| **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. |
925+
- #### Example with Date and *Filter field*
926+
```js
927+
const date = new Date(2023, 7, 2, 0, 0, 0, 0); // Wed Aug 02 2023 00:00:00 GMT+0300
928+
const events = await mg.events.get('foobar.example.com', {
929+
begin: date.toUTCString(), // 'Tue, 01 Aug 2023 21:00:00 GMT'
930+
ascending: 'yes',
931+
limit: 5,
932+
event: 'delivered'
933+
});
934+
```
923935
Promise returns: items (array of event objects), pages (paging keys grouped by id)
924936

925937
```JS
@@ -1477,7 +1489,7 @@ Method naming conventions:
14771489

14781490
Promise returns: response body
14791491

1480-
```JS
1492+
```js
14811493
{
14821494
actions: [ 'forward("http://myhost.com/messages/")', 'stop()' ],
14831495
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',

dist/README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ The following service methods are available to instantiated clients. The example
9797
- [assignIp](#assignip)
9898
- [events](#events)
9999
- [get](#get-1)
100+
- [Example with Date and *Filter field*](#example-with-date-and-filter-field)
100101
- [stats](#stats)
101102
- [getDomain](#getdomain)
102103
- [getAccount](#getaccount)
@@ -898,13 +899,15 @@ Method naming conventions:
898899

899900
- #### get
900901

901-
`mg.events.get(domain, query)`
902+
`mg.events.get(domain, data)`
902903

903904
Example:
904905

905906
```js
906-
mg.events.get('foobar.example.com', { page: 'mypageid' })
907-
.then(data => console.log(data.items)) // logs array of event objects
907+
mg.events.get('foobar.example.com', {
908+
page: 'mypageid',
909+
event: 'opened'
910+
}).then(data => console.log(data.items)) // logs array of event objects
908911
.catch(err => console.error(err)); // logs any error
909912
```
910913

@@ -918,8 +921,17 @@ Method naming conventions:
918921
| 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. |
919922
| 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. |
920923
| limit | Number of entries to return. (300 max) |
921-
| <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. |
922-
924+
| **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. |
925+
- #### Example with Date and *Filter field*
926+
```js
927+
const date = new Date(2023, 7, 2, 0, 0, 0, 0); // Wed Aug 02 2023 00:00:00 GMT+0300
928+
const events = await mg.events.get('foobar.example.com', {
929+
begin: date.toUTCString(), // 'Tue, 01 Aug 2023 21:00:00 GMT'
930+
ascending: 'yes',
931+
limit: 5,
932+
event: 'delivered'
933+
});
934+
```
923935
Promise returns: items (array of event objects), pages (paging keys grouped by id)
924936

925937
```JS
@@ -1477,7 +1489,7 @@ Method naming conventions:
14771489

14781490
Promise returns: response body
14791491

1480-
```JS
1492+
```js
14811493
{
14821494
actions: [ 'forward("http://myhost.com/messages/")', 'stop()' ],
14831495
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',

dist/mailgun.node.js

Lines changed: 14240 additions & 3 deletions
Large diffs are not rendered by default.

dist/mailgun.web.js

Lines changed: 9549 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)