Skip to content

Commit

Permalink
Merge pull request #23 from figo-connect/feature/parallel
Browse files Browse the repository at this point in the history
Feature/parallel
  • Loading branch information
JeremyCraigMartinez authored Jul 13, 2016
2 parents b0a251f + eafac46 commit fc34b4f
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 126 deletions.
39 changes: 15 additions & 24 deletions lib/figo.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ var Connection = function(client_id, client_secret, redirect_uri) {
// - **callback** (`Function`) - callback function with two parameters: `error` and `result`
//
this.query_api = function(path, data, callback) {
if (agent.figo_request) {
callback(new FigoError("sdk_error", "Each `Connection` object can only send one API request at the same time."));
return;
}

agent.figo_request = new HttpsRequest(agent, path, "POST", function(error, result) {
agent.figo_request = null;
callback(error, result);
Expand Down Expand Up @@ -418,27 +413,23 @@ var Session = function(access_token) {
// - **callback** (`Function`) - callback function with two parameters: `error` and `result`
//
this.query_api = function(path, data, method, callback) {
if (agent.figo_request) {
callback(new FigoError("sdk_error", "Each `Session` object can only send one API request at the same time."));
} else {
var request = new HttpsRequest(agent, path, method, function(error, result) {
agent.figo_request = null;
callback(error, result);
});
agent.figo_request = request;

if (data) {
data = JSON.stringify(data);
}
request.setHeader("Authorization", "Bearer " + access_token);
request.setHeader("Content-Type", "application/json");
request.setHeader("Content-Length", (data ? Buffer.byteLength(data) : "0"));
var request = new HttpsRequest(agent, path, method, function(error, result) {
agent.figo_request = null;
callback(error, result);
});
agent.figo_request = request;

if (data) {
request.write(data);
}
request.end();
if (data) {
data = JSON.stringify(data);
}
request.setHeader("Authorization", "Bearer " + access_token);
request.setHeader("Content-Type", "application/json");
request.setHeader("Content-Length", (data ? Buffer.byteLength(data) : "0"));

if (data) {
request.write(data);
}
request.end();
};

this.query_api_object = function(session, entity_type, path, data, method, collection_name, callback) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
},
"devDependencies": {
"chai": "",
"mocha": "",
"expect.js": ""
"mocha": ""
},
"engines": {
"node": ">=0.8.0"
Expand Down
Loading

0 comments on commit fc34b4f

Please sign in to comment.