mailgun.js
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -14,2 +14,4 @@ 'use strict'; | ||
var MessagesClient = require('./messages'); | ||
var ValidateClient = require('./validate'); | ||
var ParseClient = require('./parse'); | ||
@@ -37,2 +39,10 @@ class Client { | ||
this.messages = new MessagesClient(this.request); | ||
if (config.public_key) { | ||
config.key = config.public_key; | ||
this.public_request = new Request(config); | ||
this.validate = new ValidateClient(this.public_request); | ||
this.parse = new ParseClient(this.public_request); | ||
} | ||
} | ||
@@ -39,0 +49,0 @@ } |
{ | ||
"name": "mailgun.js", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "author": "Mailgun", |
@@ -69,2 +69,6 @@ # Mailgun.js [![Build Status](https://travis-ci.org/mailgun/mailgun-js.svg)](https://travis-ci.org/mailgun/mailgun-js) | ||
- [destroy](#destroy-1) | ||
- [validate](#validate) | ||
- [get](#get-4) | ||
- [parse](#parse) | ||
- [get](#get-5) | ||
@@ -872,2 +876,53 @@ Method naming conventions: | ||
### validate | ||
#### get | ||
`mg.validate.get(address)` | ||
Example: | ||
```js | ||
mg.validate.get('alice@example.com') | ||
.then(data => console.log(data)) // logs response body | ||
.catch(err => console.log(err)); // logs any error | ||
``` | ||
Promise Returns: response body | ||
``` | ||
{ | ||
address: 'alice@example.com', | ||
did_you_mean: null, | ||
is_valid: false, | ||
parts: { display_name: null, domain: null, local_part: null } | ||
} | ||
``` | ||
### parse | ||
#### get | ||
`mg.parse.get(addresses, enableDnsEspChecks)` | ||
Example: | ||
```js | ||
mg.parse.get('Alice <alice@example.com>, example.com', true) | ||
.then(data => console.log(data)) // logs response body | ||
.catch(err => console.log(err)); // logs any error | ||
``` | ||
Promise Returns: response body | ||
``` | ||
{ | ||
parsed: [], | ||
unparseable: [ | ||
'Alice <alice@example.com>', | ||
'example.com' | ||
] | ||
} | ||
``` | ||
## Browser Demo | ||
@@ -874,0 +929,0 @@ |
@@ -7,3 +7,5 @@ var Client = require('../lib/client'); | ||
var SuppressionClient = require('../lib/suppressions'); | ||
var MessagesClient = require('../lib/messages') | ||
var MessagesClient = require('../lib/messages'); | ||
var ValidateClient = require('../lib/validate'); | ||
var ParseClient = require('../lib/parse'); | ||
@@ -14,3 +16,3 @@ describe('Client', function() { | ||
beforeEach(function() { | ||
client = new Client({ username: 'username', key: 'key' }); | ||
client = new Client({ username: 'username', key: 'key', public_key: 'key' }); | ||
}); | ||
@@ -53,2 +55,10 @@ | ||
}); | ||
it('creates address validate client', function() { | ||
client.validate.should.be.instanceOf(ValidateClient); | ||
}); | ||
it('creates address parse client', function() { | ||
client.parse.should.be.instanceOf(ParseClient); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1758542
42
11107
1003
7