emailable
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict' | ||
@@ -12,7 +12,7 @@ class Batches { | ||
'batch', { emails: emails.join(','), ...options } | ||
); | ||
) | ||
} | ||
status(id, options = {}) { | ||
return this.client.makeGetRequest('batch', { id: id, ...options }); | ||
return this.client.makeGetRequest('batch', { id: id, ...options }) | ||
} | ||
@@ -22,2 +22,2 @@ | ||
module.exports = Batches; | ||
module.exports = Batches |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
'use strict' | ||
const axios = require('axios'); | ||
const axios = require('axios') | ||
@@ -8,5 +8,5 @@ class Client { | ||
constructor(key) { | ||
this.instance = axios.create({ baseURL: 'https://api.emailable.com/v1/' }); | ||
this.instance = axios.create({ baseURL: 'https://api.emailable.com/v1/' }) | ||
if (key) { | ||
this.instance.defaults.headers.common['Authorization'] = `Bearer ${key}`; | ||
this.instance.defaults.headers.common['Authorization'] = `Bearer ${key}` | ||
} | ||
@@ -26,7 +26,7 @@ } | ||
} else { | ||
reject({ message: error }); | ||
reject({ message: error }) | ||
} | ||
}); | ||
}); | ||
}; | ||
}) | ||
}) | ||
} | ||
@@ -42,8 +42,8 @@ makePostRequest(endpoint, data = {}) { | ||
}) | ||
}); | ||
}); | ||
}; | ||
}) | ||
}) | ||
} | ||
} | ||
module.exports = Client; | ||
module.exports = Client |
@@ -1,27 +0,29 @@ | ||
export class Client { | ||
constructor(key: string); | ||
declare class Client { | ||
constructor(key: string) | ||
makeGetRequest(endpoint: string, params?: object): Promise<any>; | ||
makeGetRequest(endpoint: string, params?: {}): Promise<any> | ||
makePostRequest(endpoint: string, data?: object): Promise<any>; | ||
makePostRequest(endpoint: string, data?: {}): Promise<any> | ||
} | ||
export class Batches { | ||
constructor(client: Client); | ||
declare class Batches { | ||
constructor(client: Client) | ||
verify(emails: string[], options?: object): Promise<any>; | ||
verify(emails: string[], options?: {}): Promise<any> | ||
status(id: string, options?: object): Promise<any>; | ||
status(id: string, options?: {}): Promise<any> | ||
} | ||
export class Emailable { | ||
constructor(apiKey: string); | ||
declare class Emailable { | ||
constructor(apiKey: string) | ||
verify(email: string, options?: object): Promise<any>; | ||
verify(email: string, options?: {}): Promise<any> | ||
account(): Promise<any>; | ||
account(): Promise<any> | ||
readonly batches: Batches; | ||
readonly client: Client | ||
readonly batches: Batches | ||
} | ||
export default Emailable; | ||
declare function _exports(apiKey: any): Emailable | ||
export = _exports |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
'use strict' | ||
const Client = require('./client'); | ||
const Batches = require('./batches'); | ||
const Client = require('./client') | ||
const Batches = require('./batches') | ||
@@ -9,12 +9,12 @@ class Emailable { | ||
constructor(apiKey) { | ||
this.client = new Client(apiKey); | ||
this.batches = new Batches(this.client); | ||
this.client = new Client(apiKey) | ||
this.batches = new Batches(this.client) | ||
} | ||
verify(email, options = {}) { | ||
return this.client.makePostRequest('verify', { email: email, ...options }); | ||
return this.client.makePostRequest('verify', { email: email, ...options }) | ||
} | ||
account() { | ||
return this.client.makeGetRequest('account'); | ||
return this.client.makeGetRequest('account') | ||
} | ||
@@ -24,2 +24,2 @@ | ||
module.exports = apiKey => new Emailable(apiKey); | ||
module.exports = apiKey => new Emailable(apiKey) |
{ | ||
"name": "emailable", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Email Verification that's astonishingly easy and low-cost. See https://emailable.com for details.", | ||
@@ -8,3 +8,4 @@ "main": "lib/emailable.js", | ||
"scripts": { | ||
"test": "mocha --timeout 10000 && tsd" | ||
"test": "mocha --timeout 10000 && tsd", | ||
"lint": "yarn eslint lib/ test/ --ext .js" | ||
}, | ||
@@ -36,2 +37,4 @@ "tsd": { | ||
"chai": "^4.2.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-cache-ventures": "^1.0.0", | ||
"mocha": "^9.2.0", | ||
@@ -38,0 +41,0 @@ "tsd": "^0.30.3" |
# Emailable Node Library | ||
[![Version](https://img.shields.io/npm/v/emailable.svg)](https://www.npmjs.org/package/emailable) | ||
[![Build Status](https://app.travis-ci.com/emailable/emailable-node.svg?branch=master)](https://app.travis-ci.com/github/emailable/emailable-node) | ||
![Build Status](https://github.com/emailable/emailable-node/actions/workflows/ci.yml/badge.svg) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/e1f07e3080d7ed2ca09e/maintainability)](https://codeclimate.com/github/emailable/emailable-node/maintainability) | ||
@@ -6,0 +6,0 @@ [![Downloads](https://img.shields.io/npm/dm/emailable.svg)](https://www.npmjs.com/package/emailable) |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
'use strict' | ||
const expect = require('chai').expect; | ||
const expect = require('chai').expect | ||
const emailable = require('../lib/emailable')('test_7aff7fc0142c65f86a00') | ||
@@ -10,22 +10,22 @@ | ||
emailable.account().then(response => { | ||
expect(response.owner_email).to.be.a('string'); | ||
expect(response.available_credits).to.be.a('number'); | ||
done(); | ||
}); | ||
}); | ||
expect(response.owner_email).to.be.a('string') | ||
expect(response.available_credits).to.be.a('number') | ||
done() | ||
}) | ||
}) | ||
it('should return a 401 status code when no API key', done => { | ||
require('../lib/emailable')().account().catch(error => { | ||
expect(error.code).to.be.equal(401); | ||
done(); | ||
}); | ||
}); | ||
expect(error.code).to.be.equal(401) | ||
done() | ||
}) | ||
}) | ||
it('should return a 403 status code when an invalid API key', done => { | ||
require('../lib/emailable')('test_xxxxxxxxxx').account().catch(error => { | ||
expect(error.code).to.be.equal(403); | ||
done(); | ||
}); | ||
}); | ||
expect(error.code).to.be.equal(403) | ||
done() | ||
}) | ||
}) | ||
}); | ||
}) |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
'use strict' | ||
const expect = require('chai').expect; | ||
const expect = require('chai').expect | ||
const emailable = require('../lib/emailable')('test_7aff7fc0142c65f86a00') | ||
@@ -11,6 +11,6 @@ const emails = ['deliverable@example.com', 'undeliverable@example.com'] | ||
emailable.batches.verify(emails).then(response => { | ||
expect(response.id).to.have.lengthOf(24); | ||
done(); | ||
}); | ||
}); | ||
expect(response.id).to.have.lengthOf(24) | ||
done() | ||
}) | ||
}) | ||
@@ -20,7 +20,7 @@ it('should return a payment error when passed { simulate: "payment_error" }', done => { | ||
expect(error.code).to.be.equal(402) | ||
done(); | ||
}); | ||
}); | ||
done() | ||
}) | ||
}) | ||
}); | ||
}) | ||
@@ -32,10 +32,10 @@ describe('emailable.batches.status()', () => { | ||
emailable.batches.status(response.id).then(response => { | ||
expect(response.emails).to.be.an('array'); | ||
expect(response.total_counts).to.be.a('object'); | ||
expect(response.reason_counts).to.be.a('object'); | ||
expect(response.message).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
expect(response.emails).to.be.an('array') | ||
expect(response.total_counts).to.be.a('object') | ||
expect(response.reason_counts).to.be.a('object') | ||
expect(response.message).to.be.a('string') | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -45,10 +45,10 @@ it('should return verifying response when passed { simulate: "verifying" }', done => { | ||
emailable.batches.status(response.id, { simulate: 'verifying' }).then(response => { | ||
expect(response.processed).to.be.a('number'); | ||
expect(response.total).to.be.a('number'); | ||
expect(response.message).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
expect(response.processed).to.be.a('number') | ||
expect(response.total).to.be.a('number') | ||
expect(response.message).to.be.a('string') | ||
done() | ||
}) | ||
}) | ||
}) | ||
}); | ||
}) |
@@ -1,11 +0,12 @@ | ||
import { expectType } from 'tsd'; | ||
import Emailable from '../lib/emailable'; | ||
import { expectType } from 'tsd' | ||
import Emailable from '../lib/emailable' | ||
let emailable = new Emailable('test_xxxxxxxxxx'); | ||
expectType<Promise<any>>(emailable.verify('deliverable@example.com')); | ||
expectType<Promise<any>>(emailable.verify('deliverable@example.com', { accept_all: true })); | ||
expectType<Promise<any>>(emailable.account()); | ||
expectType<Promise<any>>(emailable.batches.verify(['deliverable@example.com'])); | ||
expectType<Promise<any>>(emailable.batches.verify(['deliverable@example.com'], { simulate: 'verifying' })); | ||
expectType<Promise<any>>(emailable.batches.status('xxxxxxxxxx')); | ||
expectType<Promise<any>>(emailable.batches.status('xxxxxxxxxx', { simulate: 'verifying' })); | ||
const emailable = Emailable('test_xxxxxxxxxx') | ||
expectType<Promise<any>>(emailable.verify('deliverable@example.com')) | ||
expectType<Promise<any>>(emailable.verify('deliverable@example.com', { accept_all: true })) | ||
expectType<Promise<any>>(emailable.account()) | ||
expectType<Promise<any>>(emailable.batches.verify(['deliverable@example.com'])) | ||
expectType<Promise<any>>(emailable.batches.verify(['deliverable@example.com'], { simulate: 'verifying' })) | ||
expectType<Promise<any>>(emailable.batches.status('xxxxxxxxxx')) | ||
expectType<Promise<any>>(emailable.batches.status('xxxxxxxxxx', { simulate: 'verifying' })) |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
'use strict' | ||
const expect = require('chai').expect; | ||
const expect = require('chai').expect | ||
const emailable = require('../lib/emailable')('test_7aff7fc0142c65f86a00') | ||
@@ -10,20 +10,20 @@ | ||
emailable.verify('deliverable@example.com').then(response => { | ||
expect(response.domain).to.be.a('string'); | ||
expect(response.email).to.be.a('string'); | ||
expect(response.reason).to.be.a('string'); | ||
expect(response.score).to.be.a('number');; | ||
expect(response.state).to.be.a('string'); | ||
expect(response.user).to.be.a('string'); | ||
expect(response.duration).to.be.a('number'); | ||
done(); | ||
}); | ||
}); | ||
expect(response.domain).to.be.a('string') | ||
expect(response.email).to.be.a('string') | ||
expect(response.reason).to.be.a('string') | ||
expect(response.score).to.be.a('number') | ||
expect(response.state).to.be.a('string') | ||
expect(response.user).to.be.a('string') | ||
expect(response.duration).to.be.a('number') | ||
done() | ||
}) | ||
}) | ||
it('should return a valid state', done => { | ||
var states = ['deliverable', 'undeliverable', 'risky', 'unknown']; | ||
const states = ['deliverable', 'undeliverable', 'risky', 'unknown'] | ||
emailable.verify('deliverable@example.com').then(response => { | ||
expect(states.includes(response.state)).to.be.equal(true); | ||
done(); | ||
}); | ||
}); | ||
expect(states.includes(response.state)).to.be.equal(true) | ||
done() | ||
}) | ||
}) | ||
@@ -33,7 +33,7 @@ it('should verify an email with accept-all enabled', done => { | ||
.then(response => { | ||
expect(response.accept_all).to.be.equal(true); | ||
done(); | ||
}); | ||
}); | ||
expect(response.accept_all).to.be.equal(true) | ||
done() | ||
}) | ||
}) | ||
}); | ||
}) |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13994
15
206
5
1