washday-sdk 1.0.2 → 1.1.1

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.
Files changed (254) hide show
  1. package/README.md +127 -0
  2. package/babel.config.js +8 -0
  3. package/dist/api/attendance/delete.js +2 -0
  4. package/dist/api/attendance/get.js +89 -0
  5. package/dist/api/attendance/index.js +4 -0
  6. package/dist/api/attendance/post.js +39 -0
  7. package/dist/api/attendance/put.js +25 -0
  8. package/dist/api/auth/index.js +3 -0
  9. package/dist/api/auth/post.js +170 -0
  10. package/dist/api/axiosInstance.js +15 -11
  11. package/dist/api/cashierbox/delete.js +40 -0
  12. package/dist/api/cashierbox/get.js +63 -0
  13. package/dist/api/cashierbox/post.js +42 -0
  14. package/dist/api/cashierbox/put.js +42 -0
  15. package/dist/api/cashups/delete.js +25 -0
  16. package/dist/api/cashups/get.js +60 -0
  17. package/dist/api/cashups/index.js +4 -0
  18. package/dist/api/cashups/post.js +25 -0
  19. package/dist/api/cashups/put.js +52 -0
  20. package/dist/api/cfdi/delete.js +25 -0
  21. package/dist/api/cfdi/get.js +126 -0
  22. package/dist/api/cfdi/index.js +4 -0
  23. package/dist/api/cfdi/post.js +41 -0
  24. package/dist/api/cfdi/put.js +52 -0
  25. package/dist/api/companies/get.js +29 -0
  26. package/dist/api/companies/post.js +41 -0
  27. package/dist/api/companies/put.js +57 -0
  28. package/dist/api/countries/get.js +29 -0
  29. package/dist/api/countries/post.js +1 -0
  30. package/dist/api/countries/put.js +1 -0
  31. package/dist/api/csv/get.js +325 -0
  32. package/dist/api/csv/index.js +1 -0
  33. package/dist/api/customers/delete.js +40 -0
  34. package/dist/api/customers/get.js +75 -20
  35. package/dist/api/customers/index.js +4 -1
  36. package/dist/api/customers/post.js +41 -0
  37. package/dist/api/customers/put.js +52 -0
  38. package/dist/api/discounts/get.js +120 -0
  39. package/dist/api/discounts/post.js +40 -0
  40. package/dist/api/discounts/put.js +68 -0
  41. package/dist/api/index.js +316 -8
  42. package/dist/api/inventory/delete.js +26 -0
  43. package/dist/api/inventory/get.js +62 -0
  44. package/dist/api/inventory/index.js +4 -0
  45. package/dist/api/inventory/post.js +26 -0
  46. package/dist/api/inventory/put.js +41 -0
  47. package/dist/api/order/delete.js +40 -0
  48. package/dist/api/order/get.js +181 -0
  49. package/dist/api/order/index.js +4 -0
  50. package/dist/api/order/post.js +115 -0
  51. package/dist/api/order/put.js +202 -0
  52. package/dist/api/outsourcedOrders/delete.js +25 -0
  53. package/dist/api/outsourcedOrders/get.js +62 -0
  54. package/dist/api/outsourcedOrders/index.js +4 -0
  55. package/dist/api/outsourcedOrders/post.js +25 -0
  56. package/dist/api/outsourcedOrders/put.js +25 -0
  57. package/dist/api/partners/delete.js +25 -0
  58. package/dist/api/partners/get.js +40 -0
  59. package/dist/api/partners/index.js +4 -0
  60. package/dist/api/partners/post.js +25 -0
  61. package/dist/api/partners/put.js +25 -0
  62. package/dist/api/pdf/get.js +43 -0
  63. package/dist/api/pdf/index.js +1 -0
  64. package/dist/api/products/delete.js +40 -0
  65. package/dist/api/products/get.js +25 -0
  66. package/dist/api/products/index.js +4 -0
  67. package/dist/api/products/post.js +60 -0
  68. package/dist/api/products/put.js +40 -0
  69. package/dist/api/publics/get.js +26 -0
  70. package/dist/api/publics/index.js +1 -0
  71. package/dist/api/reports/get.js +303 -0
  72. package/dist/api/reports/index.js +1 -0
  73. package/dist/api/reviews/delete.js +15 -0
  74. package/dist/api/reviews/get.js +41 -0
  75. package/dist/api/reviews/index.js +4 -0
  76. package/dist/api/reviews/post.js +20 -0
  77. package/dist/api/reviews/put.js +52 -0
  78. package/dist/api/routes/delete.js +25 -0
  79. package/dist/api/routes/get.js +95 -0
  80. package/dist/api/routes/index.js +4 -0
  81. package/dist/api/routes/post.js +67 -0
  82. package/dist/api/routes/put.js +54 -0
  83. package/dist/api/sections/delete.js +25 -0
  84. package/dist/api/sections/get.js +71 -0
  85. package/dist/api/sections/index.js +4 -0
  86. package/dist/api/sections/post.js +26 -0
  87. package/dist/api/sections/put.js +25 -0
  88. package/dist/api/staff/delete.js +26 -0
  89. package/dist/api/staff/get.js +40 -0
  90. package/dist/api/staff/post.js +26 -0
  91. package/dist/api/staff/put.js +26 -0
  92. package/dist/api/stores/get.js +110 -0
  93. package/dist/api/stores/post.js +61 -0
  94. package/dist/api/stores/put.js +44 -0
  95. package/dist/api/stripe/get.js +1 -0
  96. package/dist/api/stripe/post.js +71 -0
  97. package/dist/api/stripe/put.js +1 -0
  98. package/dist/api/supplies/delete.js +26 -0
  99. package/dist/api/supplies/get.js +62 -0
  100. package/dist/api/supplies/post.js +26 -0
  101. package/dist/api/supplies/put.js +41 -0
  102. package/dist/api/users/delete.js +26 -0
  103. package/dist/api/users/post.js +25 -0
  104. package/dist/api/users/put.js +29 -0
  105. package/dist/enum/index.js +12 -7
  106. package/dist/index.js +3 -33
  107. package/dist/interfaces/Api.js +1 -3
  108. package/dist/interfaces/Apple.js +16 -0
  109. package/dist/interfaces/Attendance.js +1 -0
  110. package/dist/interfaces/Customer.js +1 -2
  111. package/dist/interfaces/Order.js +1 -2
  112. package/dist/interfaces/Permission.js +1 -2
  113. package/dist/interfaces/Product.js +1 -2
  114. package/dist/interfaces/Section.js +1 -2
  115. package/dist/interfaces/Store.js +1 -2
  116. package/dist/interfaces/StoreImage.js +1 -2
  117. package/dist/interfaces/User.js +1 -2
  118. package/dist/utils/apiUtils.js +9 -0
  119. package/dist/utils/index.js +2 -17
  120. package/dist/utils/orders/calculateOrderTotal.js +30 -21
  121. package/dist/utils/orders/calculateTotalTaxesIncluded.js +55 -29
  122. package/dist/utils/orders/calculateTotalTaxesOverPrice.js +56 -45
  123. package/dist/utils/orders/helpers.js +126 -17
  124. package/dist/utils/orders/index.js +3 -5
  125. package/dist/utils/receipt/generateReceiptHTML.js +157 -0
  126. package/dist/utils/util.js +63 -0
  127. package/docs/README.md +67 -0
  128. package/docs/examples/common-use-cases.md +487 -0
  129. package/docs/getting-started.md +237 -0
  130. package/docs/modules/attendance.md +404 -0
  131. package/jest.config.js +0 -0
  132. package/package.json +12 -4
  133. package/src/api/attendance/delete.ts +1 -0
  134. package/src/api/attendance/get.ts +88 -0
  135. package/src/api/attendance/index.ts +4 -0
  136. package/src/api/attendance/post.ts +38 -0
  137. package/src/api/attendance/put.ts +20 -0
  138. package/src/api/auth/index.ts +3 -0
  139. package/src/api/auth/post.ts +198 -0
  140. package/src/api/axiosInstance.ts +13 -3
  141. package/src/api/cashierbox/delete.ts +28 -0
  142. package/src/api/cashierbox/get.ts +53 -0
  143. package/src/api/cashierbox/post.ts +39 -0
  144. package/src/api/cashierbox/put.ts +32 -0
  145. package/src/api/cashups/delete.ts +15 -0
  146. package/src/api/cashups/get.ts +52 -0
  147. package/src/api/cashups/index.ts +4 -0
  148. package/src/api/cashups/post.ts +23 -0
  149. package/src/api/cashups/put.ts +53 -0
  150. package/src/api/cfdi/delete.ts +21 -0
  151. package/src/api/cfdi/get.ts +119 -0
  152. package/src/api/cfdi/index.ts +4 -0
  153. package/src/api/cfdi/post.ts +60 -0
  154. package/src/api/cfdi/put.ts +53 -0
  155. package/src/api/companies/get.ts +23 -0
  156. package/src/api/companies/post.ts +29 -0
  157. package/src/api/companies/put.ts +43 -0
  158. package/src/api/countries/get.ts +23 -0
  159. package/src/api/countries/post.ts +0 -0
  160. package/src/api/countries/put.ts +0 -0
  161. package/src/api/csv/get.ts +354 -0
  162. package/src/api/csv/index.ts +1 -0
  163. package/src/api/customers/delete.ts +29 -0
  164. package/src/api/customers/get.ts +80 -8
  165. package/src/api/customers/index.ts +4 -0
  166. package/src/api/customers/post.ts +48 -0
  167. package/src/api/customers/put.ts +68 -0
  168. package/src/api/discounts/get.ts +100 -0
  169. package/src/api/discounts/post.ts +35 -0
  170. package/src/api/discounts/put.ts +66 -0
  171. package/src/api/index.ts +318 -11
  172. package/src/api/inventory/delete.ts +16 -0
  173. package/src/api/inventory/get.ts +53 -0
  174. package/src/api/inventory/index.ts +4 -0
  175. package/src/api/inventory/post.ts +22 -0
  176. package/src/api/inventory/put.ts +35 -0
  177. package/src/api/order/delete.ts +29 -0
  178. package/src/api/order/get.ts +207 -0
  179. package/src/api/order/index.ts +4 -0
  180. package/src/api/order/post.ts +118 -0
  181. package/src/api/order/put.ts +224 -0
  182. package/src/api/outsourcedOrders/delete.ts +15 -0
  183. package/src/api/outsourcedOrders/get.ts +54 -0
  184. package/src/api/outsourcedOrders/index.ts +4 -0
  185. package/src/api/outsourcedOrders/post.ts +24 -0
  186. package/src/api/outsourcedOrders/put.ts +21 -0
  187. package/src/api/partners/delete.ts +15 -0
  188. package/src/api/partners/get.ts +28 -0
  189. package/src/api/partners/index.ts +4 -0
  190. package/src/api/partners/post.ts +21 -0
  191. package/src/api/partners/put.ts +21 -0
  192. package/src/api/pdf/get.ts +43 -0
  193. package/src/api/pdf/index.ts +1 -0
  194. package/src/api/products/delete.ts +28 -0
  195. package/src/api/products/get.ts +16 -0
  196. package/src/api/products/index.ts +4 -0
  197. package/src/api/products/post.ts +73 -0
  198. package/src/api/products/put.ts +49 -0
  199. package/src/api/publics/get.ts +16 -0
  200. package/src/api/publics/index.ts +1 -0
  201. package/src/api/reports/get.ts +329 -0
  202. package/src/api/reports/index.ts +1 -0
  203. package/src/api/reviews/delete.ts +15 -0
  204. package/src/api/reviews/get.ts +31 -0
  205. package/src/api/reviews/index.ts +4 -0
  206. package/src/api/reviews/post.ts +20 -0
  207. package/src/api/reviews/put.ts +53 -0
  208. package/src/api/routes/delete.ts +15 -0
  209. package/src/api/routes/get.ts +86 -0
  210. package/src/api/routes/index.ts +4 -0
  211. package/src/api/routes/post.ts +60 -0
  212. package/src/api/routes/put.ts +44 -0
  213. package/src/api/sections/delete.ts +15 -0
  214. package/src/api/sections/get.ts +67 -0
  215. package/src/api/sections/index.ts +4 -0
  216. package/src/api/sections/post.ts +22 -0
  217. package/src/api/sections/put.ts +23 -0
  218. package/src/api/staff/delete.ts +16 -0
  219. package/src/api/staff/get.ts +29 -0
  220. package/src/api/staff/post.ts +17 -0
  221. package/src/api/staff/put.ts +17 -0
  222. package/src/api/stores/get.ts +93 -0
  223. package/src/api/stores/post.ts +49 -0
  224. package/src/api/stores/put.ts +35 -0
  225. package/src/api/stripe/get.ts +0 -0
  226. package/src/api/stripe/post.ts +59 -0
  227. package/src/api/stripe/put.ts +0 -0
  228. package/src/api/supplies/delete.ts +16 -0
  229. package/src/api/supplies/get.ts +53 -0
  230. package/src/api/supplies/post.ts +26 -0
  231. package/src/api/supplies/put.ts +33 -0
  232. package/src/api/users/delete.ts +16 -0
  233. package/src/api/users/post.ts +18 -0
  234. package/src/api/users/put.ts +36 -0
  235. package/src/enum/index.ts +9 -1
  236. package/src/index.ts +1 -4
  237. package/src/interfaces/Api.ts +307 -2
  238. package/src/interfaces/Apple.ts +74 -0
  239. package/src/interfaces/Attendance.ts +45 -0
  240. package/src/interfaces/Customer.ts +15 -11
  241. package/src/interfaces/Order.ts +38 -1
  242. package/src/interfaces/Product.ts +1 -0
  243. package/src/interfaces/Store.ts +41 -0
  244. package/src/utils/apiUtils.ts +11 -0
  245. package/src/utils/index.ts +6 -1
  246. package/src/utils/orders/calculateOrderTotal.test.js +930 -0
  247. package/src/utils/orders/calculateOrderTotal.ts +60 -15
  248. package/src/utils/orders/calculateTotalTaxesIncluded.ts +57 -25
  249. package/src/utils/orders/calculateTotalTaxesOverPrice.ts +57 -41
  250. package/src/utils/orders/helpers.ts +195 -47
  251. package/src/utils/orders/index.ts +3 -1
  252. package/src/utils/receipt/generateReceiptHTML.ts +163 -0
  253. package/src/utils/util.ts +65 -0
  254. package/tsconfig.json +13 -9
