@pokash/n8n-nodes-optima-rest-api 1.2.1 → 1.3.0

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.
@@ -491,7 +491,7 @@ class OptimaRestApi {
491
491
  displayName: 'SQL Filter',
492
492
  name: 'filtrSQL',
493
493
  type: 'string',
494
- required: true,
494
+ required: false,
495
495
  displayOptions: {
496
496
  show: {
497
497
  resource: ['print'],
@@ -500,7 +500,7 @@ class OptimaRestApi {
500
500
  },
501
501
  default: '',
502
502
  placeholder: 'TrN_TrnId = 123',
503
- description: 'SQL filter to select documents',
503
+ description: 'SQL filter to select documents (e.g. "TrN_TrNID = 123" or "EDN_EDNId = 1002")',
504
504
  },
505
505
  // Print Format ID
506
506
  {
@@ -517,6 +517,46 @@ class OptimaRestApi {
517
517
  default: 1,
518
518
  description: 'ID of the print format from Optima',
519
519
  },
520
+ // Print Dynamic Parameters
521
+ {
522
+ displayName: 'Dynamic Parameters',
523
+ name: 'dynamicParameters',
524
+ type: 'fixedCollection',
525
+ typeOptions: {
526
+ multipleValues: true,
527
+ },
528
+ displayOptions: {
529
+ show: {
530
+ resource: ['print'],
531
+ operation: ['printDocument'],
532
+ },
533
+ },
534
+ default: {},
535
+ placeholder: 'Add Parameter',
536
+ description: 'Dynamic parameters passed to the print template',
537
+ options: [
538
+ {
539
+ name: 'parameter',
540
+ displayName: 'Parameter',
541
+ values: [
542
+ {
543
+ displayName: 'Name',
544
+ name: 'name',
545
+ type: 'string',
546
+ default: '',
547
+ description: 'Parameter name as defined in the print template',
548
+ },
549
+ {
550
+ displayName: 'Value',
551
+ name: 'value',
552
+ type: 'string',
553
+ default: '',
554
+ description: 'Parameter value',
555
+ },
556
+ ],
557
+ },
558
+ ],
559
+ },
520
560
  ],
521
561
  };
522
562
  }
@@ -934,12 +974,23 @@ class OptimaRestApi {
934
974
  }
935
975
  else if (resource === 'print') {
936
976
  if (operation === 'printDocument') {
937
- const filtrSQL = this.getNodeParameter('filtrSQL', i);
977
+ const filtrSQL = this.getNodeParameter('filtrSQL', i, '');
938
978
  const formatId = this.getNodeParameter('formatId', i);
979
+ const dynamicParamsRaw = this.getNodeParameter('dynamicParameters', i, {});
939
980
  const requestBody = {
940
981
  FormatId: formatId,
941
- FiltrSQL: filtrSQL,
942
982
  };
983
+ if (filtrSQL) {
984
+ requestBody.FiltrSQL = filtrSQL;
985
+ }
986
+ if (dynamicParamsRaw.parameter) {
987
+ const params = dynamicParamsRaw.parameter;
988
+ const dynamicParameters = {};
989
+ for (const p of params) {
990
+ dynamicParameters[p.name] = p.value;
991
+ }
992
+ requestBody.DynamicParameters = dynamicParameters;
993
+ }
943
994
  const response = await makeAuthenticatedRequest({
944
995
  method: 'POST',
945
996
  url: `${gatewayUrl}/api/Documents/Print`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokash/n8n-nodes-optima-rest-api",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "n8n node for Comarch Optima REST API integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",