washday-sdk 1.1.9 → 1.2.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 (114) hide show
  1. package/dist/api/attendance/get.js +4 -5
  2. package/dist/api/attendance/post.js +2 -3
  3. package/dist/api/attendance/put.js +1 -2
  4. package/dist/api/auth/post.js +13 -14
  5. package/dist/api/axiosInstance.js +47 -36
  6. package/dist/api/cashierbox/delete.js +2 -3
  7. package/dist/api/cashups/delete.js +1 -2
  8. package/dist/api/cashups/get.js +3 -4
  9. package/dist/api/cashups/post.js +1 -2
  10. package/dist/api/cashups/put.js +2 -2
  11. package/dist/api/cfdi/delete.js +1 -2
  12. package/dist/api/cfdi/get.js +6 -7
  13. package/dist/api/cfdi/post.js +2 -3
  14. package/dist/api/cfdi/put.js +2 -2
  15. package/dist/api/csv/get.js +13 -14
  16. package/dist/api/customers/delete.js +2 -3
  17. package/dist/api/customers/get.js +6 -6
  18. package/dist/api/customers/put.js +2 -3
  19. package/dist/api/discounts/get.js +7 -8
  20. package/dist/api/discounts/post.js +2 -3
  21. package/dist/api/discounts/put.js +4 -5
  22. package/dist/api/index.js +4 -1
  23. package/dist/api/inventory/get.js +1 -1
  24. package/dist/api/order/delete.js +2 -3
  25. package/dist/api/order/get.js +8 -9
  26. package/dist/api/order/post.js +7 -8
  27. package/dist/api/order/put.js +13 -14
  28. package/dist/api/outsourcedOrders/delete.js +1 -2
  29. package/dist/api/outsourcedOrders/get.js +3 -4
  30. package/dist/api/outsourcedOrders/post.js +1 -2
  31. package/dist/api/outsourcedOrders/put.js +1 -2
  32. package/dist/api/partners/delete.js +1 -2
  33. package/dist/api/partners/get.js +2 -3
  34. package/dist/api/partners/post.js +1 -2
  35. package/dist/api/partners/put.js +1 -2
  36. package/dist/api/pdf/get.js +1 -2
  37. package/dist/api/products/delete.js +2 -2
  38. package/dist/api/products/get.js +1 -2
  39. package/dist/api/products/put.js +1 -1
  40. package/dist/api/publics/get.js +1 -2
  41. package/dist/api/reports/get.js +15 -16
  42. package/dist/api/reviews/delete.js +1 -1
  43. package/dist/api/reviews/get.js +2 -3
  44. package/dist/api/reviews/post.js +1 -1
  45. package/dist/api/reviews/put.js +2 -2
  46. package/dist/api/routes/delete.js +1 -2
  47. package/dist/api/routes/get.js +5 -6
  48. package/dist/api/routes/post.js +3 -4
  49. package/dist/api/routes/put.js +3 -4
  50. package/dist/api/sections/delete.js +1 -2
  51. package/dist/api/sections/get.js +3 -4
  52. package/dist/api/sections/put.js +1 -2
  53. package/dist/api/staff/get.js +1 -1
  54. package/dist/api/stripe/post.js +1 -1
  55. package/dist/api/supplies/get.js +1 -1
  56. package/dist/api/users/post.js +1 -2
  57. package/package.json +1 -1
  58. package/src/api/attendance/get.ts +4 -4
  59. package/src/api/attendance/post.ts +2 -2
  60. package/src/api/attendance/put.ts +1 -1
  61. package/src/api/auth/post.ts +13 -13
  62. package/src/api/axiosInstance.ts +51 -40
  63. package/src/api/cashierbox/delete.ts +2 -2
  64. package/src/api/cashups/delete.ts +1 -1
  65. package/src/api/cashups/get.ts +3 -3
  66. package/src/api/cashups/post.ts +1 -1
  67. package/src/api/cashups/put.ts +2 -2
  68. package/src/api/cfdi/delete.ts +1 -1
  69. package/src/api/cfdi/get.ts +6 -6
  70. package/src/api/cfdi/post.ts +2 -2
  71. package/src/api/cfdi/put.ts +2 -2
  72. package/src/api/csv/get.ts +13 -13
  73. package/src/api/customers/delete.ts +2 -2
  74. package/src/api/customers/get.ts +6 -6
  75. package/src/api/customers/put.ts +2 -2
  76. package/src/api/discounts/get.ts +7 -7
  77. package/src/api/discounts/post.ts +2 -2
  78. package/src/api/discounts/put.ts +4 -4
  79. package/src/api/index.ts +4 -2
  80. package/src/api/inventory/get.ts +1 -1
  81. package/src/api/order/delete.ts +2 -2
  82. package/src/api/order/get.ts +8 -8
  83. package/src/api/order/post.ts +7 -7
  84. package/src/api/order/put.ts +13 -13
  85. package/src/api/outsourcedOrders/delete.ts +1 -1
  86. package/src/api/outsourcedOrders/get.ts +3 -3
  87. package/src/api/outsourcedOrders/post.ts +1 -1
  88. package/src/api/outsourcedOrders/put.ts +1 -1
  89. package/src/api/partners/delete.ts +1 -1
  90. package/src/api/partners/get.ts +2 -2
  91. package/src/api/partners/post.ts +1 -1
  92. package/src/api/partners/put.ts +1 -1
  93. package/src/api/pdf/get.ts +1 -1
  94. package/src/api/products/delete.ts +2 -2
  95. package/src/api/products/get.ts +1 -1
  96. package/src/api/products/put.ts +1 -1
  97. package/src/api/publics/get.ts +1 -1
  98. package/src/api/reports/get.ts +15 -15
  99. package/src/api/reviews/delete.ts +1 -1
  100. package/src/api/reviews/get.ts +2 -2
  101. package/src/api/reviews/post.ts +1 -1
  102. package/src/api/reviews/put.ts +2 -2
  103. package/src/api/routes/delete.ts +1 -1
  104. package/src/api/routes/get.ts +5 -5
  105. package/src/api/routes/post.ts +3 -3
  106. package/src/api/routes/put.ts +3 -3
  107. package/src/api/sections/delete.ts +1 -1
  108. package/src/api/sections/get.ts +3 -3
  109. package/src/api/sections/put.ts +1 -1
  110. package/src/api/staff/get.ts +1 -1
  111. package/src/api/stripe/post.ts +1 -1
  112. package/src/api/supplies/get.ts +1 -1
  113. package/src/api/users/post.ts +1 -1
  114. package/src/interfaces/Api.ts +3 -0
