@donation-alerts/api
Version:
Interact with Donation Alerts API.
87 lines (86 loc) • 2.71 kB
JavaScript
import { __decorate } from "tslib";
import { DataObject, rawDataSymbol, ReadDocumentation } from '@donation-alerts/common';
import { mapNullable } from '@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 DataObject {
/**
* The unique custom alert identifier.
*/
get id() {
return this[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[rawDataSymbol].external_id;
}
/**
* The header text of the custom alert, or `null` if no header was set.
*/
get header() {
return this[rawDataSymbol].header;
}
/**
* The message text of the custom alert, or `null` if no message was set.
*/
get message() {
return this[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[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[rawDataSymbol].sound_url;
}
/**
* Indicates whether the alert has been shown in the streamer's widget.
*/
get isShown() {
return this[rawDataSymbol].is_shown === 1;
}
/**
* The date and time when the custom alert was created.
*/
get creationDate() {
return new Date(this[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 mapNullable(this[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,
};
}
};
DonationAlertsCustomAlert = __decorate([
ReadDocumentation('api')
], DonationAlertsCustomAlert);
export { DonationAlertsCustomAlert };