@@ -0,0 +1,325 @@
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 GENERATE_EXPORT = 'api/export';
13
+ const GET_SET_REPORTS = 'api/reports';
14
+ export const exportCustomersList = function (params) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ const config = {
18
+ headers: {
19
+ Authorization: `Bearer ${this.apiToken}`,
20
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
21
+ 'Content-disposition': 'attachment; filename=[file.csv]'
22
+ },
23
+ params: {
24
+ responseType: 'blob'
25
+ }
26
+ };
27
+ const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
28
+ return yield axiosInstance.get(`${GENERATE_EXPORT}/export-all-customers?${queryParams}`, config);
29
+ }
30
+ catch (error) {
31
+ console.error('Error fetching exportCustomersList:', error);
32
+ throw error;
33
+ }
34
+ });
35
+ };
36
+ export const exportOrdersList = function (params) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ try {
39
+ const config = {
40
+ headers: {
41
+ Authorization: `Bearer ${this.apiToken}`,
42
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
43
+ 'Content-disposition': 'attachment; filename=[file.csv]'
44
+ },
45
+ params: {
46
+ responseType: 'blob'
47
+ }
48
+ };
49
+ const queryParams = generateQueryParamsStr([
50
+ 'storeId',
51
+ 'status',
52
+ 'name',
53
+ 'phone',
54
+ 'email',
55
+ 'fromDate',
56
+ 'toDate',
57
+ 'sequence',
58
+ 'pageNum',
59
+ 'limit',
60
+ 'sequenceSort',
61
+ 'cleanedDateTime',
62
+ 'readyDateTime',
63
+ 'collectedDateTime',
64
+ 'q'
65
+ ], params);
66
+ return yield axiosInstance.get(`${GENERATE_EXPORT}/export-all-orders?${queryParams}`, config);
67
+ }
68
+ catch (error) {
69
+ console.error('Error fetching exportOrdersList:', error);
70
+ throw error;
71
+ }
72
+ });
73
+ };
74
+ export const exportProductsList = function (storeId) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ try {
77
+ const config = {
78
+ headers: {
79
+ Authorization: `Bearer ${this.apiToken}`,
80
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
81
+ 'Content-disposition': 'attachment; filename=[file.csv]'
82
+ },
83
+ params: {
84
+ responseType: 'blob'
85
+ }
86
+ };
87
+ return yield axiosInstance.get(`api/product/${storeId}/export`, config);
88
+ }
89
+ catch (error) {
90
+ console.error('Error fetching exportProductsList:', error);
91
+ throw error;
92
+ }
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
+ };
148
+ export const exportCustomersReport = function (storeId, params) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ try {
151
+ const config = {
152
+ headers: {
153
+ Authorization: `Bearer ${this.apiToken}`,
154
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
155
+ 'Content-disposition': 'attachment; filename=[file.csv]'
156
+ },
157
+ params: {
158
+ responseType: 'blob'
159
+ }
160
+ };
161
+ const queryParams = generateQueryParamsStr([
162
+ 'fromDate',
163
+ 'toDate',
164
+ ], params);
165
+ return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/customers/export?${queryParams}`, config);
166
+ }
167
+ catch (error) {
168
+ console.error('Error fetching exportCustomersReport:', error);
169
+ throw error;
170
+ }
171
+ });
172
+ };
173
+ export const exportSuppliesReport = function (storeId, params) {
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ try {
176
+ const config = {
177
+ headers: {
178
+ Authorization: `Bearer ${this.apiToken}`,
179
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
180
+ 'Content-disposition': 'attachment; filename=[file.csv]'
181
+ },
182
+ params: {
183
+ responseType: 'blob'
184
+ }
185
+ };
186
+ const queryParams = generateQueryParamsStr([
187
+ 'fromDate',
188
+ 'toDate',
189
+ ], params);
190
+ return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/supplies/export?${queryParams}`, config);
191
+ }
192
+ catch (error) {
193
+ console.error('Error fetching exportCustomersReport:', error);
194
+ throw error;
195
+ }
196
+ });
197
+ };
198
+ export const exportDiscountCodesReport = function (storeId, params) {
199
+ return __awaiter(this, void 0, void 0, function* () {
200
+ try {
201
+ const config = {
202
+ headers: {
203
+ Authorization: `Bearer ${this.apiToken}`,
204
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
205
+ 'Content-disposition': 'attachment; filename=[file.csv]'
206
+ },
207
+ params: {
208
+ responseType: 'blob'
209
+ }
210
+ };
211
+ const queryParams = generateQueryParamsStr([], params);
212
+ return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/discountCodes/export?${queryParams}`, config);
213
+ }
214
+ catch (error) {
215
+ console.error('Error fetching exportCustomersReport:', error);
216
+ throw error;
217
+ }
218
+ });
219
+ };
220
+ export const exportStaffReport = function (storeId, params) {
221
+ return __awaiter(this, void 0, void 0, function* () {
222
+ try {
223
+ const config = {
224
+ headers: {
225
+ Authorization: `Bearer ${this.apiToken}`,
226
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
227
+ 'Content-disposition': 'attachment; filename=[file.csv]'
228
+ },
229
+ params: {
230
+ responseType: 'blob'
231
+ }
232
+ };
233
+ const queryParams = generateQueryParamsStr([
234
+ 'fromDate',
235
+ 'toDate',
236
+ ], params);
237
+ return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/staff/export?${queryParams}`, config);
238
+ }
239
+ catch (error) {
240
+ console.error('Error fetching exportCustomersReport:', error);
241
+ throw error;
242
+ }
243
+ });
244
+ };
245
+ export const exportProductSalesReport = function (storeId, params) {
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ try {
248
+ const config = {
249
+ headers: {
250
+ Authorization: `Bearer ${this.apiToken}`,
251
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
252
+ 'Content-disposition': 'attachment; filename=[file.csv]'
253
+ },
254
+ params: {
255
+ responseType: 'blob'
256
+ }
257
+ };
258
+ const queryParams = generateQueryParamsStr([
259
+ 'fromDate',
260
+ 'toDate',
261
+ 'timezone'
262
+ ], params);
263
+ return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/productSales/export?${queryParams}`, config);
264
+ }
265
+ catch (error) {
266
+ console.error('Error fetching exportOrdersList:', error);
267
+ throw error;
268
+ }
269
+ });
270
+ };
271
+ export const exportPaymentLinesReport = function (storeId, params) {
272
+ return __awaiter(this, void 0, void 0, function* () {
273
+ try {
274
+ const config = {
275
+ headers: {
276
+ Authorization: `Bearer ${this.apiToken}`,
277
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
278
+ 'Content-disposition': 'attachment; filename=[file.csv]'
279
+ },
280
+ params: {
281
+ responseType: 'blob'
282
+ }
283
+ };
284
+ const queryParams = generateQueryParamsStr([
285
+ 'fromDate',
286
+ 'toDate',
287
+ 'timezone'
288
+ ], params);
289
+ return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/paymentLines/export?${queryParams}`, config);
290
+ }
291
+ catch (error) {
292
+ console.error('Error fetching exportOrdersList:', error);
293
+ throw error;
294
+ }
295
+ });
296
+ };
297
+ export const exportUnpaidOrdersReportCSV = function (storeId, params) {
298
+ return __awaiter(this, void 0, void 0, function* () {
299
+ try {
300
+ const config = {
301
+ headers: {
302
+ Authorization: `Bearer ${this.apiToken}`,
303
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
304
+ 'Content-disposition': 'attachment; filename=[file.csv]'
305
+ },
306
+ params: {
307
+ responseType: 'blob'
308
+ }
309
+ };
310
+ const queryParams = generateQueryParamsStr([
311
+ 'fromDate',
312
+ 'toDate',
313
+ 'pageNum',
314
+ 'limit',
315
+ 'timezone',
316
+ 'customerName'
317
+ ], params);
318
+ return yield axiosInstance.get(`${GET_SET_REPORTS}/${storeId}/unpaidOrders/export/csv?${queryParams}`, config);
319
+ }
320
+ catch (error) {
321
+ console.error('Error fetching exportOrdersList:', error);
322
+ throw error;
323
+ }
324
+ });
325
+ };
@@ -0,0 +1 @@
1
+ export * as getModule from './get';
@@ -0,0 +1,40 @@
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 axiosInstance from "../axiosInstance";
11
+ const GET_SET_CUSTOMERS = 'api/customer';
12
+ const GET_SET_CUSTOMERS_APP = 'api/v2/washdayapp/customers';
13
+ export const deleteByIdCustomersApp = function (id) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ try {
16
+ const config = {
17
+ headers: { Authorization: `Bearer ${this.apiToken}` }
18
+ };
19
+ return yield axiosInstance.delete(`${GET_SET_CUSTOMERS_APP}/${id}`, config);
20
+ }
21
+ catch (error) {
22
+ console.error('Error fetching deleteByIdCustomersApp:', error);
23
+ throw error;
24
+ }
25
+ });
26
+ };
27
+ export const deleteById = function (id) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ try {
30
+ const config = {
31
+ headers: { Authorization: `Bearer ${this.apiToken}` }
32
+ };
33
+ return yield axiosInstance.delete(`${GET_SET_CUSTOMERS}/${id}`, config);
34
+ }
35
+ catch (error) {
36
+ console.error('Error fetching deleteById:', error);
37
+ throw error;
38
+ }
39
+ });
40
+ };
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,24 +7,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getCustomerHighlightsById = exports.getCustomerById = void 0;
16
- const axiosInstance_1 = __importDefault(require("../axiosInstance"));
10
+ import { generateQueryParamsStr } from "../../utils/apiUtils";
11
+ import axiosInstance from "../axiosInstance";
12
+ const GET_SET_CUSTOMERS_APP = 'api/v2/washdayapp/customers';
17
13
  const GET_SET_CUSTOMERS = 'api/customer';