@@ -30,7 +30,7 @@
30
30
  // const config = {
31
31
  // headers: { Authorization: `Bearer ${this.apiToken}` }
32
32
  // };
33
- // return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
33
+ // return await this.axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
34
34
  // } catch (error) {
35
35
  // console.error('Error fetching updateById:', error);
36
36
  // throw error;
@@ -45,7 +45,7 @@
45
45
  // const config = {
46
46
  // headers: { Authorization: `Bearer ${this.apiToken}` }
47
47
  // };
48
- // return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
48
+ // return await this.axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
49
49
  // } catch (error) {
50
50
  // console.error('Error fetching updateById:', error);
51
51
  // throw error;
@@ -29,7 +29,7 @@ export const exportCustomersList = async function (this: WashdayClientInstance,
29
29
  }
30
30
  };
31
31
  const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum', 'createdIn'], params)
32
- return await axiosInstance.get(`${GENERATE_EXPORT}/export-all-customers?${queryParams}`, config);
32
+ return await this.axiosInstance.get(`${GENERATE_EXPORT}/export-all-customers?${queryParams}`, config);
33
33
  } catch (error) {
34
34
  console.error('Error fetching exportCustomersList:', error);
35
35
  throw error;
@@ -81,7 +81,7 @@ export const exportOrdersList = async function (this: WashdayClientInstance, par
81
81
  'collectedDateTime',
82
82
  'q'
83
83
  ], params);
84
- return await axiosInstance.get(`${GENERATE_EXPORT}/export-all-orders?${queryParams}`, config);
84
+ return await this.axiosInstance.get(`${GENERATE_EXPORT}/export-all-orders?${queryParams}`, config);
85
85
  } catch (error) {
86
86
  console.error('Error fetching exportOrdersList:', error);
87
87
  throw error;
@@ -100,7 +100,7 @@ export const exportProductsList = async function (this: WashdayClientInstance, s
100
100
  responseType: 'blob'
101
101
  }
102
102
  };
103
- return await axiosInstance.get(`api/product/${storeId}/export`, config);
103
+ return await this.axiosInstance.get(`api/product/${storeId}/export`, config);
104
104
  } catch (error) {
105
105
  console.error('Error fetching exportProductsList:', error);
106
106
  throw error;
@@ -128,7 +128,7 @@ export const exportCleanedOrdersReport = async function (this: WashdayClientInst
128
128
  'toDate',
129
129
  'timezone'
130
130
  ], params);
131
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders/export?${queryParams}`, config);
131
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders/export?${queryParams}`, config);
132
132
  } catch (error) {
133
133
  console.error('Error fetching exportOrdersList:', error);
134
134
  throw error;
@@ -158,7 +158,7 @@ export const exportSalesReport = async function (this: WashdayClientInstance, st
158
158
  'timezone',
159
159
  'type'
160
160
  ], params);
161
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales/export?${queryParams}`, config);
161
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales/export?${queryParams}`, config);
162
162
  } catch (error) {
163
163
  console.error('Error fetching exportOrdersList:', error);
164
164
  throw error;
@@ -184,7 +184,7 @@ export const exportCustomersReport = async function (this: WashdayClientInstance
184
184
  'fromDate',
185
185
  'toDate',
186
186
  ], params);
187
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/customers/export?${queryParams}`, config);
187
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/customers/export?${queryParams}`, config);
188
188
  } catch (error) {
189
189
  console.error('Error fetching exportCustomersReport:', error);
190
190
  throw error;
@@ -210,7 +210,7 @@ export const exportSuppliesReport = async function (this: WashdayClientInstance,
210
210
  'fromDate',
211
211
  'toDate',
212
212
  ], params);
