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
@@ -18,7 +18,6 @@ var __rest = (this && this.__rest) || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
- import axiosInstance from "../axiosInstance";
22
21
  const GET_SET_ROUTES = 'api/routes';
23
22
  const GET_STORE_ROUTES_BY_ID = 'api/stores/:id/routes';
24
23
  //@deprecated
@@ -28,7 +27,7 @@ export const createRoute = function (data) {
28
27
  const config = {
29
28
  headers: { Authorization: `Bearer ${this.apiToken}` }
30
29
  };
31
- return yield axiosInstance.post(GET_SET_ROUTES, data, config);
30
+ return yield this.axiosInstance.post(GET_SET_ROUTES, data, config);
32
31
  }
33
32
  catch (error) {
34
33
  console.error('Error fetching createRoute:', error);
@@ -43,7 +42,7 @@ export const createRouteV2 = function (data) {
43
42
  headers: { Authorization: `Bearer ${this.apiToken}` }
44
43
  };
45
44
  const { storeId } = data, rest = __rest(data, ["storeId"]);
46
- return yield axiosInstance.post(GET_STORE_ROUTES_BY_ID.replace(':id', storeId), rest, config);
45
+ return yield this.axiosInstance.post(GET_STORE_ROUTES_BY_ID.replace(':id', storeId), rest, config);
47
46
  }
