@poli-digital/n8n-nodes-poli
Version:
Nó para interagir com a API da Poli
66 lines • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateTag = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const transport_1 = require("./transport");
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 ID',
name: 'accountId',
type: 'string',
default: '',
required: true,
},
{
displayName: 'Tag Name',
name: 'tagName',
type: 'string',
default: '',
required: true,
},
],
};
}
async execute() {
const items = this.getInputData();
const returnData = [];
for (let i = 0; i < items.length; i++) {
try {
const accountId = this.getNodeParameter('accountId', i);
const tagName = this.getNodeParameter('tagName', i);
const body = {
name: tagName,
};
const endpoint = `/accounts/${accountId}/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.CreateTag = CreateTag;
//# sourceMappingURL=CreateTag.operation.js.map