washday-sdk 0.0.71 → 0.0.73
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/dist/api/axiosInstance.d.ts +2 -0
- package/dist/api/axiosInstance.js +4 -8
- package/dist/api/cashierbox/delete.d.ts +2 -0
- package/dist/api/cashierbox/delete.js +3 -10
- package/dist/api/cashierbox/get.d.ts +7 -0
- package/dist/api/cashierbox/get.js +7 -16
- package/dist/api/cashierbox/post.d.ts +11 -0
- package/dist/api/cashierbox/post.js +5 -13
- package/dist/api/cashierbox/put.d.ts +4 -0
- package/dist/api/cashierbox/put.js +3 -10
- package/dist/api/companies/get.d.ts +2 -0
- package/dist/api/companies/get.js +3 -10
- package/dist/api/companies/post.d.ts +3 -0
- package/dist/api/companies/post.js +5 -13
- package/dist/api/companies/put.d.ts +4 -0
- package/dist/api/companies/put.js +7 -16
- package/dist/api/countries/get.d.ts +2 -0
- package/dist/api/countries/get.js +3 -10
- package/dist/api/countries/post.d.ts +0 -0
- package/dist/api/countries/put.d.ts +0 -0
- package/dist/api/csv/get.d.ts +11 -0
- package/dist/api/csv/get.js +5 -12
- package/dist/api/csv/index.d.ts +1 -0
- package/dist/api/csv/index.js +1 -27
- package/dist/api/customers/delete.d.ts +2 -0
- package/dist/api/customers/delete.js +3 -10
- package/dist/api/customers/get.d.ts +28 -0
- package/dist/api/customers/get.js +12 -22
- package/dist/api/customers/index.d.ts +4 -0
- package/dist/api/customers/index.js +4 -30
- package/dist/api/customers/post.d.ts +18 -0
- package/dist/api/customers/post.js +3 -10
- package/dist/api/customers/put.d.ts +18 -0
- package/dist/api/customers/put.js +3 -10
- package/dist/api/discounts/get.d.ts +6 -0
- package/dist/api/discounts/get.js +11 -22
- package/dist/api/discounts/post.d.ts +3 -0
- package/dist/api/discounts/post.js +5 -13
- package/dist/api/discounts/put.d.ts +3 -0
- package/dist/api/discounts/put.js +5 -13
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +88 -103
- package/dist/api/inventory/delete.d.ts +2 -0
- package/dist/api/inventory/delete.js +3 -10
- package/dist/api/inventory/get.d.ts +7 -0
- package/dist/api/inventory/get.js +7 -16
- package/dist/api/inventory/index.d.ts +4 -0
- package/dist/api/inventory/index.js +4 -30
- package/dist/api/inventory/post.d.ts +7 -0
- package/dist/api/inventory/post.js +3 -10
- package/dist/api/inventory/put.d.ts +8 -0
- package/dist/api/inventory/put.js +5 -13
- package/dist/api/order/delete.js +25 -0
- package/dist/api/order/get.js +58 -0
- package/dist/api/order/index.js +4 -0
- package/dist/api/order/post.js +26 -0
- package/dist/api/order/put.js +40 -0
- package/dist/api/products/delete.d.ts +3 -0
- package/dist/api/products/delete.js +5 -13
- package/dist/api/products/get.d.ts +2 -0
- package/dist/api/products/get.js +3 -10
- package/dist/api/products/index.d.ts +4 -0
- package/dist/api/products/index.js +4 -30
- package/dist/api/products/post.d.ts +27 -0
- package/dist/api/products/post.js +5 -13
- package/dist/api/products/put.d.ts +21 -0
- package/dist/api/products/put.js +5 -13
- package/dist/api/sections/delete.d.ts +2 -0
- package/dist/api/sections/delete.js +3 -10
- package/dist/api/sections/get.d.ts +7 -0
- package/dist/api/sections/get.js +5 -13
- package/dist/api/sections/index.d.ts +4 -0
- package/dist/api/sections/index.js +4 -30
- package/dist/api/sections/post.d.ts +7 -0
- package/dist/api/sections/post.js +3 -10
- package/dist/api/sections/put.d.ts +8 -0
- package/dist/api/sections/put.js +3 -10
- package/dist/api/staff/delete.d.ts +2 -0
- package/dist/api/staff/delete.js +3 -10
- package/dist/api/staff/get.d.ts +3 -0
- package/dist/api/staff/get.js +5 -13
- package/dist/api/staff/post.d.ts +2 -0
- package/dist/api/staff/post.js +3 -10
- package/dist/api/staff/put.d.ts +2 -0
- package/dist/api/staff/put.js +3 -10
- package/dist/api/stores/get.d.ts +12 -0
- package/dist/api/stores/get.js +9 -19
- package/dist/api/stores/post.d.ts +4 -0
- package/dist/api/stores/post.js +7 -16
- package/dist/api/stores/put.d.ts +6 -0
- package/dist/api/stores/put.js +5 -13
- package/dist/api/stripe/get.d.ts +0 -0
- package/dist/api/stripe/post.d.ts +6 -0
- package/dist/api/stripe/post.js +7 -16
- package/dist/api/stripe/put.d.ts +0 -0
- package/dist/api/supplies/delete.d.ts +2 -0
- package/dist/api/supplies/delete.js +3 -10
- package/dist/api/supplies/get.d.ts +7 -0
- package/dist/api/supplies/get.js +7 -16
- package/dist/api/supplies/post.d.ts +11 -0
- package/dist/api/supplies/post.js +3 -10
- package/dist/api/supplies/put.d.ts +6 -0
- package/dist/api/supplies/put.js +5 -13
- package/dist/api/users/put.d.ts +10 -0
- package/dist/api/users/put.js +3 -10
- package/dist/enum/index.d.ts +10 -0
- package/dist/enum/index.js +4 -7
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -33
- package/dist/interfaces/Api.d.ts +3 -0
- package/dist/interfaces/Api.js +1 -2
- package/dist/interfaces/Company.d.ts +0 -0
- package/dist/interfaces/Customer.d.ts +47 -0
- package/dist/interfaces/Customer.js +1 -2
- package/dist/interfaces/Order.d.ts +91 -0
- package/dist/interfaces/Order.js +1 -2
- package/dist/interfaces/Permission.d.ts +22 -0
- package/dist/interfaces/Permission.js +1 -2
- package/dist/interfaces/Product.d.ts +51 -0
- package/dist/interfaces/Product.js +1 -2
- package/dist/interfaces/Section.d.ts +13 -0
- package/dist/interfaces/Section.js +1 -2
- package/dist/interfaces/Store.d.ts +323 -0
- package/dist/interfaces/Store.js +1 -2
- package/dist/interfaces/StoreImage.d.ts +8 -0
- package/dist/interfaces/StoreImage.js +1 -2
- package/dist/interfaces/User.d.ts +38 -0
- package/dist/interfaces/User.js +1 -2
- package/dist/utils/apiUtils.d.ts +3 -0
- package/dist/utils/apiUtils.js +2 -6
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -17
- package/dist/utils/orders/calculateOrderTotal.d.ts +5 -0
- package/dist/utils/orders/calculateOrderTotal.js +10 -14
- package/dist/utils/orders/calculateTotalTaxesIncluded.d.ts +9 -0
- package/dist/utils/orders/calculateTotalTaxesIncluded.js +3 -7
- package/dist/utils/orders/calculateTotalTaxesOverPrice.d.ts +8 -0
- package/dist/utils/orders/calculateTotalTaxesOverPrice.js +7 -11
- package/dist/utils/orders/helpers.d.ts +15 -0
- package/dist/utils/orders/helpers.js +6 -13
- package/dist/utils/orders/index.d.ts +2 -0
- package/dist/utils/orders/index.js +2 -5
- package/dist/utils/receipt/generateReceiptHTML.d.ts +0 -0
- package/dist/utils/util.d.ts +0 -0
- package/package.json +2 -1
- package/src/api/axiosInstance.ts +1 -0
- package/src/api/customers/get.ts +1 -1
- package/src/api/index.ts +11 -10
- package/src/api/order/delete.ts +15 -0
- package/src/api/order/get.ts +64 -0
- package/src/api/order/index.ts +4 -0
- package/src/api/order/post.ts +21 -0
- package/src/api/order/put.ts +53 -0
- package/src/utils/apiUtils.ts +1 -1
- package/tsconfig.json +10 -9
package/package.json
CHANGED
package/src/api/axiosInstance.ts
CHANGED
|
@@ -3,6 +3,7 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
|
3
3
|
// Define the type for the Axios instance
|
|
4
4
|
let axiosInstance: AxiosInstance | null = null;
|
|
5
5
|
|
|
6
|
+
// const BASE_URL: string = 'http://localhost:5555/';
|
|
6
7
|
const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
|
|
7
8
|
|
|
8
9
|
// Function to create or return the singleton instance
|
package/src/api/customers/get.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
|
|
|
20
20
|
const config = {
|
|
21
21
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
22
22
|
};
|
|
23
|
-
const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params)
|
|
23
|
+
const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
|
|
24
24
|
return await axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
|
|
25
25
|
} catch (error) {
|
|
26
26
|
console.error('Error fetching getStoreStaff:', error);
|
package/src/api/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import * as sectionsEndpoints from './sections';
|
|
|
29
29
|
import * as productsEndpoints from './products';
|
|
30
30
|
import * as customersEndpoints from './customers';
|
|
31
31
|
import * as csvExportEndpoints from './csv';
|
|
32
|
+
import * as ordersEndpoints from './order';
|
|
32
33
|
|
|
33
34
|
type WashdayClientConstructor = {
|
|
34
35
|
new(apiToken: string): {
|
|
@@ -53,8 +54,18 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
53
54
|
WashdayClient.prototype.supplies.apiToken = apiToken;
|
|
54
55
|
WashdayClient.prototype.inventory.apiToken = apiToken;
|
|
55
56
|
WashdayClient.prototype.csv.apiToken = apiToken;
|
|
57
|
+
WashdayClient.prototype.orders.apiToken = apiToken;
|
|
56
58
|
} as any;
|
|
57
59
|
|
|
60
|
+
WashdayClient.prototype.orders = {
|
|
61
|
+
getList: ordersEndpoints.getModule.getList,
|
|
62
|
+
getById: ordersEndpoints.getModule.getById,
|
|
63
|
+
updateById: ordersEndpoints.putModule.updateById,
|
|
64
|
+
updatePaymentLineById: ordersEndpoints.putModule.updatePaymentLineById,
|
|
65
|
+
createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
|
|
66
|
+
deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
|
|
67
|
+
};
|
|
68
|
+
|
|
58
69
|
WashdayClient.prototype.customers = {
|
|
59
70
|
getCustomers: customersEndpoints.getModule.getList,
|
|
60
71
|
getCustomerById: customersEndpoints.getModule.getCustomerById,
|
|
@@ -177,14 +188,4 @@ WashdayClient.prototype.csv = {
|
|
|
177
188
|
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
178
189
|
};
|
|
179
190
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
191
|
export default WashdayClient;
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { ICustomer } from "../../interfaces/Customer";
|
|
3
|
+
import { IOrder, IOrderInfo } from "../../interfaces/Order";
|
|
4
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
5
|
+
import axiosInstance from "../axiosInstance";
|
|
6
|
+
const GET_SET_ORDER = 'api/v2/order';
|
|
7
|
+
const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
8
|
+
|
|
9
|
+
export const getList = async function (this: WashdayClientInstance, params: {
|
|
10
|
+
storeId: string | undefined,
|
|
11
|
+
status: string | undefined,
|
|
12
|
+
name: string | undefined,
|
|
13
|
+
phone: string | undefined,
|
|
14
|
+
email: string | undefined,
|
|
15
|
+
fromDate: string | undefined,
|
|
16
|
+
toDate: string | undefined,
|
|
17
|
+
sequence: string | undefined,
|
|
18
|
+
pageNum: string | undefined,
|
|
19
|
+
limit: string | undefined,
|
|
20
|
+
sequenceSort: string,
|
|
21
|
+
cleanedDateTime: string | undefined,
|
|
22
|
+
readyDateTime: string | undefined,
|
|
23
|
+
collectedDateTime: string | undefined,
|
|
24
|
+
q: string | undefined
|
|
25
|
+
}): Promise<any> {
|
|
26
|
+
try {
|
|
27
|
+
const config = {
|
|
28
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
29
|
+
};
|
|
30
|
+
const queryParams = generateQueryParamsStr([
|
|
31
|
+
'storeId',
|
|
32
|
+
'status',
|
|
33
|
+
'name',
|
|
34
|
+
'phone',
|
|
35
|
+
'email',
|
|
36
|
+
'fromDate',
|
|
37
|
+
'toDate',
|
|
38
|
+
'sequence',
|
|
39
|
+
'pageNum',
|
|
40
|
+
'limit',
|
|
41
|
+
'sequenceSort',
|
|
42
|
+
'cleanedDateTime',
|
|
43
|
+
'readyDateTime',
|
|
44
|
+
'collectedDateTime',
|
|
45
|
+
'q',
|
|
46
|
+
], params);
|
|
47
|
+
return await axiosInstance.get(`${GET_SET_ORDER}?${queryParams}`, config);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error('Error fetching getList orders:', error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const getById = async function (this: WashdayClientInstance, id: string): Promise<IOrder> {
|
|
55
|
+
try {
|
|
56
|
+
const config = {
|
|
57
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
58
|
+
};
|
|
59
|
+
return await axiosInstance.get(`${GET_SET_ORDER}/${id}`, config);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error('Error fetching:', error);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CUSTOMERS = 'api/customer';
|
|
4
|
+
const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
5
|
+
|
|
6
|
+
export const createPaymentLine = async function (this: WashdayClientInstance, id: string, data: {
|
|
7
|
+
amountPaid: number,
|
|
8
|
+
cashierBox: string,
|
|
9
|
+
paymentMethod: string
|
|
10
|
+
paymentDate: Date
|
|
11
|
+
}): Promise<any> {
|
|
12
|
+
try {
|
|
13
|
+
const config = {
|
|
14
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
15
|
+
};
|
|
16
|
+
return await axiosInstance.post(`${GET_SET_ORDER_PAYMENTLINES(id)}`, data, config);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error fetching create:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -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
|
+
};
|
package/src/utils/apiUtils.ts
CHANGED
|
@@ -2,7 +2,7 @@ export const generateQueryParamsStr = (availableQueryParamsList: Array<string> =
|
|
|
2
2
|
[key: string]: any
|
|
3
3
|
} = {}) => {
|
|
4
4
|
let queryParams = [];
|
|
5
|
-
for (let availableParam
|
|
5
|
+
for (let availableParam of availableQueryParamsList) {
|
|
6
6
|
if (receivedParamsObj.hasOwnProperty(availableParam)) {
|
|
7
7
|
queryParams.push(`${availableParam}=${receivedParamsObj[availableParam]}`)
|
|
8
8
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"outDir": "dist" // Specify the output directory for JavaScript files
|
|
9
|
+
},
|
|
10
|
+
"include": ["src/**/*.ts"]
|
|
11
|
+
}
|