fullcontact
Advanced tools
Comparing version 0.2.0 to 1.0.0
@@ -13,3 +13,3 @@ 'use strict'; | ||
this.endpoint = 'https://api.fullcontact.com/'+ api.version +'/email/'; | ||
this.endpoint = 'https://api.fullcontact.com/' + api.version + '/email/'; | ||
this.send = api.process.bind(api, this); | ||
@@ -34,3 +34,3 @@ } | ||
// | ||
args.endpoint = this.endpoint +'disposable.json'; | ||
args.endpoint = this.endpoint + 'disposable.json'; | ||
@@ -37,0 +37,0 @@ this.send({ email: args.value }, args); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
this.endpoint = 'https://api.fullcontact.com/'+ api.version +'/address/'; | ||
this.endpoint = 'https://api.fullcontact.com/' + api.version + '/address/'; | ||
this.send = api.process.bind(api, this); | ||
@@ -34,3 +34,3 @@ } | ||
// | ||
args.endpoint = this.endpoint +'locationNormalizer.json'; | ||
args.endpoint = this.endpoint + 'locationNormalizer.json'; | ||
@@ -57,3 +57,3 @@ this.send({ place: args.value }, args); | ||
// | ||
args.endpoint = this.endpoint +'locationEnrichment.json'; | ||
args.endpoint = this.endpoint + 'locationEnrichment.json'; | ||
@@ -60,0 +60,0 @@ this.send({ place: args.value }, args); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
this.endpoint = 'https://api.fullcontact.com/'+ api.version +'/name/'; | ||
this.endpoint = 'https://api.fullcontact.com/' + api.version + '/name/'; | ||
this.send = api.process.bind(api, this); | ||
@@ -34,3 +34,3 @@ } | ||
// | ||
args.endpoint = this.endpoint +'normalizer.json'; | ||
args.endpoint = this.endpoint + 'normalizer.json'; | ||
@@ -58,3 +58,3 @@ this.send({ q: args.value }, args); | ||
// | ||
args.endpoint = this.endpoint +'deducer.json'; | ||
args.endpoint = this.endpoint + 'deducer.json'; | ||
@@ -81,3 +81,3 @@ this.send(args.value, args); | ||
// | ||
args.endpoint = this.endpoint +'similarity.json'; | ||
args.endpoint = this.endpoint + 'similarity.json'; | ||
@@ -107,3 +107,3 @@ this.send({ q1: args.value, q2: args.q2 }, args); | ||
// | ||
args.endpoint = this.endpoint +'stats.json'; | ||
args.endpoint = this.endpoint + 'stats.json'; | ||
@@ -130,3 +130,3 @@ this.send(args.value, args); | ||
// | ||
args.endpoint = this.endpoint +'parser.json'; | ||
args.endpoint = this.endpoint + 'parser.json'; | ||
@@ -133,0 +133,0 @@ this.send({ q: args.value }, args); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
this.endpoint = 'https://api.fullcontact.com/'+ api.version +'/person.json'; | ||
this.endpoint = 'https://api.fullcontact.com/' + api.version + '/person.json'; | ||
this.send = api.process.bind(api, this); | ||
@@ -22,3 +22,3 @@ } | ||
* ```js | ||
* fullcontact.person.email('opensource@observe.it', [queue], fn); | ||
* fullcontact.person.email('opensource@observe.it', [queue], [webhookUrl], [webhookId], fn); | ||
* ``` | ||
@@ -25,0 +25,0 @@ * |
75
index.js
'use strict'; | ||
var request = require('request') | ||
, qs = require('qs'); | ||
, qs = require('qs'); | ||
@@ -16,3 +16,5 @@ var slice = Array.prototype.slice; | ||
function FullContact(api) { | ||
if (!(this instanceof FullContact)) return new FullContact(api); | ||
if (!(this instanceof FullContact)) { | ||
return new FullContact(api); | ||
} | ||
@@ -29,3 +31,5 @@ this.key = api; // API key | ||
if (!this.key) throw new Error('Missing API key'); | ||
if (!this.key) { | ||
throw new Error('Missing API key'); | ||
} | ||
} | ||
@@ -47,8 +51,19 @@ | ||
// | ||
if (args.queue) query.queue = args.queue; | ||
if (args.casing) query.casing = args.casing; | ||
if (args.population) query.includeZeroPopulation = !!args.population; | ||
if (args.webhookUrl) query.webhookUrl = args.webhookUrl; | ||
if (args.webhookId) query.webhookId = args.webhookId; | ||
if (args.queue) { | ||
query.queue = args.queue; | ||
} | ||
if (args.casing) { | ||
query.casing = args.casing; | ||
} | ||
if (args.population) { | ||
query.includeZeroPopulation = !!args.population; | ||
} | ||
if (args.webhookUrl) { | ||
query.webhookUrl = args.webhookUrl; | ||
} | ||
if (args.webhookId) { | ||
query.webhookId = args.webhookId; | ||
} | ||
// | ||
@@ -59,8 +74,11 @@ // The packet that is send to the server or queued when we are in queuing | ||
var packet = { | ||
method: 'GET', | ||
uri: args.endpoint || api.endpoint, | ||
qs: query | ||
method: 'GET', | ||
uri: args.endpoint || api.endpoint, | ||
qs: query | ||
}; | ||
if (this.queueing) return this.queue(packet, args); | ||
if (this.queueing) { | ||
return this.queue(packet, args); | ||
} | ||
return this.request(packet, args); | ||
@@ -78,6 +96,8 @@ }; | ||
var fn = args.fn | ||
, self = this; | ||
, self = this; | ||
request(packet, function requested(err, res, body) { | ||
if (err) return fn(err); | ||
if (err) { | ||
return fn(err); | ||
} | ||
@@ -91,6 +111,6 @@ self.ratereset = +res.headers['x-rate-limit-reset'] || self.ratereset; | ||
// | ||
if ('string' === typeof body) { | ||
if (typeof body === 'string') { | ||
try { body = JSON.parse(body); } | ||
catch (e) { | ||
return fn(new Error('Failed to parse API response ('+ e.message +')')); | ||
return fn(new Error('Failed to parse API response (' + e.message + ')')); | ||
} | ||
@@ -142,3 +162,3 @@ } | ||
this.requests.push({ | ||
url: packet.uri +'?'+ qs.stringify(packet.qs), | ||
url: packet.uri + '?' + qs.stringify(packet.qs), | ||
fn: args.fn | ||
@@ -169,3 +189,5 @@ }); | ||
requests.forEach(function cb(data) { | ||
if (data.fn) data.fn(err); | ||
if (data.fn) { | ||
data.fn(err); | ||
} | ||
}); | ||
@@ -183,3 +205,3 @@ | ||
method: 'POST', | ||
uri: 'https://api.fullcontact.com/'+ this.version +'/batch.json', | ||
uri: 'https://api.fullcontact.com/' + this.version + '/batch.json', | ||
qs: { apiKey: this.key }, | ||
@@ -192,3 +214,5 @@ json: { | ||
}, function requested(err, res, body) { | ||
if (err) return bailout(err); | ||
if (err) { | ||
return bailout(err); | ||
} | ||
@@ -256,5 +280,6 @@ fn(err, body.responses); | ||
FullContact.Location = require('./endpoints/location'); | ||
FullContact.Person = require('./endpoints/person'); | ||
FullContact.Email = require('./endpoints/email'); | ||
FullContact.Name = require('./endpoints/name'); | ||
FullContact.Person = require('./endpoints/person'); | ||
FullContact.Email = require('./endpoints/email'); | ||
FullContact.Name = require('./endpoints/name'); | ||
FullContact.Company = require('./endpoints/company'); | ||
@@ -281,2 +306,6 @@ // | ||
FullContact.define(FullContact.prototype, 'company', function define() { | ||
return new FullContact.Company(this); | ||
}); | ||
// | ||
@@ -283,0 +312,0 @@ // Expose the FullContact API. |
{ | ||
"name": "fullcontact", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "Fullcontact API bindings", | ||
@@ -8,3 +8,4 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "API_KEY=506d9c8a7aafae5a NODE_ENV=testing ./node_modules/.bin/mocha $(find test -name '*.test.js')" | ||
"test": "NODE_ENV=testing ./node_modules/.bin/mocha $(find test -name '*.test.js')", | ||
"test-travis": "API_KEY=506d9c8a7aafae5a NODE_ENV=testing ./node_modules/.bin/mocha $(find test -name '*.test.js')" | ||
}, | ||
@@ -18,10 +19,10 @@ "repository": { | ||
"dependencies": { | ||
"request": "~2.25.0", | ||
"qs": "~2.3.3" | ||
"request": "2.x.x", | ||
"qs": "2.x.x" | ||
}, | ||
"devDependencies": { | ||
"mocha": "2.1.x", | ||
"chai": "1.10.x", | ||
"pre-commit": "0.0.x" | ||
"mocha": "2.x.x", | ||
"chai": "2.x.x", | ||
"pre-commit": "1.x.x" | ||
} | ||
} |
@@ -122,4 +122,4 @@ # fullcontact | ||
The `Person` endpoint is confidently namespaced as a `.person` property. Each | ||
person API has an optional `queue` argument which you can use to indicate that | ||
The `Person` endpoint is confidently namespaced as a `.person` property. | ||
Each person API has an optional `queue` argument which you can use to indicate that | ||
this request will should be pre-processed by FullContact and that you want to | ||
@@ -131,5 +131,6 @@ fetch the details later. According to the API it should to receive the value `1` | ||
#### person.email(address, [queue], fn); | ||
#### person.email(address, [queue], [webhookUrl], [webhookId], fn); | ||
Retrieves contact information by e-mail address. | ||
Supports the use of webhooks by providing an url and id. | ||
@@ -142,2 +143,8 @@ ```js | ||
```js | ||
fullcontact.person.email('foo@bar.com', null, 'https://mycallbackurl.com', 'webhooktracker', function (err, data) { | ||
.. | ||
}); | ||
``` | ||
#### person.md5(address, [queue], fn); | ||
@@ -278,11 +285,7 @@ | ||
``` | ||
npm test | ||
API_KEY=<key> npm test | ||
``` | ||
If you want to test with your own API key please run: | ||
Don't worry if you forget it, we'll throw an error and let you know ;-). | ||
``` | ||
API_KEY=<key> ./node_modules/.bin/mocha $(find test -name '*.test.js') | ||
``` | ||
## License | ||
@@ -289,0 +292,0 @@ |
describe('FullContact.Email', function () { | ||
'use strict'; | ||
var FullContact = require('../') | ||
, chai = require('chai') | ||
, expect = chai.expect; | ||
var FullContact = require('../'); | ||
var chai = require('chai'); | ||
chai.Assertion.includeStack = true; | ||
chai.config.includeStack = true; | ||
@@ -14,2 +13,5 @@ // | ||
var key = process.env.API_KEY; | ||
if (!key) { | ||
throw new Error('Please provide your API using the API_KEY env variable.'); | ||
} | ||
@@ -16,0 +18,0 @@ // |
describe('FullContact', function () { | ||
'use strict'; | ||
var FullContact = require('../') | ||
, chai = require('chai') | ||
, expect = chai.expect; | ||
var FullContact = require('../'); | ||
var chai = require('chai'); | ||
var expect = chai.expect; | ||
chai.Assertion.includeStack = true; | ||
chai.config.includeStack = true; | ||
@@ -14,2 +14,5 @@ // | ||
var key = process.env.API_KEY; | ||
if (!key) { | ||
throw new Error('Please provide your API using the API_KEY env variable.'); | ||
} | ||
@@ -58,3 +61,3 @@ // | ||
it('errors when an invalid API key is given', function (done) { | ||
var client = new FullContact(key +'adfasfdsfadsfas'); | ||
var client = new FullContact(key + 'adfasfdsfadsfas'); | ||
@@ -75,4 +78,6 @@ client.person.email('arnout@observe.it', function (err) { | ||
api.person.email('arnout@observe.it', function email(err, data) { | ||
if (err) return done(err); | ||
api.person.email('arnout@observe.it', function email(err) { | ||
if (err) { | ||
return done(err); | ||
} | ||
@@ -92,3 +97,5 @@ ['remaining', 'ratelimit', 'ratereset'].forEach(function (prop) { | ||
api.person.email('arnout@observe.it', function email(err) { | ||
if (err) return done(err); | ||
if (err) { | ||
return done(err); | ||
} | ||
@@ -95,0 +102,0 @@ // |
describe('FullContact.Location', function () { | ||
'use strict'; | ||
var FullContact = require('../') | ||
, chai = require('chai') | ||
, expect = chai.expect; | ||
var FullContact = require('../'); | ||
var chai = require('chai'); | ||
chai.Assertion.includeStack = true; | ||
chai.config.includeStack = true; | ||
@@ -14,2 +13,5 @@ // | ||
var key = process.env.API_KEY; | ||
if (!key) { | ||
throw new Error('Please provide your API using the API_KEY env variable.'); | ||
} | ||
@@ -16,0 +18,0 @@ // |
describe('FullContact.Name', function () { | ||
'use strict'; | ||
var FullContact = require('../') | ||
, chai = require('chai') | ||
, expect = chai.expect; | ||
var FullContact = require('../'); | ||
var chai = require('chai'); | ||
chai.Assertion.includeStack = true; | ||
chai.config.includeStack = true; | ||
@@ -14,2 +13,5 @@ // | ||
var key = process.env.API_KEY; | ||
if (!key) { | ||
throw new Error('Please provide your API using the API_KEY env variable.'); | ||
} | ||
@@ -16,0 +18,0 @@ // |
describe('FullContact.Person', function () { | ||
'use strict'; | ||
var FullContact = require('../') | ||
, chai = require('chai') | ||
, expect = chai.expect; | ||
var FullContact = require('../'); | ||
var chai = require('chai'); | ||
chai.Assertion.includeStack = true; | ||
chai.config.includeStack = true; | ||
@@ -14,2 +13,5 @@ // | ||
var key = process.env.API_KEY; | ||
if (!key) { | ||
throw new Error('Please provide your API using the API_KEY env variable.'); | ||
} | ||
@@ -33,3 +35,3 @@ // | ||
}); | ||
describe('#email with webhook url/id', function () { | ||
@@ -45,5 +47,5 @@ it('retrieves data by e-mail and sets up a webhook with the right url and id', function (done) { | ||
var md5 = require('crypto').createHash('md5') | ||
.update('arnout@observe.it') | ||
.digest('hex') | ||
.toString(); | ||
.update('arnout@observe.it') | ||
.digest('hex') | ||
.toString(); | ||
@@ -73,3 +75,3 @@ it('retrieves data by md5 e-mail', function (done) { | ||
describe('#facebookId', function () { | ||
describe('#facebookId', function () { | ||
it('retrieves data by facebook id', function (done) { | ||
@@ -76,0 +78,0 @@ api.person.facebookId('1844599060', done); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
34690
19
906
0
292
6
1
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.12.0(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.9.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@2.4.26.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign@0.3.0(transitive)
- Removedboom@0.4.2(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcookie-jar@0.3.0(transitive)
- Removedcryptiles@0.2.2(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedforever-agent@0.5.2(transitive)
- Removedform-data@0.1.4(transitive)
- Removedhawk@1.0.0(transitive)
- Removedhoek@0.9.1(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedmime@1.2.11(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.3.0(transitive)
- Removedqs@0.6.62.3.3(transitive)
- Removedrequest@2.25.0(transitive)
- Removedsntp@0.2.4(transitive)
- Removedtunnel-agent@0.3.0(transitive)
Updatedqs@2.x.x
Updatedrequest@2.x.x