UNPKG

@donation-alerts/events

Version:
81 lines (80 loc) 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DonationAlertsPollUpdateEvent = void 0; const tslib_1 = require("tslib"); const common_1 = require("@donation-alerts/common"); const typescript_memoize_1 = require("typescript-memoize"); const donation_alerts_poll_option_1 = require("./donation-alerts-poll-option"); /** * Represents an updated poll object from Donation Alerts. * * @remarks * This class provides access to key properties of a poll, including its options * and configuration details. It also indicates whether the poll is active or not. */ let DonationAlertsPollUpdateEvent = class DonationAlertsPollUpdateEvent extends common_1.DataObject { /** * The unique identifier of the poll. */ get id() { return this[common_1.rawDataSymbol].id; } /** * Indicates whether the poll is currently active. * * @returns `true` if the poll is active, otherwise `false`. */ get isActive() { return this[common_1.rawDataSymbol].is_active === 1; } /** * The title of the poll. */ get title() { return this[common_1.rawDataSymbol].title; } /** * Indicates whether donors are allowed to add custom options to the poll. * * @returns `true` if custom options are allowed, otherwise `false`. */ get allowUserOptions() { return this[common_1.rawDataSymbol].allow_user_options === 1; } /** * The type of the poll, determining how the winner is calculated. * * @remarks * - `count`: The option with the most donations wins. * - `sum`: The option with the highest total donation sum wins. */ get type() { return this[common_1.rawDataSymbol].type; } /** * The list of available options for the poll. * * @remarks * Each option is represented as an instance of {@link DonationAlertsPollOption}. */ get options() { return this[common_1.rawDataSymbol].options.map(option => new donation_alerts_poll_option_1.DonationAlertsPollOption(option)); } toJSON() { return { id: this.id, isActive: this.isActive, title: this.title, allowUserOptions: this.allowUserOptions, type: this.type, options: this.options.map(option => option.toJSON()), }; } }; exports.DonationAlertsPollUpdateEvent = DonationAlertsPollUpdateEvent; tslib_1.__decorate([ (0, typescript_memoize_1.Memoize)() ], DonationAlertsPollUpdateEvent.prototype, "options", null); exports.DonationAlertsPollUpdateEvent = DonationAlertsPollUpdateEvent = tslib_1.__decorate([ (0, common_1.ReadDocumentation)('events') ], DonationAlertsPollUpdateEvent);