washday-sdk 1.2.0 → 1.3.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 (78) hide show
  1. package/dist/api/cashierbox/get.js +3 -4
  2. package/dist/api/cashierbox/post.js +2 -3
  3. package/dist/api/cashierbox/put.js +2 -3
  4. package/dist/api/companies/get.js +1 -2
  5. package/dist/api/companies/post.js +2 -3
  6. package/dist/api/companies/put.js +3 -4
  7. package/dist/api/countries/get.js +1 -2
  8. package/dist/api/customers/get.js +2 -3
  9. package/dist/api/customers/post.js +2 -3
  10. package/dist/api/customers/put.js +1 -1
  11. package/dist/api/index.js +6 -0
  12. package/dist/api/integrations/delete.js +1 -0
  13. package/dist/api/integrations/get.js +23 -0
  14. package/dist/api/integrations/index.js +3 -0
  15. package/dist/api/integrations/post.js +36 -0
  16. package/dist/api/integrations/put.js +1 -0
  17. package/dist/api/inventory/delete.js +1 -2
  18. package/dist/api/inventory/get.js +2 -3
  19. package/dist/api/inventory/post.js +1 -2
  20. package/dist/api/inventory/put.js +2 -3
  21. package/dist/api/products/delete.js +1 -2
  22. package/dist/api/products/post.js +4 -5
  23. package/dist/api/products/put.js +2 -3
  24. package/dist/api/sections/post.js +1 -2
  25. package/dist/api/staff/delete.js +1 -2
  26. package/dist/api/staff/get.js +1 -2
  27. package/dist/api/staff/post.js +1 -2
  28. package/dist/api/staff/put.js +1 -2
  29. package/dist/api/stores/get.js +6 -7
  30. package/dist/api/stores/post.js +3 -4
  31. package/dist/api/stores/put.js +2 -3
  32. package/dist/api/stripe/post.js +3 -4
  33. package/dist/api/supplies/delete.js +1 -2
  34. package/dist/api/supplies/get.js +2 -3
  35. package/dist/api/supplies/post.js +1 -2
  36. package/dist/api/supplies/put.js +2 -3
  37. package/dist/api/users/delete.js +1 -2
  38. package/dist/api/users/put.js +1 -2
  39. package/package.json +1 -1
  40. package/src/api/cashierbox/get.ts +3 -3
  41. package/src/api/cashierbox/post.ts +2 -2
  42. package/src/api/cashierbox/put.ts +2 -2
  43. package/src/api/companies/get.ts +1 -1
  44. package/src/api/companies/post.ts +2 -2
  45. package/src/api/companies/put.ts +3 -3
  46. package/src/api/countries/get.ts +1 -1
  47. package/src/api/customers/get.ts +2 -2
  48. package/src/api/customers/post.ts +2 -2
  49. package/src/api/customers/put.ts +1 -1
  50. package/src/api/index.ts +8 -1
  51. package/src/api/integrations/delete.ts +0 -0
  52. package/src/api/integrations/get.ts +15 -0
  53. package/src/api/integrations/index.ts +3 -0
  54. package/src/api/integrations/post.ts +30 -0
  55. package/src/api/integrations/put.ts +0 -0
  56. package/src/api/inventory/delete.ts +1 -1
  57. package/src/api/inventory/get.ts +2 -2
  58. package/src/api/inventory/post.ts +1 -1
  59. package/src/api/inventory/put.ts +2 -2
  60. package/src/api/products/delete.ts +1 -1
  61. package/src/api/products/post.ts +4 -4
  62. package/src/api/products/put.ts +2 -2
  63. package/src/api/sections/post.ts +1 -1
  64. package/src/api/staff/delete.ts +1 -1
  65. package/src/api/staff/get.ts +1 -1
  66. package/src/api/staff/post.ts +1 -1
  67. package/src/api/staff/put.ts +1 -1
  68. package/src/api/stores/get.ts +6 -6
  69. package/src/api/stores/post.ts +3 -3
  70. package/src/api/stores/put.ts +2 -2
  71. package/src/api/stripe/post.ts +3 -3
  72. package/src/api/supplies/delete.ts +1 -1
  73. package/src/api/supplies/get.ts +2 -2
  74. package/src/api/supplies/post.ts +1 -1
  75. package/src/api/supplies/put.ts +2 -2
  76. package/src/api/users/delete.ts +1 -1
  77. package/src/api/users/put.ts +1 -1
  78. package/src/interfaces/Api.ts +6 -0
