UNPKG

@awhere/api

Version:

The awesome aWhere API for JavaScript.

100 lines 4.19 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var PrototypeBase_1 = __importDefault(require("../PrototypeBase")); var Organization = /** @class */ (function (_super) { __extends(Organization, _super); function Organization(props) { if (props === void 0) { props = {}; } var _this = _super.call(this, props) || this; _this._deletable = true; _this._id = props._id || Organization.generateId(); _this.name = props.name; if (props.deletable !== undefined) { _this.deletable = props.deletable; } return _this; } Organization.generateId = function () { return _super.generateId.call(this, 'awhere.core.organization'); }; Organization.fromId = function (id) { return this.request.get("".concat(this.basePath, "/").concat(id)).then(function (res) { return new Organization(res.data); }); }; Organization.find = function (findOptions) { if (typeof findOptions === 'string') { throw new Error('invalid findOptions'); } return this.request.post("".concat(this.basePath), findOptions); }; Organization.create = function (data) { if (!data || typeof data === 'string') { throw new Error('invalid data'); } return this.request.put("".concat(this.basePath), data); }; Organization.update = function (id, data) { return this.request.put("".concat(this.basePath, "/").concat(id), data); }; Organization.delete = function (id) { return this.request.delete("".concat(this.basePath, "/").concat(id)); }; Organization.restore = function (id) { return this.request.put("".concat(this.basePath, "/").concat(id, "/restore")); }; Organization.prototype.save = function () { if (this._id) { return this.request.put("".concat(Organization.basePath, "/").concat(this._id), this).then(function (res) { return res.data; }); } else { return this.request.put("".concat(Organization.basePath), this).then(function (res) { return res.data; }); } }; Organization.prototype.delete = function () { return this.request.delete("".concat(Organization.basePath, "/").concat(this._id)).then(function (res) { return res.data; }); }; Organization.prototype.restore = function () { return this.request.put("".concat(Organization.basePath, "/").concat(this._id, "/restore")).then(function (res) { return res.data; }); }; Object.defineProperty(Organization.prototype, "name", { get: function () { return this._name; }, set: function (value) { this._name = value; }, enumerable: false, configurable: true }); Object.defineProperty(Organization.prototype, "deletable", { get: function () { return this._deletable; }, set: function (value) { this._deletable = value; }, enumerable: false, configurable: true }); Organization.basePath = '/admin/organization'; return Organization; }(PrototypeBase_1.default)); exports.default = Organization; //# sourceMappingURL=Oraganization.js.map