typings/lib2/messagev2/messagePayload/nonRawMessage.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NonRawMessage = void 0;
const internal_1 = require("../internal");
/**
 * Base class for all non-raw message types
 */
class NonRawMessage extends internal_1.ChannelCustomizable {
    /**
     * Convert the message to JSON object
     * @returns {object} The message in JSON format
     */
    toJson() {
        return JSON.parse(JSON.stringify(this));
    }
    /**
     * Deserialize nested object properties into corresponding class instances
     */
    deserializeNestedProperties() {
        super.deserializeNestedProperties();
        if (this.actions) {
            this.actions = internal_1.MessageUtil.deserializeActions(this.actions);
        }
        if (this.globalActions) {
            this.globalActions = internal_1.MessageUtil.deserializeActions(this.globalActions);
        }
        if (this.keywords) {
            this.keywords = internal_1.MessageUtil.deserializeKeywords(this.keywords);
        }
        if (this.voice) {
            this.voice = internal_1.MessageUtil.deserializeVoice(this.voice);
        }
        if (this.footerForm) {
            this.footerForm = internal_1.MessageUtil.deserializeReadOnlyForm(this.footerForm);
        }
    }
    /**
     * Get the actions associated with the non-raw message.
     * @returns {Action[]} The array of actions.
     */
    getActions() {
        return this.actions;
    }
    /**
     * Set the actions for the non-raw message.
     * @param {Action[]} actions - The array of actions to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setActions(actions) {
        this.actions = actions;
        return this;
    }
    /**
     * Add an action to the non-raw message.
     * @param {Action} action - The action to add.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    addAction(action) {
        if (!this.actions) {
            this.actions = [];
        }
        this.actions.push(action);
        return this;
    }
    /**
     * Get the global actions associated with the non-raw message.
     * @returns {Action[]} The array of global actions.
     */
    getGlobalActions() {
        return this.globalActions;
    }
    /**
     * Set the global actions for the non-raw message.
     * @param {Action[]} globalActions - The array of global actions to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setGlobalActions(globalActions) {
        this.globalActions = globalActions;
        return this;
    }
    /**
     * Add a global action to the non-raw message.
     * @param {Action} action - The global action to add.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    addGlobalAction(action) {
        if (!this.globalActions) {
            this.globalActions = [];
        }
        this.globalActions.push(action);
        return this;
    }
    /**
     * Get the keywords associated with the non-raw message.
     * @returns {Keyword[]} The array of keywords.
     */
    getKeywords() {
        return this.keywords;
    }
    /**
     * Set the keywords for the non-raw message.
     * @param {Keyword[]} keywords - The array of keywords to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setKeywords(keywords) {
        this.keywords = keywords;
        return this;
    }
    /**
     * Add a keyword to the non-raw message.
     * @param {Keyword} keyword - The keyword to add.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    addKeyword(keyword) {
        if (!this.keywords) {
            this.keywords = [];
        }
        this.keywords.push(keyword);
        return this;
    }
    /**
     * Get the voice associated with the non-raw message.
     * @returns {Voice} The voice settings.
     */
    getVoice() {
        return this.voice;
    }
    /**
     * Set the voice settings for the non-raw message.
     * @param {Voice} voice - The voice settings to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setVoice(voice) {
        this.voice = voice;
        return this;
    }
    /**
     * Get the footer text of the non-raw message.
     * @returns {string} The footer text.
     */
    getFooterText() {
        return this.footerText;
    }
    /**
     * Set the footer text for the non-raw message.
     * @param {string} footerText - The footer text to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setFooterText(footerText) {
        this.footerText = footerText;
        return this;
    }
    /**
     * Get the footer form associated with the non-raw message.
     * @returns {ReadOnlyForm} The form
     */
    getFooterForm() {
        return this.footerForm;
    }
    /**
     * Set the footer form for the non-raw message.
     * @param {ReadOnlyForm} footerForm - The form to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setFooterForm(footerForm) {
        this.footerForm = footerForm;
        return this;
    }
    /**
     * Get the header text of the non-raw message.
     * @returns {string} The header text.
     */
    getHeaderText() {
        return this.headerText;
    }
    /**
     * Set the header text for the non-raw message.
     * @param {string} headerText - The header text to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setHeaderText(headerText) {
        this.headerText = headerText;
        return this;
    }
    /**
     * Gets the properties of the message.
     * @returns {Map<string, any>} The properties of the message.
     */
    getProperties() {
        return this.properties;
    }
    /**
     * Gets the value of a property.
     * @param {string} propertyName The name of the property.
     * @returns {any} The property value.
     */
    getPropertyValue(propertyName) {
        return this.properties ? this.properties[propertyName] : undefined;
    }
    /**
     * Sets the properties of the message.
     * @param {Map<string, any>} properties The properties to set.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    setProperties(properties) {
        this.properties = properties;
        return this;
    }
    /**
     * Add a property to the message.
     * @param {string} name The name of the property.
     * @param {any} value The value of the property.
     * @returns {this} The current instance of the NonRawMessage class.
     */
    addProperty(name, value) {
        if (!this.properties) {
            this.properties = new Map();
        }
        this.properties[name] = value;
        return this;
    }
}
exports.NonRawMessage = NonRawMessage;