washday-sdk 1.6.76 → 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.
@@ -297,6 +297,38 @@ export const exportPaymentLinesReport = function (storeId, params) {
297
297
  }
298
298
  });
299
299
  };
300
+ export const exportOutsourcingReport = function (storeId, params) {
301
+ return __awaiter(this, void 0, void 0, function* () {
302
+ try {
303
+ const config = {
304
+ headers: {
305
+ Authorization: `Bearer ${this.apiToken}`,
306
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
307
+ 'Content-disposition': 'attachment; filename=[file.xlsx]'
308
+ },
309
+ params: {
310
+ responseType: 'blob'
311
+ }
312
+ };
313
+ const queryParams = generateQueryParamsStr([
314
+ 'statuses',
315
+ 'sequence',
316
+ 'partnerId',
317
+ 'dateFrom',
318
+ 'dateTo',
319
+ 'dateField',
320
+ 'sortBy',
321
+ 'sortDirection',
322
+ 'timezone'
323
+ ], params);
324
+ return yield this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/outsourcing/export?${queryParams}`, config);
325
+ }
326
+ catch (error) {
327
+ console.error('Error fetching exportOutsourcingReport:', error);
328
+ throw error;
329
+ }
330
+ });
331
+ };
300
332
  export const exportCashierBoxMovementsReport = function (storeId, params) {
301
333
  return __awaiter(this, void 0, void 0, function* () {
302
334
  try {
package/dist/api/index.js CHANGED
@@ -338,6 +338,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
338
338
  exportStaffReport: csvExportEndpoints.getModule.exportStaffReport,
339
339
  exportProductSalesReport: csvExportEndpoints.getModule.exportProductSalesReport,
340
340
  exportPaymentLinesReport: csvExportEndpoints.getModule.exportPaymentLinesReport,
341
+ exportOutsourcingReport: csvExportEndpoints.getModule.exportOutsourcingReport,
341
342
  exportCashierBoxMovementsReport: csvExportEndpoints.getModule.exportCashierBoxMovementsReport,
342
343
  exportUnpaidOrdersReportCSV: csvExportEndpoints.getModule.exportUnpaidOrdersReportCSV,
343
344
  exportAttendanceReport: csvExportEndpoints.getModule.exportAttendanceReport,
@@ -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.76",
3
+ "version": "1.6.78",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -327,6 +327,46 @@ export const exportPaymentLinesReport = async function (this: WashdayClientInsta
327
327
  }
328
328
  };
329
329
 
330
+ export const exportOutsourcingReport = async function (this: WashdayClientInstance, storeId: string, params: {
331
+ statuses?: string | string[]
332
+ sequence?: string
333
+ partnerId?: string
334
+ dateFrom?: string
335
+ dateTo?: string
336
+ dateField?: 'sentDate' | 'receivedDate' | 'createdAt' | 'updatedAt'
337
+ sortBy?: 'sentDate' | 'receivedDate' | 'createdAt' | 'updatedAt' | 'outsourcedOrderSequence'
338
+ sortDirection?: 'asc' | 'desc'
339
+ timezone?: string
340
+ }): Promise<any> {
341
+ try {
342
+ const config = {
343
+ headers: {
344
+ Authorization: `Bearer ${this.apiToken}`,
345
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
346
+ 'Content-disposition': 'attachment; filename=[file.xlsx]'
347
+ },
348
+ params: {
349
+ responseType: 'blob'
350
+ }
351
+ };
352
+ const queryParams = generateQueryParamsStr([
353
+ 'statuses',
354
+ 'sequence',
355
+ 'partnerId',
356
+ 'dateFrom',
357
+ 'dateTo',
358
+ 'dateField',
359
+ 'sortBy',
360
+ 'sortDirection',
361
+ 'timezone'
362
+ ], params);
363
+ return await this.axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/outsourcing/export?${queryParams}`, config);
364
+ } catch (error) {
365
+ console.error('Error fetching exportOutsourcingReport:', error);
366
+ throw error;
367
+ }
368
+ };
369
+
330
370
  export const exportCashierBoxMovementsReport = async function (this: WashdayClientInstance, storeId: string, params: {
331
371
  cashierBoxId?: string
332
372
  fromDate?: string
package/src/api/index.ts CHANGED
@@ -345,6 +345,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
345
345
  exportStaffReport: csvExportEndpoints.getModule.exportStaffReport,
346
346
  exportProductSalesReport: csvExportEndpoints.getModule.exportProductSalesReport,
347
347
  exportPaymentLinesReport: csvExportEndpoints.getModule.exportPaymentLinesReport,
348
+ exportOutsourcingReport: csvExportEndpoints.getModule.exportOutsourcingReport,
348
349
  exportCashierBoxMovementsReport: csvExportEndpoints.getModule.exportCashierBoxMovementsReport,
349
350
  exportUnpaidOrdersReportCSV: csvExportEndpoints.getModule.exportUnpaidOrdersReportCSV,
350
351
  exportAttendanceReport: csvExportEndpoints.getModule.exportAttendanceReport,
@@ -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;
@@ -325,6 +325,7 @@ export interface WashdayClientInstance {
325
325
  exportDiscountCodesReport: typeof csvExportEndpoints.getModule.exportDiscountCodesReport;
326
326
  exportProductSalesReport: typeof csvExportEndpoints.getModule.exportProductSalesReport;
327
327
  exportPaymentLinesReport: typeof csvExportEndpoints.getModule.exportPaymentLinesReport;
328
+ exportOutsourcingReport: typeof csvExportEndpoints.getModule.exportOutsourcingReport;
328
329
  exportCashierBoxMovementsReport: typeof csvExportEndpoints.getModule.exportCashierBoxMovementsReport;
329
330
  exportUnpaidOrdersReportCSV: typeof csvExportEndpoints.getModule.exportUnpaidOrdersReportCSV;
330
331
  exportCashUpReportsByDateRange: typeof csvExportEndpoints.getModule.exportCashUpReportsByDateRange;
@@ -0,0 +1,37 @@
1
+ import { exportOutsourcingReport } from "../src/api/csv/get";
2
+
3
+ describe("csv.exportOutsourcingReport", () => {
4
+ it("serializes outsourcing report export filters and requests a blob response", async () => {
5
+ const get = jest.fn().mockResolvedValue({ data: "blob-data" });
6
+ const client = {
7
+ apiToken: "token-123",
8
+ axiosInstance: { get },
9
+ } as any;
10
+
11
+ await exportOutsourcingReport.call(client, "store-1", {
12
+ statuses: ["returned", "in_process"],
13
+ sequence: "100",
14
+ partnerId: "partner-1",
15
+ dateFrom: "2026-06-01T05:00:00.000Z",
16
+ dateTo: "2026-06-02T04:59:59.999Z",
17
+ dateField: "receivedDate",
18
+ sortBy: "receivedDate",
19
+ sortDirection: "desc",
20
+ timezone: "America/Mexico_City",
21
+ });
22
+
23
+ expect(get).toHaveBeenCalledWith(
24
+ "api/reports/store-1/outsourcing/export?statuses=returned,in_process&sequence=100&partnerId=partner-1&dateFrom=2026-06-01T05:00:00.000Z&dateTo=2026-06-02T04:59:59.999Z&dateField=receivedDate&sortBy=receivedDate&sortDirection=desc&timezone=America/Mexico_City",
25
+ {
26
+ headers: {
27
+ Authorization: "Bearer token-123",
28
+ "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
29
+ "Content-disposition": "attachment; filename=[file.xlsx]",
30
+ },
31
+ params: {
32
+ responseType: "blob",
33
+ },
34
+ }
35
+ );
36
+ });
37
+ });
@@ -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
+ });