washday-sdk 1.0.1 → 1.1.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.
- package/README.md +126 -0
- package/babel.config.js +8 -0
- package/dist/api/attendance/delete.js +2 -0
- package/dist/api/attendance/get.js +83 -0
- package/dist/api/attendance/index.js +4 -0
- package/dist/api/attendance/post.js +39 -0
- package/dist/api/attendance/put.js +25 -0
- package/dist/api/auth/index.js +3 -0
- package/dist/api/auth/post.js +170 -0
- package/dist/api/axiosInstance.js +46 -0
- package/dist/api/cashierbox/delete.js +40 -0
- package/dist/api/cashierbox/get.js +63 -0
- package/dist/api/cashierbox/post.js +42 -0
- package/dist/api/cashierbox/put.js +42 -0
- package/dist/api/cashups/delete.js +25 -0
- package/dist/api/cashups/get.js +60 -0
- package/dist/api/cashups/index.js +4 -0
- package/dist/api/cashups/post.js +25 -0
- package/dist/api/cashups/put.js +52 -0
- package/dist/api/cfdi/delete.js +25 -0
- package/dist/api/cfdi/get.js +126 -0
- package/dist/api/cfdi/index.js +4 -0
- package/dist/api/cfdi/post.js +41 -0
- package/dist/api/cfdi/put.js +52 -0
- package/dist/api/companies/get.js +29 -0
- package/dist/api/companies/post.js +41 -0
- package/dist/api/companies/put.js +57 -0
- package/dist/api/countries/get.js +29 -0
- package/dist/api/countries/post.js +1 -0
- package/dist/api/countries/put.js +1 -0
- package/dist/api/csv/get.js +325 -0
- package/dist/api/csv/index.js +1 -0
- package/dist/api/customers/delete.js +40 -0
- package/dist/api/customers/get.js +106 -0
- package/dist/api/customers/index.js +4 -0
- package/dist/api/customers/post.js +41 -0
- package/dist/api/customers/put.js +52 -0
- package/dist/api/discounts/get.js +120 -0
- package/dist/api/discounts/post.js +40 -0
- package/dist/api/discounts/put.js +68 -0
- package/dist/api/index.js +319 -0
- package/dist/api/inventory/delete.js +26 -0
- package/dist/api/inventory/get.js +62 -0
- package/dist/api/inventory/index.js +4 -0
- package/dist/api/inventory/post.js +26 -0
- package/dist/api/inventory/put.js +41 -0
- package/dist/api/order/delete.js +40 -0
- package/dist/api/order/get.js +181 -0
- package/dist/api/order/index.js +4 -0
- package/dist/api/order/post.js +115 -0
- package/dist/api/order/put.js +202 -0
- package/dist/api/outsourcedOrders/delete.js +25 -0
- package/dist/api/outsourcedOrders/get.js +62 -0
- package/dist/api/outsourcedOrders/index.js +4 -0
- package/dist/api/outsourcedOrders/post.js +25 -0
- package/dist/api/outsourcedOrders/put.js +25 -0
- package/dist/api/partners/delete.js +25 -0
- package/dist/api/partners/get.js +40 -0
- package/dist/api/partners/index.js +4 -0
- package/dist/api/partners/post.js +25 -0
- package/dist/api/partners/put.js +25 -0
- package/dist/api/pdf/get.js +43 -0
- package/dist/api/pdf/index.js +1 -0
- package/dist/api/products/delete.js +40 -0
- package/dist/api/products/get.js +25 -0
- package/dist/api/products/index.js +4 -0
- package/dist/api/products/post.js +60 -0
- package/dist/api/products/put.js +40 -0
- package/dist/api/publics/get.js +26 -0
- package/dist/api/publics/index.js +1 -0
- package/dist/api/reports/get.js +303 -0
- package/dist/api/reports/index.js +1 -0
- package/dist/api/reviews/delete.js +15 -0
- package/dist/api/reviews/get.js +41 -0
- package/dist/api/reviews/index.js +4 -0
- package/dist/api/reviews/post.js +20 -0
- package/dist/api/reviews/put.js +52 -0
- package/dist/api/routes/delete.js +25 -0
- package/dist/api/routes/get.js +95 -0
- package/dist/api/routes/index.js +4 -0
- package/dist/api/routes/post.js +67 -0
- package/dist/api/routes/put.js +54 -0
- package/dist/api/sections/delete.js +25 -0
- package/dist/api/sections/get.js +71 -0
- package/dist/api/sections/index.js +4 -0
- package/dist/api/sections/post.js +26 -0
- package/dist/api/sections/put.js +25 -0
- package/dist/api/staff/delete.js +26 -0
- package/dist/api/staff/get.js +40 -0
- package/dist/api/staff/post.js +26 -0
- package/dist/api/staff/put.js +26 -0
- package/dist/api/stores/get.js +110 -0
- package/dist/api/stores/post.js +61 -0
- package/dist/api/stores/put.js +44 -0
- package/dist/api/stripe/get.js +1 -0
- package/dist/api/stripe/post.js +71 -0
- package/dist/api/stripe/put.js +1 -0
- package/dist/api/supplies/delete.js +26 -0
- package/dist/api/supplies/get.js +62 -0
- package/dist/api/supplies/post.js +26 -0
- package/dist/api/supplies/put.js +41 -0
- package/dist/api/users/delete.js +26 -0
- package/dist/api/users/post.js +25 -0
- package/dist/api/users/put.js +29 -0
- package/dist/enum/index.js +12 -7
- package/dist/index.js +3 -28
- package/dist/interfaces/Api.js +1 -0
- package/dist/interfaces/Apple.js +16 -0
- package/dist/interfaces/Attendance.js +1 -0
- package/dist/interfaces/Customer.js +1 -2
- package/dist/interfaces/Order.js +1 -2
- package/dist/interfaces/Permission.js +1 -2
- package/dist/interfaces/Product.js +1 -2
- package/dist/interfaces/Section.js +1 -2
- package/dist/interfaces/Store.js +1 -2
- package/dist/interfaces/StoreImage.js +1 -2
- package/dist/interfaces/User.js +1 -2
- package/dist/utils/apiUtils.js +9 -0
- package/dist/utils/index.js +2 -17
- package/dist/utils/orders/calculateOrderTotal.js +30 -21
- package/dist/utils/orders/calculateTotalTaxesIncluded.js +55 -29
- package/dist/utils/orders/calculateTotalTaxesOverPrice.js +56 -45
- package/dist/utils/orders/helpers.js +126 -17
- package/dist/utils/orders/index.js +3 -5
- package/dist/utils/receipt/generateReceiptHTML.js +157 -0
- package/dist/utils/util.js +63 -0
- package/docs/README.md +66 -0
- package/docs/examples/common-use-cases.md +487 -0
- package/docs/getting-started.md +237 -0
- package/docs/modules/attendance.md +404 -0
- package/jest.config.js +0 -0
- package/package.json +12 -4
- package/src/api/attendance/delete.ts +1 -0
- package/src/api/attendance/get.ts +81 -0
- package/src/api/attendance/index.ts +4 -0
- package/src/api/attendance/post.ts +37 -0
- package/src/api/attendance/put.ts +20 -0
- package/src/api/auth/index.ts +3 -0
- package/src/api/auth/post.ts +198 -0
- package/src/api/axiosInstance.ts +13 -3
- package/src/api/cashierbox/delete.ts +28 -0
- package/src/api/cashierbox/get.ts +53 -0
- package/src/api/cashierbox/post.ts +39 -0
- package/src/api/cashierbox/put.ts +32 -0
- package/src/api/cashups/delete.ts +15 -0
- package/src/api/cashups/get.ts +52 -0
- package/src/api/cashups/index.ts +4 -0
- package/src/api/cashups/post.ts +23 -0
- package/src/api/cashups/put.ts +53 -0
- package/src/api/cfdi/delete.ts +21 -0
- package/src/api/cfdi/get.ts +119 -0
- package/src/api/cfdi/index.ts +4 -0
- package/src/api/cfdi/post.ts +60 -0
- package/src/api/cfdi/put.ts +53 -0
- package/src/api/companies/get.ts +23 -0
- package/src/api/companies/post.ts +29 -0
- package/src/api/companies/put.ts +43 -0
- package/src/api/countries/get.ts +23 -0
- package/src/api/countries/post.ts +0 -0
- package/src/api/countries/put.ts +0 -0
- package/src/api/csv/get.ts +354 -0
- package/src/api/csv/index.ts +1 -0
- package/src/api/customers/delete.ts +29 -0
- package/src/api/customers/get.ts +83 -12
- package/src/api/customers/index.ts +4 -0
- package/src/api/customers/post.ts +48 -0
- package/src/api/customers/put.ts +68 -0
- package/src/api/discounts/get.ts +100 -0
- package/src/api/discounts/post.ts +35 -0
- package/src/api/discounts/put.ts +66 -0
- package/src/api/index.ts +320 -12
- package/src/api/inventory/delete.ts +16 -0
- package/src/api/inventory/get.ts +53 -0
- package/src/api/inventory/index.ts +4 -0
- package/src/api/inventory/post.ts +22 -0
- package/src/api/inventory/put.ts +35 -0
- package/src/api/order/delete.ts +29 -0
- package/src/api/order/get.ts +207 -0
- package/src/api/order/index.ts +4 -0
- package/src/api/order/post.ts +118 -0
- package/src/api/order/put.ts +224 -0
- package/src/api/outsourcedOrders/delete.ts +15 -0
- package/src/api/outsourcedOrders/get.ts +54 -0
- package/src/api/outsourcedOrders/index.ts +4 -0
- package/src/api/outsourcedOrders/post.ts +24 -0
- package/src/api/outsourcedOrders/put.ts +21 -0
- package/src/api/partners/delete.ts +15 -0
- package/src/api/partners/get.ts +28 -0
- package/src/api/partners/index.ts +4 -0
- package/src/api/partners/post.ts +21 -0
- package/src/api/partners/put.ts +21 -0
- package/src/api/pdf/get.ts +43 -0
- package/src/api/pdf/index.ts +1 -0
- package/src/api/products/delete.ts +28 -0
- package/src/api/products/get.ts +16 -0
- package/src/api/products/index.ts +4 -0
- package/src/api/products/post.ts +73 -0
- package/src/api/products/put.ts +49 -0
- package/src/api/publics/get.ts +16 -0
- package/src/api/publics/index.ts +1 -0
- package/src/api/reports/get.ts +329 -0
- package/src/api/reports/index.ts +1 -0
- package/src/api/reviews/delete.ts +15 -0
- package/src/api/reviews/get.ts +31 -0
- package/src/api/reviews/index.ts +4 -0
- package/src/api/reviews/post.ts +20 -0
- package/src/api/reviews/put.ts +53 -0
- package/src/api/routes/delete.ts +15 -0
- package/src/api/routes/get.ts +86 -0
- package/src/api/routes/index.ts +4 -0
- package/src/api/routes/post.ts +60 -0
- package/src/api/routes/put.ts +44 -0
- package/src/api/sections/delete.ts +15 -0
- package/src/api/sections/get.ts +67 -0
- package/src/api/sections/index.ts +4 -0
- package/src/api/sections/post.ts +22 -0
- package/src/api/sections/put.ts +23 -0
- package/src/api/staff/delete.ts +16 -0
- package/src/api/staff/get.ts +29 -0
- package/src/api/staff/post.ts +17 -0
- package/src/api/staff/put.ts +17 -0
- package/src/api/stores/get.ts +93 -0
- package/src/api/stores/post.ts +49 -0
- package/src/api/stores/put.ts +35 -0
- package/src/api/stripe/get.ts +0 -0
- package/src/api/stripe/post.ts +59 -0
- package/src/api/stripe/put.ts +0 -0
- package/src/api/supplies/delete.ts +16 -0
- package/src/api/supplies/get.ts +53 -0
- package/src/api/supplies/post.ts +26 -0
- package/src/api/supplies/put.ts +33 -0
- package/src/api/users/delete.ts +16 -0
- package/src/api/users/post.ts +18 -0
- package/src/api/users/put.ts +36 -0
- package/src/enum/index.ts +9 -1
- package/src/index.ts +1 -4
- package/src/interfaces/Api.ts +308 -0
- package/src/interfaces/Apple.ts +74 -0
- package/src/interfaces/Attendance.ts +45 -0
- package/src/interfaces/Customer.ts +15 -11
- package/src/interfaces/Order.ts +38 -1
- package/src/interfaces/Product.ts +1 -0
- package/src/interfaces/Store.ts +41 -0
- package/src/utils/apiUtils.ts +11 -0
- package/src/utils/index.ts +6 -1
- package/src/utils/orders/calculateOrderTotal.test.js +930 -0
- package/src/utils/orders/calculateOrderTotal.ts +60 -15
- package/src/utils/orders/calculateTotalTaxesIncluded.ts +57 -25
- package/src/utils/orders/calculateTotalTaxesOverPrice.ts +57 -41
- package/src/utils/orders/helpers.ts +195 -47
- package/src/utils/orders/index.ts +3 -1
- package/src/utils/receipt/generateReceiptHTML.ts +163 -0
- package/src/utils/util.ts +65 -0
- package/tsconfig.json +13 -9
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IStore } from "../../interfaces/Store";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
|
|
5
|
+
const GET_SET_STORE_IMAGE = 'api/store-image';
|
|
6
|
+
const GET_SET_STORES = 'api/store';
|
|
7
|
+
|
|
8
|
+
export const createStoreImage = async function (this: WashdayClientInstance, data: any): Promise<any> {
|
|
9
|
+
try {
|
|
10
|
+
const config = {
|
|
11
|
+
headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
|
|
12
|
+
};
|
|
13
|
+
const response = await axiosInstance.post(`${GET_SET_STORE_IMAGE}`, data, config);
|
|
14
|
+
return response;
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Error fetching createStoreImage:', error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const createStore = async function (this: WashdayClientInstance, data: any): Promise<any> {
|
|
22
|
+
try {
|
|
23
|
+
const config = {
|
|
24
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
25
|
+
};
|
|
26
|
+
const response = await axiosInstance.post(`${GET_SET_STORES}`, data, config);
|
|
27
|
+
return response;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Error fetching createStore:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const copyStore = async function (this: WashdayClientInstance, copyStoreId: string): Promise<any> {
|
|
35
|
+
try {
|
|
36
|
+
if (!copyStoreId) throw new Error('store id required');
|
|
37
|
+
const config = {
|
|
38
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
39
|
+
};
|
|
40
|
+
const response = await axiosInstance.post(`${GET_SET_STORES}/copy`, {
|
|
41
|
+
fromStoreId: copyStoreId
|
|
42
|
+
}, config);
|
|
43
|
+
return response;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Error fetching createStore:', error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IStore } from "../../interfaces/Store";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
const GET_SET_STORES = 'api/store';
|
|
5
|
+
const REQUEST_PARAMS = {
|
|
6
|
+
token: 'LOGGED_USER_TOKEN',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const updateStoreById = async function (this: WashdayClientInstance, storeId: string, data: IStore): Promise<{ store: IStore }> {
|
|
11
|
+
try {
|
|
12
|
+
const config = {
|
|
13
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
14
|
+
};
|
|
15
|
+
const response = await axiosInstance.put(`${GET_SET_STORES}/${storeId}`, data, config);
|
|
16
|
+
return response.data || {}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error fetching getStoreById:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export const deleteStoreById = async function (this: WashdayClientInstance, storeId: string): Promise<any> {
|
|
25
|
+
try {
|
|
26
|
+
const config = {
|
|
27
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
28
|
+
};
|
|
29
|
+
const response = await axiosInstance.delete(`${GET_SET_STORES}/${storeId}`, config);
|
|
30
|
+
return response;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('Error fetching deleteStoreById:', error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_STRIPE = 'api/stripe';
|
|
4
|
+
const GENERATE_CHECKOUT_SESSION = 'api/orders/create-checkout-session';
|
|
5
|
+
|
|
6
|
+
export const createCreateSuscriptionCheckoutSession = async function (this: WashdayClientInstance, data: {
|
|
7
|
+
priceId: string
|
|
8
|
+
}): Promise<any> {
|
|
9
|
+
try {
|
|
10
|
+
const config = {
|
|
11
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
12
|
+
};
|
|
13
|
+
const response = await axiosInstance.post(`${GET_SET_STRIPE}/create-subscription-checkout-session`, data, config);
|
|
14
|
+
return response;
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Error fetching createCreateSuscriptionCheckoutSession:', error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const createCustomerPortalSession = async function (this: WashdayClientInstance, data?: any): Promise<any> {
|
|
22
|
+
try {
|
|
23
|
+
const config = {
|
|
24
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
25
|
+
};
|
|
26
|
+
const response = await axiosInstance.post(`${GET_SET_STRIPE}/create-customer-portal-session`, data, config);
|
|
27
|
+
return response;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Error fetching createCustomerPortalSession:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const createCFDISuscrptionCheckoutSession = async function (this: WashdayClientInstance, data?: any): Promise<any> {
|
|
35
|
+
try {
|
|
36
|
+
const config = {
|
|
37
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
38
|
+
};
|
|
39
|
+
const response = await axiosInstance.post(`${GET_SET_STRIPE}/create-cfdi-subscription-checkout-session`, data, config);
|
|
40
|
+
return response;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('Error fetching createCFDISuscrptionCheckoutSession:', error);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const createGetMoreCheckoutSession = async function (this: WashdayClientInstance, data: {
|
|
48
|
+
priceId: string
|
|
49
|
+
}): Promise<any> {
|
|
50
|
+
try {
|
|
51
|
+
const config = {
|
|
52
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
53
|
+
};
|
|
54
|
+
return await axiosInstance.post(`${GENERATE_CHECKOUT_SESSION}`, data, config);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('Error fetching createGetMoreCheckoutSession:', error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
|
|
4
|
+
|
|
5
|
+
export const deleteSupplyById = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
|
|
6
|
+
try {
|
|
7
|
+
const config = {
|
|
8
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
9
|
+
};
|
|
10
|
+
const response = await axiosInstance.delete(`${GET_SET_SUPPLY(storeId)}/${id}`, config);
|
|
11
|
+
return response;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching deleteSupplyById:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
|
|
4
|
+
const GET_SET_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
|
|
5
|
+
|
|
6
|
+
export const getSupplies = async function (this: WashdayClientInstance, storeId: string, queryParams?: string): Promise<any> {
|
|
7
|
+
try {
|
|
8
|
+
const config = {
|
|
9
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
10
|
+
};
|
|
11
|
+
const response = await axiosInstance.get(`${GET_SET_SUPPLY(storeId)}?${queryParams}`, config);
|
|
12
|
+
return response;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error('Error fetching getSupplies:', error);
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const getSupplyById = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
|
|
20
|
+
try {
|
|
21
|
+
const config = {
|
|
22
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
23
|
+
};
|
|
24
|
+
return await axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}`, config);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('Error fetching getStoreSupplyById:', error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getSupplyHistory = async function (this: WashdayClientInstance, storeId: string, id: string, params?: {
|
|
32
|
+
pageNum: number;
|
|
33
|
+
limit: number
|
|
34
|
+
}): Promise<any> {
|
|
35
|
+
try {
|
|
36
|
+
const config = {
|
|
37
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
38
|
+
};
|
|
39
|
+
let queryParams = '';
|
|
40
|
+
if (params?.hasOwnProperty('pageNum')) {
|
|
41
|
+
queryParams += `pageNum=${params?.pageNum}`
|
|
42
|
+
}
|
|
43
|
+
if (params?.hasOwnProperty('limit')) {
|
|
44
|
+
queryParams += `&limit=${params?.limit}`
|
|
45
|
+
}
|
|
46
|
+
const response = await axiosInstance.get(`${GET_SET_SUPPLY(storeId)}/${id}/history?${queryParams}`, config);
|
|
47
|
+
return response;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error('Error fetching getCashierBoxMovementsHistory:', error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
|
|
4
|
+
const GET_SET_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
|
|
5
|
+
|
|
6
|
+
export const createSupply = async function (this: WashdayClientInstance, storeId: string, data: {
|
|
7
|
+
name: string;
|
|
8
|
+
code: string;
|
|
9
|
+
purchaseUnit: string;
|
|
10
|
+
usageUnit: string;
|
|
11
|
+
usageFactor: number;
|
|
12
|
+
stock: number;
|
|
13
|
+
alertOnStock: number;
|
|
14
|
+
supplyActivityHistory: []
|
|
15
|
+
}): Promise<any> {
|
|
16
|
+
try {
|
|
17
|
+
const config = {
|
|
18
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
19
|
+
};
|
|
20
|
+
const response = await axiosInstance.post(`${GET_SET_SUPPLY(storeId)}`, data, config);
|
|
21
|
+
return response;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error fetching createSupply:', error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { ISupplies } from "../../interfaces/Store";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
|
|
5
|
+
const GET_SET_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
|
|
6
|
+
|
|
7
|
+
export const updateSupplyById = async function (this: WashdayClientInstance, storeId: string, id: string, data: ISupplies): Promise<any> {
|
|
8
|
+
try {
|
|
9
|
+
const config = {
|
|
10
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
11
|
+
};
|
|
12
|
+
const response = await axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}`, data, config);
|
|
13
|
+
return response;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error fetching getStoreById:', error);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const addSupplyStock = async function (this: WashdayClientInstance, storeId: string, id: string, data: {
|
|
21
|
+
newStock: number
|
|
22
|
+
}): Promise<any> {
|
|
23
|
+
try {
|
|
24
|
+
const config = {
|
|
25
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
26
|
+
};
|
|
27
|
+
const response = await axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}/addStock`, data, config);
|
|
28
|
+
return response;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error fetching addSupplyStock:', error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_USER = 'api/user';
|
|
4
|
+
|
|
5
|
+
export const deleteUserById = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
6
|
+
try {
|
|
7
|
+
const config = {
|
|
8
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
9
|
+
};
|
|
10
|
+
const response = await axiosInstance.delete(`${GET_SET_USER}/${id}`, config);
|
|
11
|
+
return response;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching deleteUserById:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
|
|
4
|
+
const GET_SET_USER = 'api/users';
|
|
5
|
+
|
|
6
|
+
export const validateUserPin = async function (this: WashdayClientInstance, data: {
|
|
7
|
+
pin: string
|
|
8
|
+
}): Promise<any> {
|
|
9
|
+
try {
|
|
10
|
+
const config = {
|
|
11
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
12
|
+
};
|
|
13
|
+
return await axiosInstance.post(`${GET_SET_USER}/validate-pin`, data, config);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error fetching validateUserPin:', error);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IStore } from "../../interfaces/Store";
|
|
3
|
+
import { IUser } from "../../interfaces/User";
|
|
4
|
+
import axiosInstance from "../axiosInstance";
|
|
5
|
+
const GET_SET_USER = 'api/user';
|
|
6
|
+
const REQUEST_PARAMS = {
|
|
7
|
+
token: 'LOGGED_USER_TOKEN',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface userDTO {
|
|
11
|
+
printer?: {
|
|
12
|
+
name: string,
|
|
13
|
+
paperSize: string
|
|
14
|
+
}
|
|
15
|
+
freshChatRestoreID?: string
|
|
16
|
+
pushNotificationToken?: string
|
|
17
|
+
email?: string
|
|
18
|
+
name?: string
|
|
19
|
+
phoneNumber?: string
|
|
20
|
+
currentPassword?: string;
|
|
21
|
+
newPassword?: string;
|
|
22
|
+
confirmNewPassword?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const updateUserById = async function (this: WashdayClientInstance, userId: string, data: userDTO): Promise<any> {
|
|
26
|
+
try {
|
|
27
|
+
const config = {
|
|
28
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
29
|
+
};
|
|
30
|
+
const response = await axiosInstance.put(`${GET_SET_USER}/${userId}`, data, config);
|
|
31
|
+
return response.data || {}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error fetching updateUserById:', error);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
};
|
package/src/enum/index.ts
CHANGED
|
@@ -2,10 +2,18 @@ export enum DiscountCodeTypes {
|
|
|
2
2
|
PERCENTAGE = 'percentage',
|
|
3
3
|
NUMBER = 'number',
|
|
4
4
|
FREE_DELIVERY = 'freeDelivery',
|
|
5
|
-
BUY_X_GET_Y = 'buyXGetY'
|
|
5
|
+
BUY_X_GET_Y = 'buyXGetY',
|
|
6
|
+
FREE_ITEM = 'freeItem'
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export enum BuyAndGetConditionsTypes {
|
|
9
10
|
PERCENTAGE = 'percentage',
|
|
10
11
|
FREE = 'free'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export enum PaymentMethodsEnum {
|
|
15
|
+
Cash = "cash",
|
|
16
|
+
Card = "card",
|
|
17
|
+
Delivery = "delivery",
|
|
18
|
+
Transfer = "transfer",
|
|
11
19
|
}
|