UNPKG

@donation-alerts/api

Version:
90 lines (89 loc) 2.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DonationAlertsCustomAlert = void 0; const tslib_1 = require("tslib"); const common_1 = require("@donation-alerts/common"); const shared_utils_1 = require("@stimulcross/shared-utils"); /** * Represents a Donation Alerts custom alert object. * * @remarks * A custom alert is a user-defined alert, which can include custom headers, messages, images, and sounds. * These alerts are shown in the streamer's widget when triggered. */ let DonationAlertsCustomAlert = class DonationAlertsCustomAlert extends common_1.DataObject { /** * The unique custom alert identifier. */ get id() { return this[common_1.rawDataSymbol].id; } /** * The developer-provided unique identifier for the alert, or `null` if none was set. * * @remarks * This value can be used to track or manage custom alerts within external systems. */ get externalId() { return this[common_1.rawDataSymbol].external_id; } /** * The header text of the custom alert, or `null` if no header was set. */ get header() { return this[common_1.rawDataSymbol].header; } /** * The message text of the custom alert, or `null` if no message was set. */ get message() { return this[common_1.rawDataSymbol].message; } /** * The URL of the image to be displayed with the custom alert, or `null` if no URL was set. */ get imageUrl() { return this[common_1.rawDataSymbol].image_url; } /** * The URL of the sound file to be played when the custom alert is shown, or `null` if no URL was set. */ get soundUrl() { return this[common_1.rawDataSymbol].sound_url; } /** * Indicates whether the alert has been shown in the streamer's widget. */ get isShown() { return this[common_1.rawDataSymbol].is_shown === 1; } /** * The date and time when the custom alert was created. */ get creationDate() { return new Date(this[common_1.rawDataSymbol].created_at); } /** * The date and time when the custom alert was shown, or `null` if the alert has not yet been shown. */ get showDate() { return (0, shared_utils_1.mapNullable)(this[common_1.rawDataSymbol].shown_at, (v) => new Date(v)); } toJSON() { return { id: this.id, externalId: this.externalId, header: this.header, message: this.message, imageUrl: this.imageUrl, soundUrl: this.soundUrl, isShown: this.isShown, creationDate: this.creationDate, showDate: this.showDate, }; } }; exports.DonationAlertsCustomAlert = DonationAlertsCustomAlert; exports.DonationAlertsCustomAlert = DonationAlertsCustomAlert = tslib_1.__decorate([ (0, common_1.ReadDocumentation)('api') ], DonationAlertsCustomAlert);