-
Notifications
You must be signed in to change notification settings - Fork 1
/
citation.js
54 lines (49 loc) · 1.46 KB
/
citation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var NCBIRequest = require('./lib/ncbirequest'),
NCBIConf = require('./lib/ncbiconf')
var ncbiconf = new NCBIConf();
/**
* Object to do differnt actions in Citations.
* @constructor
*/
var Citation = function () {
this.ncbiconf = ncbiconf;
}
// This first version only set up the get function....
// Write in this class the different functions PUT, DELETE, etc.
/**
* Citation module.
* @module Citation
*/
Citation.prototype = {
/**
* GET any API endpoints.
* @param {string} type - NCBI endpoints (e.g. esearch).
* @param {string} params - keyword separated by commas.
* @param {function} callback - data is the parsed data received from NCBI.
* @memberOf Citation
*/
get: function (type, params, callback) {
return this.request('GET', type, params, callback)
},
/**
* Use NCBIRequest object to get NCBI API requests.
* @param {string} method - Request: GET, PUT, DELETE
* @param {string} type - NCBI endpoints (e.g. esearch).
* @param {string} params - keyword separated by commas.
* @param {function} callback - - data is the parsed data received from NCBI.
* @memberOf Citation
*/
request: function (method, type, params, callback) {
params = this.ncbiconf.params(type,params);
//console.log(params);
// build the full url
var finalPath = this.ncbiconf.path(type);
//console.log(finalPath);
return new NCBIRequest(
method
, finalPath
, params
).makeRequest(callback)
}
}
module.exports = Citation