loader.io.api
Version:
loader.io api wrapper for nodejs. If you interested in this npm package, take a look at the npm package [perst](https://dasred.github.io/perst).
56 lines (45 loc) • 1.6 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var Exception = require('../Exception.js');
var Endpoint = require('../Endpoint.js');
var Application = require('./Application.js');
var Client = require('../Client.js');
class Applications extends Endpoint['default'] {
/**
*
* @param {string} app this is the domain, for which the test must be done
* @return {Promise<Application>}
*/
async create(app) {
const responseData = await this.client.request('apps', Client['default'].METHOD.POST, {body: `app=${app}`});
if (responseData === undefined) {
throw new Exception['default'](`Loader.io app ${app} can not be created.`);
}
return new Application['default'](this.client, responseData);
}
/**
*
* @param {string} id
* @return {Promise<Application>}
*/
async get(id) {
const data = await this.client.request(`apps/${id}`, Client['default'].METHOD.GET);
if (data === undefined) {
throw new Exception['default'](`Loader.io app ${id} can not be found.`);
}
return new Application['default'](this.client, data);
}
/**
*
* @return {Promise<Application[]>}
*/
async list() {
const data = await this.client.request('apps', Client['default'].METHOD.GET);
if (data === undefined) {
return [];
}
return data.map((entry) => new Application['default'](this.client, entry));
}
}
module.exports = exports = Applications;
exports['default'] = Applications;