18
- const REQUEST_PARAMS = {
19
- token: 'LOGGED_USER_TOKEN',
20
- };
21
- const getRequestToken = () => {
22
- return this.apiToken;
14
+ export const getList = function (params, options) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ const config = {
18
+ headers: { Authorization: `Bearer ${this.apiToken}` },
19
+ signal: (options === null || options === void 0 ? void 0 : options.signal) || params.signal || undefined
20
+ };
21
+ const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
22
+ return yield axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
23
+ }
24
+ catch (error) {
25
+ if (error instanceof Error && (error.name === 'AbortError' || error.name === 'CanceledError')) {
26
+ console.log('Request was cancelled');
27
+ throw new Error('Request cancelled');
28
+ }
29
+ console.error('Error fetching customers:', error);
30
+ throw error;
31
+ }
32
+ });
23
33
  };
24
- const getCustomerById = function (customerId) {
34
+ export const getCustomerById = function (customerId) {
25
35
  return __awaiter(this, void 0, void 0, function* () {
26
36
  try {
27
- REQUEST_PARAMS.token = getRequestToken();
28
- const response = yield axiosInstance_1.default.get(`${GET_SET_CUSTOMERS}/${customerId}`, { params: REQUEST_PARAMS });
37
+ const config = {
38
+ headers: { Authorization: `Bearer ${this.apiToken}` }
39
+ };
40
+ const response = yield axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}`, config);
29
41
  return response.data;
30
42
  }
31
43
  catch (error) {
@@ -34,18 +46,61 @@ const getCustomerById = function (customerId) {
34
46
  }
35
47
  });
36
48
  };
37
- exports.getCustomerById = getCustomerById;
38
- const getCustomerHighlightsById = function (customerId) {
49
+ export const getCustomerHighlightsById = function (customerId) {
39
50
  return __awaiter(this, void 0, void 0, function* () {
40
51
  try {
41
- REQUEST_PARAMS.token = getRequestToken();
42
- const response = yield axiosInstance_1.default.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, { params: REQUEST_PARAMS });
52
+ const config = {
53
+ headers: { Authorization: `Bearer ${this.apiToken}` }
54
+ };
55
+ const response = yield axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, config);
43
56
  return response.data;
44
57
  }
58
+ catch (error) {
59
+ console.error('Error fetching getCustomerHighlightsById:', error);
60
+ throw error;
61
+ }
62
+ });
63
+ };
64
+ export const getCustomerOrders = function (customerId, params) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ try {
67
+ const config = {
68
+ headers: { Authorization: `Bearer ${this.apiToken}` }
69
+ };
70
+ const queryParams = generateQueryParamsStr(['limit', 'pageNum'], params);
71
+ return yield axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/orders?${queryParams}`, config);
72
+ }
73
+ catch (error) {
74
+ console.error('Error fetching getCustomerHighlightsById:', error);
75
+ throw error;
76
+ }
77
+ });
78
+ };
79
+ export const getCustomerByIdCustomersApp = function (customerId) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ try {
82
+ const config = {
83
+ headers: { Authorization: `Bearer ${this.apiToken}` }
84
+ };
85
+ return yield axiosInstance.get(`${GET_SET_CUSTOMERS_APP}/${customerId}`, config);
86
+ }
45
87
  catch (error) {
46
88
  console.error('Error fetching customer:', error);
47
89
  throw error;
48
90
  }
