UNPKG

@poli-digital/n8n-nodes-poli

Version:
133 lines 4.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChannelResource = exports.channelDescription = void 0; const base_1 = require("./base"); exports.channelDescription = { displayName: 'Channel', name: 'channel', value: 'channel', operations: [ { displayName: 'Create', name: 'operation', value: 'createChannel', description: 'Create a new channel', action: 'Create a channel', }, { displayName: 'List', name: 'operation', value: 'listChannels', description: 'Get list of channels', action: 'Get list of channels', }, ], properties: [ { displayName: 'Operation', name: 'operation', type: 'options', displayOptions: { show: { resource: ['channel'] } }, options: [ { name: 'Create', value: 'createChannel', }, { name: 'List', value: 'listChannels', }, ], default: 'createChannel', description: 'The operation to perform', }, { displayName: 'Application ID', name: 'applicationId', type: 'string', required: true, displayOptions: { show: { resource: ['channel'], operation: ['createChannel', 'listChannels'], }, }, default: '', description: 'The ID of the application', }, { displayName: 'Channel Name', name: 'channelName', type: 'string', required: true, displayOptions: { show: { resource: ['channel'], operation: ['createChannel'], }, }, default: '', description: 'The name of the channel', }, { displayName: 'Channel Type', name: 'channelType', type: 'options', required: true, displayOptions: { show: { resource: ['channel'], operation: ['createChannel'], }, }, options: [ { name: 'WhatsApp', value: 'whatsapp', }, { name: 'Webchat', value: 'webchat', }, { name: 'Instagram', value: 'instagram', }, ], default: 'whatsapp', description: 'The type of channel', }, { displayName: 'Channel Configuration', name: 'config', type: 'json', required: true, displayOptions: { show: { resource: ['channel'], operation: ['createChannel'], }, }, default: '{}', description: 'The channel configuration in JSON format', }, ], }; class ChannelResource extends base_1.BaseResource { static async create(executeFunctions, index) { const body = { applicationId: executeFunctions.getNodeParameter('applicationId', index), name: executeFunctions.getNodeParameter('channelName', index), type: executeFunctions.getNodeParameter('channelType', index), config: executeFunctions.getNodeParameter('config', index), }; return await this.makeRequest(executeFunctions, 'POST', '/channels', body, index); } static async list(executeFunctions, index) { const applicationId = executeFunctions.getNodeParameter('applicationId', index); const response = await this.makeRequest(executeFunctions, 'GET', `/applications/${applicationId}/channels`, {}, index); return response.channels || []; } } exports.ChannelResource = ChannelResource; //# sourceMappingURL=channel.js.map