@donation-alerts/events
Version:
Listen to various Donation Alerts events.
70 lines (69 loc) • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DonationAlertsPollOption = void 0;
const tslib_1 = require("tslib");
const common_1 = require("@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 common_1.DataObject {
/**
* The unique identifier of the poll option.
*/
get id() {
return this[common_1.rawDataSymbol].id;
}
/**
* The title of the poll option.
*/
get title() {
return this[common_1.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[common_1.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[common_1.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[common_1.rawDataSymbol].is_winner === 1;
}
toJSON() {
return {
id: this.id,
title: this.title,
amountValue: this.amountValue,
amountPercent: this.amountPercent,
isWinner: this.isWinner,
};
}
};
exports.DonationAlertsPollOption = DonationAlertsPollOption;
exports.DonationAlertsPollOption = DonationAlertsPollOption = tslib_1.__decorate([
(0, common_1.ReadDocumentation)('events')
], DonationAlertsPollOption);