eh-api-client
Advanced tools
Comparing version 0.28.0 to 0.30.0
@@ -62,2 +62,3 @@ var | ||
this._requestModificators = []; | ||
this.requestOptions = {}; | ||
}; | ||
@@ -82,5 +83,10 @@ | ||
newClient._factory = this._factory; | ||
newClient.requestOptions = this.requestOptions; | ||
return newClient; | ||
}; | ||
Client.prototype.setRequestOptions = function(options) { | ||
_.extend(this.requestOptions, options); | ||
}; | ||
Client.prototype.setRequestId = function(requestId) { | ||
@@ -115,3 +121,2 @@ this.requestId = requestId; | ||
var reqParams = { | ||
@@ -238,2 +243,3 @@ url: this.apiURL + _url(options.url), | ||
params.agent = this._factory.agent; | ||
_.defaults(params, this.requestOptions); | ||
_.defaults(params, this._factory.requestOptions); | ||
@@ -240,0 +246,0 @@ return Promise.each(this._requestModificators, function(modificator) { |
{ | ||
"name": "eh-api-client", | ||
"version": "0.28.0", | ||
"version": "0.30.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -62,2 +62,5 @@ var | ||
}); | ||
client.setRequestOptions({ | ||
timeout: 1000 | ||
}); | ||
var s; | ||
@@ -81,6 +84,3 @@ before(function(done) { | ||
it("should return network error when timeout out", function(done) { | ||
client.get({ | ||
url: "/", | ||
timeout: 1000 | ||
}, function(err) { | ||
client.get("/", function(err) { | ||
err.name.should.equal("NetworkError"); | ||
@@ -104,3 +104,4 @@ err.message.should.equal("ETIMEDOUT"); | ||
it("shouldn't return network error with default timeout", function(done) { | ||
it("shouldn't return network error with default factory timeout", function(done) { | ||
client.requestOptions = {}; | ||
client.get("/", function(err) { | ||
@@ -107,0 +108,0 @@ should.not.exists(err); |
74632
1736