48
47
  catch (error) {
49
48
  console.error('Error fetching createRouteV2:', error);
@@ -57,7 +56,7 @@ export const startRoute = function (routeId) {
57
56
  const config = {
58
57
  headers: { Authorization: `Bearer ${this.apiToken}` }
59
58
  };
60
- return yield axiosInstance.post(`${GET_SET_ROUTES}/${routeId}/start`, {}, config);
59
+ return yield this.axiosInstance.post(`${GET_SET_ROUTES}/${routeId}/start`, {}, config);
61
60
  }
62
61
  catch (error) {
63
62
  console.error('Error fetching startRoute:', error);
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import axiosInstance from "../axiosInstance";
11
10
  const GET_STORE_ROUTES = 'api/storeRoutes';
12
11
  const GET_ROUTE = 'api/routes';
13
12
  export const closeStoreRoutes = function (storeId, data) {
@@ -16,7 +15,7 @@ export const closeStoreRoutes = function (storeId, data) {
16
15
  const config = {
17
16
  headers: { Authorization: `Bearer ${this.apiToken}` }
18
17
  };
19
- return yield axiosInstance.put(`${GET_STORE_ROUTES}/${storeId}/close`, data, config);
18
+ return yield this.axiosInstance.put(`${GET_STORE_ROUTES}/${storeId}/close`, data, config);
20
19
  }
21
20
  catch (error) {
22
21
  console.error('Error fetching closeStoreRoutes:', error);
@@ -30,7 +29,7 @@ export const closeRouteById = function (routeId) {
30
29
  const config = {
31
30
  headers: { Authorization: `Bearer ${this.apiToken}` }
32
31
  };
33
- return yield axiosInstance.put(`${GET_ROUTE}/${routeId}/close`, {}, config);
32
+ return yield this.axiosInstance.put(`${GET_ROUTE}/${routeId}/close`, {}, config);
34
33
  }
35
34
  catch (error) {
36
35
  console.error('Error fetching closeRouteById:', error);
@@ -44,7 +43,7 @@ export const updateRouteById = function (routeId, data) {
44
43
  const config = {
45
44
  headers: { Authorization: `Bearer ${this.apiToken}` }
46
45
  };
47
- return yield axiosInstance.put(`${GET_ROUTE}/${routeId}`, data, config);
46
+ return yield this.axiosInstance.put(`${GET_ROUTE}/${routeId}`, data, config);
48
47
  }
49
48
  catch (error) {
50
49
  console.error('Error fetching updateRouteById:', error);
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import axiosInstance from "../axiosInstance";
11
10
  const GET_SET_SECTIONS = 'api/section';
12
11
  export const deleteById = function (id) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const deleteById = function (id) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- return yield axiosInstance.delete(`${GET_SET_SECTIONS}/${id}`, config);
17
+ return yield this.axiosInstance.delete(`${GET_SET_SECTIONS}/${id}`, config);
19
18
  }
20
19
  catch (error) {
21
20
  console.error('Error fetching deleteById:', error);
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { generateQueryParamsStr } from "../../utils/apiUtils";
11
- import axiosInstance from "../axiosInstance";
12
11
  const GET_SET_SECTIONS = 'api/section';
13
12
  const GET_SET_SECTIONS_WASHDAY_APP = 'api/v2/washdayapp/sections';
14
13
  export const getList = function (params) {
@@ -30,7 +29,7 @@ export const getList = function (params) {
30
29
  if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('products')) {
31
30
  queryParams += `&products=${params === null || params === void 0 ? void 0 : params.products}`;
32
31
  }
33
- return yield axiosInstance.get(`${GET_SET_SECTIONS}?${queryParams}`, config);
32
+ return yield this.axiosInstance.get(`${GET_SET_SECTIONS}?${queryParams}`, config);
34
33
  }
35
34
  catch (error) {
36
35
  console.error('Error fetching getStoreStaff:', error);
@@ -44,7 +43,7 @@ export const getById = function (id) {
44
43
  const config = {
45
44
  headers: { Authorization: `Bearer ${this.apiToken}` }
46
45
  };
47
- return yield axiosInstance.get(`${GET_SET_SECTIONS}/${id}`, config);
46
+ return yield this.axiosInstance.get(`${GET_SET_SECTIONS}/${id}`, config);
48
47
  }
49
48
  catch (error) {
50
49
  console.error('Error fetching getSectionById:', error);
@@ -61,7 +60,7 @@ export const getSectionsByStoreCustomersApp = function (params) {
61
60
  const queryParams = generateQueryParamsStr([
62
61
  'storeId',
63
62
  ], params);
64
- return yield axiosInstance.get(`${GET_SET_SECTIONS_WASHDAY_APP}?${queryParams}`, config);
63
+ return yield this.axiosInstance.get(`${GET_SET_SECTIONS_WASHDAY_APP}?${queryParams}`, config);
65
64
  }
66
65
  catch (error) {
67
66
  console.error('Error fetching getSectionsByStoreCustomersApp:', error);
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import axiosInstance from "../axiosInstance";
11
10
  const GET_SET_SECTIONS = 'api/section';
12
11
  export const updateById = function (id, data) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const updateById = function (id, data) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- return yield axiosInstance.put(`${GET_SET_SECTIONS}/${id}`, data, config);
17
+ return yield this.axiosInstance.put(`${GET_SET_SECTIONS}/${id}`, data, config);
19
18
  }
20
19
  catch (error) {
21
20
  console.error('Error fetching updateById:', error);
@@ -30,7 +30,7 @@ export const getStoreStaffById = function (storeId, staffId) {
30
30
  const config = {
31
31
  headers: { Authorization: `Bearer ${this.apiToken}` }
32
32
  };
33
- return yield axiosInstance.get(`${GET_SET_STAFF(storeId)}/${staffId}`, config);
33
+ return yield this.axiosInstance.get(`${GET_SET_STAFF(storeId)}/${staffId}`, config);
34
34
  }
35
35
  catch (error) {
36
36
  console.error('Error fetching getStoreStaffById:', error);
@@ -61,7 +61,7 @@ export const createGetMoreCheckoutSession = function (data) {
61
61
  const config = {
62
62
  headers: { Authorization: `Bearer ${this.apiToken}` }
63
63
  };
64
- return yield axiosInstance.post(`${GENERATE_CHECKOUT_SESSION}`, data, config);
64
+ return yield this.axiosInstance.post(`${GENERATE_CHECKOUT_SESSION}`, data, config);
65
65
  }
66
66
  catch (error) {
67
67
  console.error('Error fetching createGetMoreCheckoutSession:', error);
@@ -30,7 +30,7 @@ export const getSupplyById = function (storeId, id) {
30
30
  const config = {
31
31
  headers: { Authorization: `Bearer ${this.apiToken}` }
32
32
  };
33
- return yield axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}`, config);
33
+ return yield this.axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}`, config);
34
34
  }
35
35
  catch (error) {
36
36
  console.error('Error fetching getStoreSupplyById:', error);
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import axiosInstance from "../axiosInstance";
11
10
  const GET_SET_USER = 'api/users';
12
11
  export const validateUserPin = function (data) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const validateUserPin = function (data) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- return yield axiosInstance.post(`${GET_SET_USER}/validate-pin`, data, config);
17
+ return yield this.axiosInstance.post(`${GET_SET_USER}/validate-pin`, data, config);
19
18
  }
20
19
  catch (error) {
21
20
  console.error('Error fetching validateUserPin:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -28,7 +28,7 @@ export const getHistory = async function (this: WashdayClientInstance, params: {
28
28
  queryParams = queryParams.slice(0, -1);
29
29
 
30
30
  const url = queryParams ? `${ATTENDANCE_API}/history?${queryParams}` : `${ATTENDANCE_API}/history`;
31
- return await axiosInstance.get(url, config);
31
+ return await this.axiosInstance.get(url, config);
32
32
  } catch (error) {
33
33
  console.error('Error fetching attendance history:', error);
34
34
  throw error;
@@ -52,7 +52,7 @@ export const getStatus = async function (this: WashdayClientInstance, params?: {
52
52
  queryParams = queryParams.slice(0, -1);
53
53
 
54
54
  const url = queryParams ? `${ATTENDANCE_API}/status?${queryParams}` : `${ATTENDANCE_API}/status`;
55
- return await axiosInstance.get(url, config);
55
+ return await this.axiosInstance.get(url, config);
56
56
  } catch (error) {
57
57
  console.error('Error fetching attendance status:', error);
58
58
  throw error;
@@ -82,7 +82,7 @@ export const getStoreReport = async function (this: WashdayClientInstance, store
82
82
  queryParams = queryParams.slice(0, -1);
83
83
 
84
84
  const url = queryParams ? `${ATTENDANCE_API}/store/${storeId}/report?${queryParams}` : `${ATTENDANCE_API}/store/${storeId}/report`;
85
- return await axiosInstance.get(url, config);
85
+ return await this.axiosInstance.get(url, config);
86
86
  } catch (error) {
87
87
  console.error('Error fetching store attendance report:', error);
88
88
  throw error;
@@ -115,7 +115,7 @@ export const exportStoreReport = async function (this: WashdayClientInstance, st
115
115
  queryParams = queryParams.slice(0, -1);
116
116
 
117
117
  const url = queryParams ? `${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}` : `${ATTENDANCE_API}/store/${storeId}/report/export`;
118
- return await axiosInstance.get(url, config);
118
+ return await this.axiosInstance.get(url, config);
119
119
  } catch (error) {
120
120
  console.error('Error exporting store attendance report:', error);
121
121
  throw error;
@@ -12,7 +12,7 @@ export const clockIn = async function (this: WashdayClientInstance, data: {
12
12
  const config = {
13
13
  headers: { Authorization: `Bearer ${this.apiToken}` }
14
14
  };
15
- return await axiosInstance.post(`${ATTENDANCE_API}/clock-in`, data, config);
15
+ return await this.axiosInstance.post(`${ATTENDANCE_API}/clock-in`, data, config);
16
16
  } catch (error) {
17
17
  console.error('Error clock-in:', error);
18
18
  throw error;
@@ -28,7 +28,7 @@ export const clockOut = async function (this: WashdayClientInstance, data: {
28
28
  const config = {
29
29
  headers: { Authorization: `Bearer ${this.apiToken}` }
30
30
  };
31
- return await axiosInstance.post(`${ATTENDANCE_API}/clock-out`, data, config);
31
+ return await this.axiosInstance.post(`${ATTENDANCE_API}/clock-out`, data, config);
32
32
  } catch (error) {
33
33
  console.error('Error clock-out:', error);
34
34
  throw error;
@@ -12,7 +12,7 @@ export const updateById = async function (this: WashdayClientInstance, id: strin
12
12
  const config = {
13
13
  headers: { Authorization: `Bearer ${this.apiToken}` }
14
14
  };
15
- return await axiosInstance.put(`${ATTENDANCE_API}/${id}`, data, config);
15
+ return await this.axiosInstance.put(`${ATTENDANCE_API}/${id}`, data, config);
16
16
  } catch (error) {
17
17
  console.error('Error updating attendance entry:', error);
18
18
  throw error;
@@ -10,7 +10,7 @@ export const customerLoginToken = async function (this: WashdayClientInstance, p
10
10
  }): Promise<any> {
11
11
  try {
12
12
  const config = {};
13
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/tokenLogin`, params, config);
13
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/tokenLogin`, params, config);
14
14
  } catch (error) {
15
15
  console.error('Error fetching customerLoginToken:', error);
16
16
  throw error;
@@ -24,7 +24,7 @@ export const appleLogin = async function (this: WashdayClientInstance, params: {
24
24
  }): Promise<any> {
25
25
  try {
26
26
  const config = {};
27
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/apple`, params, config);
27
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/apple`, params, config);
28
28
  } catch (error) {
29
29
  console.error('Error fetching appleLogin:', error);
30
30
  throw error;
@@ -39,7 +39,7 @@ export const facebookLogin = async function (this: WashdayClientInstance, params
39
39
  }): Promise<any> {
40
40
  try {
41
41
  const config = {};
42
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/facebook`, params, config);
42
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/facebook`, params, config);
43
43
  } catch (error) {
44
44
  console.error('Error fetching facebookLogin:', error);
45
45
  throw error;
@@ -54,7 +54,7 @@ export const customerRegularLogin = async function (this: WashdayClientInstance,
54
54
  }): Promise<any> {
55
55
  try {
56
56
  const config = {};
57
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/login`, params, config);
57
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/login`, params, config);
58
58
  } catch (error) {
59
59
  console.error('Error fetching customerRegularLogin:', error);
60
60
  throw error;
@@ -71,7 +71,7 @@ export const customerSignUp = async function (this: WashdayClientInstance, param
71
71
  }): Promise<any> {
72
72
  try {
73
73
  const config = {};
74
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/signUp`, params, config);
74
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/signUp`, params, config);
75
75
  } catch (error) {
76
76
  console.error('Error fetching customerSignUp:', error);
77
77
  throw error;
@@ -91,7 +91,7 @@ export const googleLogin = async function (this: WashdayClientInstance, params:
91
91
  }): Promise<any> {
92
92
  try {
93
93
  const config = {};
94
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/google`, params, config);
94
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/google`, params, config);
95
95
  } catch (error) {
96
96
  console.error('Error fetching googleLogin:', error);
97
97
  throw error;
@@ -104,7 +104,7 @@ export const regularUserLogin = async function (this: WashdayClientInstance, par
104
104
  }): Promise<any> {
105
105
  try {
106
106
  const config = {};
107
- return await axiosInstance.post(`${REGULAR_USER_AUTH}/login`, params, config);
107
+ return await this.axiosInstance.post(`${REGULAR_USER_AUTH}/login`, params, config);
108
108
  } catch (error) {
109
109
  console.error('Error fetching regularUserLogin:', error);
110
110
  throw error;
@@ -124,7 +124,7 @@ export const companySignUp = async function (this: WashdayClientInstance, params
124
124
  }): Promise<any> {
125
125
  try {
126
126
  const config = {};
127
- return await axiosInstance.post(`${REGULAR_USER_AUTH}/register`, params, config);
127
+ return await this.axiosInstance.post(`${REGULAR_USER_AUTH}/register`, params, config);
128
128
  } catch (error) {
129
129
  console.error('Error fetching companySignUp:', error);
130
130
  throw error;
@@ -137,7 +137,7 @@ export const regularUserTokenLogin = async function (this: WashdayClientInstance
137
137
  }): Promise<any> {
138
138
  try {
139
139
  const config = {};
140
- return await axiosInstance.post(`${REGULAR_USER_AUTH}/tokenLogin`, params, config);
140
+ return await this.axiosInstance.post(`${REGULAR_USER_AUTH}/tokenLogin`, params, config);
141
141
  } catch (error) {
142
142
  console.error('Error fetching regularUserTokenLogin:', error);
143
143
  throw error;
@@ -150,7 +150,7 @@ export const forgotPassword = async function (this: WashdayClientInstance, param
150
150
  }): Promise<any> {
151
151
  try {
152
152
  const config = {};
153
- return await axiosInstance.post(`${REGULAR_USER_AUTH}/forget-password`, params, config);
153
+ return await this.axiosInstance.post(`${REGULAR_USER_AUTH}/forget-password`, params, config);
154
154
  } catch (error) {
155
155
  console.error('Error fetching forgotPassword:', error);
156
156
  throw error;
@@ -163,7 +163,7 @@ export const customersAppForgotPassword = async function (this: WashdayClientIns
163
163
  }): Promise<any> {
164
164
  try {
165
165
  const config = {};
166
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/${companyId}/forget-password`, params, config);
166
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/${companyId}/forget-password`, params, config);
167
167
  } catch (error) {
168
168
  console.error('Error fetching customersAppForgotPassword:', error);
169
169
  throw error;
@@ -176,7 +176,7 @@ export const customersAppChangePassword = async function (this: WashdayClientIns
176
176
  }): Promise<any> {
177
177
  try {
178
178
  const config = {};
179
- return await axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/change-password`, params, config);
179
+ return await this.axiosInstance.post(`${CUSTOMERSAPP_GET_AUTH}/change-password`, params, config);
180
180
  } catch (error) {
181
181
  console.error('Error fetching customerSignUp:', error);
182
182
  throw error;
@@ -190,7 +190,7 @@ export const pinLogin = async function (this: WashdayClientInstance, data: {
190
190
  const config = {
191
191
  headers: { Authorization: `Bearer ${this.apiToken}` }
192
192
  };
193
- return await axiosInstance.post(`${REGULAR_USER_AUTH}/pin-login`, data, config);
193
+ return await this.axiosInstance.post(`${REGULAR_USER_AUTH}/pin-login`, data, config);
194
194
  } catch (error) {
195
195
  console.error('Error fetching pinLogin:', error);
196
196
  throw error;
@@ -4,51 +4,62 @@ import { v4 } from 'uuid';
4
4
  // Define the type for the Axios instance
5
5
  let axiosInstance: AxiosInstance | null = null;
6
6
 
7
- // const BASE_URL: string = 'http://localhost:5555/';
8
- // const BASE_URL: string = 'https://washday-backend-development.herokuapp.com/';
7
+ const DEV_BASE_URL: string = 'http://localhost:5555/';
8
+ const STAGE_BASE_URL: string = 'https://washday-backend-development.herokuapp.com/';
9
+ const PROD_BASE_URL: string = 'https://washday-backend.herokuapp.com/';
9
10
  const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
10
11
 
11
12
  // Function to create or return the singleton instance
12
- const getAxiosInstance = (): AxiosInstance => {
13
- if (!axiosInstance) {
14
- axiosInstance = axios.create({
15
- baseURL: BASE_URL,
16
- headers: {
17
- 'Content-Type': 'application/json',
18
- // Add any default headers here
19
- },
20
- });
21
-
22
- // Add interceptor to set token and other options for every request
23
- axiosInstance.interceptors.request.use(
24
- (config) => {
25
- const { token, responseType = 'json', contentDisposition } = config.params || {};
26
- const { Authorization } = config.headers || {};
27
- let contentType = config.headers['Content-Type'];
28
- if (contentType === null || contentType === undefined) {
29
- contentType = 'application/json';
30
- }
31
- if (Authorization || token) {
32
- config.headers.Authorization = Authorization || `Bearer ${token}`;
33
- }
34
- if (contentType) {
35
- config.headers['Content-Type'] = contentType;
36
- }
37
- if (responseType) {
38
- config.responseType = responseType;
39
- }
40
- if (contentDisposition) {
41
- config.headers['Content-Disposition'] = contentDisposition;
42
- }
13
+ export const getAxiosInstance = (env: string = 'PROD'): AxiosInstance => {
14
+ let baseURL = BASE_URL;
15
+ switch (env) {
16
+ case 'DEV':
17
+ baseURL = DEV_BASE_URL;
18
+ break;
19
+ case 'STAGE':
20
+ baseURL = STAGE_BASE_URL;
21
+ break;
22
+ case 'PROD':
23
+ baseURL = PROD_BASE_URL;
24
+ break;
25
+ }
26
+ axiosInstance = axios.create({
27
+ baseURL: baseURL,
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ // Add any default headers here
31
+ },
32
+ });
43
33
 
44
- config.headers['x-request-id'] = v4(); // used to track requests in the backend
45
- return config;
46
- },
47
- (error) => {
48
- return Promise.reject(error);
34
+ // Add interceptor to set token and other options for every request
35
+ axiosInstance.interceptors.request.use(
36
+ (config) => {
37
+ const { token, responseType = 'json', contentDisposition } = config.params || {};
38
+ const { Authorization } = config.headers || {};
39
+ let contentType = config.headers['Content-Type'];
40
+ if (contentType === null || contentType === undefined) {
41
+ contentType = 'application/json';
49
42
  }
50
- );
51
- }
43
+ if (Authorization || token) {
44
+ config.headers.Authorization = Authorization || `Bearer ${token}`;
45
+ }
46
+ if (contentType) {
47
+ config.headers['Content-Type'] = contentType;
48
+ }
49
+ if (responseType) {
50
+ config.responseType = responseType;
51
+ }
52
+ if (contentDisposition) {
53
+ config.headers['Content-Disposition'] = contentDisposition;
54
+ }
55
+
56
+ config.headers['x-request-id'] = v4(); // used to track requests in the backend
57
+ return config;
58
+ },
59
+ (error) => {
60
+ return Promise.reject(error);
61
+ }
62
+ );
52
63
  return axiosInstance;
53
64
  };
54
65
 
@@ -8,7 +8,7 @@ export const deleteCashierBoxById = async function (this: WashdayClientInstance,
8
8
  const config = {
9
9
  headers: { Authorization: `Bearer ${this.apiToken}` }
10
10
  };
11
- return await axiosInstance.delete(`${GET_SET_CASHIER_BOX(storeId)}/${id}`, config);
11
+ return await this.axiosInstance.delete(`${GET_SET_CASHIER_BOX(storeId)}/${id}`, config);
12
12
  } catch (error) {
13
13
  console.error('Error fetching getStoreStaff:', error);
14
14
  throw error;
@@ -20,7 +20,7 @@ export const deleteCashierBoxMovementById = async function (this: WashdayClientI
20
20
  const config = {
21
21
  headers: { Authorization: `Bearer ${this.apiToken}` }
22
22
  };
23
- return await axiosInstance.delete(`${GET_SET_CASHIER_BOX_MOVEMENT(storeId, cashierBoxId)}/${movementId}`, config);
23
+ return await this.axiosInstance.delete(`${GET_SET_CASHIER_BOX_MOVEMENT(storeId, cashierBoxId)}/${movementId}`, config);
24
24
  } catch (error) {
25
25
  console.error('Error fetching getStoreStaff:', error);
26
26
  throw error;
@@ -7,7 +7,7 @@ export const deleteCashUpReport = async function (this: WashdayClientInstance, s
7
7
  const config = {
8
8
  headers: { Authorization: `Bearer ${this.apiToken}` }
9
9
  };
10
- return await axiosInstance.delete(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
10
+ return await this.axiosInstance.delete(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
11
11
  } catch (error) {
12
12
  console.error('Error fetching:', error);
13
13
  throw error;
@@ -20,7 +20,7 @@ export const getList = async function (this: WashdayClientInstance, storeId: str
20
20
  'limit',
21
21
  'cashierBoxId'
22
22
  ], params);
23
- return await axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}?${queryParams}`, config);
23
+ return await this.axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}?${queryParams}`, config);
24
24
  } catch (error) {
25
25
  console.error('Error fetching getList orders:', error);
26
26
  throw error;
@@ -32,7 +32,7 @@ export const getById = async function (this: WashdayClientInstance, storeId: str
32
32
  const config = {
33
33
  headers: { Authorization: `Bearer ${this.apiToken}` }
34
34
  };
35
- return await axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
35
+ return await this.axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
36
36
  } catch (error) {
37
37
  console.error('Error fetching:', error);
38
38
  throw error;
@@ -44,7 +44,7 @@ export const getPreviewDataForCashClose = async function (this: WashdayClientIns
44
44
  const config = {
45
45
  headers: { Authorization: `Bearer ${this.apiToken}` }
46
46
  };
47
- return await axiosInstance.get(`${GET_CASH_UP}/${storeId}/${id}`, config);
47
+ return await this.axiosInstance.get(`${GET_CASH_UP}/${storeId}/${id}`, config);
48
48
  } catch (error) {
49
49
  console.error('Error fetching:', error);
50
50
  throw error;
@@ -15,7 +15,7 @@ export const create = async function (this: WashdayClientInstance, storeId: stri
15
15
  const config = {
16
16
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
17
  };
18
- return await axiosInstance.post(`${GET_CASH_UP}/${storeId}/${id}`, data, config);
18
+ return await this.axiosInstance.post(`${GET_CASH_UP}/${storeId}/${id}`, data, config);
19
19
  } catch (error) {
20
20
  console.error('Error fetching create:', error);
21
21
  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;
@@ -10,7 +10,7 @@ export const cancelCFDI = async function (this: WashdayClientInstance, id: strin
10
10
  const config = {
11
11
  headers: { Authorization: `Bearer ${this.apiToken}` }
12
12
  };
13
- return await axiosInstance.delete(`${GET_SET_CFDI}/${id}`, {
13
+ return await this.axiosInstance.delete(`${GET_SET_CFDI}/${id}`, {
14
14
  ...config,
15
15
  data
16
16
  });
@@ -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;