mailgun.js 3.7.1 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.7.2](https://github.com/mailgun/mailgun-js/compare/v3.7.1...v3.7.2) (2021-10-28)
|
|
6
|
+
|
|
5
7
|
### [3.7.1](https://github.com/mailgun/mailgun-js/compare/v3.7.0...v3.7.1) (2021-10-28)
|
|
6
8
|
|
|
7
9
|
|
package/README.md
CHANGED
|
@@ -104,6 +104,19 @@ The following service methods are available to instantiated clients. The example
|
|
|
104
104
|
- [get](#get-5)
|
|
105
105
|
- [parse](#parse)
|
|
106
106
|
- [get](#get-6)
|
|
107
|
+
- [lists](#lists)
|
|
108
|
+
- [list](#list-4)
|
|
109
|
+
- [get](#get-7)
|
|
110
|
+
- [create](#create-5)
|
|
111
|
+
- [update](#update-2)
|
|
112
|
+
- [destroy](#destroy-3)
|
|
113
|
+
- [mailListMembers](#maillistmembers)
|
|
114
|
+
- [listMembers](#listmember)
|
|
115
|
+
- [getMember](#getmember)
|
|
116
|
+
- [createMember](#createmember)
|
|
117
|
+
- [createMembers](#createmembers)
|
|
118
|
+
- [updateMember](#updatemember)
|
|
119
|
+
- [destroyMember](#destroymember)
|
|
107
120
|
- [Browser Demo](#browser-demo)
|
|
108
121
|
- [Development](#development)
|
|
109
122
|
- [Requirements](#requirements)
|
|
@@ -1363,6 +1376,327 @@ Promise Returns: response body
|
|
|
1363
1376
|
}
|
|
1364
1377
|
```
|
|
1365
1378
|
|
|
1379
|
+
### lists
|
|
1380
|
+
|
|
1381
|
+
A client to manage mailing lists.
|
|
1382
|
+
|
|
1383
|
+
#### list
|
|
1384
|
+
|
|
1385
|
+
`mg.lists.list()`
|
|
1386
|
+
|
|
1387
|
+
Example:
|
|
1388
|
+
|
|
1389
|
+
```js
|
|
1390
|
+
mg.lists.list()
|
|
1391
|
+
.then(data => console.log(data)) // logs response body
|
|
1392
|
+
.catch(err => console.log(err)); // logs any error
|
|
1393
|
+
```
|
|
1394
|
+
|
|
1395
|
+
Promise Returns: response body
|
|
1396
|
+
|
|
1397
|
+
```
|
|
1398
|
+
[
|
|
1399
|
+
{
|
|
1400
|
+
access_level: 'readonly',
|
|
1401
|
+
address: 'noreply@sample.com',
|
|
1402
|
+
created_at: 'Wed, 27 Oct 2021 21:59:21 -0000',
|
|
1403
|
+
description: '',
|
|
1404
|
+
members_count: 0,
|
|
1405
|
+
name: '',
|
|
1406
|
+
reply_preference: 'list'
|
|
1407
|
+
}
|
|
1408
|
+
]
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
#### get
|
|
1412
|
+
|
|
1413
|
+
`mg.lists.get(mailListAddress)`
|
|
1414
|
+
|
|
1415
|
+
Example:
|
|
1416
|
+
|
|
1417
|
+
```js
|
|
1418
|
+
mg.lists.get('noreply@sample.com')
|
|
1419
|
+
.then(data => console.log(data)) // logs response body
|
|
1420
|
+
.catch(err => console.log(err)); // logs any error
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
Promise Returns: response body
|
|
1424
|
+
|
|
1425
|
+
```
|
|
1426
|
+
{
|
|
1427
|
+
access_level: 'readonly',
|
|
1428
|
+
address: 'noreply@sample.com',
|
|
1429
|
+
created_at: 'Thu, 28 Oct 2021 00:16:56 -0000',
|
|
1430
|
+
description: '',
|
|
1431
|
+
members_count: 0,
|
|
1432
|
+
name: '',
|
|
1433
|
+
reply_preference: 'list'
|
|
1434
|
+
}
|
|
1435
|
+
```
|
|
1436
|
+
|
|
1437
|
+
#### create
|
|
1438
|
+
|
|
1439
|
+
`mg.lists.create(data)`
|
|
1440
|
+
|
|
1441
|
+
Example:
|
|
1442
|
+
|
|
1443
|
+
```js
|
|
1444
|
+
mg.lists.create({
|
|
1445
|
+
address: 'reply@sample.com',
|
|
1446
|
+
name: 'Reply Address', // optional, modifiable on website
|
|
1447
|
+
description: 'Mailing lists for repliable address', // optional, modifiable on website
|
|
1448
|
+
access_level: 'readonly', // optional, modifiable on website
|
|
1449
|
+
reply_preference: 'list', // optional, modifiable on website
|
|
1450
|
+
})
|
|
1451
|
+
.then(data => console.log(data)) // logs response body
|
|
1452
|
+
.catch(err => console.log(err)); // logs any error
|
|
1453
|
+
```
|
|
1454
|
+
|
|
1455
|
+
Promise Returns: response body
|
|
1456
|
+
|
|
1457
|
+
```
|
|
1458
|
+
{
|
|
1459
|
+
access_level: 'readonly',
|
|
1460
|
+
address: 'reply@sample.com',
|
|
1461
|
+
created_at: 'Thu, 28 Oct 2021 03:12:17 -0000',
|
|
1462
|
+
description: 'Mailing lists for repliable address',
|
|
1463
|
+
members_count: 0,
|
|
1464
|
+
name: 'Reply Address',
|
|
1465
|
+
reply_preference: 'list'
|
|
1466
|
+
}
|
|
1467
|
+
```
|
|
1468
|
+
|
|
1469
|
+
#### update
|
|
1470
|
+
|
|
1471
|
+
`mg.lists.update(mailListAddress)`
|
|
1472
|
+
|
|
1473
|
+
Example:
|
|
1474
|
+
|
|
1475
|
+
```js
|
|
1476
|
+
mg.lists.update('reply@sample.com', {
|
|
1477
|
+
address: 'foo@sample.com',
|
|
1478
|
+
name: 'Foo', // optional, modifiable on website
|
|
1479
|
+
description: 'Foo bar bat', // optional, modifiable on website
|
|
1480
|
+
access_level: 'members', // optional, modifiable on website
|
|
1481
|
+
reply_preference: 'sender', // optional, modifiable on website
|
|
1482
|
+
})
|
|
1483
|
+
.then(data => console.log(data)) // logs response body
|
|
1484
|
+
.catch(err => console.log(err)); // logs any error
|
|
1485
|
+
```
|
|
1486
|
+
|
|
1487
|
+
Promise Returns: response body
|
|
1488
|
+
|
|
1489
|
+
```
|
|
1490
|
+
{
|
|
1491
|
+
access_level: 'members',
|
|
1492
|
+
address: 'foo@sample.com',
|
|
1493
|
+
created_at: 'Thu, 28 Oct 2021 03:21:15 -0000',
|
|
1494
|
+
description: 'Foo bar bat',
|
|
1495
|
+
members_count: 0,
|
|
1496
|
+
name: 'Foo',
|
|
1497
|
+
reply_preference: 'sender'
|
|
1498
|
+
}
|
|
1499
|
+
```
|
|
1500
|
+
|
|
1501
|
+
#### destroy
|
|
1502
|
+
|
|
1503
|
+
`mg.lists.destroy(mailListAddress)`
|
|
1504
|
+
|
|
1505
|
+
Example:
|
|
1506
|
+
|
|
1507
|
+
```js
|
|
1508
|
+
mg.lists.destroy('foo@sample.com')
|
|
1509
|
+
.then(data => console.log(data)) // logs response body
|
|
1510
|
+
.catch(err => console.log(err)); // logs any error
|
|
1511
|
+
```
|
|
1512
|
+
|
|
1513
|
+
Promise Returns: response body
|
|
1514
|
+
|
|
1515
|
+
```
|
|
1516
|
+
{
|
|
1517
|
+
address: 'foo@sample.com',
|
|
1518
|
+
message: 'Mailing list has been removed'
|
|
1519
|
+
}
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1522
|
+
### mailListMembers
|
|
1523
|
+
|
|
1524
|
+
A client to manage members within a specific mailing list.
|
|
1525
|
+
|
|
1526
|
+
#### listMembers
|
|
1527
|
+
|
|
1528
|
+
`mg.lists.members.listMembers(mailListAddress)`
|
|
1529
|
+
|
|
1530
|
+
Example:
|
|
1531
|
+
|
|
1532
|
+
```js
|
|
1533
|
+
mg.lists.members.listMembers('reply@sample.com')
|
|
1534
|
+
.then(data => console.log(data)) // logs response body
|
|
1535
|
+
.catch(err => console.log(err)); // logs any error
|
|
1536
|
+
```
|
|
1537
|
+
|
|
1538
|
+
Promise Returns: response body
|
|
1539
|
+
|
|
1540
|
+
```
|
|
1541
|
+
[
|
|
1542
|
+
{
|
|
1543
|
+
address: 'foo@bar.com',
|
|
1544
|
+
name: 'Jane Doe',
|
|
1545
|
+
subscribed: true,
|
|
1546
|
+
vars: { age: 50 }
|
|
1547
|
+
}
|
|
1548
|
+
]
|
|
1549
|
+
```
|
|
1550
|
+
|
|
1551
|
+
#### getMember
|
|
1552
|
+
|
|
1553
|
+
`mg.lists.members.getMember(mailListAddress, mailListMemberAddress)`
|
|
1554
|
+
|
|
1555
|
+
Example:
|
|
1556
|
+
|
|
1557
|
+
```js
|
|
1558
|
+
mg.lists.members.getMember('reply@sample.com', 'foo@bar.com')
|
|
1559
|
+
.then(data => console.log(data)) // logs response body
|
|
1560
|
+
.catch(err => console.log(err)); // logs any error
|
|
1561
|
+
```
|
|
1562
|
+
|
|
1563
|
+
Promise Returns: response body
|
|
1564
|
+
|
|
1565
|
+
```
|
|
1566
|
+
{
|
|
1567
|
+
address: 'foo@bar.com',
|
|
1568
|
+
name: 'Jane Doe',
|
|
1569
|
+
subscribed: true,
|
|
1570
|
+
vars: { age: 50 }
|
|
1571
|
+
}
|
|
1572
|
+
```
|
|
1573
|
+
|
|
1574
|
+
#### createMember
|
|
1575
|
+
|
|
1576
|
+
`mg.lists.members.createMember(mailListAddress, data)`
|
|
1577
|
+
|
|
1578
|
+
Example:
|
|
1579
|
+
|
|
1580
|
+
```js
|
|
1581
|
+
mg.lists.members.createMember('reply@sample.com', {
|
|
1582
|
+
address: 'bat@bar.com',
|
|
1583
|
+
name: 'John Smith', // optional, modifiable on website
|
|
1584
|
+
vars: {hobby: "chess"}, // optional, modifiable on website
|
|
1585
|
+
subscribed: 'no', // optional, modifiable on website
|
|
1586
|
+
upsert: 'yes', // optional, choose yes to insert if not exist, or update it exist
|
|
1587
|
+
})
|
|
1588
|
+
.then(data => console.log(data)) // logs response body
|
|
1589
|
+
.catch(err => console.log(err)); // logs any error
|
|
1590
|
+
```
|
|
1591
|
+
|
|
1592
|
+
Promise Returns: response body
|
|
1593
|
+
|
|
1594
|
+
```
|
|
1595
|
+
{
|
|
1596
|
+
address: 'bat@bar.com',
|
|
1597
|
+
name: 'John Smith',
|
|
1598
|
+
subscribed: false,
|
|
1599
|
+
vars: { hobby: 'chess' }
|
|
1600
|
+
}
|
|
1601
|
+
```
|
|
1602
|
+
|
|
1603
|
+
#### createMembers
|
|
1604
|
+
|
|
1605
|
+
`mg.lists.members.createMembers(mailListAddress, data)`
|
|
1606
|
+
|
|
1607
|
+
Example:
|
|
1608
|
+
|
|
1609
|
+
```js
|
|
1610
|
+
mg.lists.members.createMembers('reply@sample.com', {
|
|
1611
|
+
members: [
|
|
1612
|
+
{
|
|
1613
|
+
address: "bot1@foobar.com",
|
|
1614
|
+
name: "Bot1 Superbot",
|
|
1615
|
+
vars: {location: "loc1"},
|
|
1616
|
+
subscribed: true,
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
address: "bot2@foobar.com",
|
|
1620
|
+
name: "Bot2 Superbot",
|
|
1621
|
+
vars: {location: "loc2"},
|
|
1622
|
+
subscribed: false,
|
|
1623
|
+
},
|
|
1624
|
+
],
|
|
1625
|
+
upsert: "yes",
|
|
1626
|
+
})
|
|
1627
|
+
.then(data => console.log(data)) // logs response body
|
|
1628
|
+
.catch(err => console.log(err)); // logs any error
|
|
1629
|
+
```
|
|
1630
|
+
|
|
1631
|
+
Promise Returns: response body
|
|
1632
|
+
|
|
1633
|
+
```
|
|
1634
|
+
{
|
|
1635
|
+
list: {
|
|
1636
|
+
access_level: 'readonly',
|
|
1637
|
+
address: 'reply@sample.com',
|
|
1638
|
+
created_at: 'Thu, 28 Oct 2021 03:21:15 -0000',
|
|
1639
|
+
description: 'For reply purpose',
|
|
1640
|
+
members_count: 2,
|
|
1641
|
+
name: 'Reply',
|
|
1642
|
+
reply_preference: 'list'
|
|
1643
|
+
},
|
|
1644
|
+
message: 'Mailing list has been updated',
|
|
1645
|
+
'task-id': '575b943c37a211ec8a520242ac11000a'
|
|
1646
|
+
}
|
|
1647
|
+
```
|
|
1648
|
+
|
|
1649
|
+
#### updateMember
|
|
1650
|
+
|
|
1651
|
+
`mg.lists.members.updateMember(mailListAddress, mailListMemberAddress, data)`
|
|
1652
|
+
|
|
1653
|
+
Example:
|
|
1654
|
+
|
|
1655
|
+
```js
|
|
1656
|
+
mg.lists.members.updateMember('reply@sample.com', 'bot1@foobar.com', {
|
|
1657
|
+
address: 'bot0@barfoo.com',
|
|
1658
|
+
name: 'Bot0 Normalbot', // optional, modifiable on website
|
|
1659
|
+
vars: {location: "space"},
|
|
1660
|
+
subscribed: false,
|
|
1661
|
+
})
|
|
1662
|
+
.then(data => console.log(data)) // logs response body
|
|
1663
|
+
.catch(err => console.log(err)); // logs any error
|
|
1664
|
+
```
|
|
1665
|
+
|
|
1666
|
+
Promise Returns: response body
|
|
1667
|
+
|
|
1668
|
+
```
|
|
1669
|
+
{
|
|
1670
|
+
address: 'bot0@barfoo.com',
|
|
1671
|
+
name: 'Bot0 Normalbot',
|
|
1672
|
+
subscribed: false,
|
|
1673
|
+
vars: { location: 'space' }
|
|
1674
|
+
}
|
|
1675
|
+
```
|
|
1676
|
+
|
|
1677
|
+
#### destroyMember
|
|
1678
|
+
|
|
1679
|
+
`mg.lists.members.destroyMember(mailListAddress, mailListMemberAddress)`
|
|
1680
|
+
|
|
1681
|
+
Example:
|
|
1682
|
+
|
|
1683
|
+
```js
|
|
1684
|
+
mg.lists.members.destroyMember('reply@sample.com', 'bot2@foobar.com')
|
|
1685
|
+
.then(data => console.log(data)) // logs response body
|
|
1686
|
+
.catch(err => console.log(err)); // logs any error
|
|
1687
|
+
```
|
|
1688
|
+
|
|
1689
|
+
Promise Returns: response body
|
|
1690
|
+
|
|
1691
|
+
```
|
|
1692
|
+
{
|
|
1693
|
+
member: { address: 'bot2@foobar.com' },
|
|
1694
|
+
message: 'Mailing list member has been deleted'
|
|
1695
|
+
}
|
|
1696
|
+
```
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
|
|
1366
1700
|
## Browser Demo
|
|
1367
1701
|
|
|
1368
1702
|

|
|
@@ -7,7 +7,7 @@ export interface CreateUpdateList {
|
|
|
7
7
|
address: string;
|
|
8
8
|
name?: string;
|
|
9
9
|
description?: string;
|
|
10
|
-
access_level?: '
|
|
10
|
+
access_level?: 'readonly' | 'members' | 'everyone';
|
|
11
11
|
reply_preference?: 'list' | 'sender';
|
|
12
12
|
}
|
|
13
13
|
export interface DestroyedList {
|
package/lib/interfaces/lists.ts
CHANGED