zcatalyst-integ-cliq
Version:
Node.js SDK for integrating Zoho Catalyst with Zoho Cliq
36 lines (35 loc) • 1.29 kB
JavaScript
import { Handler } from '../../handler.js';
import CONSTANTS from '../../constants.js';
import HandlerResponse from '../response-objects/handler-response.js';
import { sendRequest } from '../../util.js';
import { CatalystError } from '../../error.js';
const { MESSAGEACTION } = CONSTANTS;
const { messageaction_handler } = CONSTANTS.HANDLERS;
/**
* @deprecated
* - This file name had been misspelled.
* - Exports from this file are deprecated.
* - This file will also be removed in future.
*
* Use **message-action-handler.ts** instead.
*/
export default class MessageActionHandler {
constructor() {
this.util = {
async getAttachedFile(attachments) {
const files = await Promise.all(attachments.map((attachment) => {
return sendRequest(attachment.url, 'GET');
})).catch((err) => {
throw new CatalystError('Error when getting the attached file', 0, err);
});
return files.map((file) => file.buffer);
}
};
}
executionHandler(handler) {
Handler.registerHandler(MESSAGEACTION, messageaction_handler.EXECUTION_HANDLER, handler, HandlerResponse);
}
newHandlerResponse() {
return new HandlerResponse();
}
}