@longvansoftware/service-js-client 1.0.2

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 (84) hide show
  1. package/README.md +93 -0
  2. package/dist/config/config.d.ts +26 -0
  3. package/dist/config/config.js +29 -0
  4. package/dist/src/graphql/auth/mutations.d.ts +7 -0
  5. package/dist/src/graphql/auth/mutations.js +99 -0
  6. package/dist/src/graphql/auth/queries.d.ts +1 -0
  7. package/dist/src/graphql/auth/queries.js +25 -0
  8. package/dist/src/graphql/cloud/mutations.d.ts +8 -0
  9. package/dist/src/graphql/cloud/mutations.js +115 -0
  10. package/dist/src/graphql/cloud/queries.d.ts +5 -0
  11. package/dist/src/graphql/cloud/queries.js +121 -0
  12. package/dist/src/graphql/computing/mutations.d.ts +10 -0
  13. package/dist/src/graphql/computing/mutations.js +110 -0
  14. package/dist/src/graphql/computing/queries.d.ts +3 -0
  15. package/dist/src/graphql/computing/queries.js +48 -0
  16. package/dist/src/graphql/crm/mutations.d.ts +8 -0
  17. package/dist/src/graphql/crm/mutations.js +316 -0
  18. package/dist/src/graphql/crm/queries.d.ts +7 -0
  19. package/dist/src/graphql/crm/queries.js +281 -0
  20. package/dist/src/graphql/payment/mutations.d.ts +1 -0
  21. package/dist/src/graphql/payment/mutations.js +35 -0
  22. package/dist/src/graphql/payment/queries.d.ts +2 -0
  23. package/dist/src/graphql/payment/queries.js +23 -0
  24. package/dist/src/graphql/product/mutations.d.ts +0 -0
  25. package/dist/src/graphql/product/mutations.js +1 -0
  26. package/dist/src/graphql/product/queries.d.ts +11 -0
  27. package/dist/src/graphql/product/queries.js +431 -0
  28. package/dist/src/graphql/service/mutations.d.ts +10 -0
  29. package/dist/src/graphql/service/mutations.js +284 -0
  30. package/dist/src/graphql/service/queries.d.ts +6 -0
  31. package/dist/src/graphql/service/queries.js +174 -0
  32. package/dist/src/graphql/user/mutations.d.ts +4 -0
  33. package/dist/src/graphql/user/mutations.js +118 -0
  34. package/dist/src/graphql/user/queries.d.ts +13 -0
  35. package/dist/src/graphql/user/queries.js +252 -0
  36. package/dist/src/index.d.ts +1 -0
  37. package/dist/src/index.js +5 -0
  38. package/dist/src/lib/SDK.d.ts +42 -0
  39. package/dist/src/lib/SDK.js +71 -0
  40. package/dist/src/lib/auth/index.d.ts +27 -0
  41. package/dist/src/lib/auth/index.js +72 -0
  42. package/dist/src/lib/cloud/index.d.ts +25 -0
  43. package/dist/src/lib/cloud/index.js +248 -0
  44. package/dist/src/lib/computing/index.d.ts +25 -0
  45. package/dist/src/lib/computing/index.js +254 -0
  46. package/dist/src/lib/crm/index.d.ts +21 -0
  47. package/dist/src/lib/crm/index.js +296 -0
  48. package/dist/src/lib/order/index.d.ts +452 -0
  49. package/dist/src/lib/order/index.js +1204 -0
  50. package/dist/src/lib/payment/index.d.ts +7 -0
  51. package/dist/src/lib/payment/index.js +69 -0
  52. package/dist/src/lib/product/index.d.ts +37 -0
  53. package/dist/src/lib/product/index.js +132 -0
  54. package/dist/src/lib/service/index.d.ts +94 -0
  55. package/dist/src/lib/service/index.js +348 -0
  56. package/dist/src/lib/service.d.ts +14 -0
  57. package/dist/src/lib/service.js +101 -0
  58. package/dist/src/lib/serviceSDK.d.ts +18 -0
  59. package/dist/src/lib/serviceSDK.js +187 -0
  60. package/dist/src/lib/user/index.d.ts +23 -0
  61. package/dist/src/lib/user/index.js +345 -0
  62. package/dist/src/lib/warehouse/index.d.ts +20 -0
  63. package/dist/src/lib/warehouse/index.js +48 -0
  64. package/dist/src/types/auth.d.ts +82 -0
  65. package/dist/src/types/auth.js +2 -0
  66. package/dist/src/types/cloud.d.ts +40 -0
  67. package/dist/src/types/cloud.js +2 -0
  68. package/dist/src/types/computing.d.ts +16 -0
  69. package/dist/src/types/computing.js +2 -0
  70. package/dist/src/types/crm.d.ts +291 -0
  71. package/dist/src/types/crm.js +2 -0
  72. package/dist/src/types/order.d.ts +54 -0
  73. package/dist/src/types/order.js +2 -0
  74. package/dist/src/types/product.d.ts +63 -0
  75. package/dist/src/types/product.js +2 -0
  76. package/dist/src/types/service.d.ts +29 -0
  77. package/dist/src/types/service.js +2 -0
  78. package/dist/src/types/user.d.ts +95 -0
  79. package/dist/src/types/user.js +2 -0
  80. package/dist/src/types/warehouse.d.ts +5 -0
  81. package/dist/src/types/warehouse.js +2 -0
  82. package/dist/src/utils/helpers.d.ts +4 -0
  83. package/dist/src/utils/helpers.js +41 -0
  84. package/package.json +43 -0
