UNPKG

zcatalyst-integ-cliq

Version:

Node.js SDK for integrating Zoho Catalyst with Zoho Cliq

24 lines (23 loc) 819 B
import { STATUS_CODES } from 'http'; import { CatalystError } from '../../error.js'; export default class IntegResponse { constructor() { this.contentType = 'text/plain'; this.status = 200; } buildResponse() { const response = {}; if (this.status === undefined || typeof this.status !== 'number' || STATUS_CODES[this.status] === undefined) { throw new CatalystError('Invalid status: ' + this.status); } if (this.contentType === undefined) { throw new CatalystError('content-Type is undefined'); } response.responseBody = JSON.stringify({ output: this.responseBody || '' }); response.contentType = this.contentType; response.status = this.status; return response; } }