UNPKG

node-groupme

Version:

The only GroupMe API library that isn't a million years old.

65 lines 2.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const __1 = require(".."); class Poll extends __1.Base { constructor(client, group, creator, data) { super(client, data.data.id); this.question = data.data.subject; this.group = group; this.creator = creator; this._active = data.data.status == 'active'; this.multi = data.data.type == 'multi'; this.public = data.data.visibility == 'public'; this.createdAt = data.data.created_at; this.updatedAt = data.data.last_modified; this.expiresAt = data.data.expiration; this.options = new __1.Collection(); data.data.options.forEach(option => { this.options.set(option.id, new __1.PollOption(this, option)); }); this.voters = this.public ? this.multi ? new __1.Collection() : new __1.Collection() : undefined; this.myVote = this.multi ? data.user_votes : data.user_vote; } _patch(data) { if (data.data?.subject !== undefined) this.question = data.data.subject; if (data.data?.status !== undefined) this._active = data.data.status == 'active'; if (data.data?.type !== undefined) this.multi = data.data.type == 'multi'; if (data.data?.visibility !== undefined) this.public = data.data.visibility == 'public'; if (data.data?.created_at !== undefined) this.createdAt = data.data.created_at; if (data.data?.last_modified !== undefined) this.updatedAt = data.data.last_modified; if (data.data?.expiration !== undefined) this.expiresAt = data.data.expiration; this.myVote = this.multi ? data.user_votes : data.user_vote; return this; } vote(options) { throw new Error('Method not implemented.'); } fetch() { throw new Error('Method not implemented.'); } end() { throw new Error('Method not implemented.'); } get canEnd() { throw new Error('Method not implemented.'); } get active() { throw new Error('Method not implemented.'); if (this._active /* && (this.expiresAt has passed) */) this._active = false; return this._active; } } exports.default = Poll; //# sourceMappingURL=Poll.js.map