washday-sdk 1.1.10 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) 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/cashierbox/get.js +3 -4
  8. package/dist/api/cashierbox/post.js +2 -3
  9. package/dist/api/cashierbox/put.js +2 -3
  10. package/dist/api/cashups/delete.js +1 -2
  11. package/dist/api/cashups/get.js +3 -4
  12. package/dist/api/cashups/post.js +1 -2
  13. package/dist/api/cashups/put.js +2 -2
  14. package/dist/api/cfdi/delete.js +1 -2
  15. package/dist/api/cfdi/get.js +6 -7
  16. package/dist/api/cfdi/post.js +2 -3
  17. package/dist/api/cfdi/put.js +2 -2
  18. package/dist/api/companies/get.js +1 -2
  19. package/dist/api/companies/post.js +2 -3
  20. package/dist/api/companies/put.js +3 -4
  21. package/dist/api/countries/get.js +1 -2
  22. package/dist/api/csv/get.js +13 -14
  23. package/dist/api/customers/delete.js +2 -3
  24. package/dist/api/customers/get.js +6 -7
  25. package/dist/api/customers/post.js +2 -3
  26. package/dist/api/customers/put.js +3 -4
  27. package/dist/api/discounts/get.js +7 -8
  28. package/dist/api/discounts/post.js +2 -3
  29. package/dist/api/discounts/put.js +4 -5
  30. package/dist/api/index.js +4 -1
  31. package/dist/api/inventory/delete.js +1 -2
  32. package/dist/api/inventory/get.js +3 -4
  33. package/dist/api/inventory/post.js +1 -2
  34. package/dist/api/inventory/put.js +2 -3
  35. package/dist/api/order/delete.js +2 -3
  36. package/dist/api/order/get.js +8 -9
  37. package/dist/api/order/post.js +7 -8
  38. package/dist/api/order/put.js +13 -14
  39. package/dist/api/outsourcedOrders/delete.js +1 -2
  40. package/dist/api/outsourcedOrders/get.js +3 -4
  41. package/dist/api/outsourcedOrders/post.js +1 -2
  42. package/dist/api/outsourcedOrders/put.js +1 -2
  43. package/dist/api/partners/delete.js +1 -2
  44. package/dist/api/partners/get.js +2 -3
  45. package/dist/api/partners/post.js +1 -2
  46. package/dist/api/partners/put.js +1 -2
  47. package/dist/api/pdf/get.js +1 -2
  48. package/dist/api/products/delete.js +3 -4
  49. package/dist/api/products/get.js +1 -2
  50. package/dist/api/products/post.js +4 -5
  51. package/dist/api/products/put.js +3 -4
  52. package/dist/api/publics/get.js +1 -2
  53. package/dist/api/reports/get.js +15 -16
  54. package/dist/api/reviews/delete.js +1 -1
  55. package/dist/api/reviews/get.js +2 -3
  56. package/dist/api/reviews/post.js +1 -1
  57. package/dist/api/reviews/put.js +2 -2
  58. package/dist/api/routes/delete.js +1 -2
  59. package/dist/api/routes/get.js +5 -6
  60. package/dist/api/routes/post.js +3 -4
  61. package/dist/api/routes/put.js +3 -4
  62. package/dist/api/sections/delete.js +1 -2
  63. package/dist/api/sections/get.js +3 -4
  64. package/dist/api/sections/post.js +1 -2
  65. package/dist/api/sections/put.js +1 -2
  66. package/dist/api/staff/delete.js +1 -2
  67. package/dist/api/staff/get.js +2 -3
  68. package/dist/api/staff/post.js +1 -2
  69. package/dist/api/staff/put.js +1 -2
  70. package/dist/api/stores/get.js +6 -7
  71. package/dist/api/stores/post.js +3 -4
  72. package/dist/api/stores/put.js +2 -3
  73. package/dist/api/stripe/post.js +4 -5
  74. package/dist/api/supplies/delete.js +1 -2
  75. package/dist/api/supplies/get.js +3 -4
  76. package/dist/api/supplies/post.js +1 -2
  77. package/dist/api/supplies/put.js +2 -3
  78. package/dist/api/users/delete.js +1 -2
  79. package/dist/api/users/post.js +1 -2
  80. package/dist/api/users/put.js +1 -2
  81. package/package.json +1 -1
  82. package/src/api/attendance/get.ts +4 -4
  83. package/src/api/attendance/post.ts +2 -2
  84. package/src/api/attendance/put.ts +1 -1
  85. package/src/api/auth/post.ts +13 -13
  86. package/src/api/axiosInstance.ts +51 -40
  87. package/src/api/cashierbox/delete.ts +2 -2
  88. package/src/api/cashierbox/get.ts +3 -3
  89. package/src/api/cashierbox/post.ts +2 -2
  90. package/src/api/cashierbox/put.ts +2 -2
  91. package/src/api/cashups/delete.ts +1 -1
  92. package/src/api/cashups/get.ts +3 -3
  93. package/src/api/cashups/post.ts +1 -1
  94. package/src/api/cashups/put.ts +2 -2
  95. package/src/api/cfdi/delete.ts +1 -1
  96. package/src/api/cfdi/get.ts +6 -6
  97. package/src/api/cfdi/post.ts +2 -2
  98. package/src/api/cfdi/put.ts +2 -2
  99. package/src/api/companies/get.ts +1 -1
  100. package/src/api/companies/post.ts +2 -2
  101. package/src/api/companies/put.ts +3 -3
  102. package/src/api/countries/get.ts +1 -1
  103. package/src/api/csv/get.ts +13 -13
  104. package/src/api/customers/delete.ts +2 -2
  105. package/src/api/customers/get.ts +6 -6
  106. package/src/api/customers/post.ts +2 -2
  107. package/src/api/customers/put.ts +3 -3
  108. package/src/api/discounts/get.ts +7 -7
  109. package/src/api/discounts/post.ts +2 -2
  110. package/src/api/discounts/put.ts +4 -4
  111. package/src/api/index.ts +4 -2
  112. package/src/api/inventory/delete.ts +1 -1
  113. package/src/api/inventory/get.ts +3 -3
  114. package/src/api/inventory/post.ts +1 -1
  115. package/src/api/inventory/put.ts +2 -2
  116. package/src/api/order/delete.ts +2 -2
  117. package/src/api/order/get.ts +8 -8
  118. package/src/api/order/post.ts +7 -7
  119. package/src/api/order/put.ts +13 -13
  120. package/src/api/outsourcedOrders/delete.ts +1 -1
  121. package/src/api/outsourcedOrders/get.ts +3 -3
  122. package/src/api/outsourcedOrders/post.ts +1 -1
  123. package/src/api/outsourcedOrders/put.ts +1 -1
  124. package/src/api/partners/delete.ts +1 -1
  125. package/src/api/partners/get.ts +2 -2
  126. package/src/api/partners/post.ts +1 -1
  127. package/src/api/partners/put.ts +1 -1
  128. package/src/api/pdf/get.ts +1 -1
  129. package/src/api/products/delete.ts +3 -3
  130. package/src/api/products/get.ts +1 -1
  131. package/src/api/products/post.ts +4 -4
  132. package/src/api/products/put.ts +3 -3
  133. package/src/api/publics/get.ts +1 -1
  134. package/src/api/reports/get.ts +15 -15
  135. package/src/api/reviews/delete.ts +1 -1
  136. package/src/api/reviews/get.ts +2 -2
  137. package/src/api/reviews/post.ts +1 -1
  138. package/src/api/reviews/put.ts +2 -2
  139. package/src/api/routes/delete.ts +1 -1
  140. package/src/api/routes/get.ts +5 -5
  141. package/src/api/routes/post.ts +3 -3
  142. package/src/api/routes/put.ts +3 -3
  143. package/src/api/sections/delete.ts +1 -1
  144. package/src/api/sections/get.ts +3 -3
  145. package/src/api/sections/post.ts +1 -1
  146. package/src/api/sections/put.ts +1 -1
  147. package/src/api/staff/delete.ts +1 -1
  148. package/src/api/staff/get.ts +2 -2
  149. package/src/api/staff/post.ts +1 -1
  150. package/src/api/staff/put.ts +1 -1
  151. package/src/api/stores/get.ts +6 -6
  152. package/src/api/stores/post.ts +3 -3
  153. package/src/api/stores/put.ts +2 -2
  154. package/src/api/stripe/post.ts +4 -4
  155. package/src/api/supplies/delete.ts +1 -1
  156. package/src/api/supplies/get.ts +3 -3
  157. package/src/api/supplies/post.ts +1 -1
  158. package/src/api/supplies/put.ts +2 -2
  159. package/src/api/users/delete.ts +1 -1
  160. package/src/api/users/post.ts +1 -1
  161. package/src/api/users/put.ts +1 -1
  162. package/src/interfaces/Api.ts +3 -0
