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,60 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CFDI = 'api/cfdi';
|
|
4
|
+
const GET_SET_ORDERS_CFDI = (orderID: string) => `api/order/${orderID}/cfdi`;
|
|
5
|
+
|
|
6
|
+
export const createCFDI = async function (this: WashdayClientInstance, data: {
|
|
7
|
+
ordersID: string[],
|
|
8
|
+
CFDIInfo: {
|
|
9
|
+
use: string
|
|
10
|
+
payment_method: string
|
|
11
|
+
payment_form: string
|
|
12
|
+
sendEmailInvoice?: boolean
|
|
13
|
+
date: string
|
|
14
|
+
env?: 'prod' | 'dev'
|
|
15
|
+
global?: {
|
|
16
|
+
periodicity: '',
|
|
17
|
+
months: '',
|
|
18
|
+
year: ''
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
customer?: string
|
|
22
|
+
}): Promise<any> {
|
|
23
|
+
try {
|
|
24
|
+
const config = {
|
|
25
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
26
|
+
};
|
|
27
|
+
return await axiosInstance.post(GET_SET_CFDI, data, config);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Error createCFDI:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const createGlobalCFDI = async function (this: WashdayClientInstance, data: {
|
|
35
|
+
ordersID: string[],
|
|
36
|
+
CFDIInfo: {
|
|
37
|
+
sendEmailInvoice: boolean
|
|
38
|
+
use: string
|
|
39
|
+
payment_method: string
|
|
40
|
+
payment_form: string
|
|
41
|
+
date: string
|
|
42
|
+
global: {
|
|
43
|
+
periodicity: string
|
|
44
|
+
months: string
|
|
45
|
+
year: string
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
customer?: string
|
|
49
|
+
}
|
|
50
|
+
): Promise<any> {
|
|
51
|
+
try {
|
|
52
|
+
const config = {
|
|
53
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
54
|
+
};
|
|
55
|
+
return await axiosInstance.post(`${GET_SET_CFDI}/global`, { ...data, ordersID: data.ordersID?.join(',') }, config);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('Error fetching create:', error);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
// const GET_SET_ORDER = 'api/v2/order';
|
|
4
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
5
|
+
|
|
6
|
+
// export const updateById = async function (this: WashdayClientInstance, id: string, data: {
|
|
7
|
+
// status?: string,
|
|
8
|
+
// products?: any[],
|
|
9
|
+
// buyAndGetProducts?: any[],
|
|
10
|
+
// customer?: string,
|
|
11
|
+
// discountCode?: string | null,
|
|
12
|
+
// notes?: string,
|
|
13
|
+
// privateNotes?: string,
|
|
14
|
+
// delivery?: boolean,
|
|
15
|
+
// pickup?: boolean,
|
|
16
|
+
// express?: boolean,
|
|
17
|
+
// deliveryInfo?: {
|
|
18
|
+
// date: Date,
|
|
19
|
+
// fromTime: string,
|
|
20
|
+
// toTime?: string
|
|
21
|
+
// },
|
|
22
|
+
// pickupInfo?: {
|
|
23
|
+
// date: Date,
|
|
24
|
+
// fromTime: string,
|
|
25
|
+
// toTime?: string
|
|
26
|
+
// },
|
|
27
|
+
// notifyBy?: string,
|
|
28
|
+
// }): Promise<any> {
|
|
29
|
+
// try {
|
|
30
|
+
// const config = {
|
|
31
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
// };
|
|
33
|
+
// return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
|
|
34
|
+
// } catch (error) {
|
|
35
|
+
// console.error('Error fetching updateById:', error);
|
|
36
|
+
// throw error;
|
|
37
|
+
// }
|
|
38
|
+
// };
|
|
39
|
+
|
|
40
|
+
// export const updatePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string, data: {
|
|
41
|
+
// amountPaid: number
|
|
42
|
+
// updatedDate: Date
|
|
43
|
+
// }): Promise<any> {
|
|
44
|
+
// try {
|
|
45
|
+
// const config = {
|
|
46
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
47
|
+
// };
|
|
48
|
+
// return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
|
|
49
|
+
// } catch (error) {
|
|
50
|
+
// console.error('Error fetching updateById:', error);
|
|
51
|
+
// throw error;
|
|
52
|
+
// }
|
|
53
|
+
// };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { ICustomer } from "../../interfaces/Customer";
|
|
3
|
+
import { IOrderInfo } from "../../interfaces/Order";
|
|
4
|
+
import axiosInstance from "../axiosInstance";
|
|
5
|
+
|
|
6
|
+
const GET_SET_COMPANIES = 'api/company';
|
|
7
|
+
const REQUEST_PARAMS = {
|
|
8
|
+
token: 'LOGGED_USER_TOKEN',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const getCompanyById = async function (this: WashdayClientInstance, companyId: string): Promise<any> {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
const response = await axiosInstance.get(`${GET_SET_COMPANIES}/${companyId}`, config);
|
|
18
|
+
return response;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error fetching getCompanyById:', error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_COMPANIES = 'api/company';
|
|
4
|
+
|
|
5
|
+
export const updateCompanyTaxInfoCertificates = async function (this: WashdayClientInstance, companyId: string, data: FormData): Promise<any> {
|
|
6
|
+
try {
|
|
7
|
+
const config = {
|
|
8
|
+
headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
|
|
9
|
+
};
|
|
10
|
+
const response = await axiosInstance.post(`${GET_SET_COMPANIES}/${companyId}/taxInfo/certificates`, data, config);
|
|
11
|
+
return response;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching updateCompanyTaxInfoById:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const updateCFDIOrgLogo = async function (this: WashdayClientInstance, companyId: string, data: any): Promise<any> {
|
|
19
|
+
try {
|
|
20
|
+
const config = {
|
|
21
|
+
headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
|
|
22
|
+
}
|
|
23
|
+
const response = await axiosInstance.post(`${GET_SET_COMPANIES}/${companyId}/taxInfo/logo`, data, config);
|
|
24
|
+
return response;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('Error fetching updateCFDIOrgLogo:', error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_COMPANIES = 'api/company';
|
|
4
|
+
|
|
5
|
+
export const updateCompanyById = async function (this: WashdayClientInstance, companyId: string, data: any): Promise<any> {
|
|
6
|
+
try {
|
|
7
|
+
const config = {
|
|
8
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
9
|
+
};
|
|
10
|
+
const response = await axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}`, data, config);
|
|
11
|
+
return response;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching updateCompanyById:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const updateCompanyLogoById = async function (this: WashdayClientInstance, companyId: string, data: any): Promise<any> {
|
|
19
|
+
try {
|
|
20
|
+
//TODO: company logo requires to have content-type false?
|
|
21
|
+
const config = {
|
|
22
|
+
headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
|
|
23
|
+
};
|
|
24
|
+
const response = await axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}`, data, config);
|
|
25
|
+
return response;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Error fetching updateCompanyLogoById:', error);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const updateCompanyTaxInfoById = async function (this: WashdayClientInstance, companyId: string, data: any): Promise<any> {
|
|
33
|
+
try {
|
|
34
|
+
const config = {
|
|
35
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
36
|
+
};
|
|
37
|
+
const response = await axiosInstance.put(`${GET_SET_COMPANIES}/${companyId}/taxInfo`, data, config);
|
|
38
|
+
return response;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error fetching updateCompanyTaxInfoById:', error);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { ICustomer } from "../../interfaces/Customer";
|
|
3
|
+
import { IOrderInfo } from "../../interfaces/Order";
|
|
4
|
+
import axiosInstance from "../axiosInstance";
|
|
5
|
+
|
|
6
|
+
const GET_SET_COUNTRIES = 'api/country';
|
|
7
|
+
const REQUEST_PARAMS = {
|
|
8
|
+
token: 'LOGGED_USER_TOKEN',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const getCountries = async function (this: WashdayClientInstance): Promise<any> {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: '' }
|
|
16
|
+
};
|
|
17
|
+
const response = await axiosInstance.get(`${GET_SET_COUNTRIES}`, config);
|
|
18
|
+
return response;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error fetching getCountries:', error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,354 @@
|
|
|
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 exportCustomersList = async function (this: WashdayClientInstance, params: {
|
|
9
|
+
searchTerm?: string
|
|
10
|
+
name?: string
|
|
11
|
+
phone?: string
|
|
12
|
+
email?: string
|
|
13
|
+
fromDate?: string
|
|
14
|
+
toDate?: string
|
|
15
|
+
limit: string
|
|
16
|
+
pageNum: string
|
|
17
|
+
}): Promise<any> {
|
|
18
|
+
try {
|
|
19
|
+
const config = {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
22
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
23
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
24
|
+
},
|
|
25
|
+
params: {
|
|
26
|
+
responseType: 'blob'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params)
|
|
30
|
+
return await axiosInstance.get(`${GENERATE_EXPORT}/export-all-customers?${queryParams}`, config);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('Error fetching exportCustomersList:', error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const exportOrdersList = async function (this: WashdayClientInstance, params: {
|
|
38
|
+
storeId: string | undefined,
|
|
39
|
+
status: string | undefined,
|
|
40
|
+
name: string | undefined,
|
|
41
|
+
phone: string | undefined,
|
|
42
|
+
email: string | undefined,
|
|
43
|
+
fromDate: string | undefined,
|
|
44
|
+
toDate: string | undefined,
|
|
45
|
+
sequence: string | undefined,
|
|
46
|
+
pageNum: string | undefined,
|
|
47
|
+
limit: string | undefined,
|
|
48
|
+
sequenceSort: string,
|
|
49
|
+
cleanedDateTime: string | undefined,
|
|
50
|
+
readyDateTime: string | undefined,
|
|
51
|
+
collectedDateTime: string | undefined,
|
|
52
|
+
q: string | undefined
|
|
53
|
+
}): Promise<any> {
|
|
54
|
+
try {
|
|
55
|
+
const config = {
|
|
56
|
+
headers: {
|
|
57
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
58
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
59
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
60
|
+
},
|
|
61
|
+
params: {
|
|
62
|
+
responseType: 'blob'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const queryParams = generateQueryParamsStr([
|
|
66
|
+
'storeId',
|
|
67
|
+
'status',
|
|
68
|
+
'name',
|
|
69
|
+
'phone',
|
|
70
|
+
'email',
|
|
71
|
+
'fromDate',
|
|
72
|
+
'toDate',
|
|
73
|
+
'sequence',
|
|
74
|
+
'pageNum',
|
|
75
|
+
'limit',
|
|
76
|
+
'sequenceSort',
|
|
77
|
+
'cleanedDateTime',
|
|
78
|
+
'readyDateTime',
|
|
79
|
+
'collectedDateTime',
|
|
80
|
+
'q'
|
|
81
|
+
], params);
|
|
82
|
+
return await axiosInstance.get(`${GENERATE_EXPORT}/export-all-orders?${queryParams}`, config);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const exportProductsList = async function (this: WashdayClientInstance, storeId: string): Promise<any> {
|
|
90
|
+
try {
|
|
91
|
+
const config = {
|
|
92
|
+
headers: {
|
|
93
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
94
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
95
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
96
|
+
},
|
|
97
|
+
params: {
|
|
98
|
+
responseType: 'blob'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return await axiosInstance.get(`api/product/${storeId}/export`, config);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error('Error fetching exportProductsList:', error);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const exportCleanedOrdersReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
109
|
+
fromDate?: string
|
|
110
|
+
toDate?: string
|
|
111
|
+
timezone?: string
|
|
112
|
+
}): Promise<any> {
|
|
113
|
+
try {
|
|
114
|
+
const config = {
|
|
115
|
+
headers: {
|
|
116
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
117
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
118
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
119
|
+
},
|
|
120
|
+
params: {
|
|
121
|
+
responseType: 'blob'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const queryParams = generateQueryParamsStr([
|
|
125
|
+
'fromDate',
|
|
126
|
+
'toDate',
|
|
127
|
+
'timezone'
|
|
128
|
+
], params);
|
|
129
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders/export?${queryParams}`, config);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const exportSalesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
137
|
+
fromDate?: string
|
|
138
|
+
toDate?: string
|
|
139
|
+
timezone?: string
|
|
140
|
+
type: "daily" | "month" | "year";
|
|
141
|
+
}): Promise<any> {
|
|
142
|
+
try {
|
|
143
|
+
const config = {
|
|
144
|
+
headers: {
|
|
145
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
146
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
147
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
148
|
+
},
|
|
149
|
+
params: {
|
|
150
|
+
responseType: 'blob'
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const queryParams = generateQueryParamsStr([
|
|
154
|
+
'fromDate',
|
|
155
|
+
'toDate',
|
|
156
|
+
'timezone',
|
|
157
|
+
'type'
|
|
158
|
+
], params);
|
|
159
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales/export?${queryParams}`, config);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const exportCustomersReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
167
|
+
fromDate?: string
|
|
168
|
+
toDate?: string
|
|
169
|
+
}): Promise<any> {
|
|
170
|
+
try {
|
|
171
|
+
const config = {
|
|
172
|
+
headers: {
|
|
173
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
174
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
175
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
176
|
+
},
|
|
177
|
+
params: {
|
|
178
|
+
responseType: 'blob'
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const queryParams = generateQueryParamsStr([
|
|
182
|
+
'fromDate',
|
|
183
|
+
'toDate',
|
|
184
|
+
], params);
|
|
185
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/customers/export?${queryParams}`, config);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
console.error('Error fetching exportCustomersReport:', error);
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const exportSuppliesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
193
|
+
fromDate?: string
|
|
194
|
+
toDate?: string
|
|
195
|
+
}): Promise<any> {
|
|
196
|
+
try {
|
|
197
|
+
const config = {
|
|
198
|
+
headers: {
|
|
199
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
200
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
201
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
202
|
+
},
|
|
203
|
+
params: {
|
|
204
|
+
responseType: 'blob'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const queryParams = generateQueryParamsStr([
|
|
208
|
+
'fromDate',
|
|
209
|
+
'toDate',
|
|
210
|
+
], params);
|
|
211
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/supplies/export?${queryParams}`, config);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error('Error fetching exportCustomersReport:', error);
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export const exportDiscountCodesReport = async function (this: WashdayClientInstance, storeId: string, params: {}): Promise<any> {
|
|
219
|
+
try {
|
|
220
|
+
const config = {
|
|
221
|
+
headers: {
|
|
222
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
223
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
224
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
225
|
+
},
|
|
226
|
+
params: {
|
|
227
|
+
responseType: 'blob'
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
const queryParams = generateQueryParamsStr([
|
|
231
|
+
], params);
|
|
232
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/discountCodes/export?${queryParams}`, config);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.error('Error fetching exportCustomersReport:', error);
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const exportStaffReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
240
|
+
fromDate?: string
|
|
241
|
+
toDate?: string
|
|
242
|
+
}): Promise<any> {
|
|
243
|
+
try {
|
|
244
|
+
const config = {
|
|
245
|
+
headers: {
|
|
246
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
247
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
248
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
249
|
+
},
|
|
250
|
+
params: {
|
|
251
|
+
responseType: 'blob'
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const queryParams = generateQueryParamsStr([
|
|
255
|
+
'fromDate',
|
|
256
|
+
'toDate',
|
|
257
|
+
], params);
|
|
258
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/staff/export?${queryParams}`, config);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
console.error('Error fetching exportCustomersReport:', error);
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
export const exportProductSalesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
267
|
+
fromDate?: string
|
|
268
|
+
toDate?: string
|
|
269
|
+
timezone?: string
|
|
270
|
+
}): Promise<any> {
|
|
271
|
+
try {
|
|
272
|
+
const config = {
|
|
273
|
+
headers: {
|
|
274
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
275
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
276
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
277
|
+
},
|
|
278
|
+
params: {
|
|
279
|
+
responseType: 'blob'
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
const queryParams = generateQueryParamsStr([
|
|
283
|
+
'fromDate',
|
|
284
|
+
'toDate',
|
|
285
|
+
'timezone'
|
|
286
|
+
], params);
|
|
287
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/productSales/export?${queryParams}`, config);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export const exportPaymentLinesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
295
|
+
fromDate?: string
|
|
296
|
+
toDate?: string
|
|
297
|
+
timezone?: string
|
|
298
|
+
}): Promise<any> {
|
|
299
|
+
try {
|
|
300
|
+
const config = {
|
|
301
|
+
headers: {
|
|
302
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
303
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
304
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
305
|
+
},
|
|
306
|
+
params: {
|
|
307
|
+
responseType: 'blob'
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const queryParams = generateQueryParamsStr([
|
|
311
|
+
'fromDate',
|
|
312
|
+
'toDate',
|
|
313
|
+
'timezone'
|
|
314
|
+
], params);
|
|
315
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/paymentLines/export?${queryParams}`, config);
|
|
316
|
+
} catch (error) {
|
|
317
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
318
|
+
throw error;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export const exportUnpaidOrdersReportCSV = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
323
|
+
fromDate?: string
|
|
324
|
+
toDate?: string
|
|
325
|
+
timezone?: string
|
|
326
|
+
pageNum?: string
|
|
327
|
+
limit?: string
|
|
328
|
+
customerName?: string
|
|
329
|
+
}): Promise<any> {
|
|
330
|
+
try {
|
|
331
|
+
const config = {
|
|
332
|
+
headers: {
|
|
333
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
334
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
335
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
336
|
+
},
|
|
337
|
+
params: {
|
|
338
|
+
responseType: 'blob'
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const queryParams = generateQueryParamsStr([
|
|
342
|
+
'fromDate',
|
|
343
|
+
'toDate',
|
|
344
|
+
'pageNum',
|
|
345
|
+
'limit',
|
|
346
|
+
'timezone',
|
|
347
|
+
'customerName'
|
|
348
|
+
], params);
|
|
349
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export/csv?${queryParams}`, config);
|
|
350
|
+
} catch (error) {
|
|
351
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as getModule from './get';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CUSTOMERS = 'api/customer';
|
|
4
|
+
const GET_SET_CUSTOMERS_APP = 'api/v2/washdayapp/customers';
|
|
5
|
+
|
|
6
|
+
export const deleteByIdCustomersApp = 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_CUSTOMERS_APP}/${id}`, config);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching deleteByIdCustomersApp:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export const deleteById = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
20
|
+
try {
|
|
21
|
+
const config = {
|
|
22
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
23
|
+
};
|
|
24
|
+
return await axiosInstance.delete(`${GET_SET_CUSTOMERS}/${id}`, config);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('Error fetching deleteById:', error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
};
|