UNPKG

holly-sdk

Version:
55 lines (45 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TaskSchedulesAPI = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _got = require("got"); var _got2 = _interopRequireDefault(_got); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TaskSchedulesAPI = exports.TaskSchedulesAPI = function () { function TaskSchedulesAPI(app) { _classCallCheck(this, TaskSchedulesAPI); this.app = app; } _createClass(TaskSchedulesAPI, [{ key: "getAll", value: function getAll() { return (0, _got2.default)(this.app.api.url + "/app_installations/" + this.app.manifest.name + "/task_schedules", { method: "GET", json: true }).then(function (res) { return res.body.task_schedules; }); } }, { key: "createTaskSchedule", value: function createTaskSchedule(taskSchedule) { return (0, _got2.default)(this.app.api.url + "/app_installations/" + this.app.manifest.name + "/task_schedules", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ task_schedule: taskSchedule }), json: true }).then(function (res) { return res.body.task_schedule; }); } }, { key: "destroyTaskSchedule", value: function destroyTaskSchedule(id) { return (0, _got2.default)(this.app.api.url + "/task_schedules/" + id, { method: "DELETE" }); } }]); return TaskSchedulesAPI; }();