trello-for-wolves
Version:
Node.js wrapper for Trello API...for wolves.
101 lines (100 loc) • 4.39 kB
JavaScript
;
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 __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Label = void 0;
var TrelloForWolvesError_1 = require("../TrelloForWolvesError");
var BaseResource_1 = require("./BaseResource");
var Board_1 = require("./Board");
var Label = /** @class */ (function (_super) {
__extends(Label, _super);
function Label() {
return _super !== null && _super.apply(this, arguments) || this;
}
Label.prototype.getLabel = function (params) {
return this.apiGet("/", params);
};
Label.prototype.getLabels = function (params) {
return this.apiGet("/", params);
};
Label.prototype.addLabel = function (params) {
var updatedParams = __assign({}, params);
if (this.isChildOf("board")) {
updatedParams.idBoard = this.pathElements[1];
}
if (!updatedParams.idBoard) {
throw new TrelloForWolvesError_1.TrelloForWolvesError("You must specify the \"idBoard\" param when calling addLabel()");
}
return this.apiPost("/", updatedParams);
};
Label.prototype.associateLabel = function () {
if (!this.isChildOf("card")) {
throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call associateLabel() on a card");
}
if (!this.identifier) {
throw new TrelloForWolvesError_1.TrelloForWolvesError("You must pass a label ID into the labels() instance when calling associateLabel()");
}
this.pathElements = __spreadArray(__spreadArray([], this.parentElements, true), ["idLabels"], false);
return this.apiPost("/", { value: this.identifier });
};
Label.prototype.updateLabel = function (params) {
return this.apiPut("/", params);
};
Label.prototype.updateColor = function (value) {
return this.apiPut("/color", { value: value });
};
Label.prototype.updateName = function (value) {
return this.apiPut("/name", { value: value });
};
Label.prototype.deleteLabel = function () {
return this.apiDelete("/");
};
Label.prototype.dissociateLabel = function () {
if (!this.isChildOf("card")) {
throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call dissociateLabel() on a card");
}
if (!this.identifier) {
throw new TrelloForWolvesError_1.TrelloForWolvesError("You must pass a label ID into the labels() instance when calling associateLabel()");
}
this.pathElements = __spreadArray(__spreadArray([], this.parentElements, true), ["idLabels", this.identifier], false);
return this.apiDelete("/");
};
Label.prototype.board = function () {
return new Board_1.Board(this.config, this.pathElements, "board");
};
return Label;
}(BaseResource_1.BaseResource));
exports.Label = Label;