@@ -25,7 +25,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
25
25
  'pageNum'
26
26
  ], params);
27
27
 
28
- return await axiosInstance.get(`${GET_SET_CFDI}?${queryParams}`, config);
28
+ return await this.axiosInstance.get(`${GET_SET_CFDI}?${queryParams}`, config);
29
29
  } catch (error) {
30
30
  console.error('Error fetching getList CFDI:', error);
31
31
  throw error;
@@ -39,7 +39,7 @@ export const getCFDIPreviewByOrderId = async function (this: WashdayClientInstan
39
39
  const config = {
40
40
  headers: { Authorization: `Bearer ${this.apiToken}` }
41
41
  };
42
- return await axiosInstance.get(`${GET_ORDERS_CFDI_PREVIEW(id)}`, config);
42
+ return await this.axiosInstance.get(`${GET_ORDERS_CFDI_PREVIEW(id)}`, config);
43
43
  } catch (error) {
44
44
  console.error('Error fetching:', error);
45
45
  throw error;
@@ -59,7 +59,7 @@ export const downloadCFDIPDF = async function (this: WashdayClientInstance, id:
59
59
  responseType: 'arraybuffer'
60
60
  }
61
61
  };
62
- return await axiosInstance.get(`${GET_SET_CFDI}/${id}/download/pdf`, config);
62
+ return await this.axiosInstance.get(`${GET_SET_CFDI}/${id}/download/pdf`, config);
63
63
  } catch (error) {
64
64
  console.error('Error fetching downloadCFDIPDF:', error);
65
65
  throw error;
@@ -78,7 +78,7 @@ export const downloadCFDIZIP = async function (this: WashdayClientInstance, id:
78
78
  responseType: 'arraybuffer'
79
79
  }
80
80
  };
