trello-for-wolves
Version:
Node.js wrapper for Trello API...for wolves.
90 lines (89 loc) • 3.82 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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomField = void 0;
var TrelloForWolvesError_1 = require("../TrelloForWolvesError");
var BaseResource_1 = require("./BaseResource");
var CustomFieldOption_1 = require("./CustomFieldOption");
/**
* Custom Fields are extra bits of structured data attached to cards when our
* users need a bit more than what Trello provides. To use them users need to
* enable the Custom Fields Power-Up.
* @see https://developers.trello.com/reference#custom-fields
* @class
*/
var CustomField = /** @class */ (function (_super) {
__extends(CustomField, _super);
function CustomField() {
return _super !== null && _super.apply(this, arguments) || this;
}
CustomField.prototype.getCustomField = function (params) {
return this.apiGet("/", params);
};
CustomField.prototype.getCustomFields = function (params) {
return this.apiGet("/", params);
};
CustomField.prototype.addCustomField = function (params) {
if (!this.isChildOf("board")) {
throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call addCustomField() from a board resource");
}
var idBoard = this.parentElements[1];
if (!idBoard) {
throw new TrelloForWolvesError_1.TrelloForWolvesError("You must pass an ID into the board resource when calling addCustomField()");
}
var body = __assign({}, params);
if (typeof body.displayCardFront !== "undefined") {
body["display_cardFront"] = body.displayCardFront;
delete body.displayCardFront;
}
// These are required when creating a custom field:
body.idModel = idBoard;
body.modelType = "board";
return this.apiPost("/", undefined, body);
};
CustomField.prototype.updateCustomField = function (params) {
var body = __assign({}, params);
if (body.displayCardFront) {
body["display/cardFront"] = body.displayCardFront;
delete body.displayCardFront;
}
return this.apiPut("/", {}, body);
};
CustomField.prototype.deleteCustomField = function () {
return this.apiDelete("/");
};
CustomField.prototype.options = function (idOption) {
if (idOption === void 0) { idOption = ""; }
var groupName = this.isChildOf("card") ? "item" : "options";
return new CustomFieldOption_1.CustomFieldOption(this.config, this.pathElements, groupName, {
identifier: idOption,
});
};
return CustomField;
}(BaseResource_1.BaseResource));
exports.CustomField = CustomField;