@poli-digital/n8n-nodes-poli
Version:
Nó para interagir com a API da Poli
83 lines • 2.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetChannel = exports.executeGetChannel = exports.getChannelFields = 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.getChannelFields = [
{
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 executeGetChannel() {
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.executeGetChannel = executeGetChannel;
class GetChannel {
constructor() {
this.description = {
displayName: 'Get Channel',
name: 'getChannel',
group: ['output'],
version: 1,
description: 'Get channel from Poli API',
defaults: {
name: 'Get Channel',
},
inputs: ['main'],
outputs: ['main'],
properties: exports.getChannelFields,
};
}
async execute() {
return executeGetChannel.call(this);
}
}
exports.GetChannel = GetChannel;
//# sourceMappingURL=GetChannel.operation.js.map