81
- return await axiosInstance.get(`${GET_SET_CFDI}/${id}/download/zip`, config);
81
+ return await this.axiosInstance.get(`${GET_SET_CFDI}/${id}/download/zip`, config);
82
82
  } catch (error) {
83
83
  console.error('Error fetching downloadCFDIZIP:', error);
84
84
  throw error;
@@ -91,7 +91,7 @@ export const sendCFDIByEmail = async function (this: WashdayClientInstance, id:
91
91
  const config = {
92
92
  headers: { Authorization: `Bearer ${this.apiToken}` }
93
93
  };
94
- return await axiosInstance.get(`${GET_SET_CFDI}/${id}/email`, config);
94
+ return await this.axiosInstance.get(`${GET_SET_CFDI}/${id}/email`, config);
95
95
  } catch (error) {
96
96
  console.error('Error fetching:', error);
97
97
  throw error;
@@ -111,7 +111,7 @@ export const getCFDIPreview = async function (this: WashdayClientInstance, param
111
111
  'ordersID',
112
112
  'customer',
113
113
  ], params);
114
- return await axiosInstance.get(`${GET_SET_CFDI}/preview?${queryParams}`, config);
114
+ return await this.axiosInstance.get(`${GET_SET_CFDI}/preview?${queryParams}`, config);
115
115
  } catch (error) {
116
116
  console.error('Error fetching:', error);
117
117
  throw error;
@@ -24,7 +24,7 @@ export const createCFDI = async function (this: WashdayClientInstance, data: {
24
24
  const config = {
25
25
  headers: { Authorization: `Bearer ${this.apiToken}` }
26
26
  };
27
- return await axiosInstance.post(GET_SET_CFDI, data, config);
27
+ return await this.axiosInstance.post(GET_SET_CFDI, data, config);
28
28
  } catch (error) {
29
29
  console.error('Error createCFDI:', error);
30
30
  throw error;
@@ -52,7 +52,7 @@ export const createGlobalCFDI = async function (this: WashdayClientInstance, dat
52
52
  const config = {
53
53
  headers: { Authorization: `Bearer ${this.apiToken}` }
54
54
  };
55
- return await axiosInstance.post(`${GET_SET_CFDI}/global`, { ...data, ordersID: data.ordersID?.join(',') }, config);
55
+ return await this.axiosInstance.post(`${GET_SET_CFDI}/global`, { ...data, ordersID: data.ordersID?.join(',') }, config);
56
56
  } catch (error) {
57
57
  console.error('Error fetching create:', error);
58
58
  throw error;
@@ -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;
@@ -14,7 +14,7 @@ export const getCompanyById = async function (this: WashdayClientInstance, compa
14
14
  const config = {
15
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
16
16
  };
17
- const response = await axiosInstance.get(`${GET_SET_COMPANIES}/${companyId}`, config);
17
+ const response = await this.axiosInstance.get(`${GET_SET_COMPANIES}/${companyId}`, config);
18
18
  return response;
19
19
  } catch (error) {
20
20
  console.error('Error fetching getCompanyById:', error);
@@ -7,7 +7,7 @@ export const updateCompanyTaxInfoCertificates = async function (this: WashdayCli
7
7
  const config = {
8
8
  headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
9
9
  };
10
- const response = await axiosInstance.post(`${GET_SET_COMPANIES}/${companyId}/taxInfo/certificates`, data, config);
10
+ const response = await this.axiosInstance.post(`${GET_SET_COMPANIES}/${companyId}/taxInfo/certificates`, data, config);
11
11
  return response;
12
12
  } catch (error) {
13
13
  console.error('Error fetching updateCompanyTaxInfoById:', error);
@@ -20,7 +20,7 @@ export const updateCFDIOrgLogo = async function (this: WashdayClientInstance, co
20
20
  const config = {
21
21
  headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
22
22
  }
23
- const response = await axiosInstance.post(`${GET_SET_COMPANIES}/${companyId}/taxInfo/logo`, data, config);
23
+ const response = await this.axiosInstance.post(`${GET_SET_COMPANIES}/${companyId}/taxInfo/logo`, data, config);
24
24
  return response;
25
25
  } catch (error) {
26
26
  console.error('Error fetching updateCFDIOrgLogo:', error);
@@ -7,7 +7,7 @@ export const updateCompanyById = async function (this: WashdayClientInstance, co
7
7
  const config = {
8
8
  headers: { Authorization: `Bearer ${this.apiToken}` }
9
9
  };
10
- const response = await axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}`, data, config);
10
+ const response = await this.axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}`, data, config);
11
11
  return response;
12
12
  } catch (error) {
13
13
  console.error('Error fetching updateCompanyById:', error);
@@ -21,7 +21,7 @@ export const updateCompanyLogoById = async function (this: WashdayClientInstance
21
21
  const config = {
22
22
  headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
23
23
  };
24
- const response = await axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}`, data, config);
24
+ const response = await this.axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}`, data, config);
25
25
  return response;
26
26
  } catch (error) {
27
27
  console.error('Error fetching updateCompanyLogoById:', error);
@@ -34,7 +34,7 @@ export const updateCompanyTaxInfoById = async function (this: WashdayClientInsta
34
34
  const config = {
35
35
  headers: { Authorization: `Bearer ${this.apiToken}` }
36
36
  };
37
- const response = await axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}/taxInfo`, data, config);
37
+ const response = await this.axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}/taxInfo`, data, config);
38
38
  return response;
39
39
  } catch (error) {
40
40
  console.error('Error fetching updateCompanyTaxInfoById:', error);
@@ -14,7 +14,7 @@ export const getCountries = async function (this: WashdayClientInstance): Promis
14
14
  const config = {
15
15
  headers: { Authorization: '' }
16
16
  };
17
- const response = await axiosInstance.get(`${GET_SET_COUNTRIES}`, config);
17
+ const response = await this.axiosInstance.get(`${GET_SET_COUNTRIES}`, config);
18
18
  return response;
19
19
  } catch (error) {
20
20
  console.error('Error fetching getCountries:', 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,7 +25,7 @@ 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');
@@ -41,7 +41,7 @@ export const getCustomerById = async function (this: WashdayClientInstance, cust
41
41
  const config = {
42
42
  headers: { Authorization: `Bearer ${this.apiToken}` }
43
43
  };
44
- const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}`, config);
44
+ const response = await this.axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}`, config);
45
45
  return response.data;
46
46
  } catch (error) {
47
47
  console.error('Error fetching customer:', error);
@@ -54,7 +54,7 @@ export const getCustomerHighlightsById = async function (this: WashdayClientInst
54
54
  const config = {
55
55
  headers: { Authorization: `Bearer ${this.apiToken}` }
56
56
  };
57
- const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, config);
57
+ const response = await this.axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, config);
58
58
  return response.data;
59
59
  } catch (error) {
60
60
  console.error('Error fetching getCustomerHighlightsById:', error);
@@ -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;
@@ -27,7 +27,7 @@ export const create = async function (this: WashdayClientInstance, data: {
27
27
  const config = {
28
28
  headers: { Authorization: `Bearer ${this.apiToken}` }
29
29
  };
30
- const response = await axiosInstance.post(`${GET_SET_CUSTOMERS}`, data, config);
30
+ const response = await this.axiosInstance.post(`${GET_SET_CUSTOMERS}`, data, config);
31
31
  return response;
32
32
  } catch (error) {
33
33
  console.error('Error fetching create:', error);
@@ -40,7 +40,7 @@ export const bulkCreate = async function (this: WashdayClientInstance, storeId:
40
40
  const config = {
41
41
  headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
42
42
  };
43
- const response = await axiosInstance.post(`${GET_SET_CUSTOMERS}/bulk`, data, config);
43
+ const response = await this.axiosInstance.post(`${GET_SET_CUSTOMERS}/bulk`, data, config);
44
44
  return response.data || {}
45
45
  } catch (error) {
46
46
  console.error('Error fetching customers bulkCreate:', error);
@@ -7,7 +7,7 @@ const GET_SET_CUSTOMERS_APP = 'api/v2/washdayapp/customers';
7
7
  // const config = {
8
8
  // headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
9
9
  // };
10
- // const response = await axiosInstance.put(`${GET_SET_PRODUCTS}/${storeId}/bulk`, data, config);
10
+ // const response = await this.axiosInstance.put(`${GET_SET_PRODUCTS}/${storeId}/bulk`, data, config);
11
11
  // return response.data || {}
12
12
  // } catch (error) {
13
13
  // console.error('Error fetching getStoreById:', 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,
@@ -7,7 +7,7 @@ export const deleteById = async function (this: WashdayClientInstance, storeId:
7
7
  const config = {
8
8
  headers: { Authorization: `Bearer ${this.apiToken}` }
9
9
  };
10
- const response = await axiosInstance.delete(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
10
+ const response = await this.axiosInstance.delete(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
11
11
  return response;
12
12
  } catch (error) {
13
13
  console.error('Error fetching deleteById:', error);
@@ -8,7 +8,7 @@ export const getInventory = async function (this: WashdayClientInstance, storeId
8
8
  const config = {
9
9
  headers: { Authorization: `Bearer ${this.apiToken}` }
10
10
  };
11
- const response = await axiosInstance.get(`${GET_SET_INVENTORY(storeId)}?${queryParams}`, config);
11
+ const response = await this.axiosInstance.get(`${GET_SET_INVENTORY(storeId)}?${queryParams}`, config);
12
12
  return response;
13
13
  } catch (error) {
14
14
  console.error('Error fetching getInventory:', error);
@@ -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;
@@ -43,7 +43,7 @@ export const getHistoryById = async function (this: WashdayClientInstance, store
43
43
  if (params?.hasOwnProperty('limit')) {
44
44
  queryParams += `&limit=${params?.limit}`
45
45
  }
46
- const response = await axiosInstance.get(`${GET_SET_INVENTORY(storeId)}/${id}/history?${queryParams}`, config);
46
+ const response = await this.axiosInstance.get(`${GET_SET_INVENTORY(storeId)}/${id}/history?${queryParams}`, config);
47
47
  return response;
48
48
  } catch (error) {
49
49
  console.error('Error fetching getInventoryHistory:', error);
@@ -13,7 +13,7 @@ export const create = async function (this: WashdayClientInstance, storeId: stri
13
13
  const config = {
14
14
  headers: { Authorization: `Bearer ${this.apiToken}` }
15
15
  };
16
- const response = await axiosInstance.post(`${GET_SET_INVENTORY(storeId)}`, data, config);
16
+ const response = await this.axiosInstance.post(`${GET_SET_INVENTORY(storeId)}`, data, config);
17
17
  return response;
18
18
  } catch (error) {
19
19
  console.error('Error fetching create:', error);
@@ -10,7 +10,7 @@ export const updateById = async function (this: WashdayClientInstance, storeId:
10
10
  const config = {
11
11
  headers: { Authorization: `Bearer ${this.apiToken}` }
12
12
  };
13
- const response = await axiosInstance.put(`${GET_SET_INVENTORY(storeId)}/${id}`, data, config);
13
+ const response = await this.axiosInstance.put(`${GET_SET_INVENTORY(storeId)}/${id}`, data, config);
14
14
  return response;
15
15
  } catch (error) {
16
16
  console.error('Error fetching updateById:', error);
@@ -26,7 +26,7 @@ export const addStock = async function (this: WashdayClientInstance, storeId: st
26
26
  const config = {
27
27
  headers: { Authorization: `Bearer ${this.apiToken}` }
28
28
  };
29
- const response = await axiosInstance.put(`${GET_SET_INVENTORY(storeId)}/${id}/add-stock`, data, config);
29
+ const response = await this.axiosInstance.put(`${GET_SET_INVENTORY(storeId)}/${id}/add-stock`, data, config);
30
30
  return response;
31
31
  } catch (error) {
32
32
  console.error('Error fetching addStock:', 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;