UNPKG

zcatalyst-integ-cliq

Version:

Node.js SDK for integrating Zoho Catalyst with Zoho Cliq

73 lines (72 loc) 3.34 kB
import CliqApiService from './cliq-api/cliq-api-service.js'; import { CliqConnector, ZCConnector } from './cliq-api/cliq-connector.js'; import BotHandler from './cliq-objects/handler-objects/bot-handler.js'; import CommandHandler from './cliq-objects/handler-objects/command-handler.js'; import FunctionHandler from './cliq-objects/handler-objects/function-handler.js'; import ExtensionHandler from './cliq-objects/handler-objects/extension-handler.js'; import LinkPreviewHandler from './cliq-objects/handler-objects/link-preview-handler.js'; import MessageActionHandler from './cliq-objects/handler-objects/message-action-handler.js'; import WidgetHandler from './cliq-objects/handler-objects/widget-handler.js'; import IntegResponse from './cliq-objects/response-objects/integ-response.js'; import { IIntegRequest } from './config.js'; export declare const IntegrationResponse: IntegResponse; export declare function bot(): BotHandler; export declare function command(): CommandHandler; export declare function CliqFunction(): FunctionHandler; export declare function extensionHandler(): ExtensionHandler; export declare function linkPreviewHandler(): LinkPreviewHandler; export declare function messageAction(): MessageActionHandler; export declare function widget(): WidgetHandler; export declare function connector(path: string, req: IIntegRequest): CliqConnector; export declare function cliqApiService(connector: ZCConnector): CliqApiService; /** * Executes the appropriate handler for the request * @param integRequest Integration request. The request object obtained inside the default export function in the entry point file * @param args Passthrough arguments that will be passed to the handlers during execution * @returns A promise that resolves to an Integration response * * @example * ```js * // executeHandler function. * import Cliq from 'zcatalyst-integ-cliq'; // import Cliq SDK * * // default export function * module.exports = async (request, response) => { * try { * // call the executeHandler function with Integration request object * const handlerResponse = await Cliq.execute(request); * * // end response with handlerResponse * response.end(handlerResponse); * } catch (err) { * console.log('Error while executing handler. ', err); * throw err; * } * }; * * ``` * * @example * ```js * // executeHandler function with Catalyst App (passthrough argument). * import Cliq from 'zcatalyst-integ-cliq'; // import Cliq SDK * import Catalyst from 'zcatalyst-sdk-node'; // import Catalyst SDK * * // default export function * module.exports = async (request, response) => { * const app = Catalyst.initialize(request); // initialize catalyst app with Integration Request * try { * // call the executeHandler function with Integration request object and Catalyst App object(passthrough) * const handlerResponse = await Cliq.execute(request, app); * * // end response with handlerResponse * response.end(handlerResponse); * } catch (err) { * console.log('Error while executing handler. ', err); * throw err; * } * }; * * ``` */ export declare function execute(integRequest: IIntegRequest, ...args: Array<unknown>): Promise<IntegResponse>;