washday-sdk 1.6.77 → 1.6.78

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,13 +11,18 @@ import { generateQueryParamsStr } from "../../utils/apiUtils";
11
11
  const GET_OUTSOURCED_ORDERS_BY_STORE = 'api/store/:storeId/outsourced-orders';
12
12
  const GET_OUTSOURCED_ORDERS_BY_ORDER = 'api/orders/:orderId/outsourced-orders';
13
13
  const GET_SET_OUTSOURCED_ORDERS = 'api/outsourced-orders';
14
- export const getOutsourcedOrdersByOrder = function (orderId) {
15
- return __awaiter(this, void 0, void 0, function* () {
14
+ export const getOutsourcedOrdersByOrder = function (orderId_1) {
15
+ return __awaiter(this, arguments, void 0, function* (orderId, params = {}) {
16
16
  try {
17
17
  const config = {
18
18
  headers: { Authorization: `Bearer ${this.apiToken}` }
19
19
  };
20
- return yield this.axiosInstance.get(`${GET_OUTSOURCED_ORDERS_BY_ORDER.replace(':orderId', orderId)}`, config);
20
+ const queryParams = generateQueryParamsStr([
21
+ 'partnerId',
22
+ 'statuses',
23
+ ], params);
24
+ const querySuffix = queryParams ? `?${queryParams}` : '';
25
+ return yield this.axiosInstance.get(`${GET_OUTSOURCED_ORDERS_BY_ORDER.replace(':orderId', orderId)}${querySuffix}`, config);
21
26
  }
22
27
  catch (error) {
23
28
  console.error('Error fetching getOutsourcedOrdersByOrder:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.77",
3
+ "version": "1.6.78",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -5,12 +5,20 @@ const GET_OUTSOURCED_ORDERS_BY_STORE = 'api/store/:storeId/outsourced-orders'
5
5
  const GET_OUTSOURCED_ORDERS_BY_ORDER = 'api/orders/:orderId/outsourced-orders';
6
6
  const GET_SET_OUTSOURCED_ORDERS = 'api/outsourced-orders';
7
7
 
8
- export const getOutsourcedOrdersByOrder = async function (this: WashdayClientInstance, orderId: string): Promise<any> {
8
+ export const getOutsourcedOrdersByOrder = async function (this: WashdayClientInstance, orderId: string, params: {
9
+ partnerId?: string,
10
+ statuses?: string[],
11
+ } = {}): Promise<any> {
9
12
  try {
10
13
  const config = {
11
14
  headers: { Authorization: `Bearer ${this.apiToken}` }
12
15
  };
13
- return await this.axiosInstance.get(`${GET_OUTSOURCED_ORDERS_BY_ORDER.replace(':orderId', orderId)}`, config);
16
+ const queryParams = generateQueryParamsStr([
17
+ 'partnerId',
18
+ 'statuses',
19
+ ], params);
20
+ const querySuffix = queryParams ? `?${queryParams}` : '';
21
+ return await this.axiosInstance.get(`${GET_OUTSOURCED_ORDERS_BY_ORDER.replace(':orderId', orderId)}${querySuffix}`, config);
14
22
  } catch (error) {
15
23
  console.error('Error fetching getOutsourcedOrdersByOrder:', error);
16
24
  throw error;
@@ -0,0 +1,27 @@
1
+ import { getOutsourcedOrdersByOrder } from "../src/api/outsourcedOrders/get";
2
+
3
+ describe("outsourcedOrders.getOutsourcedOrdersByOrder params", () => {
4
+ it("passes partner and statuses filters through the query string", async () => {
5
+ const get = jest.fn().mockResolvedValue({
6
+ data: {
7
+ data: [],
8
+ },
9
+ });
10
+ const client = {
11
+ apiToken: "token-123",
12
+ axiosInstance: { get },
13
+ } as any;
14
+
15
+ await getOutsourcedOrdersByOrder.call(client, "order-1", {
16
+ partnerId: "partner-1",
17
+ statuses: ["pending", "in_process"],
18
+ });
19
+
20
+ expect(get).toHaveBeenCalledWith(
21
+ "api/orders/order-1/outsourced-orders?partnerId=partner-1&statuses=pending,in_process",
22
+ {
23
+ headers: { Authorization: "Bearer token-123" },
24
+ }
25
+ );
26
+ });
27
+ });