Commit 9e3fbd4e by Ben Drucker

Pass through the query object

parent ca90443d
......@@ -12,7 +12,7 @@ function ClearbitClient (config) {
assert(this instanceof ClearbitClient, 'Client must be called with new');
assert(!!config.key, 'An API key must be provided');
this.key = config.key;
};
}
var base = 'https://%s%s.clearbit.co/v%s';
ClearbitClient.prototype.base = function (options) {
......@@ -34,17 +34,16 @@ ClearbitClient.prototype.url = function (options) {
path: ''
});
return this.base(options) + options.path;
}
};
ClearbitClient.prototype.request = function (options) {
options = _.defaults(options || {}, {
method: 'get',
data: null
method: 'get'
});
return needle.requestAsync(
options.method,
this.url(options),
options.data,
options.query,
{
username: this.key,
user_agent: 'ClearbitNode/v' + pkg.version
......
......@@ -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 () {
mock
.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