213
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/supplies/export?${queryParams}`, config);
213
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/supplies/export?${queryParams}`, config);
214
214
  } catch (error) {
215
215
  console.error('Error fetching exportCustomersReport:', error);
216
216
  throw error;
@@ -231,7 +231,7 @@ export const exportDiscountCodesReport = async function (this: WashdayClientInst
231
231
  };
232
232
  const queryParams = generateQueryParamsStr([
233
233
  ], params);
234
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/discountCodes/export?${queryParams}`, config);
234
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/discountCodes/export?${queryParams}`, config);
235
235
  } catch (error) {
236
236
  console.error('Error fetching exportCustomersReport:', error);
237
237
  throw error;
@@ -257,7 +257,7 @@ export const exportStaffReport = async function (this: WashdayClientInstance, st
257
257
  'fromDate',
258
258
  'toDate',
259
259
  ], params);
260
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/staff/export?${queryParams}`, config);
260
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/staff/export?${queryParams}`, config);
261
261
  } catch (error) {
262
262
  console.error('Error fetching exportCustomersReport:', error);
263
263
  throw error;
@@ -286,7 +286,7 @@ export const exportProductSalesReport = async function (this: WashdayClientInsta
286
286
  'toDate',
287
287
  'timezone'
288
288
  ], params);
289
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/productSales/export?${queryParams}`, config);
289
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/productSales/export?${queryParams}`, config);
290
290
  } catch (error) {
291
291
  console.error('Error fetching exportOrdersList:', error);
292
292
  throw error;
@@ -314,7 +314,7 @@ export const exportPaymentLinesReport = async function (this: WashdayClientInsta
314
314
  'toDate',
315
315
  'timezone'
316
316
  ], params);
317
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/paymentLines/export?${queryParams}`, config);
317
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/paymentLines/export?${queryParams}`, config);
318
318
  } catch (error) {
319
319
  console.error('Error fetching exportOrdersList:', error);
320
320
  throw error;
@@ -344,7 +344,7 @@ export const exportUnpaidOrdersReportCSV = async function (this: WashdayClientIn
344
344
  'timezone',
345
345
  'customerName'
346
346
  ], params);
347
- return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export?${queryParams}`, config);
347
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export?${queryParams}`, config);
348
348
  } catch (error) {
349
349
  console.error('Error fetching exportUnpaidOrdersReportCSV:', error);
350
350
  throw error;
@@ -372,7 +372,7 @@ export const exportAttendanceReport = async function (this: WashdayClientInstanc
372
372
  'toDate',
373
373
  'employeeId'
374
374
  ], params);
