Commit 92f48e7d by Alex MacCaw

Add watchlist candidates

parent 19b13741
......@@ -22,6 +22,7 @@ function ClearbitClient (config) {
this.Watchlist = require('./watchlist').Watchlist(this);
this.WatchlistEntity = require('./watchlist').WatchlistEntity(this);
this.WatchlistIndividual = require('./watchlist').WatchlistIndividual(this);
this.WatchlistCandidate = require('./watchlist').WatchlistCandidate(this);
}
var ENDPOINT = 'https://%s%s.clearbit.com/v%s';
......
......@@ -63,6 +63,19 @@ ClearbitResource.post = Promise.method(function (path, options) {
});
});
ClearbitResource.del = Promise.method(function (path, options) {
options = _.extend({
path: path,
method: 'delete',
}, this.options, options || {});
return this.client.request(options)
.bind(this)
.catch(isUnknownRecord, function () {
throw new this.NotFoundError(this.name + ' not found');
});
});
function createErrors (name) {
return {
NotFoundError: createError(name + 'NotFoundError'),
......
......@@ -25,3 +25,23 @@ exports.WatchlistEntity = resource.create('WatchlistEntity', {
return this.post('/search/entities', options);
}
});
exports.WatchlistCandidate = resource.create('WatchlistCandidate', {
api: 'watchlist'
}).extend({
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);
}
}, {
destroy: function(){
return this.constructor.del('/candidates/' + this.id);
}
});
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