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).
66 lines (52 loc) • 1.44 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var Endpoint = require('../Endpoint.js');
var Client = require('../Client.js');
class Application extends Endpoint['default'] {
static STATUS = {
VERIFIED: 'verified',
UNVERIFIED: 'unverified',
};
/**
*
* @param {Client} client
* @param {string} app
* @param {string} app_id
* @param {string} status
*/
constructor(client, {app, app_id, status}) {
super(client);
this.app_id = app_id;
this.app = app;
this.status = status;
}
/**
*
* @return {Promise<boolean>}
*/
async delete() {
try {
await this.client.request(`apps/${this.app_id}`, Client['default'].METHOD.DELETE);
}
catch {
return false;
}
return true;
}
/**
*
* @return {Promise<boolean>}
*/
async verify() {
if (this.status === Application.STATUS.VERIFIED) {
return true;
}
const data = await this.client.request(`apps/${this.app_id}`, Client['default'].METHOD.POST, {body: `method=http`});
if (data.message === 'success') {
this.status = Application.STATUS.VERIFIED;
}
return this.status === Application.STATUS.VERIFIED;
}
}
module.exports = exports = Application;
exports['default'] = Application;