49
91
  });
50
92
  };
51
- exports.getCustomerHighlightsById = getCustomerHighlightsById;
93
+ export const getCustomerLoyaltyHistory = function (customerId) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ try {
96
+ const config = {
97
+ headers: { Authorization: `Bearer ${this.apiToken}` }
98
+ };
99
+ return yield axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/loyalty-history`, config);
100
+ }
101
+ catch (error) {
102
+ console.error('Error fetching getCustomerLoyaltyHistory:', error);
103
+ throw error;
104
+ }
105
+ });
106
+ };
@@ -1 +1,4 @@
1
- "use strict";
1
+ export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
4
+ export * as putModule from './put';
@@ -0,0 +1,41 @@
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 axiosInstance from "../axiosInstance";
11
+ const GET_SET_CUSTOMERS = 'api/customer';
12
+ export const create = function (data) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ try {
15
+ const config = {
16
+ headers: { Authorization: `Bearer ${this.apiToken}` }
17
+ };
18
+ const response = yield axiosInstance.post(`${GET_SET_CUSTOMERS}`, data, config);
19
+ return response;
20
+ }
21
+ catch (error) {
22
+ console.error('Error fetching create:', error);
23
+ throw error;
24
+ }
25
+ });
26
+ };
27
+ export const bulkCreate = function (storeId, data) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ try {
30
+ const config = {
31
+ headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
32
+ };
33
+ const response = yield axiosInstance.post(`${GET_SET_CUSTOMERS}/bulk`, data, config);
34
+ return response.data || {};
35
+ }
36
+ catch (error) {
37
+ console.error('Error fetching customers bulkCreate:', error);
38
+ throw error;
39
+ }
40
+ });
41
+ };
@@ -0,0 +1,52 @@
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 axiosInstance from "../axiosInstance";
11
+ const GET_SET_CUSTOMERS = 'api/customer';
12
+ const GET_SET_CUSTOMERS_APP = 'api/v2/washdayapp/customers';
13
+ // export const bulkUpdate = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
14
+ // try {
15
+ // const config = {
16
+ // headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
17
+ // };
18
+ // const response = await axiosInstance.put(`${GET_SET_PRODUCTS}/${storeId}/bulk`, data, config);
19
+ // return response.data || {}
20
+ // } catch (error) {
21
+ // console.error('Error fetching getStoreById:', error);
22
+ // throw error;
23
+ // }
24
+ // };
25
+ export const updateById = function (id, data) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ try {
28
+ const config = {
29
+ headers: { Authorization: `Bearer ${this.apiToken}` }
30
+ };
31
+ return yield axiosInstance.put(`${GET_SET_CUSTOMERS}/${id}`, data, config);
32
+ }
33
+ catch (error) {
34
+ console.error('Error fetching updateById:', error);
35
+ throw error;
36
+ }
37
+ });
38
+ };
39
+ export const updateByIdCustomersApp = function (id, data) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ try {
42
+ const config = {
43
+ headers: { Authorization: `Bearer ${this.apiToken}` }
44
+ };
45
+ return yield axiosInstance.put(`${GET_SET_CUSTOMERS_APP}/${id}`, data, config);
46
+ }
47
+ catch (error) {
48
+ console.error('Error fetching updateByIdCustomersApp:', error);
49
+ throw error;
50
+ }
51
+ });
52
+ };