-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathliveswitch-api.js
More file actions
46 lines (44 loc) · 1.78 KB
/
liveswitch-api.js
File metadata and controls
46 lines (44 loc) · 1.78 KB
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
const SwaggerClient = require('swagger-client');
const liveswitchapi = {
apiKey: '',
apiUrl: 'https://api.liveswitch.io/swagger/1.0/swagger.json',
getApiKeys: async function(oauthToken){
var promise = new Promise(function(resolve, reject) {
reject('Not implemented yet - need to have the new key exchange api');
/*new SwaggerClient(liveswitchapi.apiUrl)
.then(
// the swagger client loaded - get the applications list
client => client.apis.ApplicationConfigs.get_ApplicationConfigs(),
reason => reject('failed to load the spec: ' + reason)
)
.then(
// success with the app list
applicationsResult => resolve(applicationsResult.body.value),
reason => reject('failed on api call: ' + reason)
);*/
});
return promise;
},
getApplications: async function(){
var promise = new Promise(function(resolve, reject) {
new SwaggerClient(liveswitchapi.apiUrl, {
requestInterceptor: (req) => {
req.headers['x-api-key'] = liveswitchapi.apiKey;
return req;
},
})
.then(
// the swagger client loaded - get the applications list
client => client.apis.ApplicationConfigs.get_ApplicationConfigs(),
reason => reject('failed to load the spec: ' + reason)
)
.then(
// success with the app list
applicationsResult => resolve(applicationsResult.body.value),
reason => reject('failed on api call: ' + reason)
);
});
return promise;
}
}
module.exports = liveswitchapi