washday-sdk 0.0.132 → 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.
@@ -118,3 +118,30 @@ export const exportCleanedOrdersReport = function (storeId, params) {
118
118
  }
119
119
  });
120
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
@@ -221,14 +221,16 @@ const WashdayClient = function WashdayClient(apiToken) {
221
221
  exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
222
222
  exportOrdersList: csvExportEndpoints.getModule.exportOrdersList,
223
223
  exportProductsList: csvExportEndpoints.getModule.exportProductsList,
224
- exportCleanedOrdersReport: csvExportEndpoints.getModule.exportCleanedOrdersReport
224
+ exportCleanedOrdersReport: csvExportEndpoints.getModule.exportCleanedOrdersReport,
225
+ exportSalesReport: csvExportEndpoints.getModule.exportSalesReport
225
226
  });
226
227
  this.pdf = bindMethods(this, {
227
228
  exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
228
229
  });
229
230
  this.reports = bindMethods(this, {
230
231
  getCleanedOrdersReport: reportsExportEndpoints.getModule.getCleanedOrdersReport,
231
- getCleanedOrdersGraphDataReport: reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport
232
+ getCleanedOrdersGraphDataReport: reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport,
233
+ getSalesReport: reportsExportEndpoints.getModule.getSalesReport
232
234
  });
233
235
  };
234
236
  export default WashdayClient;
@@ -50,3 +50,23 @@ export const getCleanedOrdersGraphDataReport = function (storeId, params) {
50
50
  }
51
51
  });
52
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.132",
3
+ "version": "0.0.133",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -131,4 +131,34 @@ export const exportCleanedOrdersReport = async function (this: WashdayClientInst
131
131
  console.error('Error fetching exportOrdersList:', error);
132
132
  throw error;
133
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
+ }
134
164
  };
package/src/api/index.ts CHANGED
@@ -227,14 +227,16 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
227
227
  exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
228
228
  exportOrdersList: csvExportEndpoints.getModule.exportOrdersList,
229
229
  exportProductsList: csvExportEndpoints.getModule.exportProductsList,
230
- exportCleanedOrdersReport: csvExportEndpoints.getModule.exportCleanedOrdersReport
230
+ exportCleanedOrdersReport: csvExportEndpoints.getModule.exportCleanedOrdersReport,
231
+ exportSalesReport: csvExportEndpoints.getModule.exportSalesReport
231
232
  });
232
233
  this.pdf = bindMethods(this, {
233
234
  exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
234
235
  });
235
236
  this.reports = bindMethods(this, {
236
237
  getCleanedOrdersReport: reportsExportEndpoints.getModule.getCleanedOrdersReport,
237
- getCleanedOrdersGraphDataReport: reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport
238
+ getCleanedOrdersGraphDataReport: reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport,
239
+ getSalesReport: reportsExportEndpoints.getModule.getSalesReport
238
240
  });
239
241
  } as any;
240
242
 
@@ -50,3 +50,25 @@ export const getCleanedOrdersGraphDataReport = async function (this: WashdayClie
50
50
  }
51
51
  };
52
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
+ };
@@ -218,5 +218,6 @@ export interface WashdayClientInstance {
218
218
  reports: {
219
219
  getCleanedOrdersReport: typeof reportsExportEndpoints.getModule.getCleanedOrdersReport;
220
220
  getCleanedOrdersGraphDataReport: typeof reportsExportEndpoints.getModule.getCleanedOrdersGraphDataReport;
221
+ getSalesReport: typeof reportsExportEndpoints.getModule.getSalesReport;
221
222
  };
222
223
  }