UNPKG

trello-for-wolves

Version:
210 lines (209 loc) 8.89 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 __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.Card = void 0; var TrelloForWolvesError_1 = require("../TrelloForWolvesError"); var isEmpty_1 = require("../utils/isEmpty"); var Action_1 = require("./Action"); var Attachment_1 = require("./Attachment"); var BaseResource_1 = require("./BaseResource"); var Board_1 = require("./Board"); var CheckItem_1 = require("./CheckItem"); var Checklist_1 = require("./Checklist"); var Comment_1 = require("./Comment"); var CustomField_1 = require("./CustomField"); var CustomFieldOption_1 = require("./CustomFieldOption"); var Label_1 = require("./Label"); var List_1 = require("./List"); var Member_1 = require("./Member"); var Stickers_1 = require("./Stickers"); var Card = /** @class */ (function (_super) { __extends(Card, _super); function Card() { return _super !== null && _super.apply(this, arguments) || this; } Card.prototype.getCard = function (params) { return this.apiGet("/", params); }; Card.prototype.getCards = function (params) { return this.apiGet("/", params); }; Card.prototype.getCardsFilteredBy = function (filter) { return this.apiGet("/".concat(filter)); }; Card.prototype.getFieldValue = function (field) { return this.apiGet("/".concat(field)); }; Card.prototype.getPluginData = function () { return this.apiGet("/pluginData"); }; Card.prototype.addCard = function (params) { var _a; var validParams = (0, isEmpty_1.isEmpty)(params) ? {} : __assign({}, params); if (this.isChildOf("list")) { validParams.idList = (_a = validParams.idList) !== null && _a !== void 0 ? _a : this.identifier; } if (!validParams.idList) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You must pass specify the \"idList\" param or pass a list ID to the lists() instance when calling addCard()"); } return this.apiPost("/", __assign(__assign({}, validParams), { separator: "/" })); }; Card.prototype.updateCard = function (params) { return this.apiPut("/", params); }; Card.prototype.updateClosedStatus = function (value) { return this.apiPut("/closed", { value: value }); }; Card.prototype.updateDescription = function (value) { return this.apiPut("/desc", { value: value }); }; Card.prototype.updateDueDate = function (value) { return this.apiPut("/due", { value: value }); }; Card.prototype.updateDueComplete = function (value) { return this.apiPut("/dueComplete", { value: value }); }; /** * Update the Id of the image attachment of this card to use as its cover. * @example PUT /1/cards/:cardId/idAttachmentCover * @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-idattachmentcover */ Card.prototype.updateAttachmentCoverImage = function (idAttachmentCover) { return this.apiPut("/idAttachmentCover", { value: idAttachmentCover }); }; Card.prototype.moveToBoard = function (idBoard, params) { return this.apiPut("/idBoard", __assign({ value: idBoard }, params)); }; Card.prototype.moveToList = function (idList) { return this.apiPut("/idList", { value: idList }); }; Card.prototype.updateName = function (value) { return this.apiPut("/name", { value: value }); }; Card.prototype.updatePosition = function (value) { return this.apiPut("/pos", { value: value }); }; Card.prototype.updateSubscribed = function (value) { return this.apiPut("/subscribed", { value: value }); }; Card.prototype.markAssociatedNotificationsRead = function () { return this.apiPost("/markAssociatedNotificationsRead"); }; Card.prototype.deleteCard = function () { return this.apiDelete("/"); }; Card.prototype.actions = function () { return new Action_1.Action(this.config, this.pathElements, "actions"); }; Card.prototype.attachments = function (idAttachment) { if (idAttachment === void 0) { idAttachment = ""; } return new Attachment_1.Attachment(this.config, this.pathElements, "attachments", { identifier: idAttachment, }); }; Card.prototype.board = function () { return new Board_1.Board(this.config, this.pathElements, "board"); }; Card.prototype.checkItem = function (idCheckItem) { return new CheckItem_1.CheckItem(this.config, this.pathElements, "checkItem", { identifier: idCheckItem, }); }; Card.prototype.checkItemStates = function () { return new CheckItem_1.CheckItem(this.config, this.pathElements, "checkItemStates"); }; Card.prototype.checklist = function (idChecklist) { return new Checklist_1.Checklist(this.config, this.pathElements, "checklist", { identifier: idChecklist, }); }; Card.prototype.checklists = function (idChecklist) { if (idChecklist === void 0) { idChecklist = ""; } return new Checklist_1.Checklist(this.config, this.pathElements, "checklists", { identifier: idChecklist, }); }; Card.prototype.comments = function (idComment) { if (idComment === void 0) { idComment = ""; } return new Comment_1.Comment(this.config, this.pathElements, "actions", { identifier: idComment, }); }; Card.prototype.customField = function (idCustomField) { var updatedPathElements = this.pathElements.reduce(function (acc, pathElement) { if (pathElement === "cards") { return __spreadArray(__spreadArray([], acc, true), ["card"], false); } return __spreadArray(__spreadArray([], acc, true), [pathElement], false); }, []); return new CustomField_1.CustomField(this.config, updatedPathElements, "customField", { identifier: idCustomField, }); }; Card.prototype.customFieldItems = function () { return new CustomFieldOption_1.CustomFieldOption(this.config, this.pathElements, "customFieldItems"); }; Card.prototype.labels = function (idLabel) { if (idLabel === void 0) { idLabel = ""; } return new Label_1.Label(this.config, this.pathElements, "labels", { identifier: idLabel, }); }; Card.prototype.list = function () { return new List_1.List(this.config, this.pathElements, "list"); }; Card.prototype.members = function (idMember) { if (idMember === void 0) { idMember = ""; } return new Member_1.Member(this.config, this.pathElements, "members", { identifier: idMember, }); }; Card.prototype.membersVoted = function (idMember) { if (idMember === void 0) { idMember = ""; } return new Member_1.Member(this.config, this.pathElements, "membersVoted", { identifier: idMember, }); }; Card.prototype.stickers = function (idSticker) { if (idSticker === void 0) { idSticker = ""; } return new Stickers_1.Sticker(this.config, this.pathElements, "stickers", { identifier: idSticker, }); }; return Card; }(BaseResource_1.BaseResource)); exports.Card = Card;