UNPKG

@donation-alerts/events

Version:
103 lines (102 loc) 3.06 kB
import { __decorate } from "tslib"; import { DataObject, rawDataSymbol, ReadDocumentation, } from '@donation-alerts/common'; import { mapNullable } from '@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 DataObject { /** * The unique identifier for the donation goal. */ get id() { return this[rawDataSymbol].id; } /** * Indicates whether the donation goal is currently active. * * @returns `true` if the goal is active, otherwise `false`. */ get isActive() { return this[rawDataSymbol].is_active === 1; } /** * The title or name of the donation goal. */ get title() { return this[rawDataSymbol].title; } /** * The currency in which the goal is measured. * * @remarks * The currency code formatted as per ISO 4217 standard */ get currency() { return this[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[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[rawDataSymbol].raised_amount; } /** * The target or goal amount for the donation. */ get goalAmount() { return this[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[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 mapNullable(this[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, }; } }; DonationAlertsGoalUpdateEvent = __decorate([ ReadDocumentation('events') ], DonationAlertsGoalUpdateEvent); export { DonationAlertsGoalUpdateEvent };