UNPKG

@donation-alerts/events

Version:
106 lines (105 loc) 3.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DonationAlertsGoalUpdateEvent = void 0; const tslib_1 = require("tslib"); const common_1 = require("@donation-alerts/common"); const shared_utils_1 = require("@stimulcross/shared-utils"); /** * Represents a goal update event from Donation Alerts. * * @remarks * This object provides structured access to the properties of a donation goal, * including its current state, progress, and relevant timestamps. */ let DonationAlertsGoalUpdateEvent = class DonationAlertsGoalUpdateEvent extends common_1.DataObject { /** * The unique identifier for the donation goal. */ get id() { return this[common_1.rawDataSymbol].id; } /** * Indicates whether the donation goal is currently active. * * @returns `true` if the goal is active, otherwise `false`. */ get isActive() { return this[common_1.rawDataSymbol].is_active === 1; } /** * The title or name of the donation goal. */ get title() { return this[common_1.rawDataSymbol].title; } /** * The currency in which the goal is measured. * * @remarks * The currency code formatted as per ISO 4217 standard */ get currency() { return this[common_1.rawDataSymbol].currency; } /** * The starting amount of the donation goal. * * @remarks * This value represents the base amount from which the progress begins. */ get startAmount() { return this[common_1.rawDataSymbol].start_amount; } /** * The total amount raised so far, including the `startAmount`. * * @remarks * This value reflects the sum of all donations added to the starting amount. */ get raisedAmount() { return this[common_1.rawDataSymbol].raised_amount; } /** * The target or goal amount for the donation. */ get goalAmount() { return this[common_1.rawDataSymbol].goal_amount; } /** * The date and time when the donation goal was started. * * @returns A `Date` object representing the start time of the goal. */ get startDate() { return new Date(this[common_1.rawDataSymbol].started_at); } /** * The scheduled end date and time for the donation goal. * * @remarks * This value can be `null` if no expiry date is set for the goal. * * @returns A `Date` object representing the expiry date of the goal, * or `null` if the goal has no end date. */ get expiryDate() { return (0, shared_utils_1.mapNullable)(this[common_1.rawDataSymbol].expires_at, (v) => new Date(v)); } toJSON() { return { id: this.id, isActive: this.isActive, title: this.title, currency: this.currency, startAmount: this.startAmount, raisedAmount: this.raisedAmount, goalAmount: this.goalAmount, startDate: this.startDate, expiryDate: this.expiryDate, }; } }; exports.DonationAlertsGoalUpdateEvent = DonationAlertsGoalUpdateEvent; exports.DonationAlertsGoalUpdateEvent = DonationAlertsGoalUpdateEvent = tslib_1.__decorate([ (0, common_1.ReadDocumentation)('events') ], DonationAlertsGoalUpdateEvent);