UNPKG

@iotile/iotile-cloud

Version:

A typescript library for interfacing with the IOTile Cloud API

75 lines 2.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var member_1 = require("./member"); var Org = /** @class */ (function () { function Org(data) { if (data === void 0) { data = {}; } this.about = ''; this.members = []; this.memberMap = {}; this.pendingInvites = []; this.pendingInviteMap = {}; this.slug = data.slug; this.name = data.name; this.createdBy = data.created_by; this.createdOn = new Date(data.created_on); this.rawData = data; if (data.about) { this.about = data.about; } if (data.avatar) { this.thumbnailUrl = data.avatar.thumbnail; this.tinyUrl = data.avatar.tiny; } if (data.current_member) { this.currentMember = new member_1.Member(data.current_member); } if (data.counts) { this.counts = data.counts; } if (data.ot) { this.orgTemplate = data.ot; } } Org.prototype.toJson = function () { return this.rawData; }; Org.prototype.getPatchPayload = function () { var payload = { name: this.name }; if (this.about) { payload.about = this.about; } return payload; }; Org.prototype.addMembers = function (members) { var _this = this; this.members = members; this.memberMap = {}; this.members.forEach(function (m) { if (m.user) { _this.memberMap[m.user.email] = m; } }); }; Org.prototype.getMember = function (slug) { return this.memberMap[slug]; }; Org.prototype.addPendingInvites = function (pendingInvites) { var _this = this; this.pendingInvites = pendingInvites; this.pendingInviteMap = {}; this.pendingInvites.forEach(function (pv) { if (pv.email) { _this.pendingInviteMap[pv.email] = pv; } }); }; Org.prototype.getPendingInvite = function (email) { return this.pendingInviteMap[email]; }; return Org; }()); exports.Org = Org; //# sourceMappingURL=org.js.map