@solution25/n8n-nodes-shopware 1.4.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.
Files changed (156) hide show
  1. package/README.md +80 -0
  2. package/dist/credentials/ShopwareOAuth2Api.credentials.d.ts +16 -0
  3. package/dist/credentials/ShopwareOAuth2Api.credentials.js +78 -0
  4. package/dist/credentials/ShopwareOAuth2Api.credentials.js.map +1 -0
  5. package/dist/nodes/Shopware/Shopware.node.d.ts +4 -0
  6. package/dist/nodes/Shopware/Shopware.node.js +23 -0
  7. package/dist/nodes/Shopware/Shopware.node.js.map +1 -0
  8. package/dist/nodes/Shopware/Shopware.node.json +18 -0
  9. package/dist/nodes/Shopware/test/v1/node/customer/getMany.test.d.ts +1 -0
  10. package/dist/nodes/Shopware/test/v1/node/customer/getMany.test.js +98 -0
  11. package/dist/nodes/Shopware/test/v1/node/customer/getMany.test.js.map +1 -0
  12. package/dist/nodes/Shopware/test/v1/node/helpers.d.ts +6 -0
  13. package/dist/nodes/Shopware/test/v1/node/helpers.js +44 -0
  14. package/dist/nodes/Shopware/test/v1/node/helpers.js.map +1 -0
  15. package/dist/nodes/Shopware/test/v1/node/order/getMany.test.d.ts +1 -0
  16. package/dist/nodes/Shopware/test/v1/node/order/getMany.test.js +111 -0
  17. package/dist/nodes/Shopware/test/v1/node/order/getMany.test.js.map +1 -0
  18. package/dist/nodes/Shopware/test/v1/node/product/getMany.test.d.ts +1 -0
  19. package/dist/nodes/Shopware/test/v1/node/product/getMany.test.js +96 -0
  20. package/dist/nodes/Shopware/test/v1/node/product/getMany.test.js.map +1 -0
  21. package/dist/nodes/Shopware/v1/ShopwareV1.node.d.ts +10 -0
  22. package/dist/nodes/Shopware/v1/ShopwareV1.node.js +23 -0
  23. package/dist/nodes/Shopware/v1/ShopwareV1.node.js.map +1 -0
  24. package/dist/nodes/Shopware/v1/actions/category/Category.resource.d.ts +8 -0
  25. package/dist/nodes/Shopware/v1/actions/category/Category.resource.js +98 -0
  26. package/dist/nodes/Shopware/v1/actions/category/Category.resource.js.map +1 -0
  27. package/dist/nodes/Shopware/v1/actions/category/create.operation.d.ts +27 -0
  28. package/dist/nodes/Shopware/v1/actions/category/create.operation.js +211 -0
  29. package/dist/nodes/Shopware/v1/actions/category/create.operation.js.map +1 -0
  30. package/dist/nodes/Shopware/v1/actions/category/deleteCategory.operation.d.ts +27 -0
  31. package/dist/nodes/Shopware/v1/actions/category/deleteCategory.operation.js +47 -0
  32. package/dist/nodes/Shopware/v1/actions/category/deleteCategory.operation.js.map +1 -0
  33. package/dist/nodes/Shopware/v1/actions/category/fields.d.ts +1 -0
  34. package/dist/nodes/Shopware/v1/actions/category/fields.js +21 -0
  35. package/dist/nodes/Shopware/v1/actions/category/fields.js.map +1 -0
  36. package/dist/nodes/Shopware/v1/actions/category/get.operation.d.ts +27 -0
  37. package/dist/nodes/Shopware/v1/actions/category/get.operation.js +77 -0
  38. package/dist/nodes/Shopware/v1/actions/category/get.operation.js.map +1 -0
  39. package/dist/nodes/Shopware/v1/actions/category/getMany.operation.d.ts +27 -0
  40. package/dist/nodes/Shopware/v1/actions/category/getMany.operation.js +164 -0
  41. package/dist/nodes/Shopware/v1/actions/category/getMany.operation.js.map +1 -0
  42. package/dist/nodes/Shopware/v1/actions/category/types.d.ts +19 -0
  43. package/dist/nodes/Shopware/v1/actions/category/types.js +3 -0
  44. package/dist/nodes/Shopware/v1/actions/category/types.js.map +1 -0
  45. package/dist/nodes/Shopware/v1/actions/category/update.operation.d.ts +27 -0
  46. package/dist/nodes/Shopware/v1/actions/category/update.operation.js +120 -0
  47. package/dist/nodes/Shopware/v1/actions/category/update.operation.js.map +1 -0
  48. package/dist/nodes/Shopware/v1/actions/customer/Customer.resource.d.ts +8 -0
  49. package/dist/nodes/Shopware/v1/actions/customer/Customer.resource.js +98 -0
  50. package/dist/nodes/Shopware/v1/actions/customer/Customer.resource.js.map +1 -0
  51. package/dist/nodes/Shopware/v1/actions/customer/create.operation.d.ts +27 -0
  52. package/dist/nodes/Shopware/v1/actions/customer/create.operation.js +301 -0
  53. package/dist/nodes/Shopware/v1/actions/customer/create.operation.js.map +1 -0
  54. package/dist/nodes/Shopware/v1/actions/customer/deleteCustomer.operation.d.ts +27 -0
  55. package/dist/nodes/Shopware/v1/actions/customer/deleteCustomer.operation.js +47 -0
  56. package/dist/nodes/Shopware/v1/actions/customer/deleteCustomer.operation.js.map +1 -0
  57. package/dist/nodes/Shopware/v1/actions/customer/fields.d.ts +4 -0
  58. package/dist/nodes/Shopware/v1/actions/customer/fields.js +30 -0
  59. package/dist/nodes/Shopware/v1/actions/customer/fields.js.map +1 -0
  60. package/dist/nodes/Shopware/v1/actions/customer/get.operation.d.ts +27 -0
  61. package/dist/nodes/Shopware/v1/actions/customer/get.operation.js +77 -0
  62. package/dist/nodes/Shopware/v1/actions/customer/get.operation.js.map +1 -0
  63. package/dist/nodes/Shopware/v1/actions/customer/getMany.operation.d.ts +27 -0
  64. package/dist/nodes/Shopware/v1/actions/customer/getMany.operation.js +319 -0
  65. package/dist/nodes/Shopware/v1/actions/customer/getMany.operation.js.map +1 -0
  66. package/dist/nodes/Shopware/v1/actions/customer/types.d.ts +54 -0
  67. package/dist/nodes/Shopware/v1/actions/customer/types.js +3 -0
  68. package/dist/nodes/Shopware/v1/actions/customer/types.js.map +1 -0
  69. package/dist/nodes/Shopware/v1/actions/customer/update.operation.d.ts +27 -0
  70. package/dist/nodes/Shopware/v1/actions/customer/update.operation.js +287 -0
  71. package/dist/nodes/Shopware/v1/actions/customer/update.operation.js.map +1 -0
  72. package/dist/nodes/Shopware/v1/actions/fields.d.ts +5 -0
  73. package/dist/nodes/Shopware/v1/actions/fields.js +26 -0
  74. package/dist/nodes/Shopware/v1/actions/fields.js.map +1 -0
  75. package/dist/nodes/Shopware/v1/actions/node.type.d.ts +9 -0
  76. package/dist/nodes/Shopware/v1/actions/node.type.js +3 -0
  77. package/dist/nodes/Shopware/v1/actions/node.type.js.map +1 -0
  78. package/dist/nodes/Shopware/v1/actions/order/Order.resource.d.ts +8 -0
  79. package/dist/nodes/Shopware/v1/actions/order/Order.resource.js +98 -0
  80. package/dist/nodes/Shopware/v1/actions/order/Order.resource.js.map +1 -0
  81. package/dist/nodes/Shopware/v1/actions/order/create.operation.d.ts +27 -0
  82. package/dist/nodes/Shopware/v1/actions/order/create.operation.js +861 -0
  83. package/dist/nodes/Shopware/v1/actions/order/create.operation.js.map +1 -0
  84. package/dist/nodes/Shopware/v1/actions/order/deleteOrder.operation.d.ts +27 -0
  85. package/dist/nodes/Shopware/v1/actions/order/deleteOrder.operation.js +47 -0
  86. package/dist/nodes/Shopware/v1/actions/order/deleteOrder.operation.js.map +1 -0
  87. package/dist/nodes/Shopware/v1/actions/order/fields.d.ts +2 -0
  88. package/dist/nodes/Shopware/v1/actions/order/fields.js +25 -0
  89. package/dist/nodes/Shopware/v1/actions/order/fields.js.map +1 -0
  90. package/dist/nodes/Shopware/v1/actions/order/get.operation.d.ts +27 -0
  91. package/dist/nodes/Shopware/v1/actions/order/get.operation.js +77 -0
  92. package/dist/nodes/Shopware/v1/actions/order/get.operation.js.map +1 -0
  93. package/dist/nodes/Shopware/v1/actions/order/getMany.operation.d.ts +27 -0
  94. package/dist/nodes/Shopware/v1/actions/order/getMany.operation.js +226 -0
  95. package/dist/nodes/Shopware/v1/actions/order/getMany.operation.js.map +1 -0
  96. package/dist/nodes/Shopware/v1/actions/order/types.d.ts +171 -0
  97. package/dist/nodes/Shopware/v1/actions/order/types.js +3 -0
  98. package/dist/nodes/Shopware/v1/actions/order/types.js.map +1 -0
  99. package/dist/nodes/Shopware/v1/actions/order/update.operation.d.ts +27 -0
  100. package/dist/nodes/Shopware/v1/actions/order/update.operation.js +723 -0
  101. package/dist/nodes/Shopware/v1/actions/order/update.operation.js.map +1 -0
  102. package/dist/nodes/Shopware/v1/actions/product/Product.resource.d.ts +8 -0
  103. package/dist/nodes/Shopware/v1/actions/product/Product.resource.js +98 -0
  104. package/dist/nodes/Shopware/v1/actions/product/Product.resource.js.map +1 -0
  105. package/dist/nodes/Shopware/v1/actions/product/create.operation.d.ts +27 -0
  106. package/dist/nodes/Shopware/v1/actions/product/create.operation.js +335 -0
  107. package/dist/nodes/Shopware/v1/actions/product/create.operation.js.map +1 -0
  108. package/dist/nodes/Shopware/v1/actions/product/deleteProduct.operation.d.ts +27 -0
  109. package/dist/nodes/Shopware/v1/actions/product/deleteProduct.operation.js +47 -0
  110. package/dist/nodes/Shopware/v1/actions/product/deleteProduct.operation.js.map +1 -0
  111. package/dist/nodes/Shopware/v1/actions/product/fields.d.ts +7 -0
  112. package/dist/nodes/Shopware/v1/actions/product/fields.js +33 -0
  113. package/dist/nodes/Shopware/v1/actions/product/fields.js.map +1 -0
  114. package/dist/nodes/Shopware/v1/actions/product/get.operation.d.ts +27 -0
  115. package/dist/nodes/Shopware/v1/actions/product/get.operation.js +77 -0
  116. package/dist/nodes/Shopware/v1/actions/product/get.operation.js.map +1 -0
  117. package/dist/nodes/Shopware/v1/actions/product/getMany.operation.d.ts +27 -0
  118. package/dist/nodes/Shopware/v1/actions/product/getMany.operation.js +319 -0
  119. package/dist/nodes/Shopware/v1/actions/product/getMany.operation.js.map +1 -0
  120. package/dist/nodes/Shopware/v1/actions/product/types.d.ts +66 -0
  121. package/dist/nodes/Shopware/v1/actions/product/types.js +3 -0
  122. package/dist/nodes/Shopware/v1/actions/product/types.js.map +1 -0
  123. package/dist/nodes/Shopware/v1/actions/product/update.operation.d.ts +27 -0
  124. package/dist/nodes/Shopware/v1/actions/product/update.operation.js +287 -0
  125. package/dist/nodes/Shopware/v1/actions/product/update.operation.js.map +1 -0
  126. package/dist/nodes/Shopware/v1/actions/router.d.ts +2 -0
  127. package/dist/nodes/Shopware/v1/actions/router.js +78 -0
  128. package/dist/nodes/Shopware/v1/actions/router.js.map +1 -0
  129. package/dist/nodes/Shopware/v1/actions/types.d.ts +97 -0
  130. package/dist/nodes/Shopware/v1/actions/types.js +3 -0
  131. package/dist/nodes/Shopware/v1/actions/types.js.map +1 -0
  132. package/dist/nodes/Shopware/v1/actions/versionDescription.d.ts +2 -0
  133. package/dist/nodes/Shopware/v1/actions/versionDescription.js +93 -0
  134. package/dist/nodes/Shopware/v1/actions/versionDescription.js.map +1 -0
  135. package/dist/nodes/Shopware/v1/helpers/handlers.d.ts +14 -0
  136. package/dist/nodes/Shopware/v1/helpers/handlers.js +261 -0
  137. package/dist/nodes/Shopware/v1/helpers/handlers.js.map +1 -0
  138. package/dist/nodes/Shopware/v1/helpers/interfaces.d.ts +1 -0
  139. package/dist/nodes/Shopware/v1/helpers/interfaces.js +3 -0
  140. package/dist/nodes/Shopware/v1/helpers/interfaces.js.map +1 -0
  141. package/dist/nodes/Shopware/v1/helpers/utils.d.ts +16 -0
  142. package/dist/nodes/Shopware/v1/helpers/utils.js +354 -0
  143. package/dist/nodes/Shopware/v1/helpers/utils.js.map +1 -0
  144. package/dist/nodes/Shopware/v1/methods/index.d.ts +1 -0
  145. package/dist/nodes/Shopware/v1/methods/index.js +38 -0
  146. package/dist/nodes/Shopware/v1/methods/index.js.map +1 -0
  147. package/dist/nodes/Shopware/v1/methods/loadOptions.d.ts +18 -0
  148. package/dist/nodes/Shopware/v1/methods/loadOptions.js +143 -0
  149. package/dist/nodes/Shopware/v1/methods/loadOptions.js.map +1 -0
  150. package/dist/nodes/Shopware/v1/transport/index.d.ts +2 -0
  151. package/dist/nodes/Shopware/v1/transport/index.js +25 -0
  152. package/dist/nodes/Shopware/v1/transport/index.js.map +1 -0
  153. package/dist/package.json +63 -0
  154. package/dist/shopware.png +0 -0
  155. package/dist/tsconfig.tsbuildinfo +1 -0
  156. package/package.json +63 -0
