UNPKG

@donation-alerts/events

Version:
67 lines (66 loc) 2.06 kB
import { __decorate } from "tslib"; import { DataObject, rawDataSymbol, ReadDocumentation } from '@donation-alerts/common'; /** * Represents an option in a Donation Alerts poll event. * * @remarks * This class provides structured access to the properties of a single poll option * and helps identify important metrics, such as the total value and its relative percentage. */ let DonationAlertsPollOption = class DonationAlertsPollOption extends DataObject { /** * The unique identifier of the poll option. */ get id() { return this[rawDataSymbol].id; } /** * The title of the poll option. */ get title() { return this[rawDataSymbol].title; } /** * The absolute value associated with this poll option. * * @remarks * Depending on the poll's type, the `amountValue` represents either the total number of donations * or the total sum of donations for this option. */ get amountValue() { return this[rawDataSymbol].amount_value; } /** * The relative percentage of this poll option compared to others. * * @remarks * This percentage reflects the option's share of the total amount across all poll options. */ get amountPercent() { return this[rawDataSymbol].amount_percent; } /** * Indicates whether this poll option is a winner. * * @remarks * A poll can have multiple winners if more than one option shares the maximum `amountValue`. * * @returns `true` if the poll option is a winner, otherwise `false`. */ get isWinner() { return this[rawDataSymbol].is_winner === 1; } toJSON() { return { id: this.id, title: this.title, amountValue: this.amountValue, amountPercent: this.amountPercent, isWinner: this.isWinner, }; } }; DonationAlertsPollOption = __decorate([ ReadDocumentation('events') ], DonationAlertsPollOption); export { DonationAlertsPollOption };