washday-sdk 1.1.2 → 1.1.4
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 +5 -2
- package/dist/api/index.js +4 -1
- package/dist/api/products/delete.js +16 -0
- package/dist/api/products/post.js +16 -0
- package/dist/api/products/put.js +16 -0
- package/package.json +1 -1
- package/src/api/attendance/get.ts +18 -15
- package/src/api/index.ts +4 -1
- package/src/api/products/delete.ts +14 -0
- package/src/api/products/post.ts +20 -0
- package/src/api/products/put.ts +20 -0
- package/src/interfaces/Api.ts +3 -0
|
@@ -95,9 +95,12 @@ export const exportStoreReport = function (storeId, params) {
|
|
|
95
95
|
const config = {
|
|
96
96
|
headers: {
|
|
97
97
|
Authorization: `Bearer ${this.apiToken}`,
|
|
98
|
-
'Content-Type': '
|
|
98
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
99
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
99
100
|
},
|
|
100
|
-
|
|
101
|
+
params: {
|
|
102
|
+
responseType: 'blob'
|
|
103
|
+
}
|
|
101
104
|
};
|
|
102
105
|
let queryParams = '';
|
|
103
106
|
if (params === null || params === void 0 ? void 0 : params.startDate)
|
package/dist/api/index.js
CHANGED
|
@@ -173,7 +173,10 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
173
173
|
deleteById: productsEndpoints.deleteModule.deleteById,
|
|
174
174
|
deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
|
|
175
175
|
updateById: productsEndpoints.putModule.updateById,
|
|
176
|
-
bulkUpdate: productsEndpoints.putModule.bulkUpdate
|
|
176
|
+
bulkUpdate: productsEndpoints.putModule.bulkUpdate,
|
|
177
|
+
createPriceOption: productsEndpoints.postModule.createPriceOption,
|
|
178
|
+
updatePriceOption: productsEndpoints.putModule.updatePriceOption,
|
|
179
|
+
deletePriceOption: productsEndpoints.deleteModule.deletePriceOption,
|
|
177
180
|
});
|
|
178
181
|
this.users = bindMethods(this, {
|
|
179
182
|
updateUserById: updateUserById,
|
|
@@ -38,3 +38,19 @@ export const deleteProductSupplyById = function (id, productSupplyId) {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
+
// New: delete (inactivate) product price option
|
|
42
|
+
export const deletePriceOption = function (productId, optionId) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
try {
|
|
45
|
+
const config = {
|
|
46
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
47
|
+
};
|
|
48
|
+
const response = yield axiosInstance.delete(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, config);
|
|
49
|
+
return response.data || {};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('Error deleting price option:', error);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
@@ -58,3 +58,19 @@ export const bulkCreate = function (storeId, data) {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
|
+
// New: create price option for a product
|
|
62
|
+
export const createPriceOption = function (productId, data) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
try {
|
|
65
|
+
const config = {
|
|
66
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
67
|
+
};
|
|
68
|
+
const response = yield axiosInstance.post(`${GET_SET_PRODUCTS}/${productId}/price-options`, data, config);
|
|
69
|
+
return response.data || {};
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error('Error creating price option:', error);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
package/dist/api/products/put.js
CHANGED
|
@@ -38,3 +38,19 @@ export const updateById = function (id, data) {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
+
// New: update product price option
|
|
42
|
+
export const updatePriceOption = function (productId, optionId, data) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
try {
|
|
45
|
+
const config = {
|
|
46
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
47
|
+
};
|
|
48
|
+
const response = yield axiosInstance.put(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, data, config);
|
|
49
|
+
return response.data || {};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('Error updating price option:', error);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
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) {
|
|
@@ -70,17 +70,17 @@ export const getStoreReport = async function (this: WashdayClientInstance, store
|
|
|
70
70
|
const config = {
|
|
71
71
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
72
72
|
};
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
let queryParams = '';
|
|
75
75
|
if (params?.startDate) queryParams += `startDate=${params.startDate}&`;
|
|
76
76
|
if (params?.endDate) queryParams += `endDate=${params.endDate}&`;
|
|
77
77
|
if (params?.employeeId) queryParams += `employeeId=${params.employeeId}&`;
|
|
78
78
|
if (params?.pageNum) queryParams += `pageNum=${params.pageNum}&`;
|
|
79
79
|
if (params?.limit) queryParams += `limit=${params.limit}&`;
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
// Remove trailing '&'
|
|
82
82
|
queryParams = queryParams.slice(0, -1);
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
const url = queryParams ? `${ATTENDANCE_API}/store/${storeId}/report?${queryParams}` : `${ATTENDANCE_API}/store/${storeId}/report`;
|
|
85
85
|
return await axiosInstance.get(url, config);
|
|
86
86
|
} catch (error) {
|
|
@@ -96,21 +96,24 @@ export const exportStoreReport = async function (this: WashdayClientInstance, st
|
|
|
96
96
|
}): Promise<any> {
|
|
97
97
|
try {
|
|
98
98
|
const config = {
|
|
99
|
-
headers: {
|
|
99
|
+
headers: {
|
|
100
100
|
Authorization: `Bearer ${this.apiToken}`,
|
|
101
|
-
'Content-Type': '
|
|
101
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
102
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
102
103
|
},
|
|
103
|
-
|
|
104
|
+
params: {
|
|
105
|
+
responseType: 'blob'
|
|
106
|
+
}
|
|
104
107
|
};
|
|
105
|
-
|
|
108
|
+
|
|
106
109
|
let queryParams = '';
|
|
107
110
|
if (params?.startDate) queryParams += `startDate=${params.startDate}&`;
|
|
108
111
|
if (params?.endDate) queryParams += `endDate=${params.endDate}&`;
|
|
109
112
|
if (params?.employeeId) queryParams += `employeeId=${params.employeeId}&`;
|
|
110
|
-
|
|
113
|
+
|
|
111
114
|
// Remove trailing '&'
|
|
112
115
|
queryParams = queryParams.slice(0, -1);
|
|
113
|
-
|
|
116
|
+
|
|
114
117
|
const url = queryParams ? `${ATTENDANCE_API}/store/${storeId}/report/export?${queryParams}` : `${ATTENDANCE_API}/store/${storeId}/report/export`;
|
|
115
118
|
return await axiosInstance.get(url, config);
|
|
116
119
|
} catch (error) {
|
package/src/api/index.ts
CHANGED
|
@@ -180,7 +180,10 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
180
180
|
deleteById: productsEndpoints.deleteModule.deleteById,
|
|
181
181
|
deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
|
|
182
182
|
updateById: productsEndpoints.putModule.updateById,
|
|
183
|
-
bulkUpdate: productsEndpoints.putModule.bulkUpdate
|
|
183
|
+
bulkUpdate: productsEndpoints.putModule.bulkUpdate,
|
|
184
|
+
createPriceOption: productsEndpoints.postModule.createPriceOption,
|
|
185
|
+
updatePriceOption: productsEndpoints.putModule.updatePriceOption,
|
|
186
|
+
deletePriceOption: productsEndpoints.deleteModule.deletePriceOption,
|
|
184
187
|
});
|
|
185
188
|
this.users = bindMethods(this, {
|
|
186
189
|
updateUserById: updateUserById,
|
|
@@ -26,3 +26,17 @@ export const deleteProductSupplyById = async function (this: WashdayClientInstan
|
|
|
26
26
|
throw error;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
// New: delete (inactivate) product price option
|
|
31
|
+
export const deletePriceOption = async function (this: WashdayClientInstance, productId: string, optionId: string): Promise<any> {
|
|
32
|
+
try {
|
|
33
|
+
const config = {
|
|
34
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
35
|
+
};
|
|
36
|
+
const response = await axiosInstance.delete(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, config);
|
|
37
|
+
return response.data || {};
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error deleting price option:', error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
};
|
package/src/api/products/post.ts
CHANGED
|
@@ -70,4 +70,24 @@ export const bulkCreate = async function (this: WashdayClientInstance, storeId:
|
|
|
70
70
|
console.error('Error fetching products bulkCreate:', error);
|
|
71
71
|
throw error;
|
|
72
72
|
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// New: create price option for a product
|
|
76
|
+
export const createPriceOption = async function (this: WashdayClientInstance, productId: string, data: {
|
|
77
|
+
label: string;
|
|
78
|
+
price: number;
|
|
79
|
+
expressPrice: number;
|
|
80
|
+
isDefault?: boolean;
|
|
81
|
+
isActive?: boolean;
|
|
82
|
+
}): Promise<any> {
|
|
83
|
+
try {
|
|
84
|
+
const config = {
|
|
85
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
86
|
+
};
|
|
87
|
+
const response = await axiosInstance.post(`${GET_SET_PRODUCTS}/${productId}/price-options`, data, config);
|
|
88
|
+
return response.data || {};
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error('Error creating price option:', error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
73
93
|
};
|
package/src/api/products/put.ts
CHANGED
|
@@ -47,3 +47,23 @@ export const updateById = async function (this: WashdayClientInstance, id: strin
|
|
|
47
47
|
throw error;
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
// New: update product price option
|
|
52
|
+
export const updatePriceOption = async function (this: WashdayClientInstance, productId: string, optionId: string, data: {
|
|
53
|
+
label?: string;
|
|
54
|
+
price?: number;
|
|
55
|
+
expressPrice?: number;
|
|
56
|
+
isDefault?: boolean;
|
|
57
|
+
isActive?: boolean;
|
|
58
|
+
}): Promise<any> {
|
|
59
|
+
try {
|
|
60
|
+
const config = {
|
|
61
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
62
|
+
};
|
|
63
|
+
const response = await axiosInstance.put(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, data, config);
|
|
64
|
+
return response.data || {};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Error updating price option:', error);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
};
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -166,6 +166,9 @@ export interface WashdayClientInstance {
|
|
|
166
166
|
deleteProductSupplyById: typeof productsEndpoints.deleteModule.deleteProductSupplyById;
|
|
167
167
|
updateById: typeof productsEndpoints.putModule.updateById;
|
|
168
168
|
bulkUpdate: typeof productsEndpoints.putModule.bulkUpdate;
|
|
169
|
+
createPriceOption: typeof productsEndpoints.postModule.createPriceOption;
|
|
170
|
+
updatePriceOption: typeof productsEndpoints.putModule.updatePriceOption;
|
|
171
|
+
deletePriceOption: typeof productsEndpoints.deleteModule.deletePriceOption;
|
|
169
172
|
};
|
|
170
173
|
users: {
|
|
171
174
|
updateUserById: typeof updateUserById;
|