washday-sdk 0.0.177 → 0.0.179
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.
|
@@ -11,17 +11,22 @@ import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
|
11
11
|
import axiosInstance from "../axiosInstance";
|
|
12
12
|
const GET_SET_CUSTOMERS_APP = 'api/v2/washdayapp/customers';
|
|
13
13
|
const GET_SET_CUSTOMERS = 'api/customer';
|
|
14
|
-
export const getList = function (params) {
|
|
14
|
+
export const getList = function (params, options) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
17
|
const config = {
|
|
18
|
-
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
18
|
+
headers: { Authorization: `Bearer ${this.apiToken}` },
|
|
19
|
+
signal: (options === null || options === void 0 ? void 0 : options.signal) || params.signal || undefined
|
|
19
20
|
};
|
|
20
21
|
const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
|
|
21
22
|
return yield axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
|
|
22
23
|
}
|
|
23
24
|
catch (error) {
|
|
24
|
-
|
|
25
|
+
if (error instanceof Error && (error.name === 'AbortError' || error.name === 'CanceledError')) {
|
|
26
|
+
console.log('Request was cancelled');
|
|
27
|
+
throw new Error('Request cancelled');
|
|
28
|
+
}
|
|
29
|
+
console.error('Error fetching customers:', error);
|
|
25
30
|
throw error;
|
|
26
31
|
}
|
|
27
32
|
});
|
|
@@ -35,7 +35,8 @@ export const getOutsourcedOrdersByStore = function (params) {
|
|
|
35
35
|
const queryParams = generateQueryParamsStr([
|
|
36
36
|
'statuses',
|
|
37
37
|
'page',
|
|
38
|
-
'limit'
|
|
38
|
+
'limit',
|
|
39
|
+
'sequence'
|
|
39
40
|
], params);
|
|
40
41
|
return yield axiosInstance.get(`${GET_OUTSOURCED_ORDERS_BY_STORE.replace(':storeId', params.storeId)}?${queryParams}`, config);
|
|
41
42
|
}
|
package/package.json
CHANGED
package/src/api/customers/get.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GenericAbortSignal } from "axios";
|
|
1
2
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
3
|
import { ICustomer } from "../../interfaces/Customer";
|
|
3
4
|
import { IOrderInfo } from "../../interfaces/Order";
|
|
@@ -15,15 +16,21 @@ export const getList = async function (this: WashdayClientInstance, params: {
|
|
|
15
16
|
toDate?: string
|
|
16
17
|
limit: string
|
|
17
18
|
pageNum: string
|
|
18
|
-
|
|
19
|
+
signal?: GenericAbortSignal
|
|
20
|
+
}, options?: { signal?: AbortSignal }): Promise<any> {
|
|
19
21
|
try {
|
|
20
22
|
const config = {
|
|
21
|
-
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
23
|
+
headers: { Authorization: `Bearer ${this.apiToken}` },
|
|
24
|
+
signal: options?.signal || params.signal || undefined
|
|
22
25
|
};
|
|
23
26
|
const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
|
|
24
27
|
return await axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
|
|
25
28
|
} catch (error) {
|
|
26
|
-
|
|
29
|
+
if (error instanceof Error && (error.name === 'AbortError' || error.name === 'CanceledError')) {
|
|
30
|
+
console.log('Request was cancelled');
|
|
31
|
+
throw new Error('Request cancelled');
|
|
32
|
+
}
|
|
33
|
+
console.error('Error fetching customers:', error);
|
|
27
34
|
throw error;
|
|
28
35
|
}
|
|
29
36
|
};
|
|
@@ -20,6 +20,7 @@ export const getOutsourcedOrdersByOrder = async function (this: WashdayClientIns
|
|
|
20
20
|
export const getOutsourcedOrdersByStore = async function (this: WashdayClientInstance, params: {
|
|
21
21
|
storeId: string,
|
|
22
22
|
statuses?: string[],
|
|
23
|
+
sequence?: string,
|
|
23
24
|
page?: number,
|
|
24
25
|
limit?: number,
|
|
25
26
|
}): Promise<any> {
|
|
@@ -30,7 +31,8 @@ export const getOutsourcedOrdersByStore = async function (this: WashdayClientIns
|
|
|
30
31
|
const queryParams = generateQueryParamsStr([
|
|
31
32
|
'statuses',
|
|
32
33
|
'page',
|
|
33
|
-
'limit'
|
|
34
|
+
'limit',
|
|
35
|
+
'sequence'
|
|
34
36
|
], params);
|
|
35
37
|
return await axiosInstance.get(`${GET_OUTSOURCED_ORDERS_BY_STORE.replace(':storeId', params.storeId)}?${queryParams}`, config);
|
|
36
38
|
} catch (error) {
|