-
Notifications
You must be signed in to change notification settings - Fork 3
/
nitroPartners.js
42 lines (35 loc) · 1.02 KB
/
nitroPartners.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
/*
Lists Nitro partners
*/
function processResponse(obj) {
for (var p in obj.nitro.results.items) {
var partner = obj.nitro.results.items[p];
console.log(partner.pid+','+partner.name+','+(partner.description||'No description'));
}
var dest = {};
if ((obj.nitro.pagination) && (obj.nitro.pagination.next)) {
dest.query = nitro.queryFrom(obj.nitro.pagination.next.href,true);
dest.path = path;
dest.callback = processResponse;
}
nitro.setReturn(dest);
return true;
}
var nitro = require('./nitroSdk');
var api = require('./nitroApi/api');
var config = require('./config.json');
var host = config.nitro.host;
var api_key = config.nitro.api_key;
var path = api.nitroPips;
for (var i=1;i<99;i++) {
var partnerId = i.toString();
while (partnerId.length<7) {
partnerId = '0' + partnerId;
}
var query = nitro.newQuery();
query.add(api.fPipsQ,'pid:s'+partnerId,true);
nitro.make_request(host,path,api_key,query,{},processResponse);
}
process.on('exit', function(code) {
//console.log('About to exit with code:', code);
});