@pokash/n8n-nodes-optima-rest-api 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @pokash/n8n-nodes-optima-rest-api might be problematic. Click here for more details.
|
@@ -246,25 +246,12 @@ class OptimaRestApi {
|
|
|
246
246
|
],
|
|
247
247
|
default: 'printDocument',
|
|
248
248
|
},
|
|
249
|
-
// Print Document ID
|
|
250
|
-
{
|
|
251
|
-
displayName: 'Document ID',
|
|
252
|
-
name: 'documentId',
|
|
253
|
-
type: 'number',
|
|
254
|
-
displayOptions: {
|
|
255
|
-
show: {
|
|
256
|
-
resource: ['print'],
|
|
257
|
-
operation: ['printDocument'],
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
default: 0,
|
|
261
|
-
description: 'ID of the document to print (optional if using SQL filter)',
|
|
262
|
-
},
|
|
263
249
|
// Print SQL Filter
|
|
264
250
|
{
|
|
265
251
|
displayName: 'SQL Filter',
|
|
266
252
|
name: 'filtrSQL',
|
|
267
253
|
type: 'string',
|
|
254
|
+
required: true,
|
|
268
255
|
displayOptions: {
|
|
269
256
|
show: {
|
|
270
257
|
resource: ['print'],
|
|
@@ -273,7 +260,7 @@ class OptimaRestApi {
|
|
|
273
260
|
},
|
|
274
261
|
default: '',
|
|
275
262
|
placeholder: 'TrN_TrnId = 123',
|
|
276
|
-
description: 'SQL filter to select documents
|
|
263
|
+
description: 'SQL filter to select documents',
|
|
277
264
|
},
|
|
278
265
|
// Print Format ID
|
|
279
266
|
{
|
|
@@ -425,18 +412,12 @@ class OptimaRestApi {
|
|
|
425
412
|
}
|
|
426
413
|
else if (resource === 'print') {
|
|
427
414
|
if (operation === 'printDocument') {
|
|
428
|
-
const
|
|
429
|
-
const filtrSQL = this.getNodeParameter('filtrSQL', i, '');
|
|
415
|
+
const filtrSQL = this.getNodeParameter('filtrSQL', i);
|
|
430
416
|
const formatId = this.getNodeParameter('formatId', i);
|
|
431
417
|
const requestBody = {
|
|
432
|
-
formatId,
|
|
418
|
+
FormatId: formatId,
|
|
419
|
+
FiltrSQL: filtrSQL,
|
|
433
420
|
};
|
|
434
|
-
if (documentId) {
|
|
435
|
-
requestBody.documentId = documentId;
|
|
436
|
-
}
|
|
437
|
-
if (filtrSQL) {
|
|
438
|
-
requestBody.filtrSQL = filtrSQL;
|
|
439
|
-
}
|
|
440
421
|
const response = await this.helpers.request({
|
|
441
422
|
method: 'POST',
|
|
442
423
|
url: `${gatewayUrl}/api/Documents/Print`,
|
|
@@ -444,13 +425,20 @@ class OptimaRestApi {
|
|
|
444
425
|
Authorization: `Bearer ${token}`,
|
|
445
426
|
},
|
|
446
427
|
body: requestBody,
|
|
447
|
-
json:
|
|
448
|
-
encoding: null, // Get binary data
|
|
428
|
+
json: false,
|
|
429
|
+
encoding: null, // Get binary data (PDF file)
|
|
449
430
|
});
|
|
450
|
-
//
|
|
431
|
+
// API returns PDF file directly as binary
|
|
432
|
+
const buffer = Buffer.isBuffer(response)
|
|
433
|
+
? response
|
|
434
|
+
: Buffer.from(response);
|
|
451
435
|
returnData.push({
|
|
452
436
|
success: true,
|
|
453
|
-
|
|
437
|
+
binary: {
|
|
438
|
+
data: buffer,
|
|
439
|
+
mimeType: 'application/pdf',
|
|
440
|
+
fileName: `document_${Date.now()}.pdf`,
|
|
441
|
+
},
|
|
454
442
|
});
|
|
455
443
|
}
|
|
456
444
|
}
|