UNPKG

@poli-digital/n8n-nodes-poli

Version:
101 lines 3.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetTeam = exports.executeGetTeam = exports.getTeamFields = 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.getTeamFields = [ { displayName: 'Team UUID', name: 'teamUuid', type: 'string', required: true, default: '', description: 'UUID do time para obter informações', }, { displayName: 'Options', name: 'options', type: 'collection', placeholder: 'Add Option', default: {}, options: [ { displayName: 'Include', name: 'include', type: 'multiOptions', options: [ { name: 'Key', value: 'key' }, { name: 'Status', value: 'status' }, { name: 'Visibility', value: 'visibility' }, { name: 'Staging', value: 'staging' }, { name: 'Attributes', value: 'attributes' }, { name: 'Users', value: 'users' }, { name: 'Metadata', value: 'metadata' }, ], default: [], description: 'Dados adicionais para incluir na resposta', }, ], }, ]; async function executeGetTeam() { var _a; const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { try { const teamUuid = (0, parameterUtils_1.getParameterSafe)(this, 'teamUuid', i, ''); const options = (0, parameterUtils_1.getParameterSafe)(this, 'options', i, {}); if (!teamUuid) { throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Team UUID é obrigatório', }); } 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 = `/teams/${teamUuid}${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.executeGetTeam = executeGetTeam; class GetTeam { constructor() { this.description = { displayName: 'Get Team', name: 'getTeam', icon: 'file:poli.svg', group: ['output'], version: 1, description: 'Get specific team information from Poli API', defaults: { name: 'Get Team', }, inputs: ['main'], outputs: ['main'], credentials: [ { name: 'poliApi', required: true, }, ], properties: exports.getTeamFields, }; } async execute() { return executeGetTeam.call(this); } } exports.GetTeam = GetTeam; //# sourceMappingURL=GetTeam.operation.js.map