@pokash/n8n-nodes-optima-rest-api 1.0.6 → 1.1.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.
Potentially problematic release.
This version of @pokash/n8n-nodes-optima-rest-api might be problematic. Click here for more details.
|
@@ -103,12 +103,57 @@ class OptimaRestApi {
|
|
|
103
103
|
displayOptions: {
|
|
104
104
|
show: {
|
|
105
105
|
resource: ['customer'],
|
|
106
|
-
operation: ['
|
|
106
|
+
operation: ['update', 'delete'],
|
|
107
107
|
},
|
|
108
108
|
},
|
|
109
109
|
default: 0,
|
|
110
110
|
description: 'The ID of the customer',
|
|
111
111
|
},
|
|
112
|
+
// Customer Get/GetAll - Filter options
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Options',
|
|
115
|
+
name: 'options',
|
|
116
|
+
type: 'collection',
|
|
117
|
+
placeholder: 'Add Option',
|
|
118
|
+
default: {},
|
|
119
|
+
displayOptions: {
|
|
120
|
+
show: {
|
|
121
|
+
resource: ['customer'],
|
|
122
|
+
operation: ['get', 'getAll'],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
options: [
|
|
126
|
+
{
|
|
127
|
+
displayName: 'Customer ID',
|
|
128
|
+
name: 'id',
|
|
129
|
+
type: 'number',
|
|
130
|
+
default: 0,
|
|
131
|
+
description: 'Specific customer ID to retrieve',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Filter',
|
|
135
|
+
name: 'filter',
|
|
136
|
+
type: 'string',
|
|
137
|
+
default: '',
|
|
138
|
+
placeholder: 'Knt_Kod = \'TEST\'',
|
|
139
|
+
description: 'SQL-like filter string for searching customers (e.g., Knt_Kod = \'ACME\' or Knt_Nip = \'1234567890\')',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
displayName: 'Skip',
|
|
143
|
+
name: 'skip',
|
|
144
|
+
type: 'number',
|
|
145
|
+
default: 0,
|
|
146
|
+
description: 'Number of records to skip (for pagination)',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
displayName: 'Take',
|
|
150
|
+
name: 'take',
|
|
151
|
+
type: 'number',
|
|
152
|
+
default: 100,
|
|
153
|
+
description: 'Maximum number of records to return (for pagination)',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
112
157
|
// Customer fields for create/update
|
|
113
158
|
{
|
|
114
159
|
displayName: 'Customer Data',
|
|
@@ -304,29 +349,42 @@ class OptimaRestApi {
|
|
|
304
349
|
for (let i = 0; i < items.length; i++) {
|
|
305
350
|
try {
|
|
306
351
|
if (resource === 'customer') {
|
|
307
|
-
if (operation === 'get') {
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
352
|
+
if (operation === 'get' || operation === 'getAll') {
|
|
353
|
+
const options = this.getNodeParameter('options', i, {});
|
|
354
|
+
// Build query parameters
|
|
355
|
+
const queryParams = new URLSearchParams();
|
|
356
|
+
if (options.id) {
|
|
357
|
+
queryParams.append('id', String(options.id));
|
|
358
|
+
}
|
|
359
|
+
if (options.filter) {
|
|
360
|
+
queryParams.append('filter', String(options.filter));
|
|
361
|
+
}
|
|
362
|
+
if (options.skip) {
|
|
363
|
+
queryParams.append('skip', String(options.skip));
|
|
364
|
+
}
|
|
365
|
+
if (options.take) {
|
|
366
|
+
queryParams.append('take', String(options.take));
|
|
367
|
+
}
|
|
368
|
+
const queryString = queryParams.toString();
|
|
369
|
+
const url = queryString
|
|
370
|
+
? `${gatewayUrl}/api/customer?${queryString}`
|
|
371
|
+
: `${gatewayUrl}/api/customer`;
|
|
320
372
|
const response = await this.helpers.request({
|
|
321
373
|
method: 'GET',
|
|
322
|
-
url
|
|
374
|
+
url,
|
|
323
375
|
headers: {
|
|
324
376
|
Authorization: `Bearer ${token}`,
|
|
325
377
|
},
|
|
326
378
|
json: true,
|
|
327
379
|
});
|
|
328
|
-
|
|
329
|
-
|
|
380
|
+
// Handle both single customer and array of customers
|
|
381
|
+
if (Array.isArray(response)) {
|
|
382
|
+
const items = response.map(item => ({ json: item }));
|
|
383
|
+
returnData.push(...items);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
returnData.push({ json: response });
|
|
387
|
+
}
|
|
330
388
|
}
|
|
331
389
|
else if (operation === 'create') {
|
|
332
390
|
const customerData = JSON.parse(this.getNodeParameter('customerData', i));
|