@@ -0,0 +1,1204 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OrderService = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ /**
15
+ * Represents a service for managing orders.
16
+ */
17
+ class OrderService extends serviceSDK_1.Service {
18
+ /**
19
+ * Constructs a new OrderService instance.
20
+ * @param endpoint - The endpoint URL for the service.
21
+ * @param orgId - The organization ID.
22
+ * @param storeId - The store ID.
23
+ */
24
+ constructor(endpoint, orgId, storeId) {
25
+ super(endpoint, orgId, storeId);
26
+ }
27
+ setToken(token) {
28
+ this.token = token;
29
+ }
30
+ /**
31
+ * Creates a new order.
32
+ * @param orderData - The data for the order.
33
+ * @param platform - The platform for the order.
34
+ * @param createDraft - Indicates whether to create a draft order.
35
+ * @returns A promise that resolves with the created order.
36
+ * @throws If an error occurs while creating the order.
37
+ */
38
+ createOrder(orderData, platform, createDraft) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${platform}?create_draft=${createDraft}`; // Replace with your actual endpoint
41
+ const method = "POST";
42
+ try {
43
+ const response = yield this.restApiCallWithToken(endpoint, method, orderData);
44
+ return response;
45
+ }
46
+ catch (error) {
47
+ console.log(`Error in createOrder: ${error}`);
48
+ throw error;
49
+ }
50
+ });
51
+ }
52
+ /**
53
+ * Creates a temporary order.
54
+ *
55
+ * @param orderData - The data for the order.
56
+ * @param platform - The platform for the order.
57
+ * @returns A promise that resolves to the response from the server.
58
+ * @throws If an error occurs during the API call.
59
+ */
60
+ createOrderTemp(orderData, platform) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${platform}/temp`; // Replace with your actual endpoint
63
+ const method = "POST";
64
+ try {
65
+ const response = yield this.restApiCallWithToken(endpoint, method, orderData);
66
+ return response;
67
+ }
68
+ catch (error) {
69
+ console.log(`Error in createOrder: ${error}`);
70
+ throw error;
71
+ }
72
+ });
73
+ }
74
+ /**
75
+ * Completes multiple orders.
76
+ * @param orderIds - The IDs of the orders to complete.
77
+ * @returns A promise that resolves when the orders are completed.
78
+ * @throws If an error occurs while completing the orders.
79
+ */
80
+ completeOrder(orderIds) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/complete?order_ids=${orderIds.join(",")}`; // Replace with your actual endpoint
83
+ const method = "PUT";
84
+ try {
85
+ const response = yield this.restApiCallWithToken(endpoint, method);
86
+ return response;
87
+ }
88
+ catch (error) {
89
+ console.log(`Error in completeOrder: ${error}`);
90
+ throw error;
91
+ }
92
+ });
93
+ }
94
+ /**
95
+ * Adds a voucher to an order.
96
+ * @param orderId - The ID of the order.
97
+ * @param voucherCode - The voucher code.
98
+ * @returns A promise that resolves when the voucher is added.
99
+ * @throws If an error occurs while adding the voucher.
100
+ */
101
+ addVoucher(orderId, voucherCode) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ const endpoint = `/orders/${this.orgId}/${orderId}/voucher/${voucherCode}`;
104
+ const method = "POST";
105
+ try {
106
+ const response = yield this.restApiCallWithToken(endpoint, method);
107
+ return response;
108
+ }
109
+ catch (error) {
110
+ console.log(`Error in addVoucher: ${error}`);
111
+ throw error;
112
+ }
113
+ });
114
+ }
115
+ /**
116
+ * Removes a voucher from an order.
117
+ * @param orderId - The ID of the order.
118
+ * @param voucherCode - The voucher code.
119
+ * @returns A promise that resolves when the voucher is removed.
120
+ * @throws If an error occurs while removing the voucher.
121
+ */
122
+ removeVoucher(orderId, voucherCode) {
123
+ return __awaiter(this, void 0, void 0, function* () {
124
+ const endpoint = `/orders/${this.orgId}/${orderId}/voucher/${voucherCode}`;
125
+ const method = "DELETE";
126
+ try {
127
+ const response = yield this.restApiCallWithToken(endpoint, method);
128
+ return response;
129
+ }
130
+ catch (error) {
131
+ console.log(`Error in removeVoucher: ${error}`);
132
+ throw error;
133
+ }
134
+ });
135
+ }
136
+ /**
137
+ * Updates the VAT (Value Added Tax) for an order.
138
+ * @param orderId - The ID of the order.
139
+ * @param vatFee - The VAT fee.
140
+ * @param vatType - The VAT type. (e.g., VALUE_GOODS, PRODUCT, etc. )
141
+ * @returns A promise that resolves when the VAT is updated.
142
+ * @throws If an error occurs while updating the VAT.
143
+ */
144
+ updateVAT(orderId, vatFee, vatType) {
145
+ return __awaiter(this, void 0, void 0, function* () {
146
+ const endpoint = `/orders/${this.orgId}/${orderId}/vat?vat_fee=${vatFee}&vat_type=${vatType}`;
147
+ const method = "PUT";
148
+ try {
149
+ const response = yield this.restApiCallWithToken(endpoint, method);
150
+ return response;
151
+ }
152
+ catch (error) {
153
+ console.log(`Error in updateVAT: ${error}`);
154
+ throw error;
155
+ }
156
+ });
157
+ }
158
+ /**
159
+ * Updates the customer and shipping address for an order.
160
+ * @param orderId - The ID of the order.
161
+ * @param customerData - The data for the customer.
162
+ * @param shippingAddress - The shipping address.
163
+ * @returns A promise that resolves when the customer and shipping address are updated.
164
+ * @throws If an error occurs while updating the customer and shipping address.
165
+ */
166
+ updateCustomerAndShippingAddress(orderId, customerData, shippingAddress) {
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ const endpoint = `/orders/FOX/${orderId}/customer`;
169
+ const method = "PUT";
170
+ const requestData = {
171
+ customer: customerData,
172
+ shipping_address: shippingAddress,
173
+ };
174
+ try {
175
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
176
+ return response;
177
+ }
178
+ catch (error) {
179
+ console.log(`Error in updateCustomerAndShippingAddress: ${error}`);
180
+ throw error;
181
+ }
182
+ });
183
+ }
184
+ /**
185
+ * Retrieves the order line items for a specific order.
186
+ * @param partnerId - The partner ID.
187
+ * @returns A promise that resolves with the order line items.
188
+ * @throws If an error occurs while retrieving the order line items.
189
+ */
190
+ /**
191
+ * Adds order line items to an order.
192
+ * @param orderId - The ID of the order.
193
+ * @param lineItems - The line items to add.
194
+ * @returns A promise that resolves when the line items are added.
195
+ * @throws If an error occurs while adding the line items.
196
+ */
197
+ addOrderLineItems(orderId, lineItems) {
198
+ return __awaiter(this, void 0, void 0, function* () {
199
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/orderLineItem`;
200
+ const method = "POST";
201
+ try {
202
+ const response = yield this.restApiCallWithToken(endpoint, method, lineItems);
203
+ return response;
204
+ }
205
+ catch (error) {
206
+ console.log(`Error in addOrderLineItems: ${error}`);
207
+ throw error;
208
+ }
209
+ });
210
+ }
211
+ /**
212
+ * Update Quantity in an order
213
+ * @param orderId - The id of the order .
214
+ * @param orderItemId - The id of order item.
215
+ * @param quantity - Quantity of profuct in order.
216
+ * @returns A promise that resolves with the created order.
217
+ * @throws If an error occurs while creating the order.
218
+ */
219
+ updateQuantityProductInOrder(orderId, orderItemId, quantity) {
220
+ return __awaiter(this, void 0, void 0, function* () {
221
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/${orderItemId}/quantity?quantity_new=${quantity}`;
222
+ const method = "PUT";
223
+ try {
224
+ const response = yield this.restApiCallWithToken(endpoint, method);
225
+ return response;
226
+ }
227
+ catch (error) {
228
+ console.log(`Error in update quantity product in order: ${error}`);
229
+ throw error;
230
+ }
231
+ });
232
+ }
233
+ /**
234
+ *Updates sale Employee
235
+ * @param orderId - The ID of the order.
236
+ * @param saleId - The Id of saler.
237
+ * @param updatedBy - Who update.
238
+ * @returns A promise that resolves when the customer and shipping address are updated.
239
+ * @throws If an error occurs while updating the customer and shipping address.
240
+ */
241
+ updateSaleEmployee(orderId, saleId, updatedBy) {
242
+ return __awaiter(this, void 0, void 0, function* () {
243
+ const endpoint = `/orders/${this.orgId}/${orderId}/saleEmployee/${saleId}?updated_by=${updatedBy}`;
244
+ const method = "PUT";
245
+ try {
246
+ const response = yield this.restApiCallWithToken(endpoint, method);
247
+ return response;
248
+ }
249
+ catch (error) {
250
+ console.log(`Error in updateSaleEmployee: ${error}`);
251
+ throw error;
252
+ }
253
+ });
254
+ }
255
+ /**
256
+ *Update type of order
257
+ * @param orderId - The ID of the order.
258
+ * @param orderType - The type of order.
259
+ * @param updatedBy - Id of person update
260
+ * @returns A promise that resolves when the customer and shipping address are updated.
261
+ * @throws If an error occurs while updating the customer and shipping address.
262
+ */
263
+ updateOrderType(orderId, orderType, updatedBy) {
264
+ return __awaiter(this, void 0, void 0, function* () {
265
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/${orderType}?updated_by=${updatedBy}`;
266
+ const method = "PUT";
267
+ try {
268
+ const response = yield this.restApiCallWithToken(endpoint, method);
269
+ return response;
270
+ }
271
+ catch (error) {
272
+ console.log(`Error in updateOrderType: ${error}`);
273
+ throw error;
274
+ }
275
+ });
276
+ }
277
+ /**
278
+ * Update new price in order
279
+ * @param orderId - The ID of the order.
280
+ * @param orderItemId - The id of order.
281
+ * @param priceNew - the new price after update
282
+ * @returns A promise that resolves when the customer and shipping address are updated.
283
+ * @throws If an error occurs while updating the customer and shipping address.
284
+ */
285
+ updatePriceInOrder(orderId, orderItemId, priceNew) {
286
+ return __awaiter(this, void 0, void 0, function* () {
287
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/${orderItemId}/price?price_new=${priceNew}`;
288
+ const method = "PUT";
289
+ try {
290
+ const response = yield this.restApiCallWithToken(endpoint, method);
291
+ return response;
292
+ }
293
+ catch (error) {
294
+ console.log(`Error in updatePriceInOrder: ${error}`);
295
+ throw error;
296
+ }
297
+ });
298
+ }
299
+ /**
300
+ * Update discount price in order
301
+ * @param orderId - The ID of the order.
302
+ * @param orderItemId - The id of order.
303
+ * @param requestData - The request data
304
+ * @returns A promise that resolves when the customer and shipping address are updated.
305
+ * @throws If an error occurs while updating the customer and shipping address.
306
+ */
307
+ updateDiscountPriceInOrder(orderId, orderItemId, requestData) {
308
+ return __awaiter(this, void 0, void 0, function* () {
309
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/${orderItemId}/discount`;
310
+ const method = "PUT";
311
+ try {
312
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
313
+ return response;
314
+ }
315
+ catch (error) {
316
+ console.log(`Error in updateDiscountPriceInOrder: ${error}`);
317
+ throw error;
318
+ }
319
+ });
320
+ }
321
+ /**
322
+ * Update cancel order
323
+ * @param orderId - The ID of the order.
324
+ * @param requestData
325
+ * @returns A promise that resolves when the customer and shipping address are updated.
326
+ * @throws If an error occurs while updating the customer and shipping address.
327
+ */
328
+ updateCancelOrder(orderId, requestData) {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/cancel`;
331
+ const method = "PUT";
332
+ try {
333
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
334
+ return response;
335
+ }
336
+ catch (error) {
337
+ console.log(`Error in updateCancelOrder: ${error}`);
338
+ throw error;
339
+ }
340
+ });
341
+ }
342
+ /**
343
+ * Update status of return order
344
+ * @param orderId - The ID of the order.
345
+ * @param statusNew - the new status of order
346
+ * @param updatedBy - Id of person update
347
+ * @returns A promise that resolves when the customer and shipping address are updated.
348
+ * @throws If an error occurs while updating the customer and shipping address.
349
+ */
350
+ updateStatusReturnOrder(orderId, statusNew, updatedBy) {
351
+ return __awaiter(this, void 0, void 0, function* () {
352
+ const endpoint = `/orders/${this.orgId}/${orderId}/${statusNew}?updated_by=${updatedBy}`;
353
+ const method = "PUT";
354
+ try {
355
+ const response = yield this.restApiCallWithToken(endpoint, method);
356
+ return response;
357
+ }
358
+ catch (error) {
359
+ console.log(`Error in updateStatusReturnOrder: ${error}`);
360
+ throw error;
361
+ }
362
+ });
363
+ }
364
+ /**
365
+ * Update Shipping service
366
+ * @param orderId - The ID of the order.
367
+ * @param shippingServiceId - the id of shipping service
368
+ * @param updatedBy - Id of person update
369
+ * @returns A promise that resolves when the customer and shipping address are updated.
370
+ * @throws If an error occurs while updating the customer and shipping address.
371
+ */
372
+ updateShippngService(orderId, shippingServiceId, updatedBy) {
373
+ return __awaiter(this, void 0, void 0, function* () {
374
+ const endpoint = `/orders/${this.orgId}/${orderId}/${shippingServiceId}/shippingService?updated_by=${updatedBy}`;
375
+ const method = "PUT";
376
+ try {
377
+ const response = yield this.restApiCallWithToken(endpoint, method);
378
+ return response;
379
+ }
380
+ catch (error) {
381
+ console.log(`Error in updateShippngService: ${error}`);
382
+ throw error;
383
+ }
384
+ });
385
+ }
386
+ /**
387
+ * Update shipping order
388
+ * @param orderId - The ID of the order.
389
+ * @param shippingId - the id of shipping
390
+ * @returns A promise that resolves when the customer and shipping address are updated.
391
+ * @throws If an error occurs while updating the customer and shipping address.
392
+ */
393
+ updateShippingOrder(orderId, shippingId) {
394
+ return __awaiter(this, void 0, void 0, function* () {
395
+ const endpoint = `/orders/${this.orgId}/${orderId}/${shippingId}/orderShipping`;
396
+ const method = "PUT";
397
+ try {
398
+ const response = yield this.restApiCallWithToken(endpoint, method);
399
+ return response;
400
+ }
401
+ catch (error) {
402
+ console.log(`Error in updateShippingOrder: ${error}`);
403
+ throw error;
404
+ }
405
+ });
406
+ }
407
+ /**
408
+ * Update shipping fee
409
+ * @param orderId - The ID of the order.
410
+ * @param shippingFee - the fee of shipping
411
+ * @returns A promise that resolves when the customer and shipping address are updated.
412
+ * @throws If an error occurs while updating the customer and shipping address.
413
+ */
414
+ updateShippingFee(orderId, shipingFee) {
415
+ return __awaiter(this, void 0, void 0, function* () {
416
+ const endpoint = `/orders/${this.orgId}/${orderId}/${shipingFee}/shippingFee`;
417
+ const method = "PUT";
418
+ try {
419
+ const response = yield this.restApiCallWithToken(endpoint, method);
420
+ return response;
421
+ }
422
+ catch (error) {
423
+ console.log(`Error in updateShippingFee: ${error}`);
424
+ throw error;
425
+ }
426
+ });
427
+ }
428
+ /**
429
+ * Update Financial Status after payment success
430
+ * @param orderId - The ID of the order.
431
+ * @param financialStatus - the status of financial
432
+ * @param updatedBy - Id of person update
433
+ * @returns A promise that resolves when the customer and shipping address are updated.
434
+ * @throws If an error occurs while updating the customer and shipping address.
435
+ */
436
+ updateFinancialStatus(orderId, financialStatus, updatedBy) {
437
+ return __awaiter(this, void 0, void 0, function* () {
438
+ const endpoint = `/orders/${this.orgId}/${orderId}/${financialStatus}/financialStatus?updated_by=${updatedBy}`;
439
+ const method = "PUT";
440
+ try {
441
+ const response = yield this.restApiCallWithToken(endpoint, method);
442
+ return response;
443
+ }
444
+ catch (error) {
445
+ console.log(`Error in updateFinancialStatus: ${error}`);
446
+ throw error;
447
+ }
448
+ });
449
+ }
450
+ /**
451
+ * Update warehouse of order
452
+ * @param orderId - The ID of the order.
453
+ * @param warehouseId - the status of warehouse
454
+ * @returns A promise that resolves when the customer and shipping address are updated.
455
+ * @throws If an error occurs while updating the customer and shipping address.
456
+ */
457
+ updateWareHouseOrder(orderId, warehouseId) {
458
+ return __awaiter(this, void 0, void 0, function* () {
459
+ const endpoint = `/orders/${this.orgId}/${orderId}/warehouse/${warehouseId}`;
460
+ const method = "PUT";
461
+ try {
462
+ const response = yield this.restApiCallWithToken(endpoint, method);
463
+ return response;
464
+ }
465
+ catch (error) {
466
+ console.log(`Error in updateWareHouseOrder: ${error}`);
467
+ throw error;
468
+ }
469
+ });
470
+ }
471
+ /**
472
+ * Update voucher
473
+ * @param orderId - The ID of the order.
474
+ * @param voucherCode - the code of voucher
475
+ * @returns A promise that resolves when the customer and shipping address are updated.
476
+ * @throws If an error occurs while updating the customer and shipping address.
477
+ */
478
+ updateVoucher(orderId, voucherCode) {
479
+ return __awaiter(this, void 0, void 0, function* () {
480
+ const endpoint = `/orders/${this.orgId}/${orderId}/voucher/${voucherCode}`;
481
+ const method = "PUT";
482
+ try {
483
+ const response = yield this.restApiCallWithToken(endpoint, method);
484
+ return response;
485
+ }
486
+ catch (error) {
487
+ console.log(`Error in updateVoucher: ${error}`);
488
+ throw error;
489
+ }
490
+ });
491
+ }
492
+ /**
493
+ * Update Vat
494
+ * @param orderId - The ID of the order.
495
+ * @param vatFee - The fee of VAT
496
+ * @param vatType - The type of vat
497
+ * @returns A promise that resolves when the customer and shipping address are updated.
498
+ * @throws If an error occurs while updating the customer and shipping address.
499
+ */
500
+ updateVat(orderId, vatFee, vatType) {
501
+ return __awaiter(this, void 0, void 0, function* () {
502
+ const endpoint = `/orders/${this.orgId}/${orderId}/vat?vat_fee=${vatFee}&vat_type=${vatType}`;
503
+ const method = "PUT";
504
+ try {
505
+ const response = yield this.restApiCallWithToken(endpoint, method);
506
+ return response;
507
+ }
508
+ catch (error) {
509
+ console.log(`Error in updateVat: ${error}`);
510
+ throw error;
511
+ }
512
+ });
513
+ }
514
+ /**
515
+ * Update Status of l order
516
+ * @param orderId - The ID of the order.
517
+ * @param status - The status of sell order
518
+ * @returns A promise that resolves when the customer and shipping address are updated.
519
+ * @throws If an error occurs while updating the customer and shipping address.
520
+ */
521
+ updateStatusSellOrder(orderId, status) {
522
+ return __awaiter(this, void 0, void 0, function* () {
523
+ const endpoint = `/orders/${this.orgId}/${orderId}/status/${status}`;
524
+ const method = "PUT";
525
+ try {
526
+ const response = yield this.restApiCallWithToken(endpoint, method);
527
+ return response;
528
+ }
529
+ catch (error) {
530
+ console.log(`Error in updateStatusSellOrder: ${error}`);
531
+ throw error;
532
+ }
533
+ });
534
+ }
535
+ /**
536
+ * Update date remain in total price
537
+ * @param orderId - The ID of the order.
538
+ * @param updatedBy - Id of person update
539
+ * @returns A promise that resolves when the customer and shipping address are updated.
540
+ * @throws If an error occurs while updating the customer and shipping address.
541
+ */
542
+ updateRemainToTalPrice(orderId, updatedBy) {
543
+ return __awaiter(this, void 0, void 0, function* () {
544
+ const endpoint = `/orders/${this.orgId}/${orderId}/remainTotalPrice?updated_by=${updatedBy}`;
545
+ const method = "PUT";
546
+ try {
547
+ const response = yield this.restApiCallWithToken(endpoint, method);
548
+ return response;
549
+ }
550
+ catch (error) {
551
+ console.log(`Error in update updateRemainToTalPrice: ${error}`);
552
+ throw error;
553
+ }
554
+ });
555
+ }
556
+ /**
557
+ * Update date create order
558
+ * @param orderId - The ID of the order.
559
+ * @param orderDate - The date of order
560
+ * @param updatedBy - Id of person update
561
+ * @returns A promise that resolves when the customer and shipping address are updated.
562
+ * @throws If an error occurs while updating the customer and shipping address.
563
+ */
564
+ updateDateCreateOrder(orderId, orderDate, updatedBy) {
565
+ return __awaiter(this, void 0, void 0, function* () {
566
+ const endpoint = `/orders/${this.orgId}/${orderId}/order-date/${orderDate}?updated_by=${updatedBy}`;
567
+ const method = "PUT";
568
+ try {
569
+ const response = yield this.restApiCallWithToken(endpoint, method);
570
+ return response;
571
+ }
572
+ catch (error) {
573
+ console.log(`Error in updateDateCreateOrder:${error} `);
574
+ throw error;
575
+ }
576
+ });
577
+ }
578
+ /**
579
+ * Update membership discount
580
+ * @param orderId - The ID of the order.
581
+ * @param requestData
582
+ * @returns A promise that resolves when the customer and shipping address are updated.
583
+ * @throws If an error occurs while updating the customer and shipping address.
584
+ */
585
+ updateMemberDiscount(orderId, requestData) {
586
+ return __awaiter(this, void 0, void 0, function* () {
587
+ const endpoint = `/orders/${this.orgId}/${orderId}/memberDiscount`;
588
+ const method = "PUT";
589
+ try {
590
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
591
+ return response;
592
+ }
593
+ catch (error) {
594
+ console.log(`Error in updateMemberDiscount: ${error}`);
595
+ throw error;
596
+ }
597
+ });
598
+ }
599
+ /**
600
+ * Update status editable order
601
+ * @param orderId - The ID of the order.
602
+ * @param editable - The editable of
603
+ * @returns A promise that resolves when the customer and shipping address are updated.
604
+ * @throws If an error occurs while updating the customer and shipping address.
605
+ */
606
+ updateEditableOrder(orderId, editable) {
607
+ return __awaiter(this, void 0, void 0, function* () {
608
+ const endpoint = `/orders/${this.orgId}/${orderId}/editable/${editable}`;
609
+ const method = "PUT";
610
+ try {
611
+ const response = yield this.restApiCallWithToken(endpoint, method);
612
+ return response;
613
+ }
614
+ catch (error) {
615
+ console.log(`Error in updateEditableOrder: ${error}`);
616
+ throw error;
617
+ }
618
+ });
619
+ }
620
+ /**
621
+ * Update discount
622
+ * @param orderId - The ID of the order.
623
+ * @param requestData
624
+ * @returns A promise that resolves when the customer and shipping address are updated.
625
+ * @throws If an error occurs while updating the customer and shipping address.
626
+ */
627
+ updateDiscount(orderId, requestData) {
628
+ return __awaiter(this, void 0, void 0, function* () {
629
+ const endpoint = `/orders/${this.orgId}/${orderId}/discount`;
630
+ const method = "PUT";
631
+ try {
632
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
633
+ return response;
634
+ }
635
+ catch (error) {
636
+ console.log(`Error in updateDiscount: ${error}`);
637
+ throw error;
638
+ }
639
+ });
640
+ }
641
+ /**
642
+ * Update info campaign promotion
643
+ * @param orderId - The ID of the order.
644
+ * @param requestData
645
+ * @returns A promise that resolves when the customer and shipping address are updated.
646
+ * @throws If an error occurs while updating the customer and shipping address.
647
+ */
648
+ updateInfoCampaignPromotion(orderId, requestData) {
649
+ return __awaiter(this, void 0, void 0, function* () {
650
+ const endpoint = `/orders/${this.orgId}/${orderId}/campaign-promotion`;
651
+ const method = "PUT";
652
+ try {
653
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
654
+ return response;
655
+ }
656
+ catch (error) {
657
+ console.log(`Error in updateInfoCampaignPromotion: ${error}`);
658
+ throw error;
659
+ }
660
+ });
661
+ }
662
+ /**
663
+ * Get list shipping service
664
+ * @param shippingCarrierId - The ID of the campaign
665
+ * @returns A promise that resolves when the customer and shipping address are updated.
666
+ * @throws If an error occurs while updating the customer and shipping address.
667
+ */
668
+ getListShippingService(shippingCarrierId) {
669
+ return __awaiter(this, void 0, void 0, function* () {
670
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${shippingCarrierId}/shippingService`;
671
+ const method = "GET";
672
+ try {
673
+ const response = yield this.restApiCallWithToken(endpoint, method);
674
+ return response;
675
+ }
676
+ catch (error) {
677
+ console.log(`Error in getListShippingService: ${error}`);
678
+ throw error;
679
+ }
680
+ });
681
+ }
682
+ /**
683
+ * Get info sell order
684
+ * @param orderId - The ID of the order.
685
+ * @returns A promise that resolves when the customer and shipping address are updated.
686
+ * @throws If an error occurs while updating the customer and shipping address.
687
+ */
688
+ getInfoSellOrder(orderId) {
689
+ return __awaiter(this, void 0, void 0, function* () {
690
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/sell_order`;
691
+ const method = "GET";
692
+ try {
693
+ const res = yield this.restApiCallWithToken(endpoint, method);
694
+ return res;
695
+ }
696
+ catch (error) {
697
+ console.log(`Error in getInfoSellOrder: ${error}`);
698
+ throw error;
699
+ }
700
+ });
701
+ }
702
+ /**
703
+ * Get info return order
704
+ * @param orderId - The ID of the order.
705
+ * @returns A promise that resolves when the customer and shipping address are updated.
706
+ * @throws If an error occurs while updating the customer and shipping address.
707
+ */
708
+ getInfoReturnOrder(orderId) {
709
+ return __awaiter(this, void 0, void 0, function* () {
710
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/return_order`;
711
+ const method = "GET";
712
+ try {
713
+ const response = yield this.restApiCallWithToken(endpoint, method);
714
+ return response;
715
+ }
716
+ catch (error) {
717
+ console.log(`Error in getReturnOrder:${error}`);
718
+ throw error;
719
+ }
720
+ });
721
+ }
722
+ /**
723
+ * Get list type order
724
+ * @returns A promise that resolves when the customer and shipping address are updated.
725
+ * @throws If an error occurs while updating the customer and shipping address.
726
+ */
727
+ getListTypeOrder() {
728
+ return __awaiter(this, void 0, void 0, function* () {
729
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/type`;
730
+ const method = "GET";
731
+ try {
732
+ const response = yield this.restApiCallWithToken(endpoint, method);
733
+ return response;
734
+ }
735
+ catch (error) {
736
+ console.log(`Error in updateListTypeOrder`);
737
+ throw error;
738
+ }
739
+ });
740
+ }
741
+ /**
742
+ * GEt list shipping carrier
743
+ * @returns A promise that resolves when the customer and shipping address are updated.
744
+ * @throws If an error occurs while updating the customer and shipping address.
745
+ */
746
+ getListShippingCarrier() {
747
+ return __awaiter(this, void 0, void 0, function* () {
748
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/shippingCarrier`;
749
+ const method = "GET";
750
+ try {
751
+ const response = yield this.restApiCallWithToken(endpoint, method);
752
+ return response;
753
+ }
754
+ catch (error) {
755
+ console.log(`Error in updateListShippingCarrier:${error}`);
756
+ throw error;
757
+ }
758
+ });
759
+ }
760
+ /**
761
+ * Get list sell order
762
+ * @param orderId
763
+ * @param requestData
764
+ * @returns A promise that resolves when the customer and shipping address are updated.
765
+ * @throws If an error occurs while updating the customer and shipping address.
766
+ */
767
+ getListSellOrder(requestData) {
768
+ return __awaiter(this, void 0, void 0, function* () {
769
+ // Convert requestData to a format suitable for URLSearchParams
770
+ const params = new URLSearchParams(Object.entries(requestData).reduce((acc, [key, value]) => {
771
+ acc[key] = Array.isArray(value) ? value.join(",") : value.toString();
772
+ return acc;
773
+ }, {})).toString();
774
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/sell_order?${params}`;
775
+ const method = "GET";
776
+ try {
777
+ const response = yield this.restApiCallWithToken(endpoint, method);
778
+ return response;
779
+ }
780
+ catch (error) {
781
+ console.error(`Error in getListSellOrder: ${error}`);
782
+ throw error;
783
+ }
784
+ });
785
+ }
786
+ getDiaries(requestData) {
787
+ return __awaiter(this, void 0, void 0, function* () {
788
+ // Convert requestData to a format suitable for URLSearchParams
789
+ const params = new URLSearchParams(Object.entries(requestData).reduce((acc, [key, value]) => {
790
+ acc[key] = Array.isArray(value) ? value.join(",") : value.toString();
791
+ return acc;
792
+ }, {})).toString();
793
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/diaries?${params}`;
794
+ const method = "GET";
795
+ try {
796
+ const response = yield this.restApiCallWithToken(endpoint, method);
797
+ return response;
798
+ }
799
+ catch (error) {
800
+ console.error(`Error in getListSellOrder: ${error}`);
801
+ throw error;
802
+ }
803
+ });
804
+ }
805
+ /**
806
+ * Get list sale order status
807
+ * @returns A promise that resolves when the customer and shipping address are updated.
808
+ * @throws If an error occurs while updating the customer and shipping address.
809
+ */
810
+ getListSaleOrderStatus() {
811
+ return __awaiter(this, void 0, void 0, function* () {
812
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/saleOrderStatus`;
813
+ const method = "GET";
814
+ try {
815
+ const response = yield this.restApiCallWithToken(endpoint, method);
816
+ return response;
817
+ }
818
+ catch (error) {
819
+ console.log(`Error in getListSaleOrderStatus:${error}`);
820
+ throw error;
821
+ }
822
+ });
823
+ }
824
+ /**
825
+ * Get list return order
826
+ * @param orderId - The id of the order
827
+ * @param requestData
828
+ * @returns A promise that resolves when the customer and shipping address are updated.
829
+ * @throws If an error occurs while updating the customer and shipping address.
830
+ */
831
+ getListReturnOrder(orderId, requestData) {
832
+ return __awaiter(this, void 0, void 0, function* () {
833
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/return_order`;
834
+ const method = "GET";
835
+ try {
836
+ const response = yield this.restApiCallWithToken(endpoint, method);
837
+ return response;
838
+ }
839
+ catch (error) {
840
+ console.log(`Error in getListReturnOrder: ${error}`);
841
+ throw error;
842
+ }
843
+ });
844
+ }
845
+ /**
846
+ * Get list return order status
847
+ * @returns A promise that resolves when the customer and shipping address are updated.
848
+ * @throws If an error occurs while updating the customer and shipping address.
849
+ */
850
+ getListReturnOrderStatus() {
851
+ return __awaiter(this, void 0, void 0, function* () {
852
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/returnOrderStatus`;
853
+ const method = "GET";
854
+ try {
855
+ const response = yield this.restApiCallWithToken(endpoint, method);
856
+ return response;
857
+ }
858
+ catch (error) {
859
+ console.log(`Error in getListReturnOrderStatus: ${error}`);
860
+ throw error;
861
+ }
862
+ });
863
+ }
864
+ /**
865
+ * remove draft order
866
+ * @param orderId - The id of order
867
+ * @param updatedBy - Thi id of person update
868
+ * @returns A promise that resolves when the customer and shipping address are updated.
869
+ * @throws If an error occurs while updating the customer and shipping address.
870
+ */
871
+ removeDraftOrder(orderId, updatedBy) {
872
+ return __awaiter(this, void 0, void 0, function* () {
873
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/draft?updated_by=${updatedBy}`;
874
+ const method = "DELETE";
875
+ try {
876
+ const response = yield this.restApiCallWithToken(endpoint, method);
877
+ return response;
878
+ }
879
+ catch (error) {
880
+ console.log(`Error in removeDraftOrder: ${error}`);
881
+ throw error;
882
+ }
883
+ });
884
+ }
885
+ /**
886
+ * Cancel product in order
887
+ * @param orderId - The id of order
888
+ * @param orderItemId - Thi id of item order
889
+ * @param reason - The reason of cancel product in order
890
+ * @returns A promise that resolves when the customer and shipping address are updated.
891
+ * @throws If an error occurs while updating the customer and shipping address.
892
+ */
893
+ cancelProductInOrder(orderId, orderItemId, reason) {
894
+ return __awaiter(this, void 0, void 0, function* () {
895
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/${orderItemId}?reason=${reason}`;
896
+ const method = "DELETE";
897
+ try {
898
+ const response = yield this.restApiCallWithToken(endpoint, method);
899
+ return response;
900
+ }
901
+ catch (error) {
902
+ console.log(`Error in removeProductInOrder: ${error}`);
903
+ throw error;
904
+ }
905
+ });
906
+ }
907
+ /**
908
+ * Remove Product in order
909
+ * @param orderId - The id of order
910
+ * @param orderItemId - Thi id of item order
911
+ * @param reason - The reason of cancel product in order
912
+ * @returns A promise that resolves when the customer and shipping address are updated.
913
+ * @throws If an error occurs while updating the customer and shipping address.
914
+ */
915
+ removeProductInOrder(orderId, orderItemId, reason) {
916
+ return __awaiter(this, void 0, void 0, function* () {
917
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/${orderItemId}/delete?reason=${reason}`;
918
+ const method = "DELETE";
919
+ try {
920
+ const response = yield this.restApiCallWithToken(endpoint, method);
921
+ return response;
922
+ }
923
+ catch (error) {
924
+ console.log(`Error in removeProductInOrder: ${error}`);
925
+ throw error;
926
+ }
927
+ });
928
+ }
929
+ /**
930
+ * Print order pdf
931
+ * @param orderId - The id of order
932
+ * @param paymentMethod - Thi id of item order
933
+ * @returns A promise that resolves when the customer and shipping address are updated.
934
+ * @throws If an error occurs while updating the customer and shipping address.
935
+ */
936
+ printOrderPdf(orderId, paymentMethod) {
937
+ return __awaiter(this, void 0, void 0, function* () {
938
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/print.pdf?payment_method=${paymentMethod}`;
939
+ const method = "POST";
940
+ try {
941
+ const response = yield this.restApiCallWithToken(endpoint, method);
942
+ console.log(response);
943
+ return response;
944
+ }
945
+ catch (error) {
946
+ console.log(`Error in printOrderPdf: ${error}`);
947
+ throw error;
948
+ }
949
+ });
950
+ }
951
+ /**
952
+ * Print order HTML
953
+ * @param orderId - The id of order
954
+ * @param paymentMethod - Thi id of item order
955
+ * @returns A promise that resolves when the customer and shipping address are updated.
956
+ * @throws If an error occurs while updating the customer and shipping address.
957
+ */
958
+ printOrderHtml(orderId, paymentMethod) {
959
+ return __awaiter(this, void 0, void 0, function* () {
960
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/print.html?payment_method=${paymentMethod}`;
961
+ const method = "POST";
962
+ try {
963
+ const response = yield this.restApiCallWithToken(endpoint, method);
964
+ return response;
965
+ }
966
+ catch (error) {
967
+ console.log(`Error in printOrderHtml: ${error}`);
968
+ throw error;
969
+ }
970
+ });
971
+ }
972
+ /**
973
+ * Create an orderReturn
974
+ * @param orderData - The id of order
975
+ * @returns A promise that resolves when the customer and shipping address are updated.
976
+ * @throws If an error occurs while updating the customer and shipping address.
977
+ */
978
+ createOrderReturn(orderData) {
979
+ return __awaiter(this, void 0, void 0, function* () {
980
+ const endpoint = `/orders/${this.orgId}/order_return`;
981
+ const method = "POST";
982
+ try {
983
+ const response = yield this.restApiCallWithToken(endpoint, method, orderData);
984
+ return response;
985
+ }
986
+ catch (error) {
987
+ console.log(`Error in createOrderReturn: ${error}`);
988
+ throw error;
989
+ }
990
+ });
991
+ }
992
+ /**
993
+ * Caculate the order
994
+ * @param orderData - The data from the order
995
+ * @returns A promise that resolves when the customer and shipping address are updated.
996
+ * @throws If an error occurs while updating the customer and shipping address.
997
+ */
998
+ calculateOrder(orderData) {
999
+ return __awaiter(this, void 0, void 0, function* () {
1000
+ const endpoint = `/orders/${this.orgId}/calculate`;
1001
+ const method = "POST";
1002
+ try {
1003
+ const response = yield this.restApiCallWithToken(endpoint, method, orderData);
1004
+ return response;
1005
+ }
1006
+ catch (error) {
1007
+ console.log(`Error in calculateOrder: ${error}`);
1008
+ throw error;
1009
+ }
1010
+ });
1011
+ }
1012
+ /**
1013
+ * get amount product able order
1014
+ * @param productIds - The id of product
1015
+ * @returns A prom that resolves when the customer and shipping address are updated.
1016
+ * @throws If an error occurs while updating the customer and shipping address.
1017
+ */
1018
+ getQuantityAbleOrder(productIds) {
1019
+ return __awaiter(this, void 0, void 0, function* () {
1020
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/quantity-future-able?product_ids=${productIds}`;
1021
+ const method = "POST";
1022
+ try {
1023
+ const response = yield this.restApiCallWithToken(endpoint, method);
1024
+ return response;
1025
+ }
1026
+ catch (error) {
1027
+ console.log(`Error in getQuantityAbleOrder: ${error}`);
1028
+ throw error;
1029
+ }
1030
+ });
1031
+ }
1032
+ /**
1033
+ * updatee note without login
1034
+ * @param orderId - The id of the order
1035
+ * @param noteId - The id of the note
1036
+ * @param note - The content of the note
1037
+ * @returns A prom that resolves when the customer and shipping address are updated.
1038
+ * @throws If an error occurs while updating the customer and shipping address.
1039
+ */
1040
+ updateNoteWithoutLogin(orderId, noteId, note) {
1041
+ return __awaiter(this, void 0, void 0, function* () {
1042
+ const endpoint = `/front/orders/${this.orgId}/${this.storeId}/${orderId}/${noteId}/note`;
1043
+ const method = "PUT";
1044
+ try {
1045
+ const response = yield this.restApiCallWithToken(endpoint, method, note);
1046
+ return response;
1047
+ }
1048
+ catch (error) {
1049
+ console.log(`Error in updateNoteWithout:${error}`);
1050
+ throw error;
1051
+ }
1052
+ });
1053
+ }
1054
+ /**
1055
+ * add voucher without login
1056
+ * @param orderId - The id of the order
1057
+ * @param voucherCode - The code of voucher
1058
+ * @param updatedBy
1059
+ * @returns A prom that resolves when the customer and shipping address are updated.
1060
+ * @throws If an error occurs while updating the customer and shipping address.
1061
+ */
1062
+ addVoucherWithoutLogin(orderId, voucherCode, updatedBy) {
1063
+ return __awaiter(this, void 0, void 0, function* () {
1064
+ const endpoint = `/front/orders/${this.orgId}/${orderId}/voucher/${voucherCode}?updated_by=${updatedBy}`;
1065
+ const method = "POST";
1066
+ try {
1067
+ const response = yield this.restApiCallWithToken(endpoint, method);
1068
+ return response;
1069
+ }
1070
+ catch (error) {
1071
+ console.log(`Error in addVoucherWithout: ${error}`);
1072
+ throw error;
1073
+ }
1074
+ });
1075
+ }
1076
+ /**
1077
+ * delete voucher without login
1078
+ * @param orderId - The id of the order
1079
+ * @param voucherCode - The code of voucher
1080
+ * @param updatedBy
1081
+ * @returns A prom that resolves when the customer and shipping address are updated.
1082
+ * @throws If an error occurs while updating the customer and shipping address.
1083
+ */
1084
+ deleteVoucherLogin(orderId, voucherCode, updatedBy) {
1085
+ return __awaiter(this, void 0, void 0, function* () {
1086
+ const endpoint = `/front/orders/${this.orgId}/${orderId}/voucher/${voucherCode}?updatedBy=${updatedBy}`;
1087
+ const method = "DELETE";
1088
+ try {
1089
+ const response = yield this.restApiCallWithToken(endpoint, method);
1090
+ return response;
1091
+ }
1092
+ catch (error) {
1093
+ console.log(`Error in deleteVoucher: ${error}`);
1094
+ throw error;
1095
+ }
1096
+ });
1097
+ }
1098
+ /**
1099
+ * get list note without login
1100
+ * @param orderId - The id of the order
1101
+ * @returns A prom that resolves when the customer and shipping address are updated.
1102
+ * @throws If an error occurs while updating the customer and shipping address.
1103
+ */
1104
+ getListNoteWithoutLogin(orderId) {
1105
+ return __awaiter(this, void 0, void 0, function* () {
1106
+ const endpoint = `/front/orders/${this.orgId}/${this.storeId}/${orderId}/note`;
1107
+ const method = "GET";
1108
+ try {
1109
+ const response = yield this.restApiCallWithToken(endpoint, method);
1110
+ return response;
1111
+ }
1112
+ catch (error) {
1113
+ console.log(`Error in getListNoteWithoutLogin:${error}`);
1114
+ throw error;
1115
+ }
1116
+ });
1117
+ }
1118
+ /**
1119
+ * create note without login
1120
+ * @param orderId - The id of the order
1121
+ * @param createdBy
1122
+ * @param note
1123
+ * @returns A prom that resolves when the customer and shipping address are updated.
1124
+ * @throws If an error occurs while updating the customer and shipping address.
1125
+ */
1126
+ createNoteWithoutLogin(orderId, createdBy, note) {
1127
+ return __awaiter(this, void 0, void 0, function* () {
1128
+ const endpoint = `/front/orders/${this.orgId}/${this.storeId}/${orderId}/note?created_by=${createdBy}`;
1129
+ const method = "POST";
1130
+ try {
1131
+ const response = yield this.restApiCallWithToken(endpoint, method, note);
1132
+ return response;
1133
+ }
1134
+ catch (error) {
1135
+ console.log(`Error in createNoteWithoutLogin: ${error}`);
1136
+ throw error;
1137
+ }
1138
+ });
1139
+ }
1140
+ /**
1141
+ * get list order realation
1142
+ * @param orderIds
1143
+ * @returns A prom that resolves when the customer and shipping address are updated.
1144
+ * @throws If an error occurs while updating the customer and shipping address.
1145
+ */
1146
+ getListOrderRelationsWithoutLogin(orderIds) {
1147
+ return __awaiter(this, void 0, void 0, function* () {
1148
+ const endpoint = `/front/orders/${this.orgId}/${this.storeId}/relations?order_ids=${orderIds.join()}`;
1149
+ const method = "GET";
1150
+ try {
1151
+ const response = yield this.restApiCallWithToken(endpoint, method);
1152
+ return response;
1153
+ }
1154
+ catch (error) {
1155
+ console.log(`Error in getListOrderRelationsWithoutLogin: ${error}`);
1156
+ throw error;
1157
+ }
1158
+ });
1159
+ }
1160
+ /**
1161
+ * get list order realation
1162
+ * @param orderId - The id of order
1163
+ * @param noteId - The id of note
1164
+ * @param deletedBy - The id of person delete
1165
+ * @returns A prom that resolves when the customer and shipping address are updated.
1166
+ * @throws If an error occurs while updating the customer and shipping address.
1167
+ */
1168
+ deleteNoteWithoutLogin(orderId, noteId, deletedBy) {
1169
+ return __awaiter(this, void 0, void 0, function* () {
1170
+ const endpoint = `/front/orders/${this.orgId}/${this.storeId}/${orderId}/${noteId}?deleted_by=${deletedBy}`;
1171
+ const method = "DELETE";
1172
+ try {
1173
+ const response = yield this.restApiCallWithToken(endpoint, method);
1174
+ return response;
1175
+ }
1176
+ catch (error) {
1177
+ console.log(`Error in deleteNoteWithoutLogin: ${error}`);
1178
+ throw error;
1179
+ }
1180
+ });
1181
+ }
1182
+ updateOrderDescription(orderId, description) {
1183
+ return __awaiter(this, void 0, void 0, function* () {
1184
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/description`;
1185
+ const method = "PUT";
1186
+ try {
1187
+ const response = yield this.restApiCallWithToken(endpoint, method, description, {
1188
+ 'Content-Type': 'text/plain'
1189
+ });
1190
+ return response;
1191
+ }
1192
+ catch (error) {
1193
+ console.log(`Error in updateOrderDescription: ${error}`);
1194
+ throw error;
1195
+ }
1196
+ });
1197
+ }
1198
+ getOrderDetail(orderId) {
1199
+ return __awaiter(this, void 0, void 0, function* () {
1200
+ return this.restApiCallWithToken(`/orders/${this.orgId}/${this.storeId}/${orderId}/sale_order`, 'GET');
1201
+ });
1202
+ }
1203
+ }
1204
+ exports.OrderService = OrderService;