UNPKG

n8n-nodes-placid

Version:

n8n node to interact with Placid API for creative generation

51 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.execute = execute; const n8n_workflow_1 = require("n8n-workflow"); const config_1 = require("../../utils/config"); async function execute(index) { try { const title = this.getNodeParameter('title', index); const width = this.getNodeParameter('width', index); const height = this.getNodeParameter('height', index); const additionalFields = this.getNodeParameter('additionalFields', index, {}); const body = { title, width, height, }; if (additionalFields.tags) { body.tags = additionalFields.tags.split(',').map(tag => tag.trim()); } if (additionalFields.custom_data) { body.custom_data = additionalFields.custom_data; } if (additionalFields.from_template) { body.from_template = additionalFields.from_template; } if (additionalFields.add_to_collections) { body.add_to_collections = additionalFields.add_to_collections.split(',').map(id => id.trim()); } const options = { method: 'POST', url: config_1.PlacidConfig.getRestUrl(config_1.PlacidConfig.ENDPOINTS.TEMPLATES), headers: { 'Accept': config_1.PlacidConfig.HTTP.HEADERS.ACCEPT, 'Content-Type': config_1.PlacidConfig.HTTP.HEADERS.CONTENT_TYPE, 'x-placid-integration': config_1.PlacidConfig.HTTP.HEADERS.PLACID_INTEGRATION, }, body, }; const response = await this.helpers.httpRequestWithAuthentication.call(this, 'placidApi', options); return { json: response, pairedItem: { item: index }, }; } catch (error) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to create template: ${error.message}`, { itemIndex: index, }); } } //# sourceMappingURL=create.operation.js.map