UNPKG

zcatalyst-integ-cliq

Version:

Node.js SDK for integrating Zoho Catalyst with Zoho Cliq

28 lines (27 loc) 1.09 kB
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; 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(); } }