@pokash/n8n-nodes-optima-rest-api 1.1.11 → 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,19 +519,41 @@ 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
|
-
}
|
|
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);
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
// Split mode - return each customer as separate item
|
|
535
|
+
if (items[i].binary) {
|
|
536
|
+
// First item gets binary
|
|
537
|
+
returnData.push({
|
|
538
|
+
json: customers[0] || {},
|
|
539
|
+
binary: items[i].binary
|
|
540
|
+
});
|
|
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
|
+
}
|
|
440
556
|
}
|
|
441
|
-
// Then add customer items (without binary to avoid duplication)
|
|
442
|
-
customers.forEach((item) => {
|
|
443
|
-
returnData.push({
|
|
444
|
-
json: item
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
557
|
}
|
|
448
558
|
else if (responseData.Customers) {
|
|
449
559
|
// Single customer - preserve binary
|
|
@@ -549,6 +659,7 @@ class OptimaRestApi {
|
|
|
549
659
|
}
|
|
550
660
|
}
|
|
551
661
|
else if (resource === 'dictionary') {
|
|
662
|
+
const options = this.getNodeParameter('options', i, {});
|
|
552
663
|
// Dictionary operations - map operation names to API endpoints
|
|
553
664
|
const dictionaryEndpoints = {
|
|
554
665
|
paymentMethods: { endpoint: 'Dictionary/PaymentMethods', dataKey: 'PaymentMethods' },
|
|
@@ -569,22 +680,44 @@ class OptimaRestApi {
|
|
|
569
680
|
});
|
|
570
681
|
// API returns { Success: true, [DataKey]: [...], TotalCount: ... }
|
|
571
682
|
const responseData = response;
|
|
683
|
+
const outputMode = options.outputMode || 'array';
|
|
572
684
|
// Extract dictionary array from response
|
|
573
685
|
if (responseData[dictConfig.dataKey] && Array.isArray(responseData[dictConfig.dataKey])) {
|
|
574
686
|
const dictItems = responseData[dictConfig.dataKey];
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
json:
|
|
579
|
-
|
|
580
|
-
|
|
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);
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
// Split mode - return each item separately
|
|
699
|
+
if (items[i].binary) {
|
|
700
|
+
// First item gets binary
|
|
701
|
+
returnData.push({
|
|
702
|
+
json: dictItems[0] || {},
|
|
703
|
+
binary: items[i].binary
|
|
704
|
+
});
|
|
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
|
+
}
|
|
581
720
|
}
|
|
582
|
-
// Then add dictionary items (without binary to avoid duplication)
|
|
583
|
-
dictItems.forEach((item) => {
|
|
584
|
-
returnData.push({
|
|
585
|
-
json: item
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
721
|
}
|
|
589
722
|
else {
|
|
590
723
|
// Fallback - return entire response if structure is unexpected
|
|
@@ -618,6 +751,7 @@ class OptimaRestApi {
|
|
|
618
751
|
returnData.push(result);
|
|
619
752
|
}
|
|
620
753
|
else if (operation === 'getAll') {
|
|
754
|
+
const options = this.getNodeParameter('options', i, {});
|
|
621
755
|
const response = await this.helpers.request({
|
|
622
756
|
method: 'GET',
|
|
623
757
|
url: `${gatewayUrl}/api/product`,
|
|
@@ -627,19 +761,41 @@ class OptimaRestApi {
|
|
|
627
761
|
json: true,
|
|
628
762
|
});
|
|
629
763
|
const products = response;
|
|
630
|
-
|
|
631
|
-
if (
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}
|
|
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);
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
// Split mode - return each product as separate item
|
|
777
|
+
if (items[i].binary) {
|
|
778
|
+
// First item gets binary
|
|
779
|
+
returnData.push({
|
|
780
|
+
json: products[0] || {},
|
|
781
|
+
binary: items[i].binary
|
|
782
|
+
});
|
|
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
|
+
}
|
|
636
798
|
}
|
|
637
|
-
// Then add product items (without binary to avoid duplication)
|
|
638
|
-
products.forEach((item) => {
|
|
639
|
-
returnData.push({
|
|
640
|
-
json: item
|
|
641
|
-
});
|
|
642
|
-
});
|
|
643
799
|
}
|
|
644
800
|
}
|
|
645
801
|
else if (resource === 'print') {
|