typings/lib2/messagev2/messagePayload/cardMessage.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Card = exports.CardMessage = exports.CardLayout = void 0;
const internal_1 = require("../internal");
/**
 * Represents the layout of a card.
 */
var CardLayout;
(function (CardLayout) {
    CardLayout["horizontal"] = "horizontal";
    CardLayout["vertical"] = "vertical";
})(CardLayout = exports.CardLayout || (exports.CardLayout = {}));
/**
 * Represents a card message.
 * @extends NonRawMessage
 */
class CardMessage extends internal_1.NonRawMessage {
    /**
     * Creates a new card message.
     * @param {Card[]} cards The cards of the message.
     * @returns {CardMessage} A new instance of the CardMessage.
     */
    constructor(cards) {
        super();
        this.type = 'card';
        this.layout = CardLayout.horizontal;
        this.cards = [];
        if (cards) {
            this.cards = cards;
        }
    }
    /**
     * Deserialize nested object properties into corresponding class instances
     */
    deserializeNestedProperties() {
        super.deserializeNestedProperties();
        if (this.cards) {
            this.cards = internal_1.MessageUtil.deserializeCards(this.cards);
        }
    }
    /**
     * Gets the layout of the card message.
     * @returns {CardLayout} The layout of the card message.
     */
    getLayout() {
        return this.layout;
    }
    /**
     * Sets the layout of the card message.
     * @param {CardLayout} layout The layout of the card message.
     * @returns {CardMessage} This card message instance.
     */
    setLayout(layout) {
        this.layout = layout;
        return this;
    }
    /**
     * Gets the list of cards in the card message.
     * @returns {Card[]} The list of cards in the card message.
     */
    getCards() {
        return this.cards;
    }
    /**
     * Sets the cards of the card message.
     * @param {Card[]} cards The cards of the card message.
     * @returns {CardMessage} This card message instance.
     */
    setCards(cards) {
        this.cards = cards;
        return this;
    }
    /**
     * Adds a card to the card message.
     * @param {Card} card The card to add.
     * @returns {CardMessage} This card message instance.
     */
    addCard(card) {
        this.cards.push(card);
        return this;
    }
}
exports.CardMessage = CardMessage;
/**
 * Represents a card.
 * @extends ChannelCustomizable
 */
class Card extends internal_1.ChannelCustomizable {
    /**
     * Constructs a Card object with the specified title.
     * @param {string} title The title of the card (required).
     */
    constructor(title) {
        super();
        this.title = title;
    }
    /**
     * Deserialize nested object properties into corresponding class instances
     */
    deserializeNestedProperties() {
        super.deserializeNestedProperties();
        if (this.voice) {
            this.voice = internal_1.MessageUtil.deserializeVoice(this.voice);
        }
        if (this.actions) {
            this.actions = internal_1.MessageUtil.deserializeActions(this.actions);
        }
    }
    /**
     * Gets the ID of the card.
     * @returns {string} The ID of the card.
     */
    getId() {
        return this.id;
    }
    /**
     * Sets the ID of the card.
     * @param {string} id The ID of the card.
     * @returns {Card} This Card instance.
     */
    setId(id) {
        this.id = id;
        return this;
    }
    /**
     * Gets the title of the card.
     * @returns {string} The title of the card.
     */
    getTitle() {
        return this.title;
    }
    /**
     * Sets the title of the card.
     * @param {string} title The title of the card.
     * @returns {Card} This Card instance.
     */
    setTitle(title) {
        this.title = title;
        return this;
    }
    /**
     * Gets the description of the card.
     * @returns {string} The description of the card.
     */
    getDescription() {
        return this.description;
    }
    /**
     * Sets the description of the card.
     * @param {string} description The description of the card.
     * @returns {Card} This Card instance.
     */
    setDescription(description) {
        this.description = description;
        return this;
    }
    /**
     * Gets the voice settings of the card.
     * @returns {Voice} the voice settings of the card.
     */
    getVoice() {
        return this.voice;
    }
    /**
     * Sets the voice settings of the card.
     * @param {Voice} voice the voice settings of the card.
     * @returns {Card} This Card instance.
     */
    setVoice(voice) {
        this.voice = voice;
        return this;
    }
    /**
     * Gets the image URL of the card.
     * @returns {string} The image URL of the card.
     */
    getImageUrl() {
        return this.imageUrl;
    }
    /**
     * Sets the image URL of the card.
     * @param {string} imageUrl The image URL of the card.
     * @returns {Card} This Card instance.
     */
    setImageUrl(imageUrl) {
        this.imageUrl = imageUrl;
        return this;
    }
    /**
     * Gets the URL of the card.
     * @returns {string} The URL of the card.
     */
    getUrl() {
        return this.url;
    }
    /**
     * Sets the URL of the card.
     * @param {string} url The URL of the card.
     * @returns {Card} This Card instance.
     */
    setUrl(url) {
        this.url = url;
        return this;
    }
    /**
     * Gets the actions of the card.
     * @returns {Action[]} The actions of the card.
     */
    getActions() {
        return this.actions;
    }
    /**
     * Adds an action to the card.
     * @param {Action} action The action to add.
     * @returns {Card} This Card instance.
     */
    addAction(action) {
        if (!this.actions) {
            this.actions = [];
        }
        this.actions.push(action);
        return this;
    }
}
exports.Card = Card;