cecon-interfaces
Version:
Interfaces de Projetos Cecon
69 lines (68 loc) • 2.27 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.N8nChatResponseEntity = void 0;
var N8nChatResponseEntity = /** @class */ (function () {
// #endregion Properties (12)
// #region Constructors (1)
function N8nChatResponseEntity(data) {
// #region Properties (12)
this.responseId = '';
this.originalMessageId = '';
this.sessionId = '';
this.userId = '';
this.message = '';
this.messageType = 'text';
this.timestamp = new Date();
this.platform = '';
this.responseData = undefined;
this.delivery = {
priority: 'normal',
};
this.metadata = undefined;
this.status = 'queued';
if (data) {
for (var key in data) {
if (data.hasOwnProperty(key) && key in this) {
this[key] = data[key];
}
}
}
}
// #endregion Constructors (1)
/**
* Adiciona um botão com callback de API opcional
*/
N8nChatResponseEntity.prototype.addButton = function (button) {
if (!this.responseData) {
this.responseData = {};
}
if (!this.responseData.buttons) {
this.responseData.buttons = [];
}
this.responseData.buttons.push(button);
this.messageType = 'button';
};
/**
* Adiciona uma resposta rápida com callback de API opcional
*/
N8nChatResponseEntity.prototype.addQuickReply = function (quickReply) {
if (!this.responseData) {
this.responseData = {};
}
if (!this.responseData.quickReplies) {
this.responseData.quickReplies = [];
}
this.responseData.quickReplies.push(quickReply);
this.messageType = 'quick_reply';
};
/**
* Valida se a resposta está pronta para ser enviada
*/
N8nChatResponseEntity.prototype.isValid = function () {
var hasBasicData = !!(this.responseId && this.userId && this.sessionId);
var hasContent = !!(this.message || this.responseData);
return hasBasicData && hasContent;
};
return N8nChatResponseEntity;
}());
exports.N8nChatResponseEntity = N8nChatResponseEntity;