washday-sdk 0.0.131 → 0.0.133
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/csv/get.js +54 -0
- package/dist/api/index.js +9 -1
- package/dist/api/reports/get.js +72 -0
- package/dist/api/reports/index.js +1 -0
- package/package.json +1 -1
- package/src/api/csv/get.ts +59 -0
- package/src/api/index.ts +9 -1
- package/src/api/reports/get.ts +74 -0
- package/src/api/reports/index.ts +1 -0
- package/src/interfaces/Api.ts +6 -0
package/dist/api/csv/get.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
11
11
|
import axiosInstance from "../axiosInstance";
|
|
12
12
|
const GENERATE_EXPORT = 'api/export';
|
|
13
|
+
const GET_SET_REPORTS = 'api/reports';
|
|
13
14
|
export const exportCustomersList = function (params) {
|
|
14
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
16
|
try {
|
|
@@ -91,3 +92,56 @@ export const exportProductsList = function (storeId) {
|
|
|
91
92
|
}
|
|
92
93
|
});
|
|
93
94
|
};
|
|
95
|
+
export const exportCleanedOrdersReport = function (storeId, params) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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
|
+
const queryParams = generateQueryParamsStr([
|
|
109
|
+
'fromDate',
|
|
110
|
+
'toDate',
|
|
111
|
+
'timezone'
|
|
112
|
+
], params);
|
|
113
|
+
return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders/export?${queryParams}`, config);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
export const exportSalesReport = function (storeId, params) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
try {
|
|
124
|
+
const config = {
|
|
125
|
+
headers: {
|
|
126
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
127
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
128
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
129
|
+
},
|
|
130
|
+
params: {
|
|
131
|
+
responseType: 'blob'
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const queryParams = generateQueryParamsStr([
|
|
135
|
+
'fromDate',
|
|
136
|
+
'toDate',
|
|
137
|
+
'timezone',
|
|
138
|
+
'type'
|
|
139
|
+
], params);
|
|
140
|
+
return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales/export?${queryParams}`, config);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
};
|
package/dist/api/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import * as productsEndpoints from './products';
|
|
|
28
28
|
import * as customersEndpoints from './customers';
|
|
29
29
|
import * as csvExportEndpoints from './csv';
|
|
30
30
|
import * as pdfExportEndpoints from './pdf';
|
|
31
|
+
import * as reportsExportEndpoints from './reports';
|
|
31
32
|
import * as ordersEndpoints from './order';
|
|
32
33
|
import * as authEndpoints from './auth';
|
|
33
34
|
import * as routesEndpoints from './routes';
|
|
@@ -219,10 +220,17 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
219
220
|
this.csv = bindMethods(this, {
|
|
220
221
|
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
221
222
|
exportOrdersList: csvExportEndpoints.getModule.exportOrdersList,
|
|
222
|
-
exportProductsList: csvExportEndpoints.getModule.exportProductsList
|
|
223
|
+
exportProductsList: csvExportEndpoints.getModule.exportProductsList,
|
|
224
|
+
exportCleanedOrdersReport: csvExportEndpoints.getModule.exportCleanedOrdersReport,
|
|
225
|
+
exportSalesReport: csvExportEndpoints.getModule.exportSalesReport
|
|
223
226
|
});
|
|
224
227
|
this.pdf = bindMethods(this, {
|
|
225
228
|
exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
|
|
226
229
|
});
|
|
230
|
+
this.reports = bindMethods(this, {
|
|
231
|
+
getCleanedOrdersReport: reportsExportEndpoints.getModule.getCleanedOrdersReport,
|
|
232
|
+
getCleanedOrdersGraphDataReport: reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport,
|
|
233
|
+
getSalesReport: reportsExportEndpoints.getModule.getSalesReport
|
|
234
|
+
});
|
|
227
235
|
};
|
|
228
236
|
export default WashdayClient;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
11
|
+
import axiosInstance from "../axiosInstance";
|
|
12
|
+
const GET_SET_REPORTS = 'api/reports';
|
|
13
|
+
export const getCleanedOrdersReport = function (storeId, params) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
const config = {
|
|
17
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
18
|
+
};
|
|
19
|
+
const queryParams = generateQueryParamsStr([
|
|
20
|
+
'toDate',
|
|
21
|
+
'fromDate',
|
|
22
|
+
'pageNum',
|
|
23
|
+
'limit',
|
|
24
|
+
'includeGraph',
|
|
25
|
+
], params);
|
|
26
|
+
return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders?${queryParams}`, config);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Error fetching getCleanedOrdersReport:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export const getCleanedOrdersGraphDataReport = function (storeId, params) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
try {
|
|
37
|
+
const config = {
|
|
38
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
39
|
+
};
|
|
40
|
+
const queryParams = generateQueryParamsStr([
|
|
41
|
+
'toDate',
|
|
42
|
+
'fromDate',
|
|
43
|
+
'timezone',
|
|
44
|
+
], params);
|
|
45
|
+
return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders-graph?${queryParams}`, config);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error('Error fetching getCleanedOrdersGraphDataReport :', error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export const getSalesReport = function (storeId, params) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
const config = {
|
|
57
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
58
|
+
};
|
|
59
|
+
const queryParams = generateQueryParamsStr([
|
|
60
|
+
'toDate',
|
|
61
|
+
'fromDate',
|
|
62
|
+
'timezone',
|
|
63
|
+
'type',
|
|
64
|
+
], params);
|
|
65
|
+
return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales?${queryParams}`, config);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('Error fetching getSalesReport:', error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as getModule from './get';
|
package/package.json
CHANGED
package/src/api/csv/get.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
|
3
3
|
import axiosInstance from "../axiosInstance";
|
|
4
4
|
|
|
5
5
|
const GENERATE_EXPORT = 'api/export';
|
|
6
|
+
const GET_SET_REPORTS = 'api/reports';
|
|
6
7
|
|
|
7
8
|
export const exportCustomersList = async function (this: WashdayClientInstance, params: {
|
|
8
9
|
searchTerm?: string
|
|
@@ -102,4 +103,62 @@ export const exportProductsList = async function (this: WashdayClientInstance, s
|
|
|
102
103
|
console.error('Error fetching exportProductsList:', error);
|
|
103
104
|
throw error;
|
|
104
105
|
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const exportCleanedOrdersReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
109
|
+
fromDate?: string
|
|
110
|
+
toDate?: string
|
|
111
|
+
timezone?: string
|
|
112
|
+
}): Promise<any> {
|
|
113
|
+
try {
|
|
114
|
+
const config = {
|
|
115
|
+
headers: {
|
|
116
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
117
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
118
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
119
|
+
},
|
|
120
|
+
params: {
|
|
121
|
+
responseType: 'blob'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const queryParams = generateQueryParamsStr([
|
|
125
|
+
'fromDate',
|
|
126
|
+
'toDate',
|
|
127
|
+
'timezone'
|
|
128
|
+
], params);
|
|
129
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders/export?${queryParams}`, config);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const exportSalesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
137
|
+
fromDate?: string
|
|
138
|
+
toDate?: string
|
|
139
|
+
timezone?: string
|
|
140
|
+
type: "daily" | "month" | "year";
|
|
141
|
+
}): Promise<any> {
|
|
142
|
+
try {
|
|
143
|
+
const config = {
|
|
144
|
+
headers: {
|
|
145
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
146
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
147
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
148
|
+
},
|
|
149
|
+
params: {
|
|
150
|
+
responseType: 'blob'
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const queryParams = generateQueryParamsStr([
|
|
154
|
+
'fromDate',
|
|
155
|
+
'toDate',
|
|
156
|
+
'timezone',
|
|
157
|
+
'type'
|
|
158
|
+
], params);
|
|
159
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales/export?${queryParams}`, config);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error('Error fetching exportOrdersList:', error);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
105
164
|
};
|
package/src/api/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import * as productsEndpoints from './products';
|
|
|
29
29
|
import * as customersEndpoints from './customers';
|
|
30
30
|
import * as csvExportEndpoints from './csv';
|
|
31
31
|
import * as pdfExportEndpoints from './pdf';
|
|
32
|
+
import * as reportsExportEndpoints from './reports';
|
|
32
33
|
import * as ordersEndpoints from './order';
|
|
33
34
|
import * as authEndpoints from './auth';
|
|
34
35
|
import * as routesEndpoints from './routes';
|
|
@@ -225,11 +226,18 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
225
226
|
this.csv = bindMethods(this, {
|
|
226
227
|
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
227
228
|
exportOrdersList: csvExportEndpoints.getModule.exportOrdersList,
|
|
228
|
-
exportProductsList: csvExportEndpoints.getModule.exportProductsList
|
|
229
|
+
exportProductsList: csvExportEndpoints.getModule.exportProductsList,
|
|
230
|
+
exportCleanedOrdersReport: csvExportEndpoints.getModule.exportCleanedOrdersReport,
|
|
231
|
+
exportSalesReport: csvExportEndpoints.getModule.exportSalesReport
|
|
229
232
|
});
|
|
230
233
|
this.pdf = bindMethods(this, {
|
|
231
234
|
exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
|
|
232
235
|
});
|
|
236
|
+
this.reports = bindMethods(this, {
|
|
237
|
+
getCleanedOrdersReport: reportsExportEndpoints.getModule.getCleanedOrdersReport,
|
|
238
|
+
getCleanedOrdersGraphDataReport: reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport,
|
|
239
|
+
getSalesReport: reportsExportEndpoints.getModule.getSalesReport
|
|
240
|
+
});
|
|
233
241
|
} as any;
|
|
234
242
|
|
|
235
243
|
export default WashdayClient;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IOrder } from "../../interfaces/Order";
|
|
3
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
4
|
+
import axiosInstance from "../axiosInstance";
|
|
5
|
+
const GET_SET_REPORTS = 'api/reports';
|
|
6
|
+
|
|
7
|
+
export const getCleanedOrdersReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
8
|
+
fromDate?: string
|
|
9
|
+
toDate?: string
|
|
10
|
+
timezone?: string
|
|
11
|
+
pageNum?: string
|
|
12
|
+
limit?: string
|
|
13
|
+
}): Promise<any> {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
const queryParams = generateQueryParamsStr([
|
|
19
|
+
'toDate',
|
|
20
|
+
'fromDate',
|
|
21
|
+
'pageNum',
|
|
22
|
+
'limit',
|
|
23
|
+
'includeGraph',
|
|
24
|
+
], params);
|
|
25
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders?${queryParams}`, config);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Error fetching getCleanedOrdersReport:', error);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const getCleanedOrdersGraphDataReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
33
|
+
fromDate?: string
|
|
34
|
+
toDate?: string
|
|
35
|
+
timezone?: string
|
|
36
|
+
}): Promise<any> {
|
|
37
|
+
try {
|
|
38
|
+
const config = {
|
|
39
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
40
|
+
};
|
|
41
|
+
const queryParams = generateQueryParamsStr([
|
|
42
|
+
'toDate',
|
|
43
|
+
'fromDate',
|
|
44
|
+
'timezone',
|
|
45
|
+
], params);
|
|
46
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/cleaned-orders-graph?${queryParams}`, config);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('Error fetching getCleanedOrdersGraphDataReport :', error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const getSalesReport = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
54
|
+
fromDate?: string
|
|
55
|
+
toDate?: string
|
|
56
|
+
timezone?: string
|
|
57
|
+
type: "daily" | "month" | "year";
|
|
58
|
+
}): Promise<any> {
|
|
59
|
+
try {
|
|
60
|
+
const config = {
|
|
61
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
62
|
+
};
|
|
63
|
+
const queryParams = generateQueryParamsStr([
|
|
64
|
+
'toDate',
|
|
65
|
+
'fromDate',
|
|
66
|
+
'timezone',
|
|
67
|
+
'type',
|
|
68
|
+
], params);
|
|
69
|
+
return await axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/sales?${queryParams}`, config);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Error fetching getSalesReport:', error);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as getModule from './get';
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -28,6 +28,7 @@ import * as productsEndpoints from '../api/products';
|
|
|
28
28
|
import * as customersEndpoints from '../api/customers';
|
|
29
29
|
import * as csvExportEndpoints from '../api/csv';
|
|
30
30
|
import * as pdfExportEndpoints from '../api/pdf';
|
|
31
|
+
import * as reportsExportEndpoints from '../api/reports';
|
|
31
32
|
import * as ordersEndpoints from '../api/order';
|
|
32
33
|
import * as routesEndpoints from '../api/routes';
|
|
33
34
|
import * as reviewsEndpoints from '../api/reviews';
|
|
@@ -214,4 +215,9 @@ export interface WashdayClientInstance {
|
|
|
214
215
|
pdf: {
|
|
215
216
|
exportUnpaidOrdersReportPDF: typeof pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF;
|
|
216
217
|
};
|
|
218
|
+
reports: {
|
|
219
|
+
getCleanedOrdersReport: typeof reportsExportEndpoints.getModule.getCleanedOrdersReport;
|
|
220
|
+
getCleanedOrdersGraphDataReport: typeof reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport;
|
|
221
|
+
getSalesReport: typeof reportsExportEndpoints.getModule.getSalesReport;
|
|
222
|
+
};
|
|
217
223
|
}
|