UNPKG

@poli-digital/n8n-nodes-poli

Version:
69 lines 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AddTagToContact = void 0; const n8n_workflow_1 = require("n8n-workflow"); const transport_1 = require("./transport"); class AddTagToContact { constructor() { this.description = { displayName: 'Add Tag To Contact', name: 'addTagToContact', icon: 'file:poli.svg', group: ['output'], version: 1, description: 'Add a tag to a contact', defaults: { name: 'Add Tag To Contact', }, inputs: ['main'], outputs: ['main'], credentials: [ { name: 'poliApi', required: true, }, ], properties: [ { displayName: 'Contact ID', name: 'contactUuid', type: 'string', required: true, default: '', description: 'UUID of the contact to which the tag will be added', }, { displayName: 'Tag ID', name: 'tagUuid', type: 'string', required: true, default: '', description: 'UUID of the tag to be added to the contact', }, ], codex: { categories: ['Poli'], }, }; } async execute() { const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { try { const contactUuid = this.getNodeParameter('contactUuid', i); const tagUuid = this.getNodeParameter('tagUuid', i); const body = { tag_uuid: tagUuid }; const endpoint = `/contacts/${contactUuid}/tags`; 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.AddTagToContact = AddTagToContact; //# sourceMappingURL=AddTagToContact.operation.js.map