"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableMessage = void 0;
const internal_1 = require("../internal");
/**
* Represents a table message.
* @extends NonRawMessage
*/
class TableMessage extends internal_1.NonRawMessage {
/**
* Creates an instance of TableMessage.
* @param {TableHeading[]} headings The table headings.
* @param {Row[]} rows The table rows.
*/
constructor(headings, rows) {
super();
this.type = 'table';
this.headings = [];
this.rows = [];
if (headings) {
this.headings = headings;
}
if (rows) {
this.rows = rows;
}
}
/**
* Deserialize nested object properties into corresponding class instances
*/
deserializeNestedProperties() {
super.deserializeNestedProperties();
if (this.headings) {
this.headings = internal_1.MessageUtil.deserializeTableHeadings(this.headings);
}
if (this.rows) {
this.rows = internal_1.MessageUtil.deserializeRows(this.rows);
}
if (this.paginationInfo) {
this.paginationInfo = internal_1.MessageUtil.deserializePaginationInfo(this.paginationInfo);
}
}
/**
* Gets the table headings.
* @returns {TableHeading[]} The table headings.
*/
getHeadings() {
return this.headings;
}
/**
* Sets the table headings.
* @param {TableHeading[]} headings The table headings.
* @returns {TableMessage} The current instance of TableMessage.
*/
setHeadings(headings) {
this.headings = headings;
return this;
}
/**
* Adds a heading to the table.
* @param {TableHeading} heading The heading to add.
* @returns {TableMessage} The current instance of TableMessage.
*/
addHeading(heading) {
this.headings.push(heading);
return this;
}
/**
* Gets the table rows.
* @returns {Row[]} The table rows.
*/
getRows() {
return this.rows;
}
/**
* Sets the table rows.
* @param {Row[]} rows The table rows.
* @returns {TableMessage} The current instance of TableMessage.
*/
setRows(rows) {
this.rows = rows;
return this;
}
/**
* Adds a row to the table.
* @param {Row} row The row to add.
* @returns {TableMessage} The current instance of TableMessage.
*/
addRow(row) {
this.rows.push(row);
return this;
}
/**
* Gets the pagination information.
* @returns {PaginationInfo | undefined} The pagination information.
*/
getPaginationInfo() {
return this.paginationInfo;
}
/**
* Sets the pagination information.
* @param {PaginationInfo} paginationInfo The pagination information.
* @returns {TableMessage} The current instance of TableMessage.
*/
setPaginationInfo(paginationInfo) {
this.paginationInfo = paginationInfo;
return this;
}
}
exports.TableMessage = TableMessage;