@pokash/n8n-nodes-optima-rest-api 1.1.12 → 1.1.20
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.
|
@@ -156,6 +156,25 @@ class OptimaRestApi {
|
|
|
156
156
|
default: 100,
|
|
157
157
|
description: 'Maximum number of records to return (for pagination)',
|
|
158
158
|
},
|
|
159
|
+
{
|
|
160
|
+
displayName: 'Output Mode',
|
|
161
|
+
name: 'outputMode',
|
|
162
|
+
type: 'options',
|
|
163
|
+
options: [
|
|
164
|
+
{
|
|
165
|
+
name: 'Multiple Items (Split)',
|
|
166
|
+
value: 'split',
|
|
167
|
+
description: 'Return each customer as a separate item',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'Single Item (Array)',
|
|
171
|
+
value: 'array',
|
|
172
|
+
description: 'Return all customers in a single item as an array',
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
default: 'split',
|
|
176
|
+
description: 'How to return the results',
|
|
177
|
+
},
|
|
159
178
|
],
|
|
160
179
|
},
|
|
161
180
|
// Customer fields for create/update
|
|
@@ -218,6 +237,40 @@ class OptimaRestApi {
|
|
|
218
237
|
],
|
|
219
238
|
default: 'paymentMethods',
|
|
220
239
|
},
|
|
240
|
+
// Dictionary Options
|
|
241
|
+
{
|
|
242
|
+
displayName: 'Options',
|
|
243
|
+
name: 'options',
|
|
244
|
+
type: 'collection',
|
|
245
|
+
placeholder: 'Add Option',
|
|
246
|
+
default: {},
|
|
247
|
+
displayOptions: {
|
|
248
|
+
show: {
|
|
249
|
+
resource: ['dictionary'],
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
options: [
|
|
253
|
+
{
|
|
254
|
+
displayName: 'Output Mode',
|
|
255
|
+
name: 'outputMode',
|
|
256
|
+
type: 'options',
|
|
257
|
+
options: [
|
|
258
|
+
{
|
|
259
|
+
name: 'Single Item (Array)',
|
|
260
|
+
value: 'array',
|
|
261
|
+
description: 'Return all items in a single item as an array',
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'Multiple Items (Split)',
|
|
265
|
+
value: 'split',
|
|
266
|
+
description: 'Return each item as a separate item',
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
default: 'array',
|
|
270
|
+
description: 'How to return the results',
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
},
|
|
221
274
|
// Document Operations
|
|
222
275
|
{
|
|
223
276
|
displayName: 'Operation',
|
|
@@ -319,6 +372,41 @@ class OptimaRestApi {
|
|
|
319
372
|
default: 0,
|
|
320
373
|
description: 'The ID of the product',
|
|
321
374
|
},
|
|
375
|
+
// Product Options
|
|
376
|
+
{
|
|
377
|
+
displayName: 'Options',
|
|
378
|
+
name: 'options',
|
|
379
|
+
type: 'collection',
|
|
380
|
+
placeholder: 'Add Option',
|
|
381
|
+
default: {},
|
|
382
|
+
displayOptions: {
|
|
383
|
+
show: {
|
|
384
|
+
resource: ['product'],
|
|
385
|
+
operation: ['getAll'],
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
options: [
|
|
389
|
+
{
|
|
390
|
+
displayName: 'Output Mode',
|
|
391
|
+
name: 'outputMode',
|
|
392
|
+
type: 'options',
|
|
393
|
+
options: [
|
|
394
|
+
{
|
|
395
|
+
name: 'Multiple Items (Split)',
|
|
396
|
+
value: 'split',
|
|
397
|
+
description: 'Return each product as a separate item',
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: 'Single Item (Array)',
|
|
401
|
+
value: 'array',
|
|
402
|
+
description: 'Return all products in a single item as an array',
|
|
403
|
+
},
|
|
404
|
+
],
|
|
405
|
+
default: 'split',
|
|
406
|
+
description: 'How to return the results',
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
},
|
|
322
410
|
// Print Operations
|
|
323
411
|
{
|
|
324
412
|
displayName: 'Operation',
|
|
@@ -431,26 +519,40 @@ class OptimaRestApi {
|
|
|
431
519
|
// Extract customers array from response
|
|
432
520
|
if (responseData.Customers && Array.isArray(responseData.Customers)) {
|
|
433
521
|
const customers = responseData.Customers;
|
|
434
|
-
|
|
435
|
-
if (
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
});
|
|
445
|
-
});
|
|
522
|
+
const outputMode = options.outputMode || 'split';
|
|
523
|
+
if (outputMode === 'array') {
|
|
524
|
+
// Return entire response as single item
|
|
525
|
+
const result = {
|
|
526
|
+
json: responseData
|
|
527
|
+
};
|
|
528
|
+
if (items[i].binary) {
|
|
529
|
+
result.binary = items[i].binary;
|
|
530
|
+
}
|
|
531
|
+
returnData.push(result);
|
|
446
532
|
}
|
|
447
533
|
else {
|
|
448
|
-
//
|
|
449
|
-
|
|
534
|
+
// Split mode - return each customer as separate item
|
|
535
|
+
if (items[i].binary) {
|
|
536
|
+
// First item gets binary
|
|
450
537
|
returnData.push({
|
|
451
|
-
json:
|
|
538
|
+
json: customers[0] || {},
|
|
539
|
+
binary: items[i].binary
|
|
452
540
|
});
|
|
453
|
-
|
|
541
|
+
// Remaining items without binary
|
|
542
|
+
customers.slice(1).forEach((item) => {
|
|
543
|
+
returnData.push({
|
|
544
|
+
json: item
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
// No binary - just add all customers normally
|
|
550
|
+
customers.forEach((item) => {
|
|
551
|
+
returnData.push({
|
|
552
|
+
json: item
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
}
|
|
454
556
|
}
|
|
455
557
|
}
|
|
456
558
|
else if (responseData.Customers) {
|
|
@@ -557,6 +659,7 @@ class OptimaRestApi {
|
|
|
557
659
|
}
|
|
558
660
|
}
|
|
559
661
|
else if (resource === 'dictionary') {
|
|
662
|
+
const options = this.getNodeParameter('options', i, {});
|
|
560
663
|
// Dictionary operations - map operation names to API endpoints
|
|
561
664
|
const dictionaryEndpoints = {
|
|
562
665
|
paymentMethods: { endpoint: 'Dictionary/PaymentMethods', dataKey: 'PaymentMethods' },
|
|
@@ -577,29 +680,43 @@ class OptimaRestApi {
|
|
|
577
680
|
});
|
|
578
681
|
// API returns { Success: true, [DataKey]: [...], TotalCount: ... }
|
|
579
682
|
const responseData = response;
|
|
683
|
+
const outputMode = options.outputMode || 'array';
|
|
580
684
|
// Extract dictionary array from response
|
|
581
685
|
if (responseData[dictConfig.dataKey] && Array.isArray(responseData[dictConfig.dataKey])) {
|
|
582
686
|
const dictItems = responseData[dictConfig.dataKey];
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
json:
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
json: item
|
|
593
|
-
});
|
|
594
|
-
});
|
|
687
|
+
if (outputMode === 'array') {
|
|
688
|
+
// Return entire response as single item
|
|
689
|
+
const result = {
|
|
690
|
+
json: responseData
|
|
691
|
+
};
|
|
692
|
+
if (items[i].binary) {
|
|
693
|
+
result.binary = items[i].binary;
|
|
694
|
+
}
|
|
695
|
+
returnData.push(result);
|
|
595
696
|
}
|
|
596
697
|
else {
|
|
597
|
-
//
|
|
598
|
-
|
|
698
|
+
// Split mode - return each item separately
|
|
699
|
+
if (items[i].binary) {
|
|
700
|
+
// First item gets binary
|
|
599
701
|
returnData.push({
|
|
600
|
-
json:
|
|
702
|
+
json: dictItems[0] || {},
|
|
703
|
+
binary: items[i].binary
|
|
601
704
|
});
|
|
602
|
-
|
|
705
|
+
// Remaining items without binary
|
|
706
|
+
dictItems.slice(1).forEach((item) => {
|
|
707
|
+
returnData.push({
|
|
708
|
+
json: item
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
// No binary - just add all items normally
|
|
714
|
+
dictItems.forEach((item) => {
|
|
715
|
+
returnData.push({
|
|
716
|
+
json: item
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
}
|
|
603
720
|
}
|
|
604
721
|
}
|
|
605
722
|
else {
|
|
@@ -634,6 +751,7 @@ class OptimaRestApi {
|
|
|
634
751
|
returnData.push(result);
|
|
635
752
|
}
|
|
636
753
|
else if (operation === 'getAll') {
|
|
754
|
+
const options = this.getNodeParameter('options', i, {});
|
|
637
755
|
const response = await this.helpers.request({
|
|
638
756
|
method: 'GET',
|
|
639
757
|
url: `${gatewayUrl}/api/product`,
|
|
@@ -643,26 +761,40 @@ class OptimaRestApi {
|
|
|
643
761
|
json: true,
|
|
644
762
|
});
|
|
645
763
|
const products = response;
|
|
646
|
-
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
});
|
|
657
|
-
});
|
|
764
|
+
const outputMode = options.outputMode || 'split';
|
|
765
|
+
if (outputMode === 'array') {
|
|
766
|
+
// Return all products as array in single item
|
|
767
|
+
const result = {
|
|
768
|
+
json: { Products: products, TotalCount: products.length }
|
|
769
|
+
};
|
|
770
|
+
if (items[i].binary) {
|
|
771
|
+
result.binary = items[i].binary;
|
|
772
|
+
}
|
|
773
|
+
returnData.push(result);
|
|
658
774
|
}
|
|
659
775
|
else {
|
|
660
|
-
//
|
|
661
|
-
|
|
776
|
+
// Split mode - return each product as separate item
|
|
777
|
+
if (items[i].binary) {
|
|
778
|
+
// First item gets binary
|
|
662
779
|
returnData.push({
|
|
663
|
-
json:
|
|
780
|
+
json: products[0] || {},
|
|
781
|
+
binary: items[i].binary
|
|
664
782
|
});
|
|
665
|
-
|
|
783
|
+
// Remaining items without binary
|
|
784
|
+
products.slice(1).forEach((item) => {
|
|
785
|
+
returnData.push({
|
|
786
|
+
json: item
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
// No binary - just add all products normally
|
|
792
|
+
products.forEach((item) => {
|
|
793
|
+
returnData.push({
|
|
794
|
+
json: item
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
}
|
|
666
798
|
}
|
|
667
799
|
}
|
|
668
800
|
}
|