washday-sdk 1.6.51 → 1.6.53
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/index.js +1 -0
- package/dist/api/order/get.js +1 -0
- package/dist/api/routes/get.js +24 -1
- package/dist/api/routes/post.js +12 -13
- package/dist/api/staff/get.js +8 -1
- package/package.json +1 -1
- package/src/api/index.ts +1 -0
- package/src/api/order/get.ts +2 -0
- package/src/api/routes/get.ts +35 -1
- package/src/api/routes/post.ts +15 -4
- package/src/api/staff/get.ts +16 -2
- package/src/interfaces/Api.ts +1 -0
- package/src/interfaces/Route.ts +3 -0
- package/test/orders.getListAssignedEmployee.test.ts +46 -0
- package/test/routes.multistore.test.ts +111 -0
- package/test/staff.getStoreAssignableStaffs.test.ts +30 -0
package/dist/api/index.js
CHANGED
|
@@ -102,6 +102,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
102
102
|
closeRouteByIdV2: routesEndpoints.putModule.closeRouteByIdV2,
|
|
103
103
|
updateRouteById: routesEndpoints.putModule.updateRouteById,
|
|
104
104
|
getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
|
|
105
|
+
getRoutes: routesEndpoints.getModule.getRoutes,
|
|
105
106
|
startRoute: routesEndpoints.postModule.startRoute,
|
|
106
107
|
reorderRouteOrders: routesEndpoints.patchModule.reorderRouteOrders,
|
|
107
108
|
});
|
package/dist/api/order/get.js
CHANGED
package/dist/api/routes/get.js
CHANGED
|
@@ -97,7 +97,8 @@ export const getRoutesByDriver = function (query) {
|
|
|
97
97
|
};
|
|
98
98
|
const queryParams = generateQueryParamsStr([
|
|
99
99
|
'status',
|
|
100
|
-
|
|
100
|
+
'scope',
|
|
101
|
+
], Object.assign(Object.assign({}, query), { scope: "driver" }));
|
|
101
102
|
return yield this.axiosInstance.get(`${GET_ROUTE}?${queryParams}`, config);
|
|
102
103
|
}
|
|
103
104
|
catch (error) {
|
|
@@ -106,3 +107,25 @@ export const getRoutesByDriver = function (query) {
|
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
};
|
|
110
|
+
export const getRoutes = function () {
|
|
111
|
+
return __awaiter(this, arguments, void 0, function* (query = {}) {
|
|
112
|
+
try {
|
|
113
|
+
const config = {
|
|
114
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
115
|
+
};
|
|
116
|
+
const queryParams = generateQueryParamsStr([
|
|
117
|
+
'scope',
|
|
118
|
+
'storeIds',
|
|
119
|
+
'status',
|
|
120
|
+
'driver',
|
|
121
|
+
'createdFrom',
|
|
122
|
+
'createdTo',
|
|
123
|
+
], query);
|
|
124
|
+
return yield this.axiosInstance.get(`${GET_ROUTE}?${queryParams}`, config);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
console.error('Error fetching getRoutes:', error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
};
|
package/dist/api/routes/post.js
CHANGED
|
@@ -7,17 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
10
|
const GET_SET_ROUTES = 'api/routes';
|
|
22
11
|
const GET_STORE_ROUTES_BY_ID = 'api/stores/:id/routes';
|
|
23
12
|
//@deprecated
|
|
@@ -41,8 +30,18 @@ export const createRouteV2 = function (data) {
|
|
|
41
30
|
const config = {
|
|
42
31
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
43
32
|
};
|
|
44
|
-
const { storeId
|
|
45
|
-
|
|
33
|
+
const { storeId, storeIds, driver, orders } = data;
|
|
34
|
+
if (storeIds) {
|
|
35
|
+
return yield this.axiosInstance.post(GET_SET_ROUTES, {
|
|
36
|
+
storeIds,
|
|
37
|
+
driver,
|
|
38
|
+
orders,
|
|
39
|
+
}, config);
|
|
40
|
+
}
|
|
41
|
+
return yield this.axiosInstance.post(GET_STORE_ROUTES_BY_ID.replace(':id', storeId), {
|
|
42
|
+
driver,
|
|
43
|
+
orders,
|
|
44
|
+
}, config);
|
|
46
45
|
}
|
|
47
46
|
catch (error) {
|
|
48
47
|
console.error('Error fetching createRouteV2:', error);
|
package/dist/api/staff/get.js
CHANGED
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
10
11
|
const GET_SET_STAFF = (storeId) => `api/store/${storeId}/staff`;
|
|
11
12
|
const GET_ASSIGNABLE_STAFF = (storeId) => `api/store/${storeId}/assignable-staffs`;
|
|
12
13
|
export const getStoreStaff = function (storeId, queryParams) {
|
|
@@ -30,7 +31,13 @@ export const getStoreAssignableStaffs = function (storeId, queryParams) {
|
|
|
30
31
|
const config = {
|
|
31
32
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
33
|
};
|
|
33
|
-
const
|
|
34
|
+
const normalizedQueryParams = typeof queryParams === "string"
|
|
35
|
+
? queryParams
|
|
36
|
+
: generateQueryParamsStr([
|
|
37
|
+
"appendAdmin",
|
|
38
|
+
"storeIds",
|
|
39
|
+
], queryParams || {});
|
|
40
|
+
const suffix = normalizedQueryParams ? `?${normalizedQueryParams}` : "";
|
|
34
41
|
const response = yield this.axiosInstance.get(`${GET_ASSIGNABLE_STAFF(storeId)}${suffix}`, config);
|
|
35
42
|
return response;
|
|
36
43
|
}
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -109,6 +109,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
109
109
|
closeRouteByIdV2: routesEndpoints.putModule.closeRouteByIdV2,
|
|
110
110
|
updateRouteById: routesEndpoints.putModule.updateRouteById,
|
|
111
111
|
getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
|
|
112
|
+
getRoutes: routesEndpoints.getModule.getRoutes,
|
|
112
113
|
startRoute: routesEndpoints.postModule.startRoute,
|
|
113
114
|
reorderRouteOrders: routesEndpoints.patchModule.reorderRouteOrders,
|
|
114
115
|
});
|
package/src/api/order/get.ts
CHANGED
|
@@ -11,6 +11,7 @@ const GET_SET_ORDER_CUSTOMERS_APP = 'api/v2/washdayapp/orders';
|
|
|
11
11
|
export const getList = async function (this: WashdayClientInstance, params: {
|
|
12
12
|
store: string | undefined,
|
|
13
13
|
storeId: string | undefined,
|
|
14
|
+
storeIds?: string[] | string,
|
|
14
15
|
status: string | undefined,
|
|
15
16
|
name: string | undefined,
|
|
16
17
|
phone: string | undefined,
|
|
@@ -43,6 +44,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
|
|
|
43
44
|
const queryParams = generateQueryParamsStr([
|
|
44
45
|
'store',
|
|
45
46
|
'storeId',
|
|
47
|
+
'storeIds',
|
|
46
48
|
'status',
|
|
47
49
|
'name',
|
|
48
50
|
'phone',
|
package/src/api/routes/get.ts
CHANGED
|
@@ -7,6 +7,17 @@ const GET_STORE_ROUTES = 'api/storeRoutes';
|
|
|
7
7
|
const GET_STORE_ROUTES_BY_ID = 'api/stores/:id/routes';
|
|
8
8
|
const GET_ROUTE = 'api/routes';
|
|
9
9
|
|
|
10
|
+
export type RouteListScope = "driver" | "company";
|
|
11
|
+
|
|
12
|
+
export type RouteListQuery = {
|
|
13
|
+
scope?: RouteListScope,
|
|
14
|
+
storeIds?: string[] | string,
|
|
15
|
+
status?: string,
|
|
16
|
+
driver?: string,
|
|
17
|
+
createdFrom?: string,
|
|
18
|
+
createdTo?: string,
|
|
19
|
+
};
|
|
20
|
+
|
|
10
21
|
//@deprecated
|
|
11
22
|
export const getOrdersForRoute = async function (this: WashdayClientInstance, params: {
|
|
12
23
|
store: string | undefined,
|
|
@@ -87,7 +98,11 @@ export const getRoutesByDriver = async function (this: WashdayClientInstance, qu
|
|
|
87
98
|
};
|
|
88
99
|
const queryParams = generateQueryParamsStr([
|
|
89
100
|
'status',
|
|
90
|
-
|
|
101
|
+
'scope',
|
|
102
|
+
], {
|
|
103
|
+
...query,
|
|
104
|
+
scope: "driver",
|
|
105
|
+
});
|
|
91
106
|
return await this.axiosInstance.get(`${GET_ROUTE}?${queryParams}`, config);
|
|
92
107
|
} catch (error) {
|
|
93
108
|
console.error('Error fetching getRoutesByDriver:', error);
|
|
@@ -95,3 +110,22 @@ export const getRoutesByDriver = async function (this: WashdayClientInstance, qu
|
|
|
95
110
|
}
|
|
96
111
|
};
|
|
97
112
|
|
|
113
|
+
export const getRoutes = async function (this: WashdayClientInstance, query: RouteListQuery = {}): Promise<{ data: { data: IRoute[] } }> {
|
|
114
|
+
try {
|
|
115
|
+
const config = {
|
|
116
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
117
|
+
};
|
|
118
|
+
const queryParams = generateQueryParamsStr([
|
|
119
|
+
'scope',
|
|
120
|
+
'storeIds',
|
|
121
|
+
'status',
|
|
122
|
+
'driver',
|
|
123
|
+
'createdFrom',
|
|
124
|
+
'createdTo',
|
|
125
|
+
], query);
|
|
126
|
+
return await this.axiosInstance.get(`${GET_ROUTE}?${queryParams}`, config);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error('Error fetching getRoutes:', error);
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
};
|
package/src/api/routes/post.ts
CHANGED
|
@@ -30,7 +30,8 @@ export const createRoute = async function (this: WashdayClientInstance, data: {
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
export const createRouteV2 = async function (this: WashdayClientInstance, data: {
|
|
33
|
-
storeId
|
|
33
|
+
storeId?: string,
|
|
34
|
+
storeIds?: string[],
|
|
34
35
|
driver: string,
|
|
35
36
|
orders: Array<string>,
|
|
36
37
|
}): Promise<any> {
|
|
@@ -38,8 +39,18 @@ export const createRouteV2 = async function (this: WashdayClientInstance, data:
|
|
|
38
39
|
const config = {
|
|
39
40
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
40
41
|
};
|
|
41
|
-
const { storeId,
|
|
42
|
-
|
|
42
|
+
const { storeId, storeIds, driver, orders } = data;
|
|
43
|
+
if (storeIds) {
|
|
44
|
+
return await this.axiosInstance.post(GET_SET_ROUTES, {
|
|
45
|
+
storeIds,
|
|
46
|
+
driver,
|
|
47
|
+
orders,
|
|
48
|
+
}, config);
|
|
49
|
+
}
|
|
50
|
+
return await this.axiosInstance.post(GET_STORE_ROUTES_BY_ID.replace(':id', storeId as string), {
|
|
51
|
+
driver,
|
|
52
|
+
orders,
|
|
53
|
+
}, config);
|
|
43
54
|
} catch (error) {
|
|
44
55
|
console.error('Error fetching createRouteV2:', error);
|
|
45
56
|
throw error;
|
|
@@ -57,4 +68,4 @@ export const startRoute = async function (this: WashdayClientInstance, routeId:
|
|
|
57
68
|
console.error('Error fetching startRoute:', error);
|
|
58
69
|
throw error;
|
|
59
70
|
}
|
|
60
|
-
};
|
|
71
|
+
};
|
package/src/api/staff/get.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
2
3
|
import axiosInstance from "../axiosInstance";
|
|
3
4
|
|
|
4
5
|
const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
|
|
@@ -17,12 +18,25 @@ export const getStoreStaff = async function (this: WashdayClientInstance, storeI
|
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
export const getStoreAssignableStaffs = async function (
|
|
21
|
+
export const getStoreAssignableStaffs = async function (
|
|
22
|
+
this: WashdayClientInstance,
|
|
23
|
+
storeId: string,
|
|
24
|
+
queryParams?: string | {
|
|
25
|
+
appendAdmin?: string,
|
|
26
|
+
storeIds?: string[] | string,
|
|
27
|
+
}
|
|
28
|
+
): Promise<any> {
|
|
21
29
|
try {
|
|
22
30
|
const config = {
|
|
23
31
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
24
32
|
};
|
|
25
|
-
const
|
|
33
|
+
const normalizedQueryParams = typeof queryParams === "string"
|
|
34
|
+
? queryParams
|
|
35
|
+
: generateQueryParamsStr([
|
|
36
|
+
"appendAdmin",
|
|
37
|
+
"storeIds",
|
|
38
|
+
], queryParams || {});
|
|
39
|
+
const suffix = normalizedQueryParams ? `?${normalizedQueryParams}` : "";
|
|
26
40
|
const response = await this.axiosInstance.get(`${GET_ASSIGNABLE_STAFF(storeId)}${suffix}`, config);
|
|
27
41
|
return response;
|
|
28
42
|
} catch (error) {
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -111,6 +111,7 @@ export interface WashdayClientInstance {
|
|
|
111
111
|
closeRouteByIdV2: typeof routesEndpoints.putModule.closeRouteByIdV2,
|
|
112
112
|
updateRouteById: typeof routesEndpoints.putModule.updateRouteById,
|
|
113
113
|
getRoutesByDriver: typeof routesEndpoints.getModule.getRoutesByDriver,
|
|
114
|
+
getRoutes: typeof routesEndpoints.getModule.getRoutes,
|
|
114
115
|
startRoute: typeof routesEndpoints.postModule.startRoute,
|
|
115
116
|
reorderRouteOrders: typeof routesEndpoints.patchModule.reorderRouteOrders,
|
|
116
117
|
},
|
package/src/interfaces/Route.ts
CHANGED
|
@@ -34,7 +34,9 @@ export interface IRouteOrder {
|
|
|
34
34
|
|
|
35
35
|
export interface IRoute {
|
|
36
36
|
_id: string;
|
|
37
|
+
company: string | { _id: string; [key: string]: any };
|
|
37
38
|
routeSequence?: number;
|
|
39
|
+
legacyStoreRouteSequence?: number;
|
|
38
40
|
closedDate?: Date | string | null;
|
|
39
41
|
createdBy: IUser | string;
|
|
40
42
|
createdDate?: Date | string;
|
|
@@ -43,6 +45,7 @@ export interface IRoute {
|
|
|
43
45
|
orders: IRouteOrder[];
|
|
44
46
|
status: RouteStatus | string;
|
|
45
47
|
store: IStore | string;
|
|
48
|
+
stores?: Array<IStore | string>;
|
|
46
49
|
startedDate?: Date | string | null;
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -53,4 +53,50 @@ describe("orders.getList assignedEmployee filter", () => {
|
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
+
|
|
57
|
+
it("passes storeIds through the order list query string", async () => {
|
|
58
|
+
const get = jest.fn().mockResolvedValue({
|
|
59
|
+
data: {
|
|
60
|
+
data: {
|
|
61
|
+
orders: [],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const client = {
|
|
66
|
+
apiToken: "token-123",
|
|
67
|
+
axiosInstance: { get },
|
|
68
|
+
} as any;
|
|
69
|
+
|
|
70
|
+
await getList.call(client, {
|
|
71
|
+
store: undefined,
|
|
72
|
+
storeId: undefined,
|
|
73
|
+
storeIds: ["store-a", "store-b"],
|
|
74
|
+
status: undefined,
|
|
75
|
+
name: undefined,
|
|
76
|
+
phone: undefined,
|
|
77
|
+
email: undefined,
|
|
78
|
+
fromDate: undefined,
|
|
79
|
+
toDate: undefined,
|
|
80
|
+
sequence: undefined,
|
|
81
|
+
pageNum: "0",
|
|
82
|
+
limit: "20",
|
|
83
|
+
sequenceSort: "-1",
|
|
84
|
+
cleanedDateTime: undefined,
|
|
85
|
+
readyDateTime: undefined,
|
|
86
|
+
collectedDateTime: undefined,
|
|
87
|
+
q: undefined,
|
|
88
|
+
pickupFromDate: undefined,
|
|
89
|
+
pickupToDate: undefined,
|
|
90
|
+
deliveryFromDate: undefined,
|
|
91
|
+
deliveryToDate: undefined,
|
|
92
|
+
} as any);
|
|
93
|
+
|
|
94
|
+
expect(get).toHaveBeenCalledWith(
|
|
95
|
+
"api/v2/order?store=undefined&storeId=undefined&storeIds=store-a,store-b&status=undefined&name=undefined&phone=undefined&email=undefined&fromDate=undefined&toDate=undefined&sequence=undefined&pageNum=0&limit=20&sequenceSort=-1&cleanedDateTime=undefined&readyDateTime=undefined&collectedDateTime=undefined&q=undefined&pickupFromDate=undefined&pickupToDate=undefined&deliveryFromDate=undefined&deliveryToDate=undefined",
|
|
96
|
+
{
|
|
97
|
+
headers: { Authorization: "Bearer token-123" },
|
|
98
|
+
signal: undefined,
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
});
|
|
56
102
|
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { getRoutes, getRoutesByDriver } from "../src/api/routes/get";
|
|
2
|
+
import { createRouteV2 } from "../src/api/routes/post";
|
|
3
|
+
import { WashdayClient } from "../src";
|
|
4
|
+
|
|
5
|
+
describe("routes multi-store api", () => {
|
|
6
|
+
it("creates multi-store routes through the root routes endpoint", async () => {
|
|
7
|
+
const post = jest.fn().mockResolvedValue({ data: { data: { _id: "route-1" } } });
|
|
8
|
+
const client = {
|
|
9
|
+
apiToken: "token-123",
|
|
10
|
+
axiosInstance: { post },
|
|
11
|
+
} as any;
|
|
12
|
+
|
|
13
|
+
await createRouteV2.call(client, {
|
|
14
|
+
storeIds: ["store-a", "store-b"],
|
|
15
|
+
driver: "driver-1",
|
|
16
|
+
orders: ["order-1"],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(post).toHaveBeenCalledWith(
|
|
20
|
+
"api/routes",
|
|
21
|
+
{
|
|
22
|
+
storeIds: ["store-a", "store-b"],
|
|
23
|
+
driver: "driver-1",
|
|
24
|
+
orders: ["order-1"],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
headers: { Authorization: "Bearer token-123" },
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("keeps the legacy store route create endpoint when only storeId is provided", async () => {
|
|
33
|
+
const post = jest.fn().mockResolvedValue({ data: { data: { _id: "route-1" } } });
|
|
34
|
+
const client = {
|
|
35
|
+
apiToken: "token-123",
|
|
36
|
+
axiosInstance: { post },
|
|
37
|
+
} as any;
|
|
38
|
+
|
|
39
|
+
await createRouteV2.call(client, {
|
|
40
|
+
storeId: "store-a",
|
|
41
|
+
driver: "driver-1",
|
|
42
|
+
orders: ["order-1"],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(post).toHaveBeenCalledWith(
|
|
46
|
+
"api/stores/store-a/routes",
|
|
47
|
+
{
|
|
48
|
+
driver: "driver-1",
|
|
49
|
+
orders: ["order-1"],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
headers: { Authorization: "Bearer token-123" },
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("requests driver routes with explicit driver scope", async () => {
|
|
58
|
+
const get = jest.fn().mockResolvedValue({ data: { data: [] } });
|
|
59
|
+
const client = {
|
|
60
|
+
apiToken: "token-123",
|
|
61
|
+
axiosInstance: { get },
|
|
62
|
+
} as any;
|
|
63
|
+
|
|
64
|
+
await getRoutesByDriver.call(client, { status: "created,in_progress" });
|
|
65
|
+
|
|
66
|
+
expect(get).toHaveBeenCalledWith(
|
|
67
|
+
"api/routes?status=created,in_progress&scope=driver",
|
|
68
|
+
{
|
|
69
|
+
headers: { Authorization: "Bearer token-123" },
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("lists company routes with filters through the root routes endpoint", async () => {
|
|
75
|
+
const get = jest.fn().mockResolvedValue({ data: { data: [] } });
|
|
76
|
+
const client = {
|
|
77
|
+
apiToken: "token-123",
|
|
78
|
+
axiosInstance: { get },
|
|
79
|
+
} as any;
|
|
80
|
+
|
|
81
|
+
await getRoutes.call(client, {
|
|
82
|
+
scope: "company",
|
|
83
|
+
storeIds: ["store-a", "store-b"],
|
|
84
|
+
status: "created,in_progress",
|
|
85
|
+
driver: "driver-1",
|
|
86
|
+
createdFrom: "2026-05-01T00:00:00.000Z",
|
|
87
|
+
createdTo: "2026-05-02T00:00:00.000Z",
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(get).toHaveBeenCalledWith(
|
|
91
|
+
"api/routes?scope=company&storeIds=store-a,store-b&status=created,in_progress&driver=driver-1&createdFrom=2026-05-01T00:00:00.000Z&createdTo=2026-05-02T00:00:00.000Z",
|
|
92
|
+
{
|
|
93
|
+
headers: { Authorization: "Bearer token-123" },
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("exposes getRoutes through the WashdayClient routes module", async () => {
|
|
99
|
+
const get = jest.fn().mockResolvedValue({ data: { data: [] } });
|
|
100
|
+
const client = new WashdayClient("token-123", "DEV") as any;
|
|
101
|
+
client.axiosInstance = { get };
|
|
102
|
+
|
|
103
|
+
expect(typeof client.routes.getRoutes).toBe("function");
|
|
104
|
+
|
|
105
|
+
await client.routes.getRoutes({ scope: "company" });
|
|
106
|
+
|
|
107
|
+
expect(get).toHaveBeenCalledWith("api/routes?scope=company", {
|
|
108
|
+
headers: { Authorization: "Bearer token-123" },
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -34,4 +34,34 @@ describe("getStoreAssignableStaffs", () => {
|
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
|
+
|
|
38
|
+
it("builds storeIds query params for assignable staff", async () => {
|
|
39
|
+
const get = jest.fn().mockResolvedValue({
|
|
40
|
+
data: {
|
|
41
|
+
data: {
|
|
42
|
+
staffs: [],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const client = {
|
|
47
|
+
apiToken: "token-123",
|
|
48
|
+
axiosInstance: { get },
|
|
49
|
+
} as any;
|
|
50
|
+
|
|
51
|
+
await getStoreAssignableStaffs.call(
|
|
52
|
+
client,
|
|
53
|
+
"store-1",
|
|
54
|
+
{
|
|
55
|
+
appendAdmin: "true",
|
|
56
|
+
storeIds: ["store-1", "store-2"],
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect(get).toHaveBeenCalledWith(
|
|
61
|
+
"api/store/store-1/assignable-staffs?appendAdmin=true&storeIds=store-1,store-2",
|
|
62
|
+
{
|
|
63
|
+
headers: { Authorization: "Bearer token-123" },
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
});
|
|
37
67
|
});
|