forked from jvenema/liveswitch-cloud-console-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (28 loc) · 1.08 KB
/
index.js
File metadata and controls
30 lines (28 loc) · 1.08 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
const SwaggerClient = require('swagger-client');
function liveswitchApi(apiKey){
this.apiKey = apiKey;
this.apiUrl = 'https://api.liveswitch.io/swagger/1.0/swagger.json';
this.getApplications = async function(){
var me = this
var promise = new Promise(function(resolve, reject) {
new SwaggerClient(me.apiUrl, {
requestInterceptor: (req) => {
req.headers['x-api-key'] = me.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: liveswitchApi }