washday-sdk 1.1.1 → 1.1.3
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/attendance/get.js +33 -0
- package/dist/api/csv/get.js +29 -4
- package/dist/api/index.js +2 -0
- package/package.json +1 -1
- package/src/api/attendance/get.ts +46 -11
- package/src/api/attendance/post.ts +0 -2
- package/src/api/csv/get.ts +31 -6
- package/src/api/index.ts +2 -0
- package/src/interfaces/Api.ts +2 -0
|
@@ -72,6 +72,8 @@ export const getStoreReport = function (storeId, params) {
|
|
|
72
72
|
queryParams += `startDate=${params.startDate}&`;
|
|
73
73
|
if (params === null || params === void 0 ? void 0 : params.endDate)
|
|
74
74
|
queryParams += `endDate=${params.endDate}&`;
|
|
75
|
+
if (params === null || params === void 0 ? void 0 : params.employeeId)
|
|
76
|
+
queryParams += `employeeId=${params.employeeId}&`;
|
|
75
77
|
if (params === null || params === void 0 ? void 0 : params.pageNum)
|
|
76
78
|
queryParams += `pageNum=${params.pageNum}&`;
|
|
77
79
|
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
@@ -87,3 +89,34 @@ export const getStoreReport = function (storeId, params) {
|
|
|
87
89
|
}
|
|
88
90
|
});
|
|
89
91
|
};
|
|
92
|
+
export const exportStoreReport = function (storeId, params) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
try {
|
|
95
|
+
const config = {
|
|
96
|
+
headers: {
|
|
97
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
98
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
99
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
100
|
+
},
|
|
101
|
+
params: {
|
|
102
|
+
responseType: 'blob'
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
let queryParams = '';
|
|
106
|
+
if (params === null || params === void 0 ? void 0 : params.startDate)
|
|
107
|
+
queryParams += `startDate=${params.startDate}&`;
|
|
108
|
+
if (params === null || params === void 0 ? void 0 : params.endDate)
|
|
109
|
+
queryParams += `endDate=${params.endDate}&`;
|
|
110
|
+
if (params === null || params === void 0 ? void 0 : params.employeeId)
|
|
111
|
+
queryParams += `employeeId=${params.employeeId}&`;
|
|
112
|
+
// Remove trailing '&'
|
|
113
|
+
queryParams = queryParams.slice(0, -1);
|
|
114
|
+
const url = queryParams ? `${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}` : `${ATTENDANCE_API}/store/${storeId}/report/export`;
|
|
115
|
+
return yield axiosInstance.get(url, config);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.error('Error exporting store attendance report:', error);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
package/dist/api/csv/get.js
CHANGED
|
@@ -11,6 +11,7 @@ import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
|
11
11
|
import axiosInstance from "../axiosInstance";
|
|
12
12
|
const GENERATE_EXPORT = 'api/export';
|
|
13
13
|
const GET_SET_REPORTS = 'api/reports';
|
|
14
|
+
const ATTENDANCE_API = 'api/attendance';
|
|
14
15
|
export const exportCustomersList = function (params) {
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
try {
|
|
@@ -310,15 +311,39 @@ export const exportUnpaidOrdersReportCSV = function (storeId, params) {
|
|
|
310
311
|
const queryParams = generateQueryParamsStr([
|
|
311
312
|
'fromDate',
|
|
312
313
|
'toDate',
|
|
313
|
-
'pageNum',
|
|
314
|
-
'limit',
|
|
315
314
|
'timezone',
|
|
316
315
|
'customerName'
|
|
317
316
|
], params);
|
|
318
|
-
return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export
|
|
317
|
+
return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export?${queryParams}`, config);
|
|
319
318
|
}
|
|
320
319
|
catch (error) {
|
|
321
|
-
console.error('Error fetching
|
|
320
|
+
console.error('Error fetching exportUnpaidOrdersReportCSV:', error);
|
|
321
|
+
throw error;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
export const exportAttendanceReport = function (storeId, params) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
try {
|
|
328
|
+
const config = {
|
|
329
|
+
headers: {
|
|
330
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
331
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
332
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
333
|
+
},
|
|
334
|
+
params: {
|
|
335
|
+
responseType: 'blob'
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const queryParams = generateQueryParamsStr([
|
|
339
|
+
'fromDate',
|
|
340
|
+
'toDate',
|
|
341
|
+
'employeeId'
|
|
342
|
+
], params);
|
|
343
|
+
return yield axiosInstance.get(`${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}`, config);
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
console.error('Error fetching exportAttendanceReport:', error);
|
|
322
347
|
throw error;
|
|
323
348
|
}
|
|
324
349
|
});
|
package/dist/api/index.js
CHANGED
|
@@ -271,6 +271,7 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
271
271
|
exportProductSalesReport: csvExportEndpoints.getModule.exportProductSalesReport,
|
|
272
272
|
exportPaymentLinesReport: csvExportEndpoints.getModule.exportPaymentLinesReport,
|
|
273
273
|
exportUnpaidOrdersReportCSV: csvExportEndpoints.getModule.exportUnpaidOrdersReportCSV,
|
|
274
|
+
exportAttendanceReport: csvExportEndpoints.getModule.exportAttendanceReport,
|
|
274
275
|
});
|
|
275
276
|
this.pdf = bindMethods(this, {
|
|
276
277
|
exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
|
|
@@ -311,6 +312,7 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
311
312
|
getHistory: attendanceEndpoints.getModule.getHistory,
|
|
312
313
|
getStatus: attendanceEndpoints.getModule.getStatus,
|
|
313
314
|
getStoreReport: attendanceEndpoints.getModule.getStoreReport,
|
|
315
|
+
exportStoreReport: attendanceEndpoints.getModule.exportStoreReport,
|
|
314
316
|
clockIn: attendanceEndpoints.postModule.clockIn,
|
|
315
317
|
clockOut: attendanceEndpoints.postModule.clockOut,
|
|
316
318
|
updateById: attendanceEndpoints.putModule.updateById,
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ export const getHistory = async function (this: WashdayClientInstance, params: {
|
|
|
15
15
|
const config = {
|
|
16
16
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
let queryParams = '';
|
|
20
20
|
if (params.userId) queryParams += `userId=${params.userId}&`; // ✅ AÑADIDO
|
|
21
21
|
if (params.storeId) queryParams += `storeId=${params.storeId}&`;
|
|
@@ -23,10 +23,10 @@ export const getHistory = async function (this: WashdayClientInstance, params: {
|
|
|
23
23
|
if (params.endDate) queryParams += `endDate=${params.endDate}&`;
|
|
24
24
|
if (params.pageNum) queryParams += `pageNum=${params.pageNum}&`;
|
|
25
25
|
if (params.limit) queryParams += `limit=${params.limit}&`;
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
// Remove trailing '&'
|
|
28
28
|
queryParams = queryParams.slice(0, -1);
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
const url = queryParams ? `${ATTENDANCE_API}/history?${queryParams}` : `${ATTENDANCE_API}/history`;
|
|
31
31
|
return await axiosInstance.get(url, config);
|
|
32
32
|
} catch (error) {
|
|
@@ -43,14 +43,14 @@ export const getStatus = async function (this: WashdayClientInstance, params?: {
|
|
|
43
43
|
const config = {
|
|
44
44
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
let queryParams = '';
|
|
48
48
|
if (params?.storeId) queryParams += `storeId=${params.storeId}&`;
|
|
49
49
|
if (params?.userId) queryParams += `userId=${params.userId}&`; // ✅ ARREGLADO - añadir &
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
// Remove trailing '&'
|
|
52
52
|
queryParams = queryParams.slice(0, -1);
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
const url = queryParams ? `${ATTENDANCE_API}/status?${queryParams}` : `${ATTENDANCE_API}/status`;
|
|
55
55
|
return await axiosInstance.get(url, config);
|
|
56
56
|
} catch (error) {
|
|
@@ -62,27 +62,62 @@ export const getStatus = async function (this: WashdayClientInstance, params?: {
|
|
|
62
62
|
export const getStoreReport = async function (this: WashdayClientInstance, storeId: string, params?: {
|
|
63
63
|
startDate?: string;
|
|
64
64
|
endDate?: string;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
employeeId?: string;
|
|
66
|
+
pageNum?: string | number;
|
|
67
|
+
limit?: string | number;
|
|
67
68
|
}): Promise<any> {
|
|
68
69
|
try {
|
|
69
70
|
const config = {
|
|
70
71
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
71
72
|
};
|
|
72
|
-
|
|
73
|
+
|
|
73
74
|
let queryParams = '';
|
|
74
75
|
if (params?.startDate) queryParams += `startDate=${params.startDate}&`;
|
|
75
76
|
if (params?.endDate) queryParams += `endDate=${params.endDate}&`;
|
|
77
|
+
if (params?.employeeId) queryParams += `employeeId=${params.employeeId}&`;
|
|
76
78
|
if (params?.pageNum) queryParams += `pageNum=${params.pageNum}&`;
|
|
77
79
|
if (params?.limit) queryParams += `limit=${params.limit}&`;
|
|
78
|
-
|
|
80
|
+
|
|
79
81
|
// Remove trailing '&'
|
|
80
82
|
queryParams = queryParams.slice(0, -1);
|
|
81
|
-
|
|
83
|
+
|
|
82
84
|
const url = queryParams ? `${ATTENDANCE_API}/store/${storeId}/report?${queryParams}` : `${ATTENDANCE_API}/store/${storeId}/report`;
|
|
83
85
|
return await axiosInstance.get(url, config);
|
|
84
86
|
} catch (error) {
|
|
85
87
|
console.error('Error fetching store attendance report:', error);
|
|
86
88
|
throw error;
|
|
87
89
|
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const exportStoreReport = async function (this: WashdayClientInstance, storeId: string, params?: {
|
|
93
|
+
startDate?: string;
|
|
94
|
+
endDate?: string;
|
|
95
|
+
employeeId?: string;
|
|
96
|
+
}): Promise<any> {
|
|
97
|
+
try {
|
|
98
|
+
const config = {
|
|
99
|
+
headers: {
|
|
100
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
101
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
102
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
103
|
+
},
|
|
104
|
+
params: {
|
|
105
|
+
responseType: 'blob'
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
let queryParams = '';
|
|
110
|
+
if (params?.startDate) queryParams += `startDate=${params.startDate}&`;
|
|
111
|
+
if (params?.endDate) queryParams += `endDate=${params.endDate}&`;
|
|
112
|
+
if (params?.employeeId) queryParams += `employeeId=${params.employeeId}&`;
|
|
113
|
+
|
|
114
|
+
// Remove trailing '&'
|
|
115
|
+
queryParams = queryParams.slice(0, -1);
|
|
116
|
+
|
|
117
|
+
const url = queryParams ? `${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}` : `${ATTENDANCE_API}/store/${storeId}/report/export`;
|
|
118
|
+
return await axiosInstance.get(url, config);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error('Error exporting store attendance report:', error);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
88
123
|
};
|
|
@@ -6,7 +6,6 @@ const ATTENDANCE_API = 'api/attendance';
|
|
|
6
6
|
export const clockIn = async function (this: WashdayClientInstance, data: {
|
|
7
7
|
storeId: string;
|
|
8
8
|
userId?: string;
|
|
9
|
-
ipAddress?: string;
|
|
10
9
|
notes?: string;
|
|
11
10
|
}): Promise<any> {
|
|
12
11
|
try {
|
|
@@ -23,7 +22,6 @@ export const clockIn = async function (this: WashdayClientInstance, data: {
|
|
|
23
22
|
export const clockOut = async function (this: WashdayClientInstance, data: {
|
|
24
23
|
userId?: string;
|
|
25
24
|
storeId?: string; // ✅ AÑADIDO - requerido por backend
|
|
26
|
-
ipAddress?: string;
|
|
27
25
|
notes?: string;
|
|
28
26
|
}): Promise<any> {
|
|
29
27
|
try {
|
package/src/api/csv/get.ts
CHANGED
|
@@ -4,6 +4,7 @@ import axiosInstance from "../axiosInstance";
|
|
|
4
4
|
|
|
5
5
|
const GENERATE_EXPORT = 'api/export';
|
|
6
6
|
const GET_SET_REPORTS = 'api/reports';
|
|
7
|
+
const ATTENDANCE_API = 'api/attendance';
|
|
7
8
|
|
|
8
9
|
export const exportCustomersList = async function (this: WashdayClientInstance, params: {
|
|
9
10
|
searchTerm?: string
|
|
@@ -323,8 +324,6 @@ export const exportUnpaidOrdersReportCSV = async function (this: WashdayClientIn
|
|
|
323
324
|
fromDate?: string
|
|
324
325
|
toDate?: string
|
|
325
326
|
timezone?: string
|
|
326
|
-
pageNum?: string
|
|
327
|
-
limit?: string
|
|
328
327
|
customerName?: string
|
|
329
328
|
}): Promise<any> {
|
|
330
329
|
try {
|
|
@@ -341,14 +340,40 @@ export const exportUnpaidOrdersReportCSV = async function (this: WashdayClientIn
|
|
|
341
340
|
const queryParams = generateQueryParamsStr([
|
|
342
341
|
'fromDate',
|
|
343
342
|
'toDate',
|
|
344
|
-
'pageNum',
|
|
345
|
-
'limit',
|
|
346
343
|
'timezone',
|
|
347
344
|
'customerName'
|
|
348
345
|
], params);
|
|
349
|
-
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export
|
|
346
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export?${queryParams}`, config);
|
|
350
347
|
} catch (error) {
|
|
351
|
-
console.error('Error fetching
|
|
348
|
+
console.error('Error fetching exportUnpaidOrdersReportCSV:', error);
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
export const exportAttendanceReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
354
|
+
fromDate?: string
|
|
355
|
+
toDate?: string
|
|
356
|
+
employeeId?: string
|
|
357
|
+
}): Promise<any> {
|
|
358
|
+
try {
|
|
359
|
+
const config = {
|
|
360
|
+
headers: {
|
|
361
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
362
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
363
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
364
|
+
},
|
|
365
|
+
params: {
|
|
366
|
+
responseType: 'blob'
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
const queryParams = generateQueryParamsStr([
|
|
370
|
+
'fromDate',
|
|
371
|
+
'toDate',
|
|
372
|
+
'employeeId'
|
|
373
|
+
], params);
|
|
374
|
+
return await axiosInstance.get(`${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}`, config);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
console.error('Error fetching exportAttendanceReport:', error);
|
|
352
377
|
throw error;
|
|
353
378
|
}
|
|
354
379
|
};
|
package/src/api/index.ts
CHANGED
|
@@ -278,6 +278,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
278
278
|
exportProductSalesReport: csvExportEndpoints.getModule.exportProductSalesReport,
|
|
279
279
|
exportPaymentLinesReport: csvExportEndpoints.getModule.exportPaymentLinesReport,
|
|
280
280
|
exportUnpaidOrdersReportCSV: csvExportEndpoints.getModule.exportUnpaidOrdersReportCSV,
|
|
281
|
+
exportAttendanceReport: csvExportEndpoints.getModule.exportAttendanceReport,
|
|
281
282
|
});
|
|
282
283
|
this.pdf = bindMethods(this, {
|
|
283
284
|
exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
|
|
@@ -318,6 +319,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
318
319
|
getHistory: attendanceEndpoints.getModule.getHistory,
|
|
319
320
|
getStatus: attendanceEndpoints.getModule.getStatus,
|
|
320
321
|
getStoreReport: attendanceEndpoints.getModule.getStoreReport,
|
|
322
|
+
exportStoreReport: attendanceEndpoints.getModule.exportStoreReport,
|
|
321
323
|
clockIn: attendanceEndpoints.postModule.clockIn,
|
|
322
324
|
clockOut: attendanceEndpoints.postModule.clockOut,
|
|
323
325
|
updateById: attendanceEndpoints.putModule.updateById,
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -263,6 +263,7 @@ export interface WashdayClientInstance {
|
|
|
263
263
|
exportCleanedOrdersReport: typeof csvExportEndpoints.getModule.exportCleanedOrdersReport,
|
|
264
264
|
exportSalesReport: typeof csvExportEndpoints.getModule.exportSalesReport,
|
|
265
265
|
exportStaffReport: typeof csvExportEndpoints.getModule.exportStaffReport,
|
|
266
|
+
exportAttendanceReport: typeof csvExportEndpoints.getModule.exportAttendanceReport,
|
|
266
267
|
};
|
|
267
268
|
pdf: {
|
|
268
269
|
exportUnpaidOrdersReportPDF: typeof pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF;
|
|
@@ -301,6 +302,7 @@ export interface WashdayClientInstance {
|
|
|
301
302
|
getHistory: typeof attendanceEndpoints.getModule.getHistory;
|
|
302
303
|
getStatus: typeof attendanceEndpoints.getModule.getStatus;
|
|
303
304
|
getStoreReport: typeof attendanceEndpoints.getModule.getStoreReport;
|
|
305
|
+
exportStoreReport: typeof attendanceEndpoints.getModule.exportStoreReport;
|
|
304
306
|
clockIn: typeof attendanceEndpoints.postModule.clockIn;
|
|
305
307
|
clockOut: typeof attendanceEndpoints.postModule.clockOut;
|
|
306
308
|
updateById: typeof attendanceEndpoints.putModule.updateById;
|