n8n-nodes-synca 1.0.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.
- package/dist/credentials/SyncaApi.credentials.d.ts +9 -0
- package/dist/credentials/SyncaApi.credentials.js +51 -0
- package/dist/credentials/SyncaApi.credentials.js.map +1 -0
- package/dist/nodes/Cashcow/SyncaCashcow.node.d.ts +10 -0
- package/dist/nodes/Cashcow/SyncaCashcow.node.js +185 -0
- package/dist/nodes/Cashcow/SyncaCashcow.node.js.map +1 -0
- package/dist/nodes/Cashcow/constants/cashcow-check-order-tracking.constant.d.ts +30 -0
- package/dist/nodes/Cashcow/constants/cashcow-check-order-tracking.constant.js +37 -0
- package/dist/nodes/Cashcow/constants/cashcow-check-order-tracking.constant.js.map +1 -0
- package/dist/nodes/Cashcow/constants/cashcow-create-or-update-product.constant.d.ts +117 -0
- package/dist/nodes/Cashcow/constants/cashcow-create-or-update-product.constant.js +290 -0
- package/dist/nodes/Cashcow/constants/cashcow-create-or-update-product.constant.js.map +1 -0
- package/dist/nodes/Cashcow/constants/cashcow-create-order.constant.d.ts +189 -0
- package/dist/nodes/Cashcow/constants/cashcow-create-order.constant.js +420 -0
- package/dist/nodes/Cashcow/constants/cashcow-create-order.constant.js.map +1 -0
- package/dist/nodes/Cashcow/constants/cashcow-get-store-mailbox.constant.d.ts +46 -0
- package/dist/nodes/Cashcow/constants/cashcow-get-store-mailbox.constant.js +166 -0
- package/dist/nodes/Cashcow/constants/cashcow-get-store-mailbox.constant.js.map +1 -0
- package/dist/nodes/Cashcow/icon copy 2.svg +53 -0
- package/dist/nodes/Cashcow/icon copy.svg +65 -0
- package/dist/nodes/Cashcow/icon.svg +1 -0
- package/dist/nodes/Cashcow/last-icon.svg +38 -0
- package/dist/nodes/Mirakl/SyncaMirakl.node.d.ts +0 -0
- package/dist/nodes/Mirakl/SyncaMirakl.node.js +2 -0
- package/dist/nodes/Mirakl/SyncaMirakl.node.js.map +1 -0
- package/dist/nodes/OLD_SyncaPriority.node.d.ts +10 -0
- package/dist/nodes/OLD_SyncaPriority.node.js +389 -0
- package/dist/nodes/OLD_SyncaPriority.node.js.map +1 -0
- package/dist/nodes/Priority/SyncaPriority.node.d.ts +18 -0
- package/dist/nodes/Priority/SyncaPriority.node.js +313 -0
- package/dist/nodes/Priority/SyncaPriority.node.js.map +1 -0
- package/dist/nodes/Priority/constants/methods.d.ts +15 -0
- package/dist/nodes/Priority/constants/methods.js +299 -0
- package/dist/nodes/Priority/constants/methods.js.map +1 -0
- package/dist/nodes/Priority/constants/priority-agents.constant.d.ts +39 -0
- package/dist/nodes/Priority/constants/priority-agents.constant.js +114 -0
- package/dist/nodes/Priority/constants/priority-agents.constant.js.map +1 -0
- package/dist/nodes/Priority/constants/priority-generic.constant.d.ts +158 -0
- package/dist/nodes/Priority/constants/priority-generic.constant.js +219 -0
- package/dist/nodes/Priority/constants/priority-generic.constant.js.map +1 -0
- package/dist/nodes/Priority/constants/priority-procedure.constant.d.ts +129 -0
- package/dist/nodes/Priority/constants/priority-procedure.constant.js +178 -0
- package/dist/nodes/Priority/constants/priority-procedure.constant.js.map +1 -0
- package/dist/nodes/Priority/constants/priority-products.constant.d.ts +158 -0
- package/dist/nodes/Priority/constants/priority-products.constant.js +209 -0
- package/dist/nodes/Priority/constants/priority-products.constant.js.map +1 -0
- package/dist/nodes/Priority/constants/priority-purchase-orders.constant.d.ts +158 -0
- package/dist/nodes/Priority/constants/priority-purchase-orders.constant.js +218 -0
- package/dist/nodes/Priority/constants/priority-purchase-orders.constant.js.map +1 -0
- package/dist/nodes/Priority/constants/priority-sales.constant.d.ts +158 -0
- package/dist/nodes/Priority/constants/priority-sales.constant.js +383 -0
- package/dist/nodes/Priority/constants/priority-sales.constant.js.map +1 -0
- package/dist/nodes/Priority/icon.png +0 -0
- package/dist/nodes/Priority/icon.svg +1 -0
- package/dist/nodes/Superpharm/SyncaSuperpharm.node.d.ts +10 -0
- package/dist/nodes/Superpharm/SyncaSuperpharm.node.js +1072 -0
- package/dist/nodes/Superpharm/SyncaSuperpharm.node.js.map +1 -0
- package/dist/nodes/Superpharm/icon.svg +1 -0
- package/dist/nodes/Superpharm/old-icon.svg +22 -0
- package/dist/package.json +55 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,1072 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncaSuperpharm = void 0;
|
|
4
|
+
function addResourceSpecificParams(requestParams, resource, operation, itemIndex, getNodeParameter) {
|
|
5
|
+
const idFields = ['order_id', 'offer_id', 'return_id', 'tracking_id', 'thread_id'];
|
|
6
|
+
for (const field of idFields) {
|
|
7
|
+
try {
|
|
8
|
+
const value = getNodeParameter(field, itemIndex, '');
|
|
9
|
+
if (value) {
|
|
10
|
+
requestParams[field] = value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const dataFields = [
|
|
17
|
+
'order_lines', 'cancelations', 'refunds', 'shipments', 'offers', 'orders', 'data'
|
|
18
|
+
];
|
|
19
|
+
for (const field of dataFields) {
|
|
20
|
+
try {
|
|
21
|
+
const value = getNodeParameter(field, itemIndex, null);
|
|
22
|
+
if (value !== null && value !== undefined) {
|
|
23
|
+
if (typeof value === 'string' && value.trim() !== '' && value !== '{}' && value !== '[]') {
|
|
24
|
+
try {
|
|
25
|
+
requestParams[field] = JSON.parse(value);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
requestParams[field] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (typeof value === 'object') {
|
|
32
|
+
requestParams[field] = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function makeRequestWithRetry(options, maxRetries, httpRequest, logger) {
|
|
41
|
+
var _a;
|
|
42
|
+
let attempt = 0;
|
|
43
|
+
while (attempt <= maxRetries) {
|
|
44
|
+
try {
|
|
45
|
+
return await httpRequest(options);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 429 && attempt < maxRetries) {
|
|
49
|
+
const retryAfter = error.response.headers['retry-after'];
|
|
50
|
+
const waitTime = retryAfter ? parseInt(retryAfter) * 1000 : Math.pow(2, attempt) * 1000;
|
|
51
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(`Rate limited, retrying in ${waitTime}ms`, { attempt });
|
|
52
|
+
await new Promise(resolve => setTimeout(resolve, waitTime));
|
|
53
|
+
attempt++;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function processResponseData(responseData, resource, operation) {
|
|
62
|
+
if (responseData === null || responseData === undefined) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
if (responseData.data && Array.isArray(responseData.data)) {
|
|
66
|
+
return responseData.data;
|
|
67
|
+
}
|
|
68
|
+
const listProperties = [
|
|
69
|
+
'orders', 'offers', 'products', 'items', 'threads', 'messages',
|
|
70
|
+
'shipments', 'promotions', 'returns', 'incidents', 'results'
|
|
71
|
+
];
|
|
72
|
+
for (const prop of listProperties) {
|
|
73
|
+
if (responseData[prop] && Array.isArray(responseData[prop])) {
|
|
74
|
+
return responseData[prop];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(responseData)) {
|
|
78
|
+
return responseData;
|
|
79
|
+
}
|
|
80
|
+
return responseData;
|
|
81
|
+
}
|
|
82
|
+
function isListOperation(operation) {
|
|
83
|
+
const listOperations = [
|
|
84
|
+
'get_orders', 'get_offers', 'get_products', 'get_inbox_threads',
|
|
85
|
+
'get_promotions', 'get_returns', 'get_incidents', 'get_shipping_types'
|
|
86
|
+
];
|
|
87
|
+
return listOperations.includes(operation);
|
|
88
|
+
}
|
|
89
|
+
class SyncaSuperpharm {
|
|
90
|
+
constructor() {
|
|
91
|
+
this.description = {
|
|
92
|
+
usableAsTool: true,
|
|
93
|
+
displayName: 'Synca Superpharm',
|
|
94
|
+
name: 'customSyncaSuperpharm',
|
|
95
|
+
icon: { light: 'file:icon.svg', dark: 'file:icon.svg' },
|
|
96
|
+
group: ['transform'],
|
|
97
|
+
version: 1,
|
|
98
|
+
description: 'Comprehensive Superpharm Marketplace API integration for Orders, Offers, Products, Inventory, Messages, Shipping, and more',
|
|
99
|
+
defaults: {
|
|
100
|
+
name: 'Synca Superpharm',
|
|
101
|
+
},
|
|
102
|
+
inputs: ["main"],
|
|
103
|
+
outputs: ["main"],
|
|
104
|
+
credentials: [
|
|
105
|
+
{
|
|
106
|
+
name: 'customSyncaApiCredentials',
|
|
107
|
+
required: true,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
properties: [
|
|
111
|
+
{
|
|
112
|
+
displayName: 'Credentials',
|
|
113
|
+
name: 'credentials',
|
|
114
|
+
type: 'options',
|
|
115
|
+
typeOptions: {
|
|
116
|
+
loadOptionsMethod: 'getCredentials',
|
|
117
|
+
},
|
|
118
|
+
default: '',
|
|
119
|
+
required: true,
|
|
120
|
+
description: 'Select the Superpharm API credentials to use',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
displayName: 'Resource',
|
|
124
|
+
name: 'resource',
|
|
125
|
+
type: 'options',
|
|
126
|
+
noDataExpression: true,
|
|
127
|
+
options: [
|
|
128
|
+
{
|
|
129
|
+
name: 'Orders',
|
|
130
|
+
value: 'orders',
|
|
131
|
+
description: 'Manage marketplace orders, acceptances, cancellations, refunds, and shipping',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'Offers',
|
|
135
|
+
value: 'offers',
|
|
136
|
+
description: 'Manage product offers, pricing, inventory, and offer status',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'Products',
|
|
140
|
+
value: 'products',
|
|
141
|
+
description: 'Manage product catalog, imports, attributes, and synchronization',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: 'Inventory',
|
|
145
|
+
value: 'inventory',
|
|
146
|
+
description: 'Manage inventory levels, stock synchronization, and fulfillment',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'Messages',
|
|
150
|
+
value: 'messages',
|
|
151
|
+
description: 'Manage customer communication, inbox threads, and order messages',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'Shipping',
|
|
155
|
+
value: 'shipping',
|
|
156
|
+
description: 'Manage shipping types, shipments, tracking, and fulfillment',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'Promotions',
|
|
160
|
+
value: 'promotions',
|
|
161
|
+
description: 'Manage promotional campaigns and marketing activities',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'Returns',
|
|
165
|
+
value: 'returns',
|
|
166
|
+
description: 'Manage returns, incidents, and customer service issues',
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
default: 'orders',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
displayName: 'Operation',
|
|
173
|
+
name: 'operation',
|
|
174
|
+
type: 'options',
|
|
175
|
+
noDataExpression: true,
|
|
176
|
+
displayOptions: { show: { resource: ['orders'] } },
|
|
177
|
+
options: [
|
|
178
|
+
{
|
|
179
|
+
name: 'Get Orders',
|
|
180
|
+
value: 'get_orders',
|
|
181
|
+
action: 'Get orders with filters',
|
|
182
|
+
description: 'Retrieve multiple orders with various filtering options',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'Get Order',
|
|
186
|
+
value: 'get_order',
|
|
187
|
+
action: 'Get a single order',
|
|
188
|
+
description: 'Retrieve details of a specific order',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'Accept Order',
|
|
192
|
+
value: 'accept_order',
|
|
193
|
+
action: 'Accept order lines',
|
|
194
|
+
description: 'Accept pending order lines',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'Cancel Order',
|
|
198
|
+
value: 'cancel_order',
|
|
199
|
+
action: 'Cancel order lines',
|
|
200
|
+
description: 'Cancel specific order lines',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'Refund Order',
|
|
204
|
+
value: 'refund_order',
|
|
205
|
+
action: 'Process order refund',
|
|
206
|
+
description: 'Process refunds for order lines',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'Ship Order',
|
|
210
|
+
value: 'ship_order',
|
|
211
|
+
action: 'Ship order',
|
|
212
|
+
description: 'Create shipments and add tracking information',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'Update Order Status',
|
|
216
|
+
value: 'update_order_status',
|
|
217
|
+
action: 'Update order status',
|
|
218
|
+
description: 'Update the status of order lines',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: 'Export Orders',
|
|
222
|
+
value: 'export_orders',
|
|
223
|
+
action: 'Export orders (async)',
|
|
224
|
+
description: 'Start asynchronous order export process',
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
default: 'get_orders',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
displayName: 'Operation',
|
|
231
|
+
name: 'operation',
|
|
232
|
+
type: 'options',
|
|
233
|
+
noDataExpression: true,
|
|
234
|
+
displayOptions: { show: { resource: ['offers'] } },
|
|
235
|
+
options: [
|
|
236
|
+
{
|
|
237
|
+
name: 'Get Offers',
|
|
238
|
+
value: 'get_offers',
|
|
239
|
+
action: 'Get offers with filters',
|
|
240
|
+
description: 'Retrieve multiple offers with filtering options',
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: 'Get Offer',
|
|
244
|
+
value: 'get_offer',
|
|
245
|
+
action: 'Get a single offer',
|
|
246
|
+
description: 'Retrieve details of a specific offer',
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: 'Create Offer',
|
|
250
|
+
value: 'create_offer',
|
|
251
|
+
action: 'Create new offers',
|
|
252
|
+
description: 'Create new product offers',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'Update Offer',
|
|
256
|
+
value: 'update_offer',
|
|
257
|
+
action: 'Update existing offers',
|
|
258
|
+
description: 'Update existing product offers',
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: 'Import Offers',
|
|
262
|
+
value: 'import_offers',
|
|
263
|
+
action: 'Import offers (bulk)',
|
|
264
|
+
description: 'Bulk import offers via file or data',
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: 'Export Offers',
|
|
268
|
+
value: 'export_offers',
|
|
269
|
+
action: 'Export offers (async)',
|
|
270
|
+
description: 'Start asynchronous offer export process',
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: 'Update Offer Status',
|
|
274
|
+
value: 'update_offer_status',
|
|
275
|
+
action: 'Update offer status',
|
|
276
|
+
description: 'Update the status of offers',
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
default: 'get_offers',
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
displayName: 'Operation',
|
|
283
|
+
name: 'operation',
|
|
284
|
+
type: 'options',
|
|
285
|
+
noDataExpression: true,
|
|
286
|
+
displayOptions: { show: { resource: ['products'] } },
|
|
287
|
+
options: [
|
|
288
|
+
{
|
|
289
|
+
name: 'Get Products',
|
|
290
|
+
value: 'get_products',
|
|
291
|
+
action: 'Get products',
|
|
292
|
+
description: 'Retrieve product information',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: 'Import Products',
|
|
296
|
+
value: 'import_products',
|
|
297
|
+
action: 'Import products (bulk)',
|
|
298
|
+
description: 'Bulk import products via file or data',
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: 'Sync Catalog',
|
|
302
|
+
value: 'sync_catalog',
|
|
303
|
+
action: 'Synchronize catalog',
|
|
304
|
+
description: 'Synchronize product catalog data',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: 'Get Product Attributes',
|
|
308
|
+
value: 'get_product_attributes',
|
|
309
|
+
action: 'Get product attributes',
|
|
310
|
+
description: 'Retrieve product attribute definitions',
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
default: 'get_products',
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
displayName: 'Operation',
|
|
317
|
+
name: 'operation',
|
|
318
|
+
type: 'options',
|
|
319
|
+
noDataExpression: true,
|
|
320
|
+
displayOptions: { show: { resource: ['inventory'] } },
|
|
321
|
+
options: [
|
|
322
|
+
{
|
|
323
|
+
name: 'Update Inventory',
|
|
324
|
+
value: 'update_inventory',
|
|
325
|
+
action: 'Update inventory levels',
|
|
326
|
+
description: 'Update product inventory quantities',
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: 'Get Inventory Status',
|
|
330
|
+
value: 'get_inventory_status',
|
|
331
|
+
action: 'Get inventory status',
|
|
332
|
+
description: 'Retrieve current inventory status',
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: 'Sync Inventory',
|
|
336
|
+
value: 'sync_inventory',
|
|
337
|
+
action: 'Synchronize inventory',
|
|
338
|
+
description: 'Synchronize inventory data',
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
default: 'update_inventory',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
displayName: 'Operation',
|
|
345
|
+
name: 'operation',
|
|
346
|
+
type: 'options',
|
|
347
|
+
noDataExpression: true,
|
|
348
|
+
displayOptions: { show: { resource: ['messages'] } },
|
|
349
|
+
options: [
|
|
350
|
+
{
|
|
351
|
+
name: 'Get Inbox Threads',
|
|
352
|
+
value: 'get_inbox_threads',
|
|
353
|
+
action: 'Get inbox threads',
|
|
354
|
+
description: 'Retrieve message threads from inbox',
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: 'Send Message',
|
|
358
|
+
value: 'send_message',
|
|
359
|
+
action: 'Send message',
|
|
360
|
+
description: 'Send a new message or reply to thread',
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: 'Get Order Messages',
|
|
364
|
+
value: 'get_order_messages',
|
|
365
|
+
action: 'Get order messages',
|
|
366
|
+
description: 'Retrieve messages related to specific order',
|
|
367
|
+
},
|
|
368
|
+
],
|
|
369
|
+
default: 'get_inbox_threads',
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
displayName: 'Operation',
|
|
373
|
+
name: 'operation',
|
|
374
|
+
type: 'options',
|
|
375
|
+
noDataExpression: true,
|
|
376
|
+
displayOptions: { show: { resource: ['shipping'] } },
|
|
377
|
+
options: [
|
|
378
|
+
{
|
|
379
|
+
name: 'Get Shipping Types',
|
|
380
|
+
value: 'get_shipping_types',
|
|
381
|
+
action: 'Get shipping types',
|
|
382
|
+
description: 'Retrieve available shipping methods',
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: 'Create Shipment',
|
|
386
|
+
value: 'create_shipment',
|
|
387
|
+
action: 'Create shipment',
|
|
388
|
+
description: 'Create new shipment with tracking',
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: 'Get Tracking Info',
|
|
392
|
+
value: 'get_tracking_info',
|
|
393
|
+
action: 'Get tracking information',
|
|
394
|
+
description: 'Retrieve shipment tracking details',
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
name: 'Update Shipping From',
|
|
398
|
+
value: 'update_shipping_from',
|
|
399
|
+
action: 'Update shipping origin',
|
|
400
|
+
description: 'Update shipping origin warehouse',
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
default: 'get_shipping_types',
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
displayName: 'Operation',
|
|
407
|
+
name: 'operation',
|
|
408
|
+
type: 'options',
|
|
409
|
+
noDataExpression: true,
|
|
410
|
+
displayOptions: { show: { resource: ['promotions'] } },
|
|
411
|
+
options: [
|
|
412
|
+
{
|
|
413
|
+
name: 'Get Promotions',
|
|
414
|
+
value: 'get_promotions',
|
|
415
|
+
action: 'Get promotions',
|
|
416
|
+
description: 'Retrieve promotional campaigns',
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: 'Create Promotion',
|
|
420
|
+
value: 'create_promotion',
|
|
421
|
+
action: 'Create promotion',
|
|
422
|
+
description: 'Create new promotional campaign',
|
|
423
|
+
},
|
|
424
|
+
],
|
|
425
|
+
default: 'get_promotions',
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
displayName: 'Operation',
|
|
429
|
+
name: 'operation',
|
|
430
|
+
type: 'options',
|
|
431
|
+
noDataExpression: true,
|
|
432
|
+
displayOptions: { show: { resource: ['returns'] } },
|
|
433
|
+
options: [
|
|
434
|
+
{
|
|
435
|
+
name: 'Get Returns',
|
|
436
|
+
value: 'get_returns',
|
|
437
|
+
action: 'Get returns',
|
|
438
|
+
description: 'Retrieve return requests',
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
name: 'Process Return',
|
|
442
|
+
value: 'process_return',
|
|
443
|
+
action: 'Process return',
|
|
444
|
+
description: 'Process a return request',
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
name: 'Get Incidents',
|
|
448
|
+
value: 'get_incidents',
|
|
449
|
+
action: 'Get incidents',
|
|
450
|
+
description: 'Retrieve customer service incidents',
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
name: 'Create Incident',
|
|
454
|
+
value: 'create_incident',
|
|
455
|
+
action: 'Create incident',
|
|
456
|
+
description: 'Create new customer service incident',
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
default: 'get_returns',
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
displayName: 'Order ID',
|
|
463
|
+
name: 'order_id',
|
|
464
|
+
type: 'string',
|
|
465
|
+
default: '',
|
|
466
|
+
required: true,
|
|
467
|
+
displayOptions: {
|
|
468
|
+
show: {
|
|
469
|
+
resource: ['orders'],
|
|
470
|
+
operation: ['get_order', 'accept_order', 'cancel_order', 'refund_order', 'ship_order'],
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
description: 'The unique identifier of the order',
|
|
474
|
+
placeholder: 'ORD-12345-A',
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
displayName: 'Offer ID',
|
|
478
|
+
name: 'offer_id',
|
|
479
|
+
type: 'string',
|
|
480
|
+
default: '',
|
|
481
|
+
required: true,
|
|
482
|
+
displayOptions: {
|
|
483
|
+
show: {
|
|
484
|
+
resource: ['offers'],
|
|
485
|
+
operation: ['get_offer'],
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
description: 'The unique identifier of the offer',
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
displayName: 'Return ID',
|
|
492
|
+
name: 'return_id',
|
|
493
|
+
type: 'string',
|
|
494
|
+
default: '',
|
|
495
|
+
required: true,
|
|
496
|
+
displayOptions: {
|
|
497
|
+
show: {
|
|
498
|
+
resource: ['returns'],
|
|
499
|
+
operation: ['process_return'],
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
description: 'The unique identifier of the return',
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
displayName: 'Tracking ID',
|
|
506
|
+
name: 'tracking_id',
|
|
507
|
+
type: 'string',
|
|
508
|
+
default: '',
|
|
509
|
+
required: true,
|
|
510
|
+
displayOptions: {
|
|
511
|
+
show: {
|
|
512
|
+
resource: ['shipping'],
|
|
513
|
+
operation: ['get_tracking_info'],
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
description: 'The tracking identifier for the shipment',
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
displayName: 'Thread ID',
|
|
520
|
+
name: 'thread_id',
|
|
521
|
+
type: 'string',
|
|
522
|
+
default: '',
|
|
523
|
+
displayOptions: {
|
|
524
|
+
show: {
|
|
525
|
+
resource: ['messages'],
|
|
526
|
+
operation: ['send_message'],
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
description: 'The thread ID for replying to existing message thread',
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
displayName: 'Order Lines Data',
|
|
533
|
+
name: 'order_lines',
|
|
534
|
+
type: 'json',
|
|
535
|
+
default: '[]',
|
|
536
|
+
displayOptions: {
|
|
537
|
+
show: {
|
|
538
|
+
resource: ['orders'],
|
|
539
|
+
operation: ['accept_order', 'update_shipping_from'],
|
|
540
|
+
},
|
|
541
|
+
},
|
|
542
|
+
description: 'JSON array of order line data for accepting orders',
|
|
543
|
+
placeholder: '[{"id": "order-line-1", "accepted": true}]',
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
displayName: 'Cancelations Data',
|
|
547
|
+
name: 'cancelations',
|
|
548
|
+
type: 'json',
|
|
549
|
+
default: '[]',
|
|
550
|
+
required: true,
|
|
551
|
+
displayOptions: {
|
|
552
|
+
show: {
|
|
553
|
+
resource: ['orders'],
|
|
554
|
+
operation: ['cancel_order'],
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
description: 'JSON array of cancelation data',
|
|
558
|
+
placeholder: '[{"order_line_id": "line-1", "quantity": 1, "reason": "CUSTOMER_CANCELATION"}]',
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
displayName: 'Refunds Data',
|
|
562
|
+
name: 'refunds',
|
|
563
|
+
type: 'json',
|
|
564
|
+
default: '[]',
|
|
565
|
+
required: true,
|
|
566
|
+
displayOptions: {
|
|
567
|
+
show: {
|
|
568
|
+
resource: ['orders'],
|
|
569
|
+
operation: ['refund_order'],
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
description: 'JSON array of refund data',
|
|
573
|
+
placeholder: '[{"order_line_id": "line-1", "quantity": 1, "reason": "ITEM_NOT_RECEIVED"}]',
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
displayName: 'Shipments Data',
|
|
577
|
+
name: 'shipments',
|
|
578
|
+
type: 'json',
|
|
579
|
+
default: '[]',
|
|
580
|
+
required: true,
|
|
581
|
+
displayOptions: {
|
|
582
|
+
show: {
|
|
583
|
+
resource: ['orders', 'shipping'],
|
|
584
|
+
operation: ['ship_order', 'create_shipment'],
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
description: 'JSON array of shipment data',
|
|
588
|
+
placeholder: '[{"order_line_id": "line-1", "carrier_code": "UPS", "tracking_number": "1Z999AA1234567890"}]',
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
displayName: 'Offers Data',
|
|
592
|
+
name: 'offers',
|
|
593
|
+
type: 'json',
|
|
594
|
+
default: '[]',
|
|
595
|
+
required: true,
|
|
596
|
+
displayOptions: {
|
|
597
|
+
show: {
|
|
598
|
+
resource: ['offers'],
|
|
599
|
+
operation: ['create_offer', 'update_offer', 'update_offer_status'],
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
description: 'JSON array of offer data',
|
|
603
|
+
placeholder: '[{"product_sku": "SKU123", "price": 29.99, "quantity": 100}]',
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
displayName: 'Orders Data',
|
|
607
|
+
name: 'orders',
|
|
608
|
+
type: 'json',
|
|
609
|
+
default: '[]',
|
|
610
|
+
required: true,
|
|
611
|
+
displayOptions: {
|
|
612
|
+
show: {
|
|
613
|
+
resource: ['orders'],
|
|
614
|
+
operation: ['update_order_status'],
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
description: 'JSON array of order status updates',
|
|
618
|
+
placeholder: '[{"order_id": "ORD-123", "order_lines": [{"id": "line-1", "status": "SHIPPED"}]}]',
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
displayName: 'Data',
|
|
622
|
+
name: 'data',
|
|
623
|
+
type: 'json',
|
|
624
|
+
default: '{}',
|
|
625
|
+
displayOptions: {
|
|
626
|
+
show: {
|
|
627
|
+
operation: ['import_products', 'import_offers', 'update_inventory', 'send_message', 'create_promotion', 'process_return', 'create_incident'],
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
description: 'JSON data for the operation',
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
displayName: 'Query Options',
|
|
634
|
+
name: 'queryOptions',
|
|
635
|
+
type: 'collection',
|
|
636
|
+
placeholder: 'Add Option',
|
|
637
|
+
default: {},
|
|
638
|
+
options: [
|
|
639
|
+
{
|
|
640
|
+
displayName: 'Limit',
|
|
641
|
+
name: 'limit',
|
|
642
|
+
type: 'number',
|
|
643
|
+
default: 10,
|
|
644
|
+
description: 'Maximum number of items to return (1-100)',
|
|
645
|
+
typeOptions: {
|
|
646
|
+
minValue: 1,
|
|
647
|
+
maxValue: 100,
|
|
648
|
+
},
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
displayName: 'Offset',
|
|
652
|
+
name: 'offset',
|
|
653
|
+
type: 'number',
|
|
654
|
+
default: 0,
|
|
655
|
+
description: 'Number of items to skip (for pagination)',
|
|
656
|
+
typeOptions: {
|
|
657
|
+
minValue: 0,
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
displayName: 'Page Token',
|
|
662
|
+
name: 'page_token',
|
|
663
|
+
type: 'string',
|
|
664
|
+
default: '',
|
|
665
|
+
description: 'Token for seek-based pagination',
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
displayName: 'Sort',
|
|
669
|
+
name: 'sort',
|
|
670
|
+
type: 'string',
|
|
671
|
+
default: '',
|
|
672
|
+
description: 'Field to sort by',
|
|
673
|
+
placeholder: 'date_created',
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
displayName: 'Order',
|
|
677
|
+
name: 'order',
|
|
678
|
+
type: 'options',
|
|
679
|
+
options: [
|
|
680
|
+
{ name: 'Ascending', value: 'asc' },
|
|
681
|
+
{ name: 'Descending', value: 'desc' },
|
|
682
|
+
],
|
|
683
|
+
default: 'asc',
|
|
684
|
+
description: 'Sort direction',
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
displayName: 'Shop ID',
|
|
688
|
+
name: 'shop_id',
|
|
689
|
+
type: 'string',
|
|
690
|
+
default: '',
|
|
691
|
+
description: 'Shop ID for multi-shop users',
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
displayName: 'Locale',
|
|
695
|
+
name: 'locale',
|
|
696
|
+
type: 'string',
|
|
697
|
+
default: '',
|
|
698
|
+
description: 'Locale for internationalized data',
|
|
699
|
+
placeholder: 'en_US',
|
|
700
|
+
},
|
|
701
|
+
],
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
displayName: 'Filters',
|
|
705
|
+
name: 'filters',
|
|
706
|
+
type: 'collection',
|
|
707
|
+
placeholder: 'Add Filter',
|
|
708
|
+
default: {},
|
|
709
|
+
displayOptions: {
|
|
710
|
+
show: {
|
|
711
|
+
operation: ['get_orders', 'get_offers', 'get_products', 'export_orders', 'export_offers'],
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
options: [
|
|
715
|
+
{
|
|
716
|
+
displayName: 'Order State Codes',
|
|
717
|
+
name: 'order_state_codes',
|
|
718
|
+
type: 'string',
|
|
719
|
+
default: '',
|
|
720
|
+
description: 'Comma-separated order state codes (e.g., SHIPPING,SHIPPED)',
|
|
721
|
+
placeholder: 'SHIPPING,SHIPPED,CLOSED',
|
|
722
|
+
displayOptions: {
|
|
723
|
+
show: {
|
|
724
|
+
'/resource': ['orders'],
|
|
725
|
+
},
|
|
726
|
+
},
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
displayName: 'Order IDs',
|
|
730
|
+
name: 'order_ids',
|
|
731
|
+
type: 'string',
|
|
732
|
+
default: '',
|
|
733
|
+
description: 'Comma-separated order IDs',
|
|
734
|
+
displayOptions: {
|
|
735
|
+
show: {
|
|
736
|
+
'/resource': ['orders'],
|
|
737
|
+
},
|
|
738
|
+
},
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
displayName: 'Start Date',
|
|
742
|
+
name: 'start_date',
|
|
743
|
+
type: 'dateTime',
|
|
744
|
+
default: '',
|
|
745
|
+
description: 'Start date for filtering (ISO 8601 format)',
|
|
746
|
+
displayOptions: {
|
|
747
|
+
show: {
|
|
748
|
+
'/resource': ['orders', 'promotions', 'returns'],
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
displayName: 'End Date',
|
|
754
|
+
name: 'end_date',
|
|
755
|
+
type: 'dateTime',
|
|
756
|
+
default: '',
|
|
757
|
+
description: 'End date for filtering (ISO 8601 format)',
|
|
758
|
+
displayOptions: {
|
|
759
|
+
show: {
|
|
760
|
+
'/resource': ['orders', 'promotions', 'returns'],
|
|
761
|
+
},
|
|
762
|
+
},
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
displayName: 'Payment Workflow',
|
|
766
|
+
name: 'payment_workflow',
|
|
767
|
+
type: 'options',
|
|
768
|
+
options: [
|
|
769
|
+
{ name: 'Pay on Acceptance', value: 'PAY_ON_ACCEPTANCE' },
|
|
770
|
+
{ name: 'Pay on Delivery', value: 'PAY_ON_DELIVERY' },
|
|
771
|
+
{ name: 'Pay on Due Date', value: 'PAY_ON_DUE_DATE' },
|
|
772
|
+
{ name: 'Pay on Shipment', value: 'PAY_ON_SHIPMENT' },
|
|
773
|
+
],
|
|
774
|
+
default: '',
|
|
775
|
+
description: 'Payment workflow filter',
|
|
776
|
+
displayOptions: {
|
|
777
|
+
show: {
|
|
778
|
+
'/resource': ['orders'],
|
|
779
|
+
},
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
displayName: 'Channel Codes',
|
|
784
|
+
name: 'channel_codes',
|
|
785
|
+
type: 'string',
|
|
786
|
+
default: '',
|
|
787
|
+
description: 'Comma-separated channel codes',
|
|
788
|
+
displayOptions: {
|
|
789
|
+
show: {
|
|
790
|
+
'/resource': ['orders'],
|
|
791
|
+
},
|
|
792
|
+
},
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
displayName: 'Has Incident',
|
|
796
|
+
name: 'has_incident',
|
|
797
|
+
type: 'boolean',
|
|
798
|
+
default: false,
|
|
799
|
+
description: 'Filter orders with incidents',
|
|
800
|
+
displayOptions: {
|
|
801
|
+
show: {
|
|
802
|
+
'/resource': ['orders'],
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
displayName: 'Product IDs',
|
|
808
|
+
name: 'product_ids',
|
|
809
|
+
type: 'string',
|
|
810
|
+
default: '',
|
|
811
|
+
description: 'Comma-separated product IDs',
|
|
812
|
+
displayOptions: {
|
|
813
|
+
show: {
|
|
814
|
+
'/resource': ['offers', 'products', 'inventory'],
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
displayName: 'Offer State Codes',
|
|
820
|
+
name: 'offer_state_codes',
|
|
821
|
+
type: 'string',
|
|
822
|
+
default: '',
|
|
823
|
+
description: 'Comma-separated offer state codes',
|
|
824
|
+
placeholder: 'ACTIVE,INACTIVE',
|
|
825
|
+
displayOptions: {
|
|
826
|
+
show: {
|
|
827
|
+
'/resource': ['offers'],
|
|
828
|
+
},
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
displayName: 'Category Codes',
|
|
833
|
+
name: 'category_codes',
|
|
834
|
+
type: 'string',
|
|
835
|
+
default: '',
|
|
836
|
+
description: 'Comma-separated category codes',
|
|
837
|
+
displayOptions: {
|
|
838
|
+
show: {
|
|
839
|
+
'/resource': ['offers', 'products'],
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
displayName: 'Updated Since',
|
|
845
|
+
name: 'updated_since',
|
|
846
|
+
type: 'dateTime',
|
|
847
|
+
default: '',
|
|
848
|
+
description: 'Filter items updated since this date',
|
|
849
|
+
displayOptions: {
|
|
850
|
+
show: {
|
|
851
|
+
'/resource': ['offers', 'products'],
|
|
852
|
+
},
|
|
853
|
+
},
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
displayName: 'Entity Type',
|
|
857
|
+
name: 'entity_type',
|
|
858
|
+
type: 'string',
|
|
859
|
+
default: '',
|
|
860
|
+
description: 'Entity type for message filtering',
|
|
861
|
+
displayOptions: {
|
|
862
|
+
show: {
|
|
863
|
+
'/resource': ['messages'],
|
|
864
|
+
},
|
|
865
|
+
},
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
displayName: 'Entity ID',
|
|
869
|
+
name: 'entity_id',
|
|
870
|
+
type: 'string',
|
|
871
|
+
default: '',
|
|
872
|
+
description: 'Entity ID for message filtering',
|
|
873
|
+
displayOptions: {
|
|
874
|
+
show: {
|
|
875
|
+
'/resource': ['messages'],
|
|
876
|
+
},
|
|
877
|
+
},
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
displayName: 'Read Status',
|
|
881
|
+
name: 'read_status',
|
|
882
|
+
type: 'options',
|
|
883
|
+
options: [
|
|
884
|
+
{ name: 'Read', value: 'READ' },
|
|
885
|
+
{ name: 'Unread', value: 'UNREAD' },
|
|
886
|
+
],
|
|
887
|
+
default: '',
|
|
888
|
+
description: 'Message read status filter',
|
|
889
|
+
displayOptions: {
|
|
890
|
+
show: {
|
|
891
|
+
'/resource': ['messages'],
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
},
|
|
895
|
+
],
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
displayName: 'Advanced Options',
|
|
899
|
+
name: 'advancedOptions',
|
|
900
|
+
type: 'collection',
|
|
901
|
+
placeholder: 'Add Option',
|
|
902
|
+
default: {},
|
|
903
|
+
options: [
|
|
904
|
+
{
|
|
905
|
+
displayName: 'Return Full Response',
|
|
906
|
+
name: 'returnFullResponse',
|
|
907
|
+
type: 'boolean',
|
|
908
|
+
default: false,
|
|
909
|
+
description: 'Whether to return the full API response including metadata',
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
displayName: 'Handle Rate Limiting',
|
|
913
|
+
name: 'handleRateLimit',
|
|
914
|
+
type: 'boolean',
|
|
915
|
+
default: true,
|
|
916
|
+
description: 'Whether to automatically retry on rate limit (429) errors',
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
displayName: 'Request Timeout',
|
|
920
|
+
name: 'timeout',
|
|
921
|
+
type: 'number',
|
|
922
|
+
default: 60,
|
|
923
|
+
description: 'Request timeout in seconds',
|
|
924
|
+
typeOptions: {
|
|
925
|
+
minValue: 10,
|
|
926
|
+
maxValue: 300,
|
|
927
|
+
},
|
|
928
|
+
},
|
|
929
|
+
],
|
|
930
|
+
},
|
|
931
|
+
],
|
|
932
|
+
};
|
|
933
|
+
this.methods = {
|
|
934
|
+
loadOptions: {
|
|
935
|
+
async getCredentials() {
|
|
936
|
+
try {
|
|
937
|
+
const credentials = await this.getCredentials('customSyncaApiCredentials');
|
|
938
|
+
const options = {
|
|
939
|
+
method: 'GET',
|
|
940
|
+
url: `${credentials.baseUrl}/v1/invoke/get-credentials`,
|
|
941
|
+
headers: {
|
|
942
|
+
'x-api-token': credentials === null || credentials === void 0 ? void 0 : credentials.apiToken,
|
|
943
|
+
},
|
|
944
|
+
};
|
|
945
|
+
const response = await this.helpers.httpRequest(options);
|
|
946
|
+
if (Array.isArray(response)) {
|
|
947
|
+
return response.map((cred) => ({
|
|
948
|
+
name: cred.name || cred.id,
|
|
949
|
+
value: cred.id,
|
|
950
|
+
}));
|
|
951
|
+
}
|
|
952
|
+
return [];
|
|
953
|
+
}
|
|
954
|
+
catch (error) {
|
|
955
|
+
return [
|
|
956
|
+
{
|
|
957
|
+
name: 'Default Superpharm Credentials',
|
|
958
|
+
value: 'default',
|
|
959
|
+
},
|
|
960
|
+
];
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
},
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
async execute() {
|
|
967
|
+
var _a, _b;
|
|
968
|
+
const items = this.getInputData();
|
|
969
|
+
const returnData = [];
|
|
970
|
+
for (let i = 0; i < items.length; i++) {
|
|
971
|
+
try {
|
|
972
|
+
const resource = this.getNodeParameter('resource', i);
|
|
973
|
+
const operation = this.getNodeParameter('operation', i);
|
|
974
|
+
const credentialsId = this.getNodeParameter('credentials', i);
|
|
975
|
+
const queryOptions = this.getNodeParameter('queryOptions', i, {});
|
|
976
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
977
|
+
const advancedOptions = this.getNodeParameter('advancedOptions', i, {});
|
|
978
|
+
const credentials = await this.getCredentials('customSyncaApiCredentials');
|
|
979
|
+
const requestParams = {
|
|
980
|
+
...queryOptions,
|
|
981
|
+
...filters,
|
|
982
|
+
};
|
|
983
|
+
addResourceSpecificParams(requestParams, resource, operation, i, this.getNodeParameter);
|
|
984
|
+
const headers = {
|
|
985
|
+
'x-api-token': credentials.apiToken,
|
|
986
|
+
'Content-Type': 'application/json',
|
|
987
|
+
};
|
|
988
|
+
const timeout = advancedOptions.timeout ? advancedOptions.timeout * 1000 : 60000;
|
|
989
|
+
const options = {
|
|
990
|
+
method: 'POST',
|
|
991
|
+
url: `${credentials.baseUrl}/v1/invoke/${credentialsId}/${operation}`,
|
|
992
|
+
headers,
|
|
993
|
+
body: requestParams,
|
|
994
|
+
json: true,
|
|
995
|
+
timeout,
|
|
996
|
+
};
|
|
997
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug('Superpharm API Request', {
|
|
998
|
+
action: operation,
|
|
999
|
+
resource,
|
|
1000
|
+
url: options.url,
|
|
1001
|
+
params: requestParams
|
|
1002
|
+
});
|
|
1003
|
+
let responseData;
|
|
1004
|
+
if (advancedOptions.handleRateLimit) {
|
|
1005
|
+
responseData = await makeRequestWithRetry(options, 3, this.helpers.httpRequest, this.logger);
|
|
1006
|
+
}
|
|
1007
|
+
else {
|
|
1008
|
+
responseData = await this.helpers.httpRequest(options);
|
|
1009
|
+
}
|
|
1010
|
+
if (advancedOptions.returnFullResponse) {
|
|
1011
|
+
returnData.push({
|
|
1012
|
+
json: responseData,
|
|
1013
|
+
pairedItem: { item: i },
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
else {
|
|
1017
|
+
const processedData = processResponseData(responseData, resource, operation);
|
|
1018
|
+
if (isListOperation(operation) && Array.isArray(processedData)) {
|
|
1019
|
+
if (processedData.length > 0) {
|
|
1020
|
+
processedData.forEach((item) => {
|
|
1021
|
+
returnData.push({
|
|
1022
|
+
json: item,
|
|
1023
|
+
pairedItem: { item: i },
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
returnData.push({
|
|
1029
|
+
json: {
|
|
1030
|
+
message: `No ${resource} found`,
|
|
1031
|
+
count: 0,
|
|
1032
|
+
resource,
|
|
1033
|
+
operation
|
|
1034
|
+
},
|
|
1035
|
+
pairedItem: { item: i },
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
else {
|
|
1040
|
+
returnData.push({
|
|
1041
|
+
json: processedData,
|
|
1042
|
+
pairedItem: { item: i },
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
catch (error) {
|
|
1048
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.error('Superpharm API Error', {
|
|
1049
|
+
error: error.message,
|
|
1050
|
+
resource: this.getNodeParameter('resource', i),
|
|
1051
|
+
operation: this.getNodeParameter('operation', i),
|
|
1052
|
+
});
|
|
1053
|
+
if (this.continueOnFail()) {
|
|
1054
|
+
returnData.push({
|
|
1055
|
+
json: {
|
|
1056
|
+
error: error.message,
|
|
1057
|
+
resource: this.getNodeParameter('resource', i, ''),
|
|
1058
|
+
operation: this.getNodeParameter('operation', i, ''),
|
|
1059
|
+
timestamp: new Date().toISOString(),
|
|
1060
|
+
},
|
|
1061
|
+
pairedItem: { item: i },
|
|
1062
|
+
});
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
throw error;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return [returnData];
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
exports.SyncaSuperpharm = SyncaSuperpharm;
|
|
1072
|
+
//# sourceMappingURL=SyncaSuperpharm.node.js.map
|