Commit 330e254e by Alex MacCaw

Merge pull request #9 from clearbit/alex-watchlist-candidates-v3

Add Watchlist candidates
parents 0207cfcb 4b6e6f03
......@@ -20,6 +20,7 @@ function ClearbitClient (config) {
this.Person = require('./person').Person(this);
this.PersonCompany = require('./person').PersonCompany(this);
this.Watchlist = require('./watchlist').Watchlist(this);
this.WatchlistCandidate = require('./watchlist').WatchlistCandidate(this);
this.WatchlistEntity = require('./watchlist').WatchlistEntity(this);
this.WatchlistIndividual = require('./watchlist').WatchlistIndividual(this);
}
......
......@@ -40,6 +40,20 @@ ClearbitResource.post = function (path, options) {
});
};
ClearbitResource.del = function (path, options) {
options = _.extend({
path: path,
method: 'delete'
}, this.options, options);
return this.client.request(options)
.bind(this)
.then(cast)
.catch(isUnknownRecord, function () {
throw new this.NotFoundError(this.name + ' not found');
});
};
exports.create = function (name, options) {
var Resource = function () {
ClearbitResource.apply(this, arguments);
......
......@@ -28,3 +28,23 @@ exports.WatchlistEntity = resource.create('WatchlistEntity', {
return this.post('/search/entities', options);
}
});
exports.WatchlistCandidate = resource.create('WatchlistCandidate', {
api: 'watchlist'
}).extend({
destroy: function(){
return this.constructor.del('/candidates/' + this.id);
}
}, {
all: function(options) {
return this.get('/candidates', options);
},
create: function(options) {
return this.post('/candidates', options);
},
find: function(id, options) {
return this.get('/candidates/' + id, options);
}
});
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