Commit 4b6e6f03 by Alex MacCaw

add Watchlist candidates

parent 0207cfcb
...@@ -20,6 +20,7 @@ function ClearbitClient (config) { ...@@ -20,6 +20,7 @@ function ClearbitClient (config) {
this.Person = require('./person').Person(this); this.Person = require('./person').Person(this);
this.PersonCompany = require('./person').PersonCompany(this); this.PersonCompany = require('./person').PersonCompany(this);
this.Watchlist = require('./watchlist').Watchlist(this); this.Watchlist = require('./watchlist').Watchlist(this);
this.WatchlistCandidate = require('./watchlist').WatchlistCandidate(this);
this.WatchlistEntity = require('./watchlist').WatchlistEntity(this); this.WatchlistEntity = require('./watchlist').WatchlistEntity(this);
this.WatchlistIndividual = require('./watchlist').WatchlistIndividual(this); this.WatchlistIndividual = require('./watchlist').WatchlistIndividual(this);
} }
......
...@@ -40,6 +40,20 @@ ClearbitResource.post = function (path, options) { ...@@ -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) { exports.create = function (name, options) {
var Resource = function () { var Resource = function () {
ClearbitResource.apply(this, arguments); ClearbitResource.apply(this, arguments);
......
...@@ -28,3 +28,23 @@ exports.WatchlistEntity = resource.create('WatchlistEntity', { ...@@ -28,3 +28,23 @@ exports.WatchlistEntity = resource.create('WatchlistEntity', {
return this.post('/search/entities', options); 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