UNPKG

n8n-nodes-thepdfmaker

Version:

n8n node for businesses looking to streamline document generation. Create professional invoices, reports, and more from your data sources.

95 lines 3.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ThePDFMakerGeneratePDF = void 0; const constants_1 = require("./constants"); class ThePDFMakerGeneratePDF { constructor() { this.description = { displayName: 'The PDF Maker Generate PDF', name: 'ThePDFMakerGeneratePDF', icon: 'file:thepdfmaker.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["templateActions"] + ": " + $parameter["resource"]}}', description: 'Generate PDF from data source', defaults: { name: 'The PDF Maker Generate PDF', }, inputs: ['main'], outputs: ['main'], credentials: [ { name: 'thePDFMakerGeneratePDFApi', required: true, }, ], requestDefaults: { baseURL: constants_1.BASE_URL, headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'x-api-key': '={{$credentials.apiKey}}', }, }, properties: [ { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, options: [ { name: 'Template', value: 'template', }, ], default: 'template', }, { displayName: 'Template Name or ID', name: 'templateId', type: 'options', description: 'Choose a template to generate a PDF. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.', required: true, noDataExpression: true, displayOptions: { show: { resource: ['template'], }, }, typeOptions: { loadOptionsMethod: 'getTemplates', }, routing: { request: { method: 'POST', url: '=/api/n8n/generate-pdf', body: { templateId: '={{$value}}', data: '={{$json}}', }, }, }, default: '', }, ], }; this.methods = { loadOptions: { async getTemplates() { const response = await this.helpers.httpRequestWithAuthentication.call(this, 'thePDFMakerGeneratePDFApi', { url: `${constants_1.BASE_URL}api/n8n/get-template-options`, method: 'GET', }); const templates = Array.isArray(response) ? response : response.data; return templates.map((template) => ({ name: template === null || template === void 0 ? void 0 : template.name, value: template === null || template === void 0 ? void 0 : template.value, })); }, }, }; } } exports.ThePDFMakerGeneratePDF = ThePDFMakerGeneratePDF; //# sourceMappingURL=ThePDFMakerGeneratePDF.node.js.map