375
- return await axiosInstance.get(`${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}`, config);
375
+ return await this.axiosInstance.get(`${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}`, config);
376
376
  } catch (error) {
377
377
  console.error('Error fetching exportAttendanceReport:', error);
378
378
  throw error;
@@ -8,7 +8,7 @@ export const deleteByIdCustomersApp = async function (this: WashdayClientInstanc
8
8
  const config = {
9
9
  headers: { Authorization: `Bearer ${this.apiToken}` }
10
10
  };
11
- return await axiosInstance.delete(`${GET_SET_CUSTOMERS_APP}/${id}`, config);
11
+ return await this.axiosInstance.delete(`${GET_SET_CUSTOMERS_APP}/${id}`, config);
12
12
  } catch (error) {
13
13
  console.error('Error fetching deleteByIdCustomersApp:', error);
14
14
  throw error;
@@ -21,7 +21,7 @@ export const deleteById = async function (this: WashdayClientInstance, id: strin
21
21
  const config = {
22
22
  headers: { Authorization: `Bearer ${this.apiToken}` }
23
23
  };
24
- return await axiosInstance.delete(`${GET_SET_CUSTOMERS}/${id}`, config);
24
+ return await this.axiosInstance.delete(`${GET_SET_CUSTOMERS}/${id}`, config);
25
25
  } catch (error) {
26
26
  console.error('Error fetching deleteById:', error);
27
27
  throw error;
@@ -25,13 +25,13 @@ export const getList = async function (this: WashdayClientInstance, params: {
25
25
  signal: options?.signal || params.signal || undefined
26
26
  };
27
27
  const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum', 'createdIn'], params);
28
- return await axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
28
+ return await this.axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
29
29
  } catch (error) {
30
30
  if (error instanceof Error && (error.name === 'AbortError' || error.name === 'CanceledError')) {
31
31
  console.log('Request was cancelled');
32
- throw new Error('Request cancelled');
32
+ throw error;
33
33
  }
34
- console.error('Error fetching customers:', error);
34
+ console.error('Washday SDK - Error fetching customers:', error);
35
35
  throw error;
36
36
  }
37
37
  };
@@ -71,7 +71,7 @@ export const getCustomerOrders = async function (this: WashdayClientInstance, cu
71
71
  headers: { Authorization: `Bearer ${this.apiToken}` }
72
72
  };
73
73
  const queryParams = generateQueryParamsStr(['limit', 'pageNum'], params);
74
- return await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/orders?${queryParams}`, config);
74
+ return await this.axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/orders?${queryParams}`, config);
75
75
  } catch (error) {
76
76
  console.error('Error fetching getCustomerHighlightsById:', error);
77
77
  throw error;
@@ -84,7 +84,7 @@ export const getCustomerByIdCustomersApp = async function (this: WashdayClientIn
84
84
  const config = {
85
85
  headers: { Authorization: `Bearer ${this.apiToken}` }
86
86
  };
87
- return await axiosInstance.get(`${GET_SET_CUSTOMERS_APP}/${customerId}`, config);
87
+ return await this.axiosInstance.get(`${GET_SET_CUSTOMERS_APP}/${customerId}`, config);
88
88
  } catch (error) {
89
89
  console.error('Error fetching customer:', error);
90
90
  throw error;
@@ -97,7 +97,7 @@ export const getCustomerLoyaltyHistory = async function (this: WashdayClientInst
97
97
  const config = {
98
98
  headers: { Authorization: `Bearer ${this.apiToken}` }
99
99
  };
100
- return await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/loyalty-history`, config);
100
+ return await this.axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/loyalty-history`, config);
101
101
  } catch (error) {
102
102
  console.error('Error fetching getCustomerLoyaltyHistory:', error);
103
103
  throw error;
@@ -39,7 +39,7 @@ export const updateById = async function (this: WashdayClientInstance, id: strin
39
39
  const config = {
40
40
  headers: { Authorization: `Bearer ${this.apiToken}` }
41
41
  };
42
- return await axiosInstance.put(`${GET_SET_CUSTOMERS}/${id}`, data, config);
42
+ return await this.axiosInstance.put(`${GET_SET_CUSTOMERS}/${id}`, data, config);
43
43
  } catch (error) {
44
44
  console.error('Error fetching updateById:', error);
45
45
  throw error;
@@ -60,7 +60,7 @@ export const updateByIdCustomersApp = async function (this: WashdayClientInstanc
60
60
  const config = {
61
61
  headers: { Authorization: `Bearer ${this.apiToken}` }
62
62
  };
63
- return await axiosInstance.put(`${GET_SET_CUSTOMERS_APP}/${id}`, data, config);
63
+ return await this.axiosInstance.put(`${GET_SET_CUSTOMERS_APP}/${id}`, data, config);
64
64
  } catch (error) {
65
65
  console.error('Error fetching updateByIdCustomersApp:', error);
66
66
  throw error;
@@ -16,7 +16,7 @@ export const getDiscountCodes = async function (this: WashdayClientInstance, sto
16
16
  const config = {
17
17
  headers: { Authorization: `Bearer ${this.apiToken}` }
18
18
  };
19
- return await axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}?${queryParams}`, config);
19
+ return await this.axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}?${queryParams}`, config);
20
20
  } catch (error) {
21
21
  console.error('Error fetching getStores:', error);
22
22
  throw error;
@@ -32,7 +32,7 @@ export const getAutomaticDiscounts = async function (this: WashdayClientInstance
32
32
  const config = {
33
33
  headers: { Authorization: `Bearer ${this.apiToken}` }
34
34
  };
35
- return await axiosInstance.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}?${queryParams}`, config);
35
+ return await this.axiosInstance.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}?${queryParams}`, config);
36
36
  } catch (error) {
37
37
  console.error('Error fetching getStores:', error);
38
38
  throw error;
@@ -44,7 +44,7 @@ export const getDiscountCodeById = async function (this: WashdayClientInstance,
44
44
  const config = {
45
45
  headers: { Authorization: `Bearer ${this.apiToken}` }
46
46
  };
47
- return await axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
47
+ return await this.axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
48
48
  } catch (error) {
49
49
  console.error('Error fetching getDiscountCodeById:', error);
50
50
  throw error;
@@ -56,7 +56,7 @@ export const getAutomaticDiscountById = async function (this: WashdayClientInsta
56
56
  const config = {
57
57
  headers: { Authorization: `Bearer ${this.apiToken}` }
58
58
  };
59
- return await axiosInstance.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
59
+ return await this.axiosInstance.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
60
60
  } catch (error) {
61
61
  console.error('Error fetching getDiscountCodeById:', error);
62
62
  throw error;
@@ -68,7 +68,7 @@ export const verifyDiscountCode = async function (this: WashdayClientInstance, s
68
68
  const config = {
69
69
  headers: { Authorization: `Bearer ${this.apiToken}` }
70
70
  };
71
- return await axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${code}/verify`, config);
71
+ return await this.axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${code}/verify`, config);
72
72
  } catch (error) {
73
73
  console.error('Error fetching verifyDiscountCode:', error);
74
74
  throw error;
@@ -80,7 +80,7 @@ export const verifyDiscountCodeCustomersApp = async function (this: WashdayClien
80
80
  const config = {
81
81
  headers: { Authorization: `Bearer ${this.apiToken}` }
82
82
  };
83
- return await axiosInstance.get(`${GET_DISCOUNT_CODES_CUSTOMER_APP}/${storeId}/${code}/verify`, config);
83
+ return await this.axiosInstance.get(`${GET_DISCOUNT_CODES_CUSTOMER_APP}/${storeId}/${code}/verify`, config);
84
84
  } catch (error) {
85
85
  console.error('Error fetching verifyDiscountCodeCustomersApp:', error);
86
86
  throw error;
@@ -92,7 +92,7 @@ export const getAvailableAutomaticDiscounts = async function (this: WashdayClien
92
92
  const config = {
93
93
  headers: { Authorization: `Bearer ${this.apiToken}` }
94
94
  };
95
- return await axiosInstance.get(`${GET_AVAILABLE_AUTOMATIC_DISCOUNTS}/${storeId}?currentDate=${date}`, config);
95
+ return await this.axiosInstance.get(`${GET_AVAILABLE_AUTOMATIC_DISCOUNTS}/${storeId}?currentDate=${date}`, config);
96
96
  } catch (error) {
97
97
  console.error('Error fetching getAvailableAutomaticDiscounts:', error);
98
98
  throw error;
@@ -11,7 +11,7 @@ export const createAutomaticDiscount = async function (this: WashdayClientInstan
11
11
  const config = {
12
12
  headers: { Authorization: `Bearer ${this.apiToken}` }
13
13
  };
14
- return await axiosInstance.post(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}`, data, config);
14
+ return await this.axiosInstance.post(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}`, data, config);
15
15
  } catch (error) {
16
16
  console.error('Error fetching createAutomaticDiscount:', error);
17
17
  throw error;
@@ -24,7 +24,7 @@ export const createDiscountCode = async function (this: WashdayClientInstance, s
24
24
  const config = {
25
25
  headers: { Authorization: `Bearer ${this.apiToken}` }
26
26
  };
27
- return await axiosInstance.post(`${GET_SET_DISCOUNT_CODES}/${storeId}`, data, config);
27
+ return await this.axiosInstance.post(`${GET_SET_DISCOUNT_CODES}/${storeId}`, data, config);
28
28
  } catch (error) {
29
29
  console.error('Error fetching createAutomaticDiscount:', error);
30
30
  throw error;
@@ -10,7 +10,7 @@ export const deleteDiscountCodeById = async function (this: WashdayClientInstanc
10
10
  const config = {
11
11
  headers: { Authorization: `Bearer ${this.apiToken}` }
12
12
  };
13
- return await axiosInstance.delete(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
13
+ return await this.axiosInstance.delete(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
14
14
  } catch (error) {
15
15
  console.error('Error fetching deleteDiscountCodeById:', error);
16
16
  throw error;
@@ -22,7 +22,7 @@ export const deleteAutomaticDiscountById = async function (this: WashdayClientIn
22
22
  const config = {
23
23
  headers: { Authorization: `Bearer ${this.apiToken}` }
24
24
  };
25
- return await axiosInstance.delete(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
25
+ return await this.axiosInstance.delete(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
26
26
  } catch (error) {
27
27
  console.error('Error fetching deleteAutomaticDiscountById:', error);
28
28
  throw error;
@@ -37,7 +37,7 @@ export const updateAutomaticDiscountById = async function (this: WashdayClientIn
37
37
  const config = {
38
38
  headers: { Authorization: `Bearer ${this.apiToken}` }
39
39
  };
40
- return await axiosInstance.put(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, data, config);
40
+ return await this.axiosInstance.put(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, data, config);
41
41
  } catch (error) {
42
42
  console.error('Error fetching updateById:', error);
43
43
  throw error;
@@ -57,7 +57,7 @@ export const updateDiscountCodeById = async function (this: WashdayClientInstanc
57
57
  const config = {
58
58
  headers: { Authorization: `Bearer ${this.apiToken}` }
59
59
  };
60
- return await axiosInstance.put(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, data, config);
60
+ return await this.axiosInstance.put(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, data, config);
61
61
  } catch (error) {
62
62
  console.error('Error fetching updateDiscountCodeById:', error);
63
63
  throw error;
package/src/api/index.ts CHANGED
@@ -43,7 +43,7 @@ import * as partnersEndpoints from './partners';
43
43
  import * as outsourcedOrdersEndpoints from './outsourcedOrders';
44
44
  import * as publicsEndpoints from './publics';
45
45
  import { validateUserPin } from "./users/post";
46
-
46
+ import { getAxiosInstance } from "./axiosInstance";
47
47
  type WashdayClientConstructor = {
48
48
  new(apiToken: string): WashdayClientInstance
49
49
  };
@@ -57,8 +57,10 @@ function bindMethods<T>(instance: any, methods: any): T {
57
57
  return boundMethods;
58
58
  }
59
59
 
60
- const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string) {
60
+ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string, env:string = 'PROD') {
61
61
  this.apiToken = apiToken;
62
+ this.env = env;
63
+ this.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env);
62
64
  this.cashup = bindMethods(this, {
63
65
  getList: cashupsEndpoints.getModule.getList,
64
66
  getById: cashupsEndpoints.getModule.getById,
@@ -21,7 +21,7 @@ export const getInventoryById = async function (this: WashdayClientInstance, sto
21
21
  const config = {
22
22
  headers: { Authorization: `Bearer ${this.apiToken}` }
23
23
  };
24
- return await axiosInstance.get(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
24
+ return await this.axiosInstance.get(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
25
25
  } catch (error) {
26
26
  console.error('Error fetching getInventoryById:', error);
27
27
  throw error;
@@ -8,7 +8,7 @@ export const deletePaymentLineById = async function (this: WashdayClientInstance
8
8
  const config = {
9
9
  headers: { Authorization: `Bearer ${this.apiToken}` }
10
10
  };
11
- return await axiosInstance.delete(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
11
+ return await this.axiosInstance.delete(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
12
12
  } catch (error) {
13
13
  console.error('Error fetching deleteById:', error);
14
14
  throw error;
@@ -21,7 +21,7 @@ export const cancelOrderByIdCustomersApp = async function (this: WashdayClientIn
21
21
  const config = {
22
22
  headers: { Authorization: `Bearer ${this.apiToken}` }
23
23
  };
24
- return await axiosInstance.delete(`${GET_SET_ORDER_CUSTOMERS_APP}/${id}`, config);
24
+ return await this.axiosInstance.delete(`${GET_SET_ORDER_CUSTOMERS_APP}/${id}`, config);
25
25
  } catch (error) {
26
26
  console.error('Error fetching cancelOrderByIdCustomersApp:', error);
27
27
  throw error;
@@ -63,7 +63,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
63
63
  'cfdiId',
64
64
  ], params);
65
65
  // ], { ...params, q: params.q ? encodeURIComponent(params.q) : undefined });
66
- return await axiosInstance.get(`${GET_SET_ORDER}?${queryParams}`, config);
66
+ return await this.axiosInstance.get(`${GET_SET_ORDER}?${queryParams}`, config);
67
67
  } catch (error) {
68
68
  console.error('Error fetching getList orders:', error);
69
69
  throw error;
@@ -83,7 +83,7 @@ export const getOrdersHeaderSummary = async function (this: WashdayClientInstanc
83
83
  'status',
84
84
  ], params);
85
85
 
86
- return await axiosInstance.get(`${GET_HEADER_SUMMARY}?${queryParams}`, config);
86
+ return await this.axiosInstance.get(`${GET_HEADER_SUMMARY}?${queryParams}`, config);
87
87
  } catch (error) {
88
88
  console.error('Error fetching getOrdersHeaderSummary :', error);
89
89
  throw error;
@@ -101,7 +101,7 @@ export const getById = async function (this: WashdayClientInstance, id: string,
101
101
  const queryParams = generateQueryParamsStr([
102
102
  'fetchSection',
103
103
  ], params);
104
- return await axiosInstance.get(`${GET_SET_ORDER}/${id}?${queryParams}`, config);
104
+ return await this.axiosInstance.get(`${GET_SET_ORDER}/${id}?${queryParams}`, config);
105
105
  } catch (error) {
106
106
  console.error('Error fetching:', error);
107
107
  throw error;
@@ -113,7 +113,7 @@ export const getCFDIOrdersByDateAndStore = async function (this: WashdayClientIn
113
113
  const config = {
114
114
  headers: { Authorization: `Bearer ${this.apiToken}` }
115
115
  };
116
- return await axiosInstance.get(`${GET_SET_ORDER}/${id}`, config);
116
+ return await this.axiosInstance.get(`${GET_SET_ORDER}/${id}`, config);
117
117
  } catch (error) {
118
118
  console.error('Error fetching:', error);
119
119
  throw error;
@@ -136,7 +136,7 @@ export const fetchOrdersForCFDI = async function (this: WashdayClientInstance, p
136
136
  "storeID",
137
137
  "customerID"
138
138
  ], params);
139
- return await axiosInstance.get(`${GET_SET_ORDER_CFDI}/cfdiPreview?${queryParams}`, config);
139
+ return await this.axiosInstance.get(`${GET_SET_ORDER_CFDI}/cfdiPreview?${queryParams}`, config);
140
140
  } catch (error) {
141
141
  console.error('Error fetching:', error);
142
142
  throw error;
@@ -175,7 +175,7 @@ export const getListCustomersApp = async function (this: WashdayClientInstance,
175
175
  'readyDateTime',
176
176
  'collectedDateTime',
177
177
  ], params);
178
- return await axiosInstance.get(`${GET_SET_ORDER_CUSTOMERS_APP}?${queryParams}`, config);
178
+ return await this.axiosInstance.get(`${GET_SET_ORDER_CUSTOMERS_APP}?${queryParams}`, config);
179
179
  } catch (error) {
180
180
  console.error('Error fetching getListCustomersApp orders:', error);
181
181
  throw error;
@@ -187,7 +187,7 @@ export const getByIdCustomersApp = async function (this: WashdayClientInstance,
187
187
  const config = {
188
188
  headers: { Authorization: `Bearer ${this.apiToken}` }
189
189
  };
190
- return await axiosInstance.get(`${GET_SET_ORDER_CUSTOMERS_APP}/${id}`, config);
190
+ return await this.axiosInstance.get(`${GET_SET_ORDER_CUSTOMERS_APP}/${id}`, config);
191
191
  } catch (error) {
192
192
  console.error('Error fetching:', error);
193
193
  throw error;
@@ -199,7 +199,7 @@ export const getRequestedOrdersSummary = async function (this: WashdayClientInst
199
199
  const config = {
200
200
  headers: { Authorization: `Bearer ${this.apiToken}` }
201
201
  };
202
- return await axiosInstance.get(`${GET_SET_ORDER}/requested-summary?storeIds=${storeIds}`, config);
202
+ return await this.axiosInstance.get(`${GET_SET_ORDER}/requested-summary?storeIds=${storeIds}`, config);
203
203
  } catch (error) {
204
204
  console.error('Error fetching:', error);
205
205
  throw error;
@@ -18,7 +18,7 @@ export const createPaymentLine = async function (this: WashdayClientInstance, id
18
18
  const config = {
19
19
  headers: { Authorization: `Bearer ${this.apiToken}` }
20
20
  };
21
- return await axiosInstance.post(`${GET_SET_ORDER_PAYMENTLINES(id)}`, data, config);
21
+ return await this.axiosInstance.post(`${GET_SET_ORDER_PAYMENTLINES(id)}`, data, config);
22
22
  } catch (error) {
23
23
  console.error('Error fetching create:', error);
24
24
  throw error;
@@ -31,7 +31,7 @@ export const sendEmailReceipt = async function (this: WashdayClientInstance, id:
31
31
  const config = {
32
32
  headers: { Authorization: `Bearer ${this.apiToken}` }
33
33
  };
34
- return await axiosInstance.post(`${GET_SET_ORDER}/${id}/sendEmailReceipt`, {}, config);
34
+ return await this.axiosInstance.post(`${GET_SET_ORDER}/${id}/sendEmailReceipt`, {}, config);
35
35
  } catch (error) {
36
36
  console.error('Error fetching create:', error);
37
37
  throw error;
@@ -43,7 +43,7 @@ export const createOrderCustomersApp = async function (this: WashdayClientInstan
43
43
  const config = {
44
44
  headers: { Authorization: `Bearer ${this.apiToken}` }
45
45
  };
46
- return await axiosInstance.post(`${GET_SET_ORDER_CUSTOMERS_APP}`, data, config);
46
+ return await this.axiosInstance.post(`${GET_SET_ORDER_CUSTOMERS_APP}`, data, config);
47
47
  } catch (error) {
48
48
  console.error('Error fetching createOrderCustomersApp:', error);
49
49
  throw error;
@@ -55,7 +55,7 @@ export const createOrderUsersApp = async function (this: WashdayClientInstance,
55
55
  const config = {
56
56
  headers: { Authorization: `Bearer ${this.apiToken}` }
57
57
  };
58
- return await axiosInstance.post(`${GET_SET_ORDER}`, data, config);
58
+ return await this.axiosInstance.post(`${GET_SET_ORDER}`, data, config);
59
59
  } catch (error) {
60
60
  console.error('Error fetching createOrderUsersApp:', error);
61
61
  throw error;
@@ -77,7 +77,7 @@ export const bulkCreatePaymentLines = async function (this: WashdayClientInstanc
77
77
  const config = {
78
78
  headers: { Authorization: `Bearer ${this.apiToken}` }
79
79
  };
80
- return await axiosInstance.post(`${GET_SET_ORDER}/${storeId}/bulkPaymentLines`, body, config);
80
+ return await this.axiosInstance.post(`${GET_SET_ORDER}/${storeId}/bulkPaymentLines`, body, config);
81
81
  } catch (error) {
82
82
  console.error('Error fetching bulkCreatePaymentLines:', error);
83
83
  throw error;
@@ -94,7 +94,7 @@ export const createOrderEvidence = async function (this: WashdayClientInstance,
94
94
  'Content-Type': false
95
95
  }
96
96
  };
97
- return await axiosInstance.post(`${GET_SET_ORDER}/${orderId}/evidence`, data, config);
97
+ return await this.axiosInstance.post(`${GET_SET_ORDER}/${orderId}/evidence`, data, config);
98
98
  } catch (error) {
99
99
  console.error('Error fetching createOrderEvidence:', error);
100
100
  throw error;
@@ -110,7 +110,7 @@ export const getRedeemPointsPreview = async function (this: WashdayClientInstanc
110
110
  const config = {
111
111
  headers: { Authorization: `Bearer ${this.apiToken}` }
112
112
  };
113
- return await axiosInstance.post(`${GET_SET_ORDER}/redeemPointsPreview`, data, config);
113
+ return await this.axiosInstance.post(`${GET_SET_ORDER}/redeemPointsPreview`, data, config);
114
114
  } catch (error) {
115
115
  console.error('Error fetching getRedeemPointsPreview:', error);
116
116
  throw error;
@@ -33,7 +33,7 @@ export const updateById = async function (this: WashdayClientInstance, id: strin
33
33
  const config = {
34
34
  headers: { Authorization: `Bearer ${this.apiToken}` }
35
35
  };
36
- return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
36
+ return await this.axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
37
37
  } catch (error) {
38
38
  console.error('Error fetching updateById:', error);
39
39
  throw error;
@@ -49,7 +49,7 @@ export const updatePaymentLineById = async function (this: WashdayClientInstance
49
49
  const config = {
50
50
  headers: { Authorization: `Bearer ${this.apiToken}` }
51
51
  };
52
- return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
52
+ return await this.axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
53
53
  } catch (error) {
54
54
  console.error('Error fetching updateById:', error);
55
55
  throw error;
@@ -63,7 +63,7 @@ export const setOrderCancelledBySequence = async function (this: WashdayClientIn
63
63
  const config = {
64
64
  headers: { Authorization: `Bearer ${this.apiToken}` }
65
65
  };
66
- return await axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/cancelled`, data, config);
66
+ return await this.axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/cancelled`, data, config);
67
67
  } catch (error) {
68
68
  console.error('Error fetching setOrderCancelledBySequence:', error);
69
69
  throw error;
@@ -75,7 +75,7 @@ export const setOrderCleaningBySequence = async function (this: WashdayClientIns
75
75
  const config = {
76
76
  headers: { Authorization: `Bearer ${this.apiToken}` }
77
77
  };
78
- return await axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/cleaning`, {}, config);
78
+ return await this.axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/cleaning`, {}, config);
79
79
  } catch (error) {
80
80
  console.error('Error fetching setOrderCleaningBySequence:', error);
81
81
  throw error;
@@ -95,7 +95,7 @@ export const setOrderCleanedBySequence = async function (this: WashdayClientInst
95
95
  const queryParams = generateQueryParamsStr([
96
96
  'markOutsourcedAsReturned',
97
97
  ], params);
98
- return await axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/cleaned?${queryParams}`, data, config);
98
+ return await this.axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/cleaned?${queryParams}`, data, config);
99
99
  } catch (error) {
100
100
  console.error('Error fetching setOrderCleanedBySequence:', error);
101
101
  throw error;
@@ -111,7 +111,7 @@ export const setOrderCollectedBySequence = async function (this: WashdayClientIn
111
111
  const config = {
112
112
  headers: { Authorization: `Bearer ${this.apiToken}` }
113
113
  };
114
- return await axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/collected`, data, config);
114
+ return await this.axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/collected`, data, config);
115
115
  } catch (error) {
116
116
  console.error('Error fetching setOrderCollectedBySequence:', error);
117
117
  throw error;
@@ -125,7 +125,7 @@ export const setOrdePickingBySequence = async function (this: WashdayClientInsta
125
125
  const config = {
126
126
  headers: { Authorization: `Bearer ${this.apiToken}` }
127
127
  };
128
- return await axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/picking`, data, config);
128
+ return await this.axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/picking`, data, config);
129
129
  } catch (error) {
130
130
  console.error('Error fetching setOrdePickingBySequence:', error);
131
131
  throw error;
@@ -139,7 +139,7 @@ export const setOrdeDeliveringBySequence = async function (this: WashdayClientIn
139
139
  const config = {
140
140
  headers: { Authorization: `Bearer ${this.apiToken}` }
141
141
  };
142
- return await axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/delivering`, data, config);
142
+ return await this.axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/delivering`, data, config);
143
143
  } catch (error) {
144
144
  console.error('Error fetching setOrdeDeliveringBySequence:', error);
145
145
  throw error;
@@ -153,7 +153,7 @@ export const setOrdeDeliveredBySequence = async function (this: WashdayClientIns
153
153
  const config = {
154
154
  headers: { Authorization: `Bearer ${this.apiToken}` }
155
155
  };
156
- return await axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/delivered`, data, config);
156
+ return await this.axiosInstance.put(`${GET_SET_ORDER_OLD}/${sequence}/${storeId}/delivered`, data, config);
157
157
  } catch (error) {
158
158
  console.error('Error fetching setOrdeDeliveredBySequence:', error);
159
159
  throw error;
@@ -165,7 +165,7 @@ export const setOrderAcceptedBySequence = async function (this: WashdayClientIns
165
165
  const config = {
166
166
  headers: { Authorization: `Bearer ${this.apiToken}` }
167
167
  };
168
- return await axiosInstance.put(`${GET_SET_ORDER}/${sequence}/${storeId}/accepted`, {}, config);
168
+ return await this.axiosInstance.put(`${GET_SET_ORDER}/${sequence}/${storeId}/accepted`, {}, config);
169
169
  } catch (error) {
170
170
  console.error('Error fetching setOrderAcceptedBySequence:', error);
171
171
  throw error;
@@ -180,7 +180,7 @@ export const bulkCancel = async function (this: WashdayClientInstance, storeId:
180
180
  const config = {
181
181
  headers: { Authorization: `Bearer ${this.apiToken}` }
182
182
  };
183
- return await axiosInstance.put(`${GET_SET_ORDER}/${storeId}/bulkCancel`, body, config);
183
+ return await this.axiosInstance.put(`${GET_SET_ORDER}/${storeId}/bulkCancel`, body, config);
184
184
  } catch (error) {
185
185
  console.error('Error fetching bulkCancel:', error);
186
186
  throw error;
@@ -201,7 +201,7 @@ export const bulkClean = async function (this: WashdayClientInstance, storeId: s
201
201
  const queryParams = generateQueryParamsStr([
202
202
  'markOutsourcedAsReturned',
203
203
  ], params);
204
- return await axiosInstance.put(`${GET_SET_ORDER}/${storeId}/bulkClean?${queryParams}`, body, config);
204
+ return await this.axiosInstance.put(`${GET_SET_ORDER}/${storeId}/bulkClean?${queryParams}`, body, config);
205
205
  } catch (error) {
206
206
  console.error('Error fetching bulkClean:', error);
207
207
  throw error;
@@ -216,7 +216,7 @@ export const bulkCollect = async function (this: WashdayClientInstance, storeId:
216
216
  const config = {
217
217
  headers: { Authorization: `Bearer ${this.apiToken}` }
218
218
  };
219
- return await axiosInstance.put(`${GET_SET_ORDER}/${storeId}/bulkCollect`, body, config);
219
+ return await this.axiosInstance.put(`${GET_SET_ORDER}/${storeId}/bulkCollect`, body, config);
220
220
  } catch (error) {
221
221
  console.error('Error fetching bulkCollect:', error);
222
222
  throw error;
@@ -7,7 +7,7 @@ export const deleteOutsourcedOrderById = async function (this: WashdayClientInst
7
7
  const config = {
8
8
  headers: { Authorization: `Bearer ${this.apiToken}` }
9
9
  };
10
- return await axiosInstance.delete(`${GET_SET_OUTSOURCED_ORDERS}/${id}`, config);
10
+ return await this.axiosInstance.delete(`${GET_SET_OUTSOURCED_ORDERS}/${id}`, config);
11
11
  } catch (error) {
12
12
  console.error('Error fetching deleteOutsourcedOrderById:', error);
13
13
  throw error;