Commit 9e3fbd4e by Ben Drucker

Pass through the query object

parent ca90443d
...@@ -12,7 +12,7 @@ function ClearbitClient (config) { ...@@ -12,7 +12,7 @@ function ClearbitClient (config) {
assert(this instanceof ClearbitClient, 'Client must be called with new'); assert(this instanceof ClearbitClient, 'Client must be called with new');
assert(!!config.key, 'An API key must be provided'); assert(!!config.key, 'An API key must be provided');
this.key = config.key; this.key = config.key;
}; }
var base = 'https://%s%s.clearbit.co/v%s'; var base = 'https://%s%s.clearbit.co/v%s';
ClearbitClient.prototype.base = function (options) { ClearbitClient.prototype.base = function (options) {
...@@ -34,17 +34,16 @@ ClearbitClient.prototype.url = function (options) { ...@@ -34,17 +34,16 @@ ClearbitClient.prototype.url = function (options) {
path: '' path: ''
}); });
return this.base(options) + options.path; return this.base(options) + options.path;
} };
ClearbitClient.prototype.request = function (options) { ClearbitClient.prototype.request = function (options) {
options = _.defaults(options || {}, { options = _.defaults(options || {}, {
method: 'get', method: 'get'
data: null
}); });
return needle.requestAsync( return needle.requestAsync(
options.method, options.method,
this.url(options), this.url(options),
options.data, options.query,
{ {
username: this.key, username: this.key,
user_agent: 'ClearbitNode/v' + pkg.version user_agent: 'ClearbitNode/v' + pkg.version
......
...@@ -86,6 +86,19 @@ describe('ClearbitClient', function () { ...@@ -86,6 +86,19 @@ describe('ClearbitClient', function () {
}); });
}); });
it('can generate a qs', function () {
mock
.get('/v1/people/email/bvdrucker@gmail.com?webhook_id=123')
.reply(202);
return client.request({
api: 'person',
path: '/people/email/bvdrucker@gmail.com',
query: {
webhook_id: '123'
}
});
});
it('sends a basic auth header', function () { it('sends a basic auth header', function () {
mock mock
.get('/v1/people/email/bvdrucker@gmail.com') .get('/v1/people/email/bvdrucker@gmail.com')
......
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