UNPKG

pterowrap

Version:

A node.js wrapper for Pterodactyl API

52 lines (51 loc) 2.04 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const TaskManager_1 = __importDefault(require("../../../managers/client/server/TaskManager")); class Schedule { constructor(_client, data, _parentServer) { this._client = _client; this._parentServer = _parentServer; const attributes = data.attributes; this.id = attributes.id; this.name = attributes.name; this.cron = attributes.cron; this.is_active = attributes.is_active; this.is_processing = attributes.is_processing; this.last_run_at = attributes.last_run_at; this.next_run_at = attributes.next_run_at; this.created_at = attributes.created_at; this.updated_at = attributes.updated_at; this.relationships = attributes.relationships ? attributes.relationships : {}; this.tasks = new TaskManager_1.default(this._client, this._parentServer, this); this.raw = attributes; } update(params) { return new Promise(async (resolve, reject) => { try { const data = await this._client.call({ endpoint: `servers/${this._parentServer.identifier}/schedules/${this.id}`, method: "POST", body: params, }); resolve(new Schedule(this._client, data, this._parentServer)); } catch (e) { reject(e); } }); } delete() { return new Promise(async (resolve, reject) => { try { resolve(await this._client.call({ endpoint: `servers/${this._parentServer.identifier}/schedules/${this.id}`, method: "DELETE" })); } catch (e) { reject(e); } }); } } exports.default = Schedule;