UNPKG

n8n-nodes-placid

Version:

n8n node to interact with Placid API for creative generation

48 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.execute = execute; const n8n_workflow_1 = require("n8n-workflow"); 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: 'https://api.placid.app/api/rest/templates', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body, }; const response = await this.helpers.httpRequestWithAuthentication.call(this, 'placidApi', options); return { json: response, }; } catch (error) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to create template: ${error.message}`, { itemIndex: index, }); } } //# sourceMappingURL=create.operation.js.map