@@ -0,0 +1,861 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.execute = execute;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ const transport_1 = require("../../transport");
7
+ const fields_1 = require("./fields");
8
+ const utils_1 = require("../../helpers/utils");
9
+ const properties = [
10
+ {
11
+ displayName: 'Order Number',
12
+ name: 'orderNumber',
13
+ type: 'string',
14
+ default: '',
15
+ placeholder: 'e.g. ON752834790',
16
+ description: 'Optional order identifier',
17
+ },
18
+ {
19
+ displayName: 'Date and Time',
20
+ name: 'dateAndTime',
21
+ type: 'dateTime',
22
+ required: true,
23
+ default: '',
24
+ description: 'Optional order date and time',
25
+ },
26
+ {
27
+ displayName: 'Currency',
28
+ name: 'currency',
29
+ type: 'options',
30
+ required: true,
31
+ typeOptions: {
32
+ loadOptionsMethod: 'getOrderCurrencies',
33
+ },
34
+ default: '',
35
+ description: 'Choose the order currency from the list',
36
+ },
37
+ {
38
+ displayName: 'State',
39
+ name: 'state',
40
+ type: 'options',
41
+ required: true,
42
+ typeOptions: {
43
+ loadOptionsMethod: 'getOrderStates',
44
+ },
45
+ default: '',
46
+ description: 'Choose the order state from the list',
47
+ },
48
+ {
49
+ displayName: 'Guest Order',
50
+ name: 'guestOrder',
51
+ type: 'boolean',
52
+ default: false,
53
+ description: 'Whether the order is a guest order',
54
+ },
55
+ {
56
+ displayName: 'Guest',
57
+ name: 'guestUi',
58
+ placeholder: 'Add Guest Details',
59
+ type: 'fixedCollection',
60
+ default: {},
61
+ typeOptions: {
62
+ multipleValues: false,
63
+ },
64
+ displayOptions: {
65
+ show: {
66
+ guestOrder: [true],
67
+ },
68
+ },
69
+ description: 'Add guest order details',
70
+ options: [
71
+ {
72
+ name: 'guestValues',
73
+ displayName: 'Guest Details',
74
+ values: [
75
+ {
76
+ displayName: 'First Name',
77
+ name: 'firstName',
78
+ type: 'string',
79
+ required: true,
80
+ default: '',
81
+ description: 'Guest customer first name',
82
+ },
83
+ {
84
+ displayName: 'Last Name',
85
+ name: 'lastName',
86
+ type: 'string',
87
+ required: true,
88
+ default: '',
89
+ description: 'Guest customer last name',
90
+ },
91
+ {
92
+ displayName: 'Email',
93
+ name: 'email',
94
+ type: 'string',
95
+ placeholder: 'name@email.com',
96
+ required: true,
97
+ default: '',
98
+ description: 'Guest customer email',
99
+ },
100
+ {
101
+ displayName: 'Salutation',
102
+ name: 'salutation',
103
+ type: 'options',
104
+ typeOptions: {
105
+ loadOptionsMethod: 'getSalutations',
106
+ },
107
+ required: true,
108
+ default: '',
109
+ description: 'Guest customer salutation',
110
+ },
111
+ ],
112
+ },
113
+ ],
114
+ },
115
+ {
116
+ displayName: 'Billing Address',
117
+ name: 'billingAddressUi',
118
+ placeholder: 'Add Billing Address',
119
+ type: 'fixedCollection',
120
+ default: {},
121
+ typeOptions: {
122
+ multipleValues: false,
123
+ },
124
+ displayOptions: {
125
+ show: {
126
+ guestOrder: [true],
127
+ },
128
+ },
129
+ description: 'Add guest billing address',
130
+ options: [
131
+ {
132
+ name: 'billingAddressValues',
133
+ displayName: 'Billing Address',
134
+ values: [
135
+ {
136
+ displayName: 'Country',
137
+ name: 'country',
138
+ type: 'options',
139
+ typeOptions: {
140
+ loadOptionsMethod: 'getCountries',
141
+ },
142
+ required: true,
143
+ default: '',
144
+ description: 'Country of the billing address',
145
+ },
146
+ {
147
+ displayName: 'First Name',
148
+ name: 'firstName',
149
+ type: 'string',
150
+ required: true,
151
+ default: '',
152
+ description: 'Customer first name',
153
+ },
154
+ {
155
+ displayName: 'Last Name',
156
+ name: 'lastName',
157
+ type: 'string',
158
+ required: true,
159
+ default: '',
160
+ description: 'Customer last name',
161
+ },
162
+ {
163
+ displayName: 'City',
164
+ name: 'city',
165
+ type: 'string',
166
+ required: true,
167
+ default: '',
168
+ description: 'Billing address city',
169
+ },
170
+ {
171
+ displayName: 'Street',
172
+ name: 'street',
173
+ type: 'string',
174
+ required: true,
175
+ default: '',
176
+ description: 'Billing address street',
177
+ },
178
+ ],
179
+ },
180
+ ],
181
+ },
182
+ {
183
+ displayName: 'Shipping Address',
184
+ name: 'shippingAddressUi',
185
+ placeholder: 'Add Shipping Address',
186
+ type: 'fixedCollection',
187
+ default: {},
188
+ typeOptions: {
189
+ multipleValues: false,
190
+ },
191
+ displayOptions: {
192
+ show: {
193
+ guestOrder: [true],
194
+ },
195
+ },
196
+ description: 'Add guest shipping address',
197
+ options: [
198
+ {
199
+ name: 'shippingAddressValues',
200
+ displayName: 'Shipping Address',
201
+ values: [
202
+ {
203
+ displayName: 'Country',
204
+ name: 'country',
205
+ type: 'options',
206
+ typeOptions: {
207
+ loadOptionsMethod: 'getCountries',
208
+ },
209
+ required: true,
210
+ default: '',
211
+ description: 'Country of the shipping address',
212
+ },
213
+ {
214
+ displayName: 'First Name',
215
+ name: 'firstName',
216
+ type: 'string',
217
+ required: true,
218
+ default: '',
219
+ description: 'Customer first name',
220
+ },
221
+ {
222
+ displayName: 'Last Name',
223
+ name: 'lastName',
224
+ type: 'string',
225
+ required: true,
226
+ default: '',
227
+ description: 'Customer last name',
228
+ },
229
+ {
230
+ displayName: 'City',
231
+ name: 'city',
232
+ type: 'string',
233
+ required: true,
234
+ default: '',
235
+ description: 'Shipping address city',
236
+ },
237
+ {
238
+ displayName: 'Street',
239
+ name: 'street',
240
+ type: 'string',
241
+ required: true,
242
+ default: '',
243
+ description: 'Shipping address street',
244
+ },
245
+ ],
246
+ },
247
+ ],
248
+ },
249
+ {
250
+ displayName: 'Sales Channel',
251
+ name: 'salesChannel',
252
+ type: 'options',
253
+ typeOptions: {
254
+ loadOptionsMethod: 'getSalesChannels',
255
+ },
256
+ displayOptions: {
257
+ show: {
258
+ guestOrder: [true],
259
+ },
260
+ },
261
+ default: '',
262
+ description: 'Select sales channel for the guest order',
263
+ },
264
+ {
265
+ displayName: 'Customer Number',
266
+ name: 'customerNumber',
267
+ type: 'string',
268
+ displayOptions: {
269
+ show: {
270
+ guestOrder: [false],
271
+ },
272
+ },
273
+ default: '',
274
+ placeholder: 'e.g. C10001',
275
+ description: 'Number of the order customer',
276
+ },
277
+ {
278
+ displayName: 'Line Items',
279
+ name: 'lineItems',
280
+ placeholder: 'Add Line Item',
281
+ type: 'fixedCollection',
282
+ typeOptions: {
283
+ multipleValues: true,
284
+ },
285
+ description: 'Order line items',
286
+ default: {},
287
+ options: [
288
+ {
289
+ name: 'lineItem',
290
+ displayName: 'Line Item',
291
+ values: [
292
+ {
293
+ displayName: 'Product Number',
294
+ name: 'productNumber',
295
+ type: 'string',
296
+ required: true,
297
+ default: '',
298
+ placeholder: 'e.g. P10001',
299
+ description: 'Line item product number',
300
+ },
301
+ {
302
+ displayName: 'Quantity',
303
+ name: 'quantity',
304
+ type: 'number',
305
+ typeOptions: {
306
+ maxValue: 999000000,
307
+ minValue: 0,
308
+ },
309
+ required: true,
310
+ default: 1,
311
+ placeholder: 'e.g. 5',
312
+ description: 'Line item quantity',
313
+ },
314
+ ],
315
+ },
316
+ ],
317
+ },
318
+ {
319
+ displayName: 'Transactions',
320
+ name: 'transactions',
321
+ placeholder: 'Add Transaction',
322
+ type: 'fixedCollection',
323
+ typeOptions: {
324
+ multipleValues: true,
325
+ },
326
+ description: 'Order transactions',
327
+ default: {},
328
+ options: [
329
+ {
330
+ name: 'transaction',
331
+ displayName: 'Transaction',
332
+ values: [
333
+ {
334
+ displayName: 'Payment Method',
335
+ name: 'paymentMethod',
336
+ type: 'options',
337
+ typeOptions: {
338
+ loadOptionsMethod: 'getPaymentMethods',
339
+ },
340
+ required: true,
341
+ default: '',
342
+ description: 'Transaction payment method',
343
+ },
344
+ {
345
+ displayName: 'State',
346
+ name: 'state',
347
+ type: 'options',
348
+ typeOptions: {
349
+ loadOptionsMethod: 'getTransactionStates',
350
+ },
351
+ required: true,
352
+ default: '',
353
+ description: 'State of the transaction (e.g. Paid)',
354
+ },
355
+ ],
356
+ },
357
+ ],
358
+ },
359
+ {
360
+ displayName: 'Deliveries',
361
+ name: 'deliveries',
362
+ placeholder: 'Add Delivery',
363
+ type: 'fixedCollection',
364
+ typeOptions: {
365
+ multipleValues: true,
366
+ },
367
+ description: 'Order deliveries',
368
+ default: {},
369
+ options: [
370
+ {
371
+ name: 'delivery',
372
+ displayName: 'Delivery',
373
+ values: [
374
+ {
375
+ displayName: 'Shipping Method',
376
+ name: 'shippingMethod',
377
+ type: 'options',
378
+ typeOptions: {
379
+ loadOptionsMethod: 'getShippingMethods',
380
+ },
381
+ required: true,
382
+ default: '',
383
+ description: 'Delivery shipping method',
384
+ },
385
+ {
386
+ displayName: 'State',
387
+ name: 'state',
388
+ type: 'options',
389
+ typeOptions: {
390
+ loadOptionsMethod: 'getDeliveryStates',
391
+ },
392
+ required: true,
393
+ default: '',
394
+ description: 'State of the delivery (e.g. Shipped)',
395
+ },
396
+ {
397
+ displayName: 'Use Customer Shipping Address',
398
+ name: 'customerShippingAddress',
399
+ type: 'boolean',
400
+ default: true,
401
+ description: 'Whether to use the customer shipping address',
402
+ },
403
+ {
404
+ displayName: 'Address',
405
+ name: 'addressUi',
406
+ placeholder: 'Add Address',
407
+ type: 'fixedCollection',
408
+ default: {},
409
+ typeOptions: {
410
+ multipleValues: false,
411
+ },
412
+ displayOptions: {
413
+ show: {
414
+ customerShippingAddress: [false],
415
+ },
416
+ },
417
+ description: 'Add delivery shipping address',
418
+ options: [
419
+ {
420
+ name: 'addressValues',
421
+ displayName: 'Address',
422
+ values: [
423
+ {
424
+ displayName: 'Country',
425
+ name: 'country',
426
+ type: 'options',
427
+ typeOptions: {
428
+ loadOptionsMethod: 'getCountries',
429
+ },
430
+ required: true,
431
+ default: '',
432
+ description: 'Country of the shippng address',
433
+ },
434
+ {
435
+ displayName: 'First Name',
436
+ name: 'firstName',
437
+ type: 'string',
438
+ required: true,
439
+ default: '',
440
+ description: 'Customer first name',
441
+ },
442
+ {
443
+ displayName: 'Last Name',
444
+ name: 'lastName',
445
+ type: 'string',
446
+ required: true,
447
+ default: '',
448
+ description: 'Customer last name',
449
+ },
450
+ {
451
+ displayName: 'City',
452
+ name: 'city',
453
+ type: 'string',
454
+ required: true,
455
+ default: '',
456
+ description: 'Shipping address city',
457
+ },
458
+ {
459
+ displayName: 'Street',
460
+ name: 'street',
461
+ type: 'string',
462
+ required: true,
463
+ default: '',
464
+ description: 'Shipping address street',
465
+ },
466
+ ],
467
+ },
468
+ ],
469
+ },
470
+ ],
471
+ },
472
+ ],
473
+ },
474
+ ];
475
+ const displayOptions = {
476
+ show: {
477
+ resource: ['order'],
478
+ operation: ['create'],
479
+ },
480
+ };
481
+ exports.description = (0, n8n_workflow_1.updateDisplayOptions)(displayOptions, properties);
482
+ async function execute(items) {
483
+ const returnData = [];
484
+ for (let i = 0; i < items.length; i++) {
485
+ try {
486
+ const orderId = (0, utils_1.uuidv7)();
487
+ const customerData = {};
488
+ const globalDefaults = {};
489
+ let orderCustomer;
490
+ const customerNumber = !this.getNodeParameter('guestOrder', i)
491
+ ? this.getNodeParameter('customerNumber', i)
492
+ : null;
493
+ if (customerNumber) {
494
+ const customer = await utils_1.getCustomerByNumber.call(this, customerNumber, i);
495
+ globalDefaults.languageId = customer.languageId;
496
+ globalDefaults.salesChannelId = customer.salesChannelId;
497
+ customerData.firstName = customer.firstName;
498
+ customerData.lastName = customer.lastName;
499
+ customerData.email = customer.email;
500
+ customerData.salutationId = customer.salutationId;
501
+ customerData.billingAddress = customer.billingAddress;
502
+ customerData.shippingAddress = customer.shippingAddress;
503
+ orderCustomer = {
504
+ firstName: customer.firstName,
505
+ lastName: customer.lastName,
506
+ email: customer.email,
507
+ salutationId: customer.salutationId,
508
+ customerId: customer.id,
509
+ customerNumber,
510
+ };
511
+ }
512
+ else {
513
+ const guest = this.getNodeParameter('guestUi', i)
514
+ .guestValues;
515
+ const guestBillingAddress = this.getNodeParameter('billingAddressUi', i).billingAddressValues;
516
+ const guestShippingAddress = this.getNodeParameter('shippingAddressUi', i).shippingAddressValues;
517
+ globalDefaults.languageId = await utils_1.getDefaultLanguageId.call(this);
518
+ globalDefaults.salesChannelId = this.getNodeParameter('salesChannel', i);
519
+ customerData.firstName = guest.firstName;
520
+ customerData.lastName = guest.lastName;
521
+ customerData.email = guest.email;
522
+ customerData.salutationId = guest.salutation;
523
+ customerData.billingAddress = {
524
+ id: (0, utils_1.uuidv7)(),
525
+ countryId: guestBillingAddress.country,
526
+ firstName: guestBillingAddress.firstName,
527
+ lastName: guestBillingAddress.lastName,
528
+ city: guestBillingAddress.city,
529
+ street: guestBillingAddress.street,
530
+ };
531
+ customerData.shippingAddress = {
532
+ id: (0, utils_1.uuidv7)(),
533
+ countryId: guestShippingAddress.country,
534
+ firstName: guestShippingAddress.firstName,
535
+ lastName: guestShippingAddress.lastName,
536
+ city: guestShippingAddress.city,
537
+ street: guestShippingAddress.street,
538
+ };
539
+ orderCustomer = {
540
+ firstName: guest.firstName,
541
+ lastName: guest.lastName,
542
+ email: guest.email,
543
+ salutationId: guest.salutation,
544
+ customerNumber: 'guest-' + (0, n8n_workflow_1.randomString)(6),
545
+ };
546
+ }
547
+ const currencyData = this.getNodeParameter('currency', i).split('-');
548
+ const nodeLineItems = this.getNodeParameter('lineItems', i).lineItem;
549
+ if (!nodeLineItems || nodeLineItems.length === 0) {
550
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Missing order line items', {
551
+ description: 'At least one line item must be provided',
552
+ itemIndex: i,
553
+ });
554
+ }
555
+ const lineItems = await Promise.all(nodeLineItems.map(async (lineItem) => {
556
+ const { identifier, productId, label, states, unitPrice, taxRate } = await utils_1.getLineItemData.call(this, lineItem.productNumber, currencyData[0], i);
557
+ const quantity = lineItem.quantity;
558
+ const totalPrice = unitPrice * quantity;
559
+ const tax = totalPrice * (taxRate / 100);
560
+ const taxPrice = totalPrice + tax;
561
+ const price = {
562
+ unitPrice,
563
+ totalPrice,
564
+ quantity,
565
+ calculatedTaxes: [
566
+ {
567
+ tax,
568
+ taxRate,
569
+ price: taxPrice,
570
+ },
571
+ ],
572
+ taxRules: [
573
+ {
574
+ taxRate,
575
+ percentage: 100,
576
+ },
577
+ ],
578
+ };
579
+ return {
580
+ identifier,
581
+ productId,
582
+ quantity,
583
+ label,
584
+ states,
585
+ price,
586
+ };
587
+ }));
588
+ const defaultTaxRate = await utils_1.getDefaultTaxRate.call(this);
589
+ const totalPrice = lineItems.reduce((acc, item) => acc + item.price.totalPrice, 0);
590
+ const orderTax = totalPrice * (defaultTaxRate / 100);
591
+ const taxPrice = totalPrice + orderTax;
592
+ const quantity = lineItems.reduce((acc, item) => acc + item.quantity, 0);
593
+ const price = {
594
+ netPrice: totalPrice,
595
+ totalPrice: taxPrice,
596
+ calculatedTaxes: [
597
+ {
598
+ tax: orderTax,
599
+ taxRate: defaultTaxRate,
600
+ price: taxPrice,
601
+ },
602
+ ],
603
+ taxRules: [
604
+ {
605
+ taxRate: defaultTaxRate,
606
+ percentage: 100,
607
+ },
608
+ ],
609
+ positionPrice: totalPrice,
610
+ rawTotal: totalPrice,
611
+ taxStatus: 'gross',
612
+ };
613
+ let transactions = [];
614
+ const nodeTransactions = this.getNodeParameter('transactions', i).transaction;
615
+ if (nodeTransactions && nodeTransactions.length > 0) {
616
+ transactions = nodeTransactions.map((transaction) => {
617
+ const amount = {
618
+ unitPrice: totalPrice,
619
+ totalPrice: taxPrice,
620
+ quantity,
621
+ calculatedTaxes: [
622
+ {
623
+ tax: orderTax,
624
+ taxRate: defaultTaxRate,
625
+ price: taxPrice,
626
+ },
627
+ ],
628
+ taxRules: [
629
+ {
630
+ taxRate: defaultTaxRate,
631
+ percentage: 100,
632
+ },
633
+ ],
634
+ };
635
+ return {
636
+ paymentMethodId: transaction.paymentMethod,
637
+ stateId: transaction.state,
638
+ amount,
639
+ };
640
+ });
641
+ }
642
+ const addresses = [
643
+ {
644
+ id: customerData.shippingAddress.id,
645
+ countryId: customerData.shippingAddress.countryId,
646
+ firstName: customerData.shippingAddress.firstName,
647
+ lastName: customerData.shippingAddress.lastName,
648
+ city: customerData.shippingAddress.city,
649
+ street: customerData.shippingAddress.street,
650
+ },
651
+ ];
652
+ let deliveries = [];
653
+ const nodeDeliveries = this.getNodeParameter('deliveries', i).delivery;
654
+ if (nodeDeliveries && nodeDeliveries.length > 0) {
655
+ deliveries = await Promise.all(nodeDeliveries.map(async (delivery) => {
656
+ let shippingOrderAddressId;
657
+ if (delivery.customerShippingAddress) {
658
+ shippingOrderAddressId = addresses[0].id;
659
+ }
660
+ else {
661
+ const address = delivery.addressUi.addressValues;
662
+ if (!address) {
663
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Missing shipping address', {
664
+ description: 'A shipping address must be provided for the selected delivery if not using the customer one',
665
+ itemIndex: i,
666
+ });
667
+ }
668
+ for (const key in address) {
669
+ if (address[key] === '') {
670
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Missing required value for shipping address', {
671
+ description: `Shipping address ${key} must be a valid value.`,
672
+ itemIndex: i,
673
+ });
674
+ }
675
+ }
676
+ shippingOrderAddressId = (0, utils_1.uuidv7)();
677
+ addresses.push({
678
+ id: shippingOrderAddressId,
679
+ countryId: address.country,
680
+ firstName: address.firstName,
681
+ lastName: address.lastName,
682
+ city: address.city,
683
+ street: address.street,
684
+ });
685
+ }
686
+ const { ['unitPrice']: shippingPrice, ['taxRate']: shippingTaxRate } = await utils_1.getShippingMethodData.call(this, delivery.shippingMethod, currencyData[0]);
687
+ const deliveryTime = await utils_1.getShippingDeliveryTime.call(this, delivery.shippingMethod);
688
+ const shippingTax = shippingPrice * (shippingTaxRate / 100);
689
+ const shippingTaxPrice = shippingPrice + shippingTax;
690
+ const shippingCosts = {
691
+ unitPrice: shippingPrice,
692
+ totalPrice: shippingPrice,
693
+ quantity: 1,
694
+ calculatedTaxes: [
695
+ {
696
+ tax: shippingTax,
697
+ taxRate: shippingTaxRate,
698
+ price: shippingTaxPrice,
699
+ },
700
+ ],
701
+ taxRules: [
702
+ {
703
+ taxRate: shippingTaxRate,
704
+ percentage: 100,
705
+ },
706
+ ],
707
+ };
708
+ const shippingDateEarliest = new Date();
709
+ const shippingDateLatest = new Date();
710
+ switch (deliveryTime.unit) {
711
+ case 'hour':
712
+ shippingDateEarliest.setHours(shippingDateEarliest.getHours() + deliveryTime.min);
713
+ shippingDateLatest.setHours(shippingDateLatest.getHours() + deliveryTime.max);
714
+ break;
715
+ case 'day':
716
+ shippingDateEarliest.setDate(shippingDateEarliest.getDate() + deliveryTime.min);
717
+ shippingDateLatest.setDate(shippingDateLatest.getDate() + deliveryTime.max);
718
+ break;
719
+ case 'week':
720
+ shippingDateEarliest.setDate(shippingDateEarliest.getDate() + deliveryTime.min * 7);
721
+ shippingDateLatest.setDate(shippingDateLatest.getDate() + deliveryTime.max * 7);
722
+ break;
723
+ }
724
+ return {
725
+ shippingOrderAddressId,
726
+ shippingMethodId: delivery.shippingMethod,
727
+ stateId: delivery.state,
728
+ shippingDateEarliest,
729
+ shippingDateLatest,
730
+ shippingCosts,
731
+ };
732
+ }));
733
+ }
734
+ let shippingCosts;
735
+ if (deliveries.length === 0) {
736
+ const defaultShippingMethod = await utils_1.getDefaultShippingMethod.call(this);
737
+ const { ['unitPrice']: shippingPrice, ['taxRate']: shippingTaxRate } = await utils_1.getShippingMethodData.call(this, defaultShippingMethod, currencyData[0]);
738
+ const shippingTax = shippingPrice * (shippingTaxRate / 100);
739
+ const shippingTaxPrice = shippingPrice + shippingTax;
740
+ shippingCosts = {
741
+ unitPrice: shippingPrice,
742
+ totalPrice: shippingPrice,
743
+ quantity: 1,
744
+ calculatedTaxes: [
745
+ {
746
+ tax: shippingTax,
747
+ taxRate: shippingTaxRate,
748
+ price: shippingTaxPrice,
749
+ },
750
+ ],
751
+ taxRules: [
752
+ {
753
+ taxRate: shippingTaxRate,
754
+ percentage: 100,
755
+ },
756
+ ],
757
+ };
758
+ }
759
+ else {
760
+ const deliveriesUnitPrice = deliveries.reduce((acc, delivery) => acc + delivery.shippingCosts.unitPrice, 0);
761
+ const deliveriesTax = deliveries.reduce((acc, delivery) => acc + delivery.shippingCosts.calculatedTaxes[0].tax, 0);
762
+ const deliveriesTaxRate = deliveries[0].shippingCosts.taxRules[0].taxRate;
763
+ const deliveriesTaxPrice = deliveriesUnitPrice + deliveriesTax;
764
+ shippingCosts = {
765
+ unitPrice: deliveriesUnitPrice,
766
+ totalPrice: deliveriesUnitPrice,
767
+ quantity: 1,
768
+ calculatedTaxes: [
769
+ {
770
+ tax: deliveriesTax,
771
+ taxRate: deliveriesTaxRate,
772
+ price: deliveriesTaxPrice,
773
+ },
774
+ ],
775
+ taxRules: [
776
+ {
777
+ taxRate: deliveriesTaxRate,
778
+ percentage: 100,
779
+ },
780
+ ],
781
+ };
782
+ }
783
+ const parsedItemRounding = JSON.parse(currencyData[3]);
784
+ const itemRounding = {
785
+ decimals: parsedItemRounding.decimals,
786
+ interval: parsedItemRounding.interval,
787
+ roundForNet: parsedItemRounding.roundForNet,
788
+ };
789
+ const parsedTotalRounding = JSON.parse(currencyData[4]);
790
+ const totalRounding = {
791
+ decimals: parsedTotalRounding.decimals,
792
+ interval: parsedTotalRounding.interval,
793
+ roundForNet: parsedTotalRounding.roundForNet,
794
+ };
795
+ const serializedBillingAddress = {
796
+ id: customerData.billingAddress.id,
797
+ countryId: customerData.billingAddress.countryId,
798
+ firstName: customerData.billingAddress.firstName,
799
+ lastName: customerData.billingAddress.lastName,
800
+ city: customerData.billingAddress.city,
801
+ street: customerData.billingAddress.street,
802
+ };
803
+ const createBody = {
804
+ id: orderId,
805
+ currencyId: currencyData[0],
806
+ languageId: globalDefaults.languageId,
807
+ salesChannelId: globalDefaults.salesChannelId,
808
+ billingAddressId: customerData.billingAddress.id,
809
+ orderNumber: this.getNodeParameter('orderNumber', i),
810
+ orderDateTime: this.getNodeParameter('dateAndTime', i),
811
+ stateId: this.getNodeParameter('state', i),
812
+ currencyFactor: parseInt(currencyData[2]),
813
+ itemRounding,
814
+ totalRounding,
815
+ orderCustomer,
816
+ billingAddress: serializedBillingAddress,
817
+ lineItems,
818
+ price,
819
+ shippingCosts,
820
+ transactions,
821
+ deliveries,
822
+ addresses,
823
+ };
824
+ const searchBody = {
825
+ fields: fields_1.orderFields,
826
+ includes: {
827
+ order: fields_1.orderFields,
828
+ },
829
+ filter: [{ type: 'equals', field: 'id', value: orderId }],
830
+ };
831
+ for (const key in createBody) {
832
+ const typedKey = key;
833
+ if (Array.isArray(createBody[typedKey]) &&
834
+ createBody[typedKey].length === 0) {
835
+ delete createBody[typedKey];
836
+ }
837
+ else if (createBody[typedKey] === '') {
838
+ delete createBody[typedKey];
839
+ }
840
+ }
841
+ await transport_1.apiRequest.call(this, 'POST', `/order`, createBody);
842
+ const response = await transport_1.apiRequest.call(this, 'POST', `/search/order`, searchBody);
843
+ const executionData = this.helpers.constructExecutionMetaData((0, utils_1.wrapData)(response.data), {
844
+ itemData: { item: i },
845
+ });
846
+ returnData.push(...executionData);
847
+ }
848
+ catch (error) {
849
+ if (this.continueOnFail()) {
850
+ returnData.push({ json: { error: error.message } });
851
+ continue;
852
+ }
853
+ if (error instanceof n8n_workflow_1.NodeOperationError) {
854
+ throw error;
855
+ }
856
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
857
+ }
858
+ }
859
+ return returnData;
860
+ }
861
+ //# sourceMappingURL=create.operation.js.map