UNPKG

@poli-digital/n8n-nodes-poli

Version:
83 lines 3.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetAccountChannel = exports.executeGetAccountChannel = exports.getAccountChannelFields = void 0; const n8n_workflow_1 = require("n8n-workflow"); const transport_1 = require("./transport"); const parameterUtils_1 = require("./utils/parameterUtils"); const responseFilter_1 = require("./utils/responseFilter"); exports.getAccountChannelFields = [ { displayName: 'Account Channel UUID', name: 'accountChannelUuid', type: 'string', default: '', required: true, description: 'UUID do canal da conta', }, { displayName: 'Options', name: 'options', type: 'collection', placeholder: 'Add Option', default: {}, options: [ { displayName: 'Include', name: 'include', type: 'multiOptions', options: [ { name: 'Config', value: 'config' }, ], default: [], description: 'Campos adicionais para incluir na resposta', }, ], }, ]; async function executeGetAccountChannel() { var _a; const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { try { const accountChannelUuid = (0, parameterUtils_1.getParameterSafe)(this, 'accountChannelUuid', i, ''); const options = (0, parameterUtils_1.getParameterSafe)(this, 'options', i, {}); const params = new URLSearchParams(); if ((_a = options.include) === null || _a === void 0 ? void 0 : _a.length) { params.append('include', options.include.join(',')); } const queryString = params.toString(); const endpoint = `/account-channels/${accountChannelUuid}${queryString ? `?${queryString}` : ''}`; const responseData = await transport_1.apiRequest.call(this, 'GET', endpoint); const filteredData = (0, responseFilter_1.processApiResponseForN8n)(responseData, true); returnData.push({ json: filteredData }); } catch (error) { throw new n8n_workflow_1.NodeApiError(this.getNode(), error); } } return [returnData]; } exports.executeGetAccountChannel = executeGetAccountChannel; class GetAccountChannel { constructor() { this.description = { displayName: 'Get Account Channel', name: 'getAccountChannel', group: ['output'], version: 1, description: 'Get account channel from Poli API', defaults: { name: 'Get Account Channel', }, inputs: ['main'], outputs: ['main'], properties: exports.getAccountChannelFields, }; } async execute() { return executeGetAccountChannel.call(this); } } exports.GetAccountChannel = GetAccountChannel; //# sourceMappingURL=GetAccountChannel.operation.js.map