UNPKG

@poli-digital/n8n-nodes-poli

Version:
89 lines 3.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreateTag = void 0; const n8n_workflow_1 = require("n8n-workflow"); const transport_1 = require("./transport"); const parameterUtils_1 = require("./utils/parameterUtils"); class CreateTag { constructor() { this.description = { displayName: 'Create Tag', name: 'createTag', icon: 'file:poli.svg', group: ['output'], version: 1, description: 'Create a new tag', defaults: { name: 'Create Tag', }, inputs: ['main'], outputs: ['main'], credentials: [ { name: 'poliApi', required: true, }, ], properties: [ { displayName: 'Account UUID', name: 'accountId', type: 'string', default: '', required: true, }, { displayName: 'Tag Name', name: 'tagName', type: 'string', default: '', required: true, }, { displayName: 'Description', name: 'description', type: 'string', default: '', required: true, }, { displayName: 'Color', name: 'color', type: 'string', default: '#f0f0f0', required: true, description: 'Color in hexadecimal format (e.g., #f0f0f0)', }, ], }; } async execute() { const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { try { const accountId = (0, parameterUtils_1.getParameterSafe)(this, 'accountId', i, '', true); const tagName = (0, parameterUtils_1.getParameterSafe)(this, 'tagName', i, ''); const description = (0, parameterUtils_1.getParameterSafe)(this, 'description', i, ''); const color = (0, parameterUtils_1.getParameterSafe)(this, 'color', i, '#f0f0f0'); const body = { status: 'ACTIVE', attributes: { name: tagName, description: description, color: color, }, }; const endpoint = `/accounts/${accountId}/tags?include=attributes`; const responseData = await transport_1.apiRequest.call(this, 'POST', endpoint, body); returnData.push({ json: responseData }); } catch (error) { throw new n8n_workflow_1.NodeApiError(this.getNode(), error); } } return [returnData]; } } exports.CreateTag = CreateTag; //# sourceMappingURL=CreateTag.operation.js.map