@@ -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_STORES = 'api/store';
13
12
  const GET_SET_STORE_IMAGE = 'api/store-image';
14
13
  const REQUEST_PARAMS = {
@@ -24,7 +23,7 @@ export const getStores = function (params) {
24
23
  if (params.isActive) {
25
24
  queryParams += `isActive=${params.isActive}`;
26
25
  }
27
- const response = yield axiosInstance.get(`${GET_SET_STORES}?${queryParams}`, { params: Object.assign({}, REQUEST_PARAMS) });
26
+ const response = yield this.axiosInstance.get(`${GET_SET_STORES}?${queryParams}`, { params: Object.assign({}, REQUEST_PARAMS) });
28
27
  return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.stores) || [];
29
28
  }
30
29
  catch (error) {
@@ -39,7 +38,7 @@ export const getStoreReviewLink = function (storeId) {
39
38
  const config = {
40
39
  headers: { Authorization: `Bearer ${this.apiToken}` }
41
40
  };
42
- const response = yield axiosInstance.get(`${GET_SET_STORES}/review-link/${storeId}`, config);
41
+ const response = yield this.axiosInstance.get(`${GET_SET_STORES}/review-link/${storeId}`, config);
43
42
  return response;
44
43
  }
45
44
  catch (error) {
@@ -53,7 +52,7 @@ export const getStoreById = function (storeId) {
53
52
  var _a;
54
53
  try {
55
54
  REQUEST_PARAMS.token = this.apiToken;
56
- const response = yield axiosInstance.get(`${GET_SET_STORES}/${storeId}`, { params: Object.assign({}, REQUEST_PARAMS) });
55
+ const response = yield this.axiosInstance.get(`${GET_SET_STORES}/${storeId}`, { params: Object.assign({}, REQUEST_PARAMS) });
57
56
  return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.data) || {};
58
57
  }
59
58
  catch (error) {
@@ -68,7 +67,7 @@ export const getStoreImages = function (storeId) {
68
67
  const config = {
69
68
  headers: { Authorization: `Bearer ${this.apiToken}` }
70
69
  };
71
- const response = yield axiosInstance.get(`${GET_SET_STORE_IMAGE}?store=${storeId}`, config);
70
+ const response = yield this.axiosInstance.get(`${GET_SET_STORE_IMAGE}?store=${storeId}`, config);
72
71
  return response;
73
72
  }
74
73
  catch (error) {
@@ -83,7 +82,7 @@ export const getStoresByName = function (query) {
83
82
  try {
84
83
  const config = {};
85
84
  const queryParams = generateQueryParamsStr(['q'], query);
86
- const response = yield axiosInstance.get(`${GET_STORES_WASHDAY_APP}?${queryParams}`, config);
85
+ const response = yield this.axiosInstance.get(`${GET_STORES_WASHDAY_APP}?${queryParams}`, config);
87
86
  return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.stores) || [];
88
87
  }
89
88
  catch (error) {
@@ -99,7 +98,7 @@ export const getStoresByIdCustomersApp = function (id) {
99
98
  const config = {
100
99
  headers: { Authorization: `Bearer ${this.apiToken}` }
101
100
  };
102
- const response = yield axiosInstance.get(`${GET_STORES_WASHDAY_APP}/${id}`, config);
101
+ const response = yield this.axiosInstance.get(`${GET_STORES_WASHDAY_APP}/${id}`, config);
103
102
  return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.store) || [];
104
103
  }
105
104
  catch (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_STORE_IMAGE = 'api/store-image';
12
11
  const GET_SET_STORES = 'api/store';
13
12
  export const createStoreImage = function (data) {
@@ -16,7 +15,7 @@ export const createStoreImage = function (data) {
16
15
  const config = {
17
16
  headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
18
17
  };
19
- const response = yield axiosInstance.post(`${GET_SET_STORE_IMAGE}`, data, config);
18
+ const response = yield this.axiosInstance.post(`${GET_SET_STORE_IMAGE}`, data, config);
20
19
  return response;
21
20
  }
22
21
  catch (error) {
@@ -31,7 +30,7 @@ export const createStore = function (data) {
31
30
  const config = {
32
31
  headers: { Authorization: `Bearer ${this.apiToken}` }
33
32
  };
34
- const response = yield axiosInstance.post(`${GET_SET_STORES}`, data, config);
33
+ const response = yield this.axiosInstance.post(`${GET_SET_STORES}`, data, config);
35
34
  return response;
36
35
  }
37
36
  catch (error) {
@@ -48,7 +47,7 @@ export const copyStore = function (copyStoreId) {
48
47
  const config = {
49
48
  headers: { Authorization: `Bearer ${this.apiToken}` }
50
49
  };
51
- const response = yield axiosInstance.post(`${GET_SET_STORES}/copy`, {
50
+ const response = yield this.axiosInstance.post(`${GET_SET_STORES}/copy`, {
52
51
  fromStoreId: copyStoreId
53
52
  }, config);
54
53
  return response;
@@ -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_STORES = 'api/store';
12
11
  const REQUEST_PARAMS = {
13
12
  token: 'LOGGED_USER_TOKEN',
@@ -18,7 +17,7 @@ export const updateStoreById = function (storeId, data) {
18
17
  const config = {
19
18
  headers: { Authorization: `Bearer ${this.apiToken}` }
20
19
  };
21
- const response = yield axiosInstance.put(`${GET_SET_STORES}/${storeId}`, data, config);
20
+ const response = yield this.axiosInstance.put(`${GET_SET_STORES}/${storeId}`, data, config);
22
21
  return response.data || {};
23
22
  }
24
23
  catch (error) {
@@ -33,7 +32,7 @@ export const deleteStoreById = function (storeId) {
33
32
  const config = {
34
33
  headers: { Authorization: `Bearer ${this.apiToken}` }
35
34
  };
36
- const response = yield axiosInstance.delete(`${GET_SET_STORES}/${storeId}`, config);
35
+ const response = yield this.axiosInstance.delete(`${GET_SET_STORES}/${storeId}`, config);
37
36
  return response;
38
37
  }
39
38
  catch (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_STRIPE = 'api/stripe';
12
11
  const GENERATE_CHECKOUT_SESSION = 'api/orders/create-checkout-session';
13
12
  export const createCreateSuscriptionCheckoutSession = function (data) {
@@ -16,7 +15,7 @@ export const createCreateSuscriptionCheckoutSession = function (data) {
16
15
  const config = {
17
16
  headers: { Authorization: `Bearer ${this.apiToken}` }
18
17
  };
19
- const response = yield axiosInstance.post(`${GET_SET_STRIPE}/create-subscription-checkout-session`, data, config);
18
+ const response = yield this.axiosInstance.post(`${GET_SET_STRIPE}/create-subscription-checkout-session`, data, config);
20
19
  return response;
21
20
  }
22
21
  catch (error) {
@@ -31,7 +30,7 @@ export const createCustomerPortalSession = function (data) {
31
30
  const config = {
32
31
  headers: { Authorization: `Bearer ${this.apiToken}` }
33
32
  };
34
- const response = yield axiosInstance.post(`${GET_SET_STRIPE}/create-customer-portal-session`, data, config);
33
+ const response = yield this.axiosInstance.post(`${GET_SET_STRIPE}/create-customer-portal-session`, data, config);
35
34
  return response;
36
35
  }
37
36
  catch (error) {
@@ -46,7 +45,7 @@ export const createCFDISuscrptionCheckoutSession = function (data) {
46
45
  const config = {
47
46
  headers: { Authorization: `Bearer ${this.apiToken}` }
48
47
  };
49
- const response = yield axiosInstance.post(`${GET_SET_STRIPE}/create-cfdi-subscription-checkout-session`, data, config);
48
+ const response = yield this.axiosInstance.post(`${GET_SET_STRIPE}/create-cfdi-subscription-checkout-session`, data, config);
50
49
  return response;
51
50
  }
52
51
  catch (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_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
12
11
  export const deleteSupplyById = function (storeId, id) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const deleteSupplyById = function (storeId, id) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- const response = yield axiosInstance.delete(`${GET_SET_SUPPLY(storeId)}/${id}`, config);
17
+ const response = yield this.axiosInstance.delete(`${GET_SET_SUPPLY(storeId)}/${id}`, config);
19
18
  return response;
20
19
  }
21
20
  catch (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_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
12
11
  export const getSupplies = function (storeId, queryParams) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const getSupplies = function (storeId, queryParams) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- const response = yield axiosInstance.get(`${GET_SET_SUPPLY(storeId)}?${queryParams}`, config);
17
+ const response = yield this.axiosInstance.get(`${GET_SET_SUPPLY(storeId)}?${queryParams}`, config);
19
18
  return response;
20
19
  }
21
20
  catch (error) {
@@ -51,7 +50,7 @@ export const getSupplyHistory = function (storeId, id, params) {
51
50
  if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('limit')) {
52
51
  queryParams += `&limit=${params === null || params === void 0 ? void 0 : params.limit}`;
53
52
  }
54
- const response = yield axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}/history?${queryParams}`, config);
53
+ const response = yield this.axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}/history?${queryParams}`, config);
55
54
  return response;
56
55
  }
57
56
  catch (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_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
12
11
  export const createSupply = function (storeId, data) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const createSupply = function (storeId, data) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- const response = yield axiosInstance.post(`${GET_SET_SUPPLY(storeId)}`, data, config);
17
+ const response = yield this.axiosInstance.post(`${GET_SET_SUPPLY(storeId)}`, data, config);
19
18
  return response;
20
19
  }
21
20
  catch (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_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
12
11
  export const updateSupplyById = function (storeId, id, data) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const updateSupplyById = function (storeId, id, data) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- const response = yield axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}`, data, config);
17
+ const response = yield this.axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}`, data, config);
19
18
  return response;
20
19
  }
21
20
  catch (error) {
@@ -30,7 +29,7 @@ export const addSupplyStock = function (storeId, id, data) {
30
29
  const config = {
31
30
  headers: { Authorization: `Bearer ${this.apiToken}` }
32
31
  };
33
- const response = yield axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}/addStock`, data, config);
32
+ const response = yield this.axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}/addStock`, data, config);
34
33
  return response;
35
34
  }
36
35
  catch (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/user';
12
11
  export const deleteUserById = function (id) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -15,7 +14,7 @@ export const deleteUserById = function (id) {
15
14
  const config = {
16
15
  headers: { Authorization: `Bearer ${this.apiToken}` }
17
16
  };
18
- const response = yield axiosInstance.delete(`${GET_SET_USER}/${id}`, config);
17
+ const response = yield this.axiosInstance.delete(`${GET_SET_USER}/${id}`, config);
19
18
  return response;
20
19
  }
21
20
  catch (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/user';
12
11
  const REQUEST_PARAMS = {
13
12
  token: 'LOGGED_USER_TOKEN',
@@ -18,7 +17,7 @@ export const updateUserById = function (userId, data) {
18
17
  const config = {
19
18
  headers: { Authorization: `Bearer ${this.apiToken}` }
20
19
  };
21
- const response = yield axiosInstance.put(`${GET_SET_USER}/${userId}`, data, config);
20
+ const response = yield this.axiosInstance.put(`${GET_SET_USER}/${userId}`, data, config);
22
21
  return response.data || {};
23
22
  }
24
23
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -8,7 +8,7 @@ export const getCashierboxesByStoreId = async function (this: WashdayClientInsta
8
8
  const config = {
9
9
  headers: { Authorization: `Bearer ${this.apiToken}` }
10
10
  };
11
- const response = await axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}?${queryParams || ''}`, config);
11
+ const response = await this.axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}?${queryParams || ''}`, config);
12
12
  return response;
13
13
  } catch (error) {
14
14
  console.error('Error fetching getCashierboxesByStoreId:', error);
@@ -21,7 +21,7 @@ export const getCashierboxesById = async function (this: WashdayClientInstance,
21
21
  const config = {
22
22
  headers: { Authorization: `Bearer ${this.apiToken}` }
23
23
  };
24
- const response = await axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}/${id}?${queryParams}`, config);
24
+ const response = await this.axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}/${id}?${queryParams}`, config);
25
25
  return response;
26
26
  } catch (error) {
27
27
  console.error('Error fetching getCashierboxesById:', error);
@@ -44,7 +44,7 @@ export const getCashierBoxMovementsHistory = async function (this: WashdayClient
44
44
  if (params?.hasOwnProperty('limit')) {
45
45
  queryParams += `&limit=${params?.limit}`
46
46
  }
47
- const response = await axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}/${id}/history?${queryParams}`, config);
47
+ const response = await this.axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}/${id}/history?${queryParams}`, config);
48
48
  return response;
49
49
  } catch (error) {
50
50
  console.error('Error fetching getCashierBoxMovementsHistory:', error);
@@ -11,7 +11,7 @@ export const createCashierBox = async function (this: WashdayClientInstance, sto
11
11
  const config = {
12
12
  headers: { Authorization: `Bearer ${this.apiToken}` }
13
13
  };
14
- const response = await axiosInstance.post(`${GET_SET_CASHIER_BOX(storeId)}`, data, config);
14
+ const response = await this.axiosInstance.post(`${GET_SET_CASHIER_BOX(storeId)}`, data, config);
15
15
  return response;
16
16
  } catch (error) {
17
17
  console.error('Error fetching getStoreStaff:', error);
@@ -30,7 +30,7 @@ export const addCashierBoxMovement = async function (this: WashdayClientInstance
30
30
  const config = {
31
31
  headers: { Authorization: `Bearer ${this.apiToken}` }
32
32
  };
33
- const response = await axiosInstance.post(`${GET_SET_CASHIER_BOX(storeId)}/${id}/add-movement`, data, config);
33
+ const response = await this.axiosInstance.post(`${GET_SET_CASHIER_BOX(storeId)}/${id}/add-movement`, data, config);
34
34
  return response;
35
35
  } catch (error) {
36
36
  console.error('Error fetching createStoreImage:', error);
@@ -9,7 +9,7 @@ export const updateCashierBoxById = async function (this: WashdayClientInstance,
9
9
  const config = {
10
10
  headers: { Authorization: `Bearer ${this.apiToken}` }
11
11
  };
12
- const response = await axiosInstance.put(`${GET_SET_CASHIER_BOX(storeId)}/${id}`, data, config);
12
+ const response = await this.axiosInstance.put(`${GET_SET_CASHIER_BOX(storeId)}/${id}`, data, config);
13
13
  return response;
14
14
  } catch (error) {
15
15
  console.error('Error fetching getStoreById:', error);
@@ -22,7 +22,7 @@ export const updateCashierBoxMovementById = async function (this: WashdayClientI
22
22
  const config = {
23
23
  headers: { Authorization: `Bearer ${this.apiToken}` }
24
24
  };
25
- const response = await axiosInstance.put(`${GET_SET_CASHIER_BOX_MOVEMENT(storeId, cashierBoxId)}/${id}`, data, config);
25
+ const response = await this.axiosInstance.put(`${GET_SET_CASHIER_BOX_MOVEMENT(storeId, cashierBoxId)}/${id}`, data, config);
26
26
  return response;
27
27
  } catch (error) {
28
28
  console.error('Error fetching getStoreById:', 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);
@@ -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);
@@ -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);
package/src/api/index.ts CHANGED
@@ -44,6 +44,8 @@ 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
+ import * as integrationsEndpoints from './integrations';
48
+
47
49
  type WashdayClientConstructor = {
48
50
  new(apiToken: string): WashdayClientInstance
49
51
  };
@@ -57,7 +59,7 @@ function bindMethods<T>(instance: any, methods: any): T {
57
59
  return boundMethods;
58
60
  }
59
61
 
60
- const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string, env:string = 'PROD') {
62
+ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string, env: string = 'PROD') {
61
63
  this.apiToken = apiToken;
62
64
  this.env = env;
63
65
  this.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env);
@@ -329,6 +331,11 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
329
331
  clockOut: attendanceEndpoints.postModule.clockOut,
330
332
  updateById: attendanceEndpoints.putModule.updateById,
331
333
  });
334
+ this.integrations = bindMethods(this, {
335
+ getMPConnectionStatus: integrationsEndpoints.getModule.getMPConnectionStatus,
336
+ startMPOAuthFlow: integrationsEndpoints.postModule.startMPOAuthFlow,
337
+ disconnectMP: integrationsEndpoints.postModule.disconnectMP,
338
+ });
332
339
  } as any;
333
340
 
334
341
  export default WashdayClient;
File without changes
@@ -0,0 +1,15 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+
3
+ const BASE_ROUTER = 'api/integrations';
4
+
5
+ export const getMPConnectionStatus = async function (this: WashdayClientInstance): Promise<any> {
6
+ try {
7
+ const config = {
8
+ headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ };
10
+ return await this.axiosInstance.get(`${BASE_ROUTER}/mp/connection`, config);
11
+ }
12
+ catch (error) {
13
+ throw error;
14
+ }
15
+ };
@@ -0,0 +1,3 @@
1
+ // export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
@@ -0,0 +1,30 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+
3
+ const BASE_ROUTER = 'api/integrations';
4
+
5
+
6
+ export const startMPOAuthFlow = async function (this: WashdayClientInstance, data: {
7
+ redirectUri: string;
8
+ }): Promise<any> {
9
+ try {
10
+ const config = {
11
+ headers: { Authorization: `Bearer ${this.apiToken}` }
12
+ };
13
+ return await this.axiosInstance.post(`${BASE_ROUTER}/mp/oauth/start`, data, config);
14
+ }
15
+ catch (error) {
16
+ throw error;
17
+ }
18
+ };
19
+
20
+ export const disconnectMP = async function (this: WashdayClientInstance): Promise<any> {
21
+ try {
22
+ const config = {
23
+ headers: { Authorization: `Bearer ${this.apiToken}` }
24
+ };
25
+ return await this.axiosInstance.post(`${BASE_ROUTER}/mp/disconnect`, {}, config);
26
+ }
27
+ catch (error) {
28
+ throw error;
29
+ }
30
+ };
File without changes
@@ -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);
@@ -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);
@@ -33,7 +33,7 @@ export const deletePriceOption = async function (this: WashdayClientInstance, pr
33
33
  const config = {
34
34
  headers: { Authorization: `Bearer ${this.apiToken}` }
35
35
  };
36
- const response = await axiosInstance.delete(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, config);
36
+ const response = await this.axiosInstance.delete(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, config);
37
37
  return response.data || {};
38
38
  } catch (error) {
39
39
  console.error('Error deleting price option:', error);