-
Notifications
You must be signed in to change notification settings - Fork 3
/
nitroServices.js
53 lines (43 loc) · 1.37 KB
/
nitroServices.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
/**
Lists Nitro linear services (the delivery mechanisms for programme delivery)
*/
const util = require('util');
function processResponse(obj) {
for (var m in obj.nitro.results.items) {
var serv = obj.nitro.results.items[m];
console.log(serv.sid+'|'+serv.name+'|'+serv.media_type+'|'+(serv.description ? serv.description : '')+'|'+serv.partner);
}
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.nitroServices;
if ((process.argv.length>2) && (process.argv[2] == 'a')) {
for (var i=2;i<29;i++) {
var p = i.toString();
while (p.length<7) {
p = '0'+p;
}
var query = nitro.newQuery();
query.add(api.fServicesPartnerPid,'s'+p,true);
nitro.make_request(host,path,api_key,query,{},processResponse);
}
}
else {
var query = nitro.newQuery();
if (process.argv.length>2) query.add(api.fServicesServiceType,process.argv[2],true);
nitro.make_request(host,path,api_key,query,{},processResponse);
}
process.on('exit', function(code) {
//console.log('About to exit with code:', code);
});