@pokash/n8n-nodes-optima-rest-api 1.0.6 → 1.1.1

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: ['get', 'update', 'delete'],
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,49 @@ 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 customerId = this.getNodeParameter('customerId', i);
309
- const response = await this.helpers.request({
310
- method: 'GET',
311
- url: `${gatewayUrl}/api/customer?id=${customerId}`,
312
- headers: {
313
- Authorization: `Bearer ${token}`,
314
- },
315
- json: true,
316
- });
317
- returnData.push({ json: response });
318
- }
319
- else if (operation === 'getAll') {
352
+ if (operation === 'get' || operation === 'getAll') {
353
+ const options = this.getNodeParameter('options', i, {});
354
+ // Build query parameters (use PascalCase to match C# API)
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: `${gatewayUrl}/api/customer`,
374
+ url,
323
375
  headers: {
324
376
  Authorization: `Bearer ${token}`,
325
377
  },
326
378
  json: true,
327
379
  });
328
- const items = response.map(item => ({ json: item }));
329
- returnData.push(...items);
380
+ // API returns { Success: true, Customers: [...], TotalCount: ... }
381
+ const responseData = response;
382
+ // Extract customers array from response
383
+ if (responseData.Customers && Array.isArray(responseData.Customers)) {
384
+ const items = responseData.Customers.map(item => ({ json: item }));
385
+ returnData.push(...items);
386
+ }
387
+ else if (responseData.Customers) {
388
+ // Single customer
389
+ returnData.push({ json: responseData.Customers });
390
+ }
391
+ else {
392
+ // Fallback - return entire response if structure is unexpected
393
+ returnData.push({ json: responseData });
394
+ }
330
395
  }
331
396
  else if (operation === 'create') {
332
397
  const customerData = JSON.parse(this.getNodeParameter('customerData', i));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokash/n8n-nodes-optima-rest-api",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "n8n node for Comarch Optima REST API integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",