UNPKG

trello-for-wolves

Version:
314 lines (313 loc) 15.8 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.Member = void 0; var TrelloForWolvesError_1 = require("../TrelloForWolvesError"); var isEmpty_1 = require("../utils/isEmpty"); var Action_1 = require("./Action"); var BaseResource_1 = require("./BaseResource"); var Board_1 = require("./Board"); var BoardBackgrounds_1 = require("./BoardBackgrounds"); var BoardStar_1 = require("./BoardStar"); var Card_1 = require("./Card"); var CustomEmoji_1 = require("./CustomEmoji"); var Enterprise_1 = require("./Enterprise"); var Notification_1 = require("./Notification"); var Organization_1 = require("./Organization"); var SavedSearch_1 = require("./SavedSearch"); var Stickers_1 = require("./Stickers"); var Token_1 = require("./Token"); /** * Everyone with a Trello account is called a member. * @se https://developers.trello.com/reference#member * @class */ var Member = /** @class */ (function (_super) { __extends(Member, _super); function Member() { return _super !== null && _super.apply(this, arguments) || this; } Member.prototype.getMember = function (params) { return this.apiGet("/", params); }; /** * @param [params] Options for data to return. * @param [params.fields] * @param [params.filter] Pass a SCIM-style query to filter members. This takes precedence over the * all/normal/admins value of members. If any of the below member_* args are set, * the member array will be paginated. * @param [params.sort] This parameter expects a SCIM-style sorting value prefixed by a - to sort * descending. If no - is prefixed, it will be sorted ascending. Note that the * members array returned will be paginated if members is "normal" or "admins". * Pagination can be controlled with member_startIndex, etc, but the API * response will not contain the total available result count or pagination status data. * @param [params.sortBy] This parameter expects a SCIM-style sorting value. Note that the members array * returned will be paginated if members is "normal" or "admins". Pagination * can be controlled with member_startIndex, etc, but the API response will not * contain the total available result count or pagination status data. * @param [params.sortOrder] Order to sort records by. * @param [params.startIndex] Any integer between 0 and 9999. * @param [params.count] SCIM-style filter. * @param [params.organizationFields] Organization fields to include in response. * @param [params.boardFields] Board fields to include in response. */ Member.prototype.getMembers = function (params) { return this.apiGet("/", params); }; Member.prototype.getMembersFilteredBy = function (filter) { return this.apiGet("/", { filter: filter }); }; Member.prototype.getFieldValue = function (field) { return this.apiGet("/".concat(field)); }; Member.prototype.getDeltas = function (params) { return this.apiGet("/deltas", params); }; /** * Associates a member with a board, card, or organization. * @see https://developers.trello.com/reference#boardsidlabelnamesmembers * @see https://developers.trello.com/reference#boardsidlabelnamesmembersidmember * @see https://developers.trello.com/reference#cardsididmembers * @see https://developers.trello.com/reference#organizationsidmembers-1 * @see https://developers.trello.com/reference#organizationsidmembersidmember */ Member.prototype.associateMember = function (params) { if (!this.isChildOf(["board", "card", "organization"])) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call associateMember() from a board, card, or organization"); } if (this.isChildOf("card")) { if (!this.identifier) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You must pass a member ID into the members() instance when calling associateMember()"); } if (!(0, isEmpty_1.isEmpty)(params)) { throw new TrelloForWolvesError_1.TrelloForWolvesError("No params are allowed when calling associateMember() from a card"); } this.pathElements = __spreadArray(__spreadArray([], this.parentElements, true), ["idMembers"], false); return this.apiPost("/", { value: this.identifier }); } if (!(params === null || params === void 0 ? void 0 : params.email) && !this.identifier) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You must specify the \"email\" param or pass a member ID into the members() instance when calling associateMember()"); } if (this.isChildOf("board")) { var body = {}; if (params === null || params === void 0 ? void 0 : params.fullName) { body.fullName = params.fullName; delete params.fullName; } return this.apiPut("/", params, body); } return this.apiPut("/", params); }; Member.prototype.associateMembers = function (idMembers) { if (!this.isChildOf("card")) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call associateMembers() from a card"); } this.pathElements = __spreadArray(__spreadArray([], this.parentElements, true), ["idMembers"], false); return this.apiPut("/", { value: idMembers }); }; Member.prototype.uploadAvatar = function (file) { return this.apiPost("/avatar", { file: file }); }; Member.prototype.updateMember = function (params) { return this.apiPut("/", __assign(__assign({}, params), { separator: "/" })); }; Member.prototype.updateAvatarSource = function (value) { return this.apiPut("/avatarSource", { value: value }); }; Member.prototype.updateBio = function (value) { return this.apiPut("/bio", { value: value }); }; Member.prototype.updateFullName = function (value) { return this.apiPut("/fullName", { value: value }); }; Member.prototype.updateInitials = function (value) { return this.apiPut("/initials", { value: value }); }; Member.prototype.updateUsername = function (value) { return this.apiPut("/username", { value: value }); }; Member.prototype.makeAdminForEnterprise = function () { if (!this.isChildOf("enterprise")) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call makeAdminForEnterprise() on an enterprise"); } this.pathElements = __spreadArray(__spreadArray([], this.parentElements, true), ["admins", this.identifier], false); return this.apiPut("/"); }; /** * Updates the deactivated status for a member associated with an enterprise * or organization. * @see https://developers.trello.com/reference#enterprisesidmembersidmemberdeactivated-1 * @see https://developers.trello.com/reference#organizationsidmembersidmemberdeactivated */ Member.prototype.updateDeactivatedStatus = function (value) { if (!this.isChildOf(["enterprise", "organization"])) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call updateDeactivatedStatus() on an enterprise or organization"); } return this.apiPut("/deactivated", { value: value }); }; /** * Updates the member type for a member associated with a board or organization. * @see https://developers.trello.com/reference/#boardsidlabelnamesmembers * @see https://developers.trello.com/reference/#organizationsidmembers-1 */ Member.prototype.updateMemberType = function (type) { if (!this.isChildOf(["board", "organization"])) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call updateMemberType() on a board or organization"); } return this.apiPut("/", { type: type }); }; Member.prototype.updateColorBlind = function (value) { return this.apiPut("/prefs/colorBlind", { value: value }); }; Member.prototype.updateLocale = function (value) { return this.apiPut("/prefs/locale", { value: value }); }; Member.prototype.updateMinutesBetweenSummaries = function (value) { return this.apiPut("/prefs/minutesBetweenSummaries", { value: value }); }; Member.prototype.voteOnCard = function () { // Remove the identifier from the path elements, we pass the member ID to // the request via the `value` param: this.pathElements.pop(); return this.apiPost("/", { value: this.identifier }); }; Member.prototype.dismissOneTimeMessages = function (value) { return this.apiPost("/oneTimeMessagesDismissed", { value: value }); }; /** * Removes a member's association with a board, card, or organization (and * optionally all team boards), doesn't actually delete it. * @param [isRemovedFromBoards=false] Removes the member from all of the boards * for an organization as well. * @see https://developers.trello.com/reference#boardsidmembersidmember * @see https://developers.trello.com/reference#organizationsidmembersidmember-1 * @see https://developers.trello.com/reference#organizationsidmembersidmember-1 */ Member.prototype.dissociateMember = function (isRemovedFromBoards) { if (isRemovedFromBoards === void 0) { isRemovedFromBoards = false; } if (!this.isChildOf(["board", "card", "organization"])) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call dissociateMember() on a board, card, or organization"); } if (this.isChildOf("card")) { if (!this.identifier) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You must pass a member ID into the members() instance when calling dissociateMember()"); } this.pathElements = __spreadArray(__spreadArray([], this.parentElements, true), [ "idMembers", this.identifier, ], false); return this.apiDelete("/"); } var endpoint = isRemovedFromBoards ? "/all" : "/"; return this.apiDelete(endpoint); }; Member.prototype.removeAdminForEnterprise = function () { if (!this.isChildOf("enterprise")) { throw new TrelloForWolvesError_1.TrelloForWolvesError("You can only call removeAdminForEnterprise() on an enterprise"); } this.pathElements = __spreadArray(__spreadArray([], this.parentElements, true), ["admins", this.identifier], false); return this.apiDelete("/"); }; Member.prototype.removeVoteFromCard = function () { return this.apiDelete("/"); }; Member.prototype.actions = function () { return new Action_1.Action(this.config, this.pathElements, "actions"); }; Member.prototype.boardBackgrounds = function (idBoardBackground) { if (idBoardBackground === void 0) { idBoardBackground = ""; } return new BoardBackgrounds_1.BoardBackground(this.config, this.pathElements, "boardBackgrounds", { identifier: idBoardBackground, }); }; Member.prototype.boardStars = function (idBoardStar) { if (idBoardStar === void 0) { idBoardStar = ""; } return new BoardStar_1.BoardStar(this.config, this.pathElements, "boardStars", { identifier: idBoardStar, }); }; Member.prototype.boards = function () { return new Board_1.Board(this.config, this.pathElements, "boards"); }; Member.prototype.boardsInvited = function () { return new Board_1.Board(this.config, this.pathElements, "boardsInvited"); }; Member.prototype.cards = function () { return new Card_1.Card(this.config, this.pathElements, "cards"); }; Member.prototype.customBoardBackgrounds = function (idCustomBoardBackground) { if (idCustomBoardBackground === void 0) { idCustomBoardBackground = ""; } return new BoardBackgrounds_1.CustomBoardBackground(this.config, this.pathElements, "customBoardBackgrounds", { identifier: idCustomBoardBackground, }); }; Member.prototype.customEmojis = function (idCustomEmoji) { if (idCustomEmoji === void 0) { idCustomEmoji = ""; } return new CustomEmoji_1.CustomEmoji(this.config, this.pathElements, "customEmoji", { identifier: idCustomEmoji, }); }; Member.prototype.customStickers = function (idCustomSticker) { if (idCustomSticker === void 0) { idCustomSticker = ""; } return new Stickers_1.CustomSticker(this.config, this.pathElements, "customStickers", { identifier: idCustomSticker, }); }; Member.prototype.enterprises = function () { return new Enterprise_1.Enterprise(this.config, this.pathElements, "enterprises"); }; Member.prototype.notifications = function () { return new Notification_1.Notification(this.config, this.pathElements, "notifications"); }; Member.prototype.organizations = function () { return new Organization_1.Organization(this.config, this.pathElements, "organizations"); }; Member.prototype.organizationsInvited = function () { return new Organization_1.Organization(this.config, this.pathElements, "organizationsInvited"); }; Member.prototype.savedSearches = function (idSavedSearch) { if (idSavedSearch === void 0) { idSavedSearch = ""; } return new SavedSearch_1.SavedSearch(this.config, this.pathElements, "savedSearches", { identifier: idSavedSearch, }); }; Member.prototype.tokens = function () { return new Token_1.Token(this.config, this.pathElements, "tokens"); }; return Member; }(BaseResource_1.BaseResource)); exports.Member = Member;