@pokash/n8n-nodes-optima-rest-api 1.0.3 → 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 (alternative to Document ID)',
263
+ description: 'SQL filter to select documents',
277
264
  },
278
265
  // Print Format ID
279
266
  {
@@ -321,7 +308,7 @@ class OptimaRestApi {
321
308
  const customerId = this.getNodeParameter('customerId', i);
322
309
  const response = await this.helpers.request({
323
310
  method: 'GET',
324
- url: `${gatewayUrl}/api/customer/${customerId}`,
311
+ url: `${gatewayUrl}/api/customer?id=${customerId}`,
325
312
  headers: {
326
313
  Authorization: `Bearer ${token}`,
327
314
  },
@@ -356,9 +343,11 @@ class OptimaRestApi {
356
343
  else if (operation === 'update') {
357
344
  const customerId = this.getNodeParameter('customerId', i);
358
345
  const customerData = JSON.parse(this.getNodeParameter('customerData', i));
346
+ // Add ID to the customer data for PUT request
347
+ customerData.ID = customerId;
359
348
  const response = await this.helpers.request({
360
349
  method: 'PUT',
361
- url: `${gatewayUrl}/api/customer/${customerId}`,
350
+ url: `${gatewayUrl}/api/customer`,
362
351
  headers: {
363
352
  Authorization: `Bearer ${token}`,
364
353
  },
@@ -401,7 +390,7 @@ class OptimaRestApi {
401
390
  const productId = this.getNodeParameter('productId', i);
402
391
  const response = await this.helpers.request({
403
392
  method: 'GET',
404
- url: `${gatewayUrl}/api/product/${productId}`,
393
+ url: `${gatewayUrl}/api/product?id=${productId}`,
405
394
  headers: {
406
395
  Authorization: `Bearer ${token}`,
407
396
  },
@@ -423,18 +412,12 @@ class OptimaRestApi {
423
412
  }
424
413
  else if (resource === 'print') {
425
414
  if (operation === 'printDocument') {
426
- const documentId = this.getNodeParameter('documentId', i, null);
427
- const filtrSQL = this.getNodeParameter('filtrSQL', i, '');
415
+ const filtrSQL = this.getNodeParameter('filtrSQL', i);
428
416
  const formatId = this.getNodeParameter('formatId', i);
429
417
  const requestBody = {
430
- formatId,
418
+ FormatId: formatId,
419
+ FiltrSQL: filtrSQL,
431
420
  };
432
- if (documentId) {
433
- requestBody.documentId = documentId;
434
- }
435
- if (filtrSQL) {
436
- requestBody.filtrSQL = filtrSQL;
437
- }
438
421
  const response = await this.helpers.request({
439
422
  method: 'POST',
440
423
  url: `${gatewayUrl}/api/Documents/Print`,
@@ -442,13 +425,20 @@ class OptimaRestApi {
442
425
  Authorization: `Bearer ${token}`,
443
426
  },
444
427
  body: requestBody,
445
- json: true,
446
- encoding: null, // Get binary data
428
+ json: false,
429
+ encoding: null, // Get binary data (PDF file)
447
430
  });
448
- // Return PDF as binary data
431
+ // API returns PDF file directly as binary
432
+ const buffer = Buffer.isBuffer(response)
433
+ ? response
434
+ : Buffer.from(response);
449
435
  returnData.push({
450
436
  success: true,
451
- pdf: Buffer.from(response).toString('base64'),
437
+ binary: {
438
+ data: buffer,
439
+ mimeType: 'application/pdf',
440
+ fileName: `document_${Date.now()}.pdf`,
441
+ },
452
442
  });
453
443
  }
454
444
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokash/n8n-nodes-optima-rest-api",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "n8n node for Comarch Optima REST API integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",