washday-sdk 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -0
- package/babel.config.js +8 -0
- package/dist/api/attendance/delete.js +2 -0
- package/dist/api/attendance/get.js +89 -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 +15 -11
- 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 +75 -20
- package/dist/api/customers/index.js +4 -1
- 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 +316 -8
- 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 -33
- package/dist/interfaces/Api.js +1 -3
- 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 +67 -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 +88 -0
- package/src/api/attendance/index.ts +4 -0
- package/src/api/attendance/post.ts +38 -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 +80 -8
- 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 +318 -11
- 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 +307 -2
- 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,28 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_PARTNERS = 'api/partners';
|
|
4
|
+
|
|
5
|
+
export const getPartners = async function (this: WashdayClientInstance): Promise<any> {
|
|
6
|
+
try {
|
|
7
|
+
//THIS WILL FETCH ALL COMPANY PARTNERS
|
|
8
|
+
const config = {
|
|
9
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
10
|
+
};
|
|
11
|
+
return await axiosInstance.get(`${GET_SET_PARTNERS}`, config);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching getPartners:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getPartnerById = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
19
|
+
try {
|
|
20
|
+
const config = {
|
|
21
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
22
|
+
};
|
|
23
|
+
return await axiosInstance.get(`${GET_SET_PARTNERS}/${id}`, config);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error fetching getPartnerById:', error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IAddress } from "../../interfaces/Customer";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
const GET_SET_PARTNERS = 'api/partners';
|
|
5
|
+
|
|
6
|
+
export const createPartner = async function (this: WashdayClientInstance, data: {
|
|
7
|
+
name: string,
|
|
8
|
+
contactEmail?: string,
|
|
9
|
+
contactPhone?: string,
|
|
10
|
+
address?: IAddress
|
|
11
|
+
}): Promise<any> {
|
|
12
|
+
try {
|
|
13
|
+
const config = {
|
|
14
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
15
|
+
};
|
|
16
|
+
return await axiosInstance.post(GET_SET_PARTNERS, data, config);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error fetching createPartner:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IAddress } from "../../interfaces/Customer";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
const GET_SET_PARTNERS = 'api/partners';
|
|
5
|
+
|
|
6
|
+
export const updatePartnerById = async function (this: WashdayClientInstance, id: string, data: {
|
|
7
|
+
name: string,
|
|
8
|
+
contactEmail?: string,
|
|
9
|
+
contactPhone?: string,
|
|
10
|
+
address?: IAddress
|
|
11
|
+
}): Promise<any> {
|
|
12
|
+
try {
|
|
13
|
+
const config = {
|
|
14
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
15
|
+
};
|
|
16
|
+
return await axiosInstance.put(`${GET_SET_PARTNERS}/${id}`, data, config);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error fetching updatePartnerById:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
|
|
5
|
+
const GENERATE_EXPORT = 'api/export';
|
|
6
|
+
const GET_SET_REPORTS = 'api/reports';
|
|
7
|
+
|
|
8
|
+
export const exportUnpaidOrdersReportPDF = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
9
|
+
store: string | undefined,
|
|
10
|
+
fromDate: string | undefined,
|
|
11
|
+
toDate: string | undefined,
|
|
12
|
+
timezone: string | undefined,
|
|
13
|
+
customerName: string | undefined,
|
|
14
|
+
}): Promise<any> {
|
|
15
|
+
try {
|
|
16
|
+
const config = {
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
19
|
+
},
|
|
20
|
+
params: {
|
|
21
|
+
responseType: 'blob'
|
|
22
|
+
},
|
|
23
|
+
// responseType: 'blob', // Important for handling the PDF blob response
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const queryParams = generateQueryParamsStr(['store', 'fromDate', 'toDate', 'timezone', 'customerName'], params);
|
|
27
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export/pdf?${queryParams}`, config);
|
|
28
|
+
|
|
29
|
+
// // Create a link element, trigger a download
|
|
30
|
+
// const url = window.URL.createObjectURL(new Blob([response.data]));
|
|
31
|
+
// const link = document.createElement('a');
|
|
32
|
+
// link.href = url;
|
|
33
|
+
// link.setAttribute('download', 'Reporte_Pedidos_Pago_Pendiente.pdf'); // Change the filename here if needed
|
|
34
|
+
// document.body.appendChild(link);
|
|
35
|
+
// link.click();
|
|
36
|
+
// link.remove();
|
|
37
|
+
|
|
38
|
+
// return response.data;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error fetching exportUnpaidOrdersReportPDF:', error);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as getModule from './get';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_PRODUCTS = 'api/product';
|
|
4
|
+
const GET_SET_PRODUCTS_SUPPLY = 'api/product-supply';
|
|
5
|
+
|
|
6
|
+
export const deleteById = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
7
|
+
try {
|
|
8
|
+
const config = {
|
|
9
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
10
|
+
};
|
|
11
|
+
return await axiosInstance.delete(`${GET_SET_PRODUCTS}/${id}`, config);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching deleteById:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const deleteProductSupplyById = async function (this: WashdayClientInstance, id: string, productSupplyId: string): Promise<any> {
|
|
19
|
+
try {
|
|
20
|
+
const config = {
|
|
21
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
22
|
+
};
|
|
23
|
+
return await axiosInstance.delete(`${GET_SET_PRODUCTS_SUPPLY}/${id}/${productSupplyId}`, config);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error fetching deleteProductSupplyById:', error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IStore } from "../../interfaces/Store";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
const GET_SET_PRODUCTS = 'api/product';
|
|
5
|
+
|
|
6
|
+
export const getById = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
7
|
+
try {
|
|
8
|
+
const config = {
|
|
9
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
10
|
+
};
|
|
11
|
+
return await axiosInstance.get(`${GET_SET_PRODUCTS}/${id}`, config);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching getById:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_PRODUCTS_SUPPLY = 'api/product-supply';
|
|
4
|
+
const GET_SET_PRODUCTS = 'api/product';
|
|
5
|
+
|
|
6
|
+
export const create = async function (this: WashdayClientInstance, data: {
|
|
7
|
+
name: string;
|
|
8
|
+
price: number;
|
|
9
|
+
expressPrice: number;
|
|
10
|
+
type: 'normal' | 'weight';
|
|
11
|
+
pieces: number;
|
|
12
|
+
sku?: string;
|
|
13
|
+
overlayText: string;
|
|
14
|
+
order: number;
|
|
15
|
+
taxExemptOne: boolean;
|
|
16
|
+
taxExemptTwo: boolean;
|
|
17
|
+
taxExemptThree: boolean;
|
|
18
|
+
showInApp: boolean;
|
|
19
|
+
image: string;
|
|
20
|
+
store: string; //this is used to valdate product limit creation of store(we might remove it later and validate by token getting company and store id using section id)
|
|
21
|
+
section: string;
|
|
22
|
+
invoice_description: string;
|
|
23
|
+
invoice_product_key: string;
|
|
24
|
+
invoice_product_unit_key: string;
|
|
25
|
+
invoice_product_unit_name: string;
|
|
26
|
+
productSupplies: Array<any>
|
|
27
|
+
isOutsourced?: boolean
|
|
28
|
+
outsourcingPartner?: string
|
|
29
|
+
barcode?: string
|
|
30
|
+
}): Promise<any> {
|
|
31
|
+
try {
|
|
32
|
+
const config = {
|
|
33
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
34
|
+
};
|
|
35
|
+
const response = await axiosInstance.post(`${GET_SET_PRODUCTS}`, data, config);
|
|
36
|
+
return response;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('Error fetching create:', error);
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const createProductSupply = async function (this: WashdayClientInstance, id: string, data: {
|
|
44
|
+
supplyId: string;
|
|
45
|
+
usageAmount: number;
|
|
46
|
+
}): Promise<any> {
|
|
47
|
+
try {
|
|
48
|
+
const config = {
|
|
49
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
50
|
+
};
|
|
51
|
+
const response = await axiosInstance.post(`${GET_SET_PRODUCTS_SUPPLY}/${id}`, data, config);
|
|
52
|
+
return response;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('Error fetching createProductSupply:', error);
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const bulkCreate = async function (this: WashdayClientInstance, storeId: string, data: FormData): Promise<any> {
|
|
60
|
+
try {
|
|
61
|
+
const config = {
|
|
62
|
+
headers: {
|
|
63
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
64
|
+
'Content-Type': 'multipart/form-data' // Let axios handle the boundary
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const response = await axiosInstance.post(`${GET_SET_PRODUCTS}/${storeId}/bulk`, data, config);
|
|
68
|
+
return response.data || {};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Error fetching products bulkCreate:', error);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_PRODUCTS = 'api/product';
|
|
4
|
+
|
|
5
|
+
export const bulkUpdate = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
|
|
6
|
+
try {
|
|
7
|
+
const config = {
|
|
8
|
+
headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
|
|
9
|
+
};
|
|
10
|
+
const response = await axiosInstance.put(`${GET_SET_PRODUCTS}/${storeId}/bulk`, data, config);
|
|
11
|
+
return response.data || {}
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching getStoreById:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const updateById = async function (this: WashdayClientInstance, id: string, data: {
|
|
19
|
+
name?: string;
|
|
20
|
+
price?: number;
|
|
21
|
+
expressPrice?: number;
|
|
22
|
+
type?: 'normal' | 'weight';
|
|
23
|
+
pieces?: number;
|
|
24
|
+
sku?: string;
|
|
25
|
+
overlayText?: string;
|
|
26
|
+
order?: number;
|
|
27
|
+
taxExemptOne?: boolean;
|
|
28
|
+
taxExemptTwo?: boolean;
|
|
29
|
+
taxExemptThree?: boolean;
|
|
30
|
+
showInApp?: boolean;
|
|
31
|
+
image?: string;
|
|
32
|
+
invoice_product_key?: string,
|
|
33
|
+
invoice_description?: string,
|
|
34
|
+
invoice_product_unit_key?: string
|
|
35
|
+
invoice_product_unit_name?: string
|
|
36
|
+
isOutsourced?: boolean
|
|
37
|
+
outsourcingPartner?: string,
|
|
38
|
+
barcode?: string
|
|
39
|
+
}): Promise<any> {
|
|
40
|
+
try {
|
|
41
|
+
const config = {
|
|
42
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
43
|
+
};
|
|
44
|
+
return await axiosInstance.put(`${GET_SET_PRODUCTS}/${id}`, data, config);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error fetching updateById:', error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_PUBLIC = '/api/public';
|
|
4
|
+
const GET_PUBLIC_ORDERS_ROUTES = '/api/public/orders';
|
|
5
|
+
|
|
6
|
+
export const getOrderPublicReceipt = async function (this: WashdayClientInstance, orderPublicToken: string): Promise<any> {
|
|
7
|
+
try {
|
|
8
|
+
const config = {
|
|
9
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
10
|
+
};
|
|
11
|
+
return await axiosInstance.get(`${GET_PUBLIC_ORDERS_ROUTES}/${orderPublicToken}/receipt`, config);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching getOrderPublicReceipt:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as getModule from './get';
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IOrder } from "../../interfaces/Order";
|
|
3
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
4
|
+
import axiosInstance from "../axiosInstance";
|
|
5
|
+
const GET_SET_REPORTS = 'api/reports';
|
|
6
|
+
const GET_SET_STATISTICS = 'api/statistics';
|
|
7
|
+
|
|
8
|
+
export const getCleanedOrdersReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
9
|
+
fromDate?: string
|
|
10
|
+
toDate?: string
|
|
11
|
+
timezone?: string
|
|
12
|
+
pageNum?: string
|
|
13
|
+
limit?: string
|
|
14
|
+
}): Promise<any> {
|
|
15
|
+
try {
|
|
16
|
+
const config = {
|
|
17
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
18
|
+
};
|
|
19
|
+
const queryParams = generateQueryParamsStr([
|
|
20
|
+
'toDate',
|
|
21
|
+
'fromDate',
|
|
22
|
+
'pageNum',
|
|
23
|
+
'limit',
|
|
24
|
+
'timezone',
|
|
25
|
+
'includeGraph',
|
|
26
|
+
], params);
|
|
27
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders?${queryParams}`, config);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Error fetching getCleanedOrdersReport:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const getCleanedOrdersGraphDataReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
35
|
+
fromDate?: string
|
|
36
|
+
toDate?: string
|
|
37
|
+
timezone?: string
|
|
38
|
+
}): Promise<any> {
|
|
39
|
+
try {
|
|
40
|
+
const config = {
|
|
41
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
42
|
+
};
|
|
43
|
+
const queryParams = generateQueryParamsStr([
|
|
44
|
+
'toDate',
|
|
45
|
+
'fromDate',
|
|
46
|
+
'timezone',
|
|
47
|
+
], params);
|
|
48
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders-graph?${queryParams}`, config);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Error fetching getCleanedOrdersGraphDataReport :', error);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const getSalesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
56
|
+
fromDate?: string
|
|
57
|
+
toDate?: string
|
|
58
|
+
timezone?: string
|
|
59
|
+
type: "daily" | "month" | "year";
|
|
60
|
+
}): Promise<any> {
|
|
61
|
+
try {
|
|
62
|
+
const config = {
|
|
63
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
64
|
+
};
|
|
65
|
+
const queryParams = generateQueryParamsStr([
|
|
66
|
+
'toDate',
|
|
67
|
+
'fromDate',
|
|
68
|
+
'timezone',
|
|
69
|
+
'type',
|
|
70
|
+
], params);
|
|
71
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales?${queryParams}`, config);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('Error fetching getSalesReport:', error);
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const getCustomersReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
79
|
+
fromDate?: string
|
|
80
|
+
toDate?: string
|
|
81
|
+
}): Promise<any> {
|
|
82
|
+
try {
|
|
83
|
+
const config = {
|
|
84
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
85
|
+
};
|
|
86
|
+
const queryParams = generateQueryParamsStr([
|
|
87
|
+
'storeId',
|
|
88
|
+
'fromDate',
|
|
89
|
+
'toDate',
|
|
90
|
+
], params);
|
|
91
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/customers?${queryParams}`, config);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('Error fetching getCustomersReport:', error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const getSuppliesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
99
|
+
fromDate?: string
|
|
100
|
+
toDate?: string
|
|
101
|
+
}): Promise<any> {
|
|
102
|
+
try {
|
|
103
|
+
const config = {
|
|
104
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
105
|
+
};
|
|
106
|
+
const queryParams = generateQueryParamsStr([
|
|
107
|
+
'storeId',
|
|
108
|
+
'fromDate',
|
|
109
|
+
'toDate',
|
|
110
|
+
], params);
|
|
111
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/supplies?${queryParams}`, config);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error('Error fetching getSuppliesReport:', error);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const getDiscountCodesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
119
|
+
}): Promise<any> {
|
|
120
|
+
try {
|
|
121
|
+
const config = {
|
|
122
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
123
|
+
};
|
|
124
|
+
const queryParams = generateQueryParamsStr([
|
|
125
|
+
], params);
|
|
126
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/discountCodes?${queryParams}`, config);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error('Error fetching getDiscountCodesReport:', error);
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const getStaffReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
134
|
+
fromDate?: string
|
|
135
|
+
toDate?: string
|
|
136
|
+
}): Promise<any> {
|
|
137
|
+
try {
|
|
138
|
+
const config = {
|
|
139
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
140
|
+
};
|
|
141
|
+
const queryParams = generateQueryParamsStr([
|
|
142
|
+
'storeId',
|
|
143
|
+
'fromDate',
|
|
144
|
+
'toDate',
|
|
145
|
+
], params);
|
|
146
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/staff?${queryParams}`, config);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error('Error fetching getStaffReport:', error);
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const getProductSalesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
154
|
+
fromDate?: string
|
|
155
|
+
toDate?: string
|
|
156
|
+
timezone?: string
|
|
157
|
+
}): Promise<any> {
|
|
158
|
+
try {
|
|
159
|
+
const config = {
|
|
160
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
161
|
+
};
|
|
162
|
+
const queryParams = generateQueryParamsStr([
|
|
163
|
+
'toDate',
|
|
164
|
+
'fromDate',
|
|
165
|
+
'timezone',
|
|
166
|
+
], params);
|
|
167
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/productSales?${queryParams}`, config);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.error('Error fetching getProductSalesReport:', error);
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const getPaymentLinesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
175
|
+
fromDate?: string
|
|
176
|
+
toDate?: string
|
|
177
|
+
timezone?: string
|
|
178
|
+
pageNum?: string
|
|
179
|
+
limit?: string
|
|
180
|
+
}): Promise<any> {
|
|
181
|
+
try {
|
|
182
|
+
const config = {
|
|
183
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
184
|
+
};
|
|
185
|
+
const queryParams = generateQueryParamsStr([
|
|
186
|
+
'fromDate',
|
|
187
|
+
'toDate',
|
|
188
|
+
'pageNum',
|
|
189
|
+
'limit',
|
|
190
|
+
'timezone',
|
|
191
|
+
], params);
|
|
192
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/paymentLines?${queryParams}`, config);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error('Error fetching getPaymentLinesReport:', error);
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const getUnpaidOrdersReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
200
|
+
fromDate?: string
|
|
201
|
+
toDate?: string
|
|
202
|
+
timezone?: string
|
|
203
|
+
pageNum?: string
|
|
204
|
+
limit?: string
|
|
205
|
+
customerName?: string
|
|
206
|
+
}): Promise<any> {
|
|
207
|
+
try {
|
|
208
|
+
const config = {
|
|
209
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
210
|
+
};
|
|
211
|
+
const queryParams = generateQueryParamsStr([
|
|
212
|
+
'fromDate',
|
|
213
|
+
'toDate',
|
|
214
|
+
'pageNum',
|
|
215
|
+
'limit',
|
|
216
|
+
'timezone',
|
|
217
|
+
'customerName'
|
|
218
|
+
], params);
|
|
219
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders?${queryParams}`, config);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
console.error('Error fetching getUnpaidOrdersReport:', error);
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const getAnnualSalesStatistics = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
227
|
+
fromDate?: string
|
|
228
|
+
toDate?: string
|
|
229
|
+
timezone?: string
|
|
230
|
+
}): Promise<any> {
|
|
231
|
+
try {
|
|
232
|
+
const config = {
|
|
233
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
234
|
+
};
|
|
235
|
+
const queryParams = generateQueryParamsStr([
|
|
236
|
+
'toDate',
|
|
237
|
+
'fromDate',
|
|
238
|
+
'timezone',
|
|
239
|
+
], params);
|
|
240
|
+
return await axiosInstance.get(`${GET_SET_STATISTICS}/${storeId}/annual?${queryParams}`, config);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
console.error('Error fetching getAnnualSalesStatistics :', error);
|
|
243
|
+
throw error;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const getPaymentMethodStatistics = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
248
|
+
fromDate?: string
|
|
249
|
+
toDate?: string
|
|
250
|
+
timezone?: string
|
|
251
|
+
}): Promise<any> {
|
|
252
|
+
try {
|
|
253
|
+
const config = {
|
|
254
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
255
|
+
};
|
|
256
|
+
const queryParams = generateQueryParamsStr([
|
|
257
|
+
'toDate',
|
|
258
|
+
'fromDate',
|
|
259
|
+
'timezone',
|
|
260
|
+
], params);
|
|
261
|
+
return await axiosInstance.get(`${GET_SET_STATISTICS}/${storeId}/ordersPaymentMethod?${queryParams}`, config);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.error('Error fetching getPaymentMethodStatistics :', error);
|
|
264
|
+
throw error;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export const getProductsStatistics = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
269
|
+
fromDate?: string
|
|
270
|
+
toDate?: string
|
|
271
|
+
timezone?: string
|
|
272
|
+
}): Promise<any> {
|
|
273
|
+
try {
|
|
274
|
+
const config = {
|
|
275
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
276
|
+
};
|
|
277
|
+
const queryParams = generateQueryParamsStr([
|
|
278
|
+
'toDate',
|
|
279
|
+
'fromDate',
|
|
280
|
+
'timezone',
|
|
281
|
+
], params);
|
|
282
|
+
return await axiosInstance.get(`${GET_SET_STATISTICS}/${storeId}/ordersProduct?${queryParams}`, config);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
console.error('Error fetching getProductsStatistics :', error);
|
|
285
|
+
throw error;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export const getMonthSalesStatistics = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
290
|
+
fromDate?: string
|
|
291
|
+
toDate?: string
|
|
292
|
+
timezone?: string
|
|
293
|
+
}): Promise<any> {
|
|
294
|
+
try {
|
|
295
|
+
const config = {
|
|
296
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
297
|
+
};
|
|
298
|
+
const queryParams = generateQueryParamsStr([
|
|
299
|
+
'toDate',
|
|
300
|
+
'fromDate',
|
|
301
|
+
'timezone',
|
|
302
|
+
], params);
|
|
303
|
+
return await axiosInstance.get(`${GET_SET_STATISTICS}/${storeId}/month?${queryParams}`, config);
|
|
304
|
+
} catch (error) {
|
|
305
|
+
console.error('Error fetching getMonthSalesStatistics :', error);
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export const getPopularDaysStatistics = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
311
|
+
fromDate?: string
|
|
312
|
+
toDate?: string
|
|
313
|
+
timezone?: string
|
|
314
|
+
}): Promise<any> {
|
|
315
|
+
try {
|
|
316
|
+
const config = {
|
|
317
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
318
|
+
};
|
|
319
|
+
const queryParams = generateQueryParamsStr([
|
|
320
|
+
'toDate',
|
|
321
|
+
'fromDate',
|
|
322
|
+
'timezone',
|
|
323
|
+
], params);
|
|
324
|
+
return await axiosInstance.get(`${GET_SET_STATISTICS}/${storeId}/popularDays?${queryParams}`, config);
|
|
325
|
+
} catch (error) {
|
|
326
|
+
console.error('Error fetching getPopularDaysStatistics :', error);
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as getModule from './get';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
4
|
+
|
|
5
|
+
// export const deletePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string): Promise<any> {
|
|
6
|
+
// try {
|
|
7
|
+
// const config = {
|
|
8
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
9
|
+
// };
|
|
10
|
+
// return await axiosInstance.delete(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
|
|
11
|
+
// } catch (error) {
|
|
12
|
+
// console.error('Error fetching deleteById:', error);
|
|
13
|
+
// throw error;
|
|
14
|
+
// }
|
|
15
|
+
// };
|