mailgun.js 4.2.0 → 4.2.1

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,18 @@
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
+ ### [4.2.1](https://github.com/mailgun/mailgun.js/compare/v4.2.0...v4.2.1) (2022-02-04)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * Remove redundant logs ([27142a0](https://github.com/mailgun/mailgun.js/commits/27142a0f0af6bbb18463a46c50f36dce66f85ad5))
11
+
12
+
13
+ ### Other changes
14
+
15
+ * Update readme ([ea795e6](https://github.com/mailgun/mailgun.js/commits/ea795e62eea82d575907691a570f867b863c0fb9))
16
+
5
17
  ## [4.2.0](https://github.com/mailgun/mailgun.js/compare/v4.1.6...v4.2.0) (2022-02-02)
6
18
 
7
19
 
package/README.md CHANGED
@@ -43,16 +43,6 @@ const mailgun = new Mailgun(formData);
43
43
  const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere'});
44
44
  ```
45
45
 
46
- To use `validate` and `parse` methods, you must additionally include `public_key`. If you're using only those methods, `key` can be an empty string.
47
-
48
- ```js
49
- const mg = mailgun.client({
50
- username: 'api',
51
- key: process.env.MAILGUN_API_KEY || '',
52
- public_key: process.env.MAILGUN_PUBLIC_KEY || 'pubkey-yourkeyhere'
53
- });
54
- ```
55
-
56
46
  In the case your mailgun account is eu hosted you would need to define eu's subdomain as `url` in mailgun's Client constructor:
57
47
 
58
48
  ```js
@@ -102,12 +92,15 @@ The following service methods are available to instantiated clients. The example
102
92
  - [destroy](#destroy-2)
103
93
  - [validate](#validate)
104
94
  - [get](#get-5)
105
- - [parse](#parse)
106
- - [get](#get-6)
107
- - [lists](#lists)
108
- - [list](#list-4)
109
- - [get](#get-7)
95
+ - [Multiple Validation](#multiple-validation)
110
96
  - [create](#create-5)
97
+ - [list](#list-4)
98
+ - [get](#get-5)
99
+ - [destroy](#destroy-3)
100
+ - [lists](#lists)
101
+ - [list](#list-5)
102
+ - [get](#get-6)
103
+ - [create](#create-6)
111
104
  - [update](#update-2)
112
105
  - [destroy](#destroy-3)
113
106
  - [mailListMembers](#maillistmembers)
@@ -1334,7 +1327,7 @@ Promise Returns: response body
1334
1327
  Example:
1335
1328
 
1336
1329
  ```js
1337
- mg.validate.get('alice@example.com')
1330
+ mg.validate.get('foo@mailgun.net')
1338
1331
  .then(data => console.log(data)) // logs response body
1339
1332
  .catch(err => console.log(err)); // logs any error
1340
1333
  ```
@@ -1350,29 +1343,137 @@ Promise Returns: response body
1350
1343
  }
1351
1344
  ```
1352
1345
 
1353
- ### parse
1346
+ ### Multiple Validation
1347
+ https://documentation.mailgun.com/en/latest/api-email-validation.html#email-validation
1348
+ #### create
1349
+ `mg.validate.multipleValidation.create('name_of_the_list', { file })`
1354
1350
 
1355
- #### get
1351
+ ```js
1352
+ const fsPromises = require('fs').promises;
1353
+ const filepath = path.resolve(__dirname, '../path_to_your_file_with_emails_list.csv');
1356
1354
 
1357
- `mg.parse.get(addresses, enableDnsEspChecks)`
1355
+ ...
1358
1356
 
1359
- Example:
1357
+ (async () => {
1358
+ try {
1359
+ const file = {
1360
+ filename: 'test.csv',
1361
+ data: await fsPromises.readFile(filepath)
1362
+ };
1363
+
1364
+ const validateBulkResult = await mg.validate.multipleValidation.create('name_of_the_list', { file });
1365
+ console.log('validateBulkResult', validateBulkResult);
1366
+ } catch (error) {
1367
+ console.error(error);
1368
+ }
1369
+ })();
1370
+ ```
1371
+
1372
+ Response shape:
1373
+ ```JSON
1374
+ {
1375
+ "id": "name_of_the_list",
1376
+ "message": "The validation job was submitted."
1377
+ }
1378
+ ```
1379
+
1380
+ #### list
1381
+
1382
+ `mg.validate.multipleValidation.list()`
1360
1383
 
1361
1384
  ```js
1362
- mg.parse.get('Alice <alice@example.com>, example.com', true)
1385
+ mg.validate.multipleValidation.list()
1363
1386
  .then(data => console.log(data)) // logs response body
1364
1387
  .catch(err => console.log(err)); // logs any error
1365
1388
  ```
1366
1389
 
1367
- Promise Returns: response body
1390
+ Response shape:
1391
+ ```JSON
1392
+ {
1393
+ "jobs": [
1394
+ {
1395
+ "created_at": 1643965937,
1396
+ "download_url": {
1397
+ "csv": "csv-url",
1398
+ "json": "json-url"
1399
+ },
1400
+ "id": "name_of_the_list",
1401
+ "quantity": 40,
1402
+ "records_processed": 40,
1403
+ "status": "uploaded",
1404
+ "summary": {
1405
+ "result": {
1406
+ "catch_all": 0,
1407
+ "deliverable": 0,
1408
+ "do_not_send": 0,
1409
+ "undeliverable": 0,
1410
+ "unknown": 40
1411
+ },
1412
+ "risk": { "high": 0, "low": 0, "medium": 0, "unknown": 40 }
1413
+ }
1414
+ }
1415
+ ],
1416
+ "paging": {
1417
+ "first": "https://api.mailgun.net/v4/address/validate/bulk?limit=100&page=first&pivot=",
1418
+ "last": "https://api.mailgun.net/v4/address/validate/bulk?limit=100&page=last&pivot=",
1419
+ "next": "https://api.mailgun.net/v4/address/validate/bulk?limit=100&page=next&pivot=b4808b5b-1111-2222-3333-6cd0b63f41ea",
1420
+ "prev": "https://api.mailgun.net/v4/address/validate/bulk?limit=100&page=prev&pivot="
1421
+ },
1422
+ "total": 1
1423
+ }
1424
+ ```
1425
+
1426
+ #### get
1427
+
1428
+ `mg.validate.multipleValidation.get('name_of_the_list')`
1368
1429
 
1430
+ ```js
1431
+ mg.validate.multipleValidation.get('name_of_the_list')
1432
+ .then(data => console.log(data)) // logs response body
1433
+ .catch(err => console.log(err)); // logs any error
1369
1434
  ```
1435
+
1436
+ Response shape:
1437
+ ```JSON
1438
+ {
1439
+ "created_at": 1643965937,
1440
+ "download_url": {
1441
+ "csv": "csv-url",
1442
+ "json": "json-url"
1443
+ },
1444
+ "id": "name_of_the_list",
1445
+ "quantity": 40,
1446
+ "records_processed": 40,
1447
+ "status": "uploaded",
1448
+ "summary": {
1449
+ "result": {
1450
+ "catch_all": 0,
1451
+ "deliverable": 0,
1452
+ "do_not_send": 0,
1453
+ "undeliverable": 0,
1454
+ "unknown": 40
1455
+ },
1456
+ "risk": { "high": 0, "low": 0, "medium": 0, "unknown": 40 }
1457
+ }
1458
+ }
1459
+ ```
1460
+
1461
+ #### destroy
1462
+
1463
+ `mg.validate.multipleValidation.destroy('name_of_the_list');`
1464
+
1465
+ cancels bulk validation job
1466
+ ```js
1467
+ mg.validate.multipleValidation.destroy('name_of_the_list');
1468
+ .then(data => console.log(data)) // logs response body
1469
+ .catch(err => console.log(err)); // logs any error
1470
+ ```
1471
+
1472
+ Response shape:
1473
+ ```JSON
1370
1474
  {
1371
- parsed: [],
1372
- unparseable: [
1373
- 'Alice <alice@example.com>',
1374
- 'example.com'
1375
- ]
1475
+ "body": "Validation job canceled.",
1476
+ "status": 200
1376
1477
  }
1377
1478
  ```
1378
1479