Commit e0cfbcbc by Arnout Kazemier

Merge pull request #6 from AdriVanHoudt/master

Webhook support for person.email
parents 03a7ad80 8817aabe
language: node_js language: node_js
node_js: node_js:
- "0.8"
- "0.10" - "0.10"
...@@ -25,7 +25,7 @@ function Person(api) { ...@@ -25,7 +25,7 @@ function Person(api) {
* @api public * @api public
*/ */
Person.prototype.email = function email() { Person.prototype.email = function email() {
var args = this.api.args(arguments, 'queue'); var args = this.api.args(arguments, 'queue', 'webhookUrl', 'webhookId');
this.send({ email: args.value }, args); this.send({ email: args.value }, args);
return this; return this;
......
...@@ -45,6 +45,8 @@ FullContact.prototype.process = function req(api, query, args) { ...@@ -45,6 +45,8 @@ FullContact.prototype.process = function req(api, query, args) {
if (args.queue) query.queue = args.queue; if (args.queue) query.queue = args.queue;
if (args.casing) query.casing = args.casing; if (args.casing) query.casing = args.casing;
if (args.population) query.includeZeroPopulation = !!args.population; if (args.population) query.includeZeroPopulation = !!args.population;
if (args.webhookUrl) query.webhookUrl = args.webhookUrl;
if (args.webhookId) query.webhookId = args.webhookId;
// //
// The packet that is send to the server or queued when we are in queuing // The packet that is send to the server or queued when we are in queuing
...@@ -93,7 +95,7 @@ FullContact.prototype.request = function req(packet, args) { ...@@ -93,7 +95,7 @@ FullContact.prototype.request = function req(packet, args) {
// it will have a "message" property when it's a failed request so we can // it will have a "message" property when it's a failed request so we can
// leverage that to return a nice error. // leverage that to return a nice error.
// //
if (body.status !== 200) { if (body.status !== 200 && body.status !== 202) {
err = new Error(body.message); err = new Error(body.message);
err.status = body.status; err.status = body.status;
......
...@@ -29,12 +29,20 @@ describe('FullContact.Person', function () { ...@@ -29,12 +29,20 @@ describe('FullContact.Person', function () {
it('provides the proper casing'); it('provides the proper casing');
}); });
describe('#email with webhook url/id', function () {
it('retrieves data by e-mail and sets up a webhook with the right url and id', function (done) {
api.person.email('arnout@observe.it', null, 'http://requestb.in/1bxgb751', 'webhookTest', done);
});
it('provides the proper casing');
});
describe('#md5', function () { describe('#md5', function () {
var md5 = require('crypto').createHash('md5') var md5 = require('crypto').createHash('md5')
.update('arnout@observe.it') .update('arnout@observe.it')
.digest('hex') .digest('hex')
.toString(); .toString();
it('retrieves data by md5 e-mail', function (done) { it('retrieves data by md5 e-mail', function (done) {
api.person.md5(md5, done); api.person.md5(md5, done);
...@@ -68,7 +76,9 @@ describe('FullContact.Person', function () { ...@@ -68,7 +76,9 @@ describe('FullContact.Person', function () {
}); });
describe('#phone', function () { describe('#phone', function () {
it('retrieves data by phone number'); it('retrieves data by phone number', function (done) {
api.person.phone('+13037170414', done);
});
it('provides the proper casing'); it('provides the proper casing');
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment