-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add eras-client for projects stats callouts (#227)
- Loading branch information
1 parent
10e0ccf
commit 0758126
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var config = require('./config'); | ||
var JSONAPIClient = require('./json-api-client'); | ||
var makeHTTPRequest = JSONAPIClient.makeHTTPRequest; | ||
|
||
var erasClient = { | ||
query: function (params) { | ||
if (params.type === undefined) { | ||
return Promise.reject(new Error('Missing required parameter: type (either classifications or comments) must be specified.')); | ||
} | ||
|
||
var data = {}; | ||
if (params.workflowID) { | ||
data['workflow_id'] = params.workflowID; | ||
} | ||
if (params.projectID) { | ||
data['project_id'] = params.projectID; | ||
} | ||
if (params.period) { | ||
data['period'] = params.period; | ||
} | ||
|
||
var erasURL = [config.erasHost, params.type].join('/'); | ||
|
||
return makeHTTPRequest('GET', erasURL, data).then(function (response) { | ||
var results = JSON.parse(response.text); | ||
return results; | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = erasClient; |