UNPKG

@donation-alerts/events

Version:
78 lines (77 loc) 2.45 kB
import { __decorate } from "tslib"; import { DataObject, rawDataSymbol, ReadDocumentation } from '@donation-alerts/common'; import { Memoize } from 'typescript-memoize'; import { DonationAlertsPollOption, } from "./donation-alerts-poll-option.mjs"; /** * 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 DataObject { /** * The unique identifier of the poll. */ get id() { return this[rawDataSymbol].id; } /** * Indicates whether the poll is currently active. * * @returns `true` if the poll is active, otherwise `false`. */ get isActive() { return this[rawDataSymbol].is_active === 1; } /** * The title of the poll. */ get title() { return this[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[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[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[rawDataSymbol].options.map(option => new 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()), }; } }; __decorate([ Memoize() ], DonationAlertsPollUpdateEvent.prototype, "options", null); DonationAlertsPollUpdateEvent = __decorate([ ReadDocumentation('events') ], DonationAlertsPollUpdateEvent); export { DonationAlertsPollUpdateEvent };