@kiminix/tp-client 1.35.0 → 1.37.0

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 (69) hide show
  1. package/dist/business/types/get-all.d.ts +3 -19
  2. package/dist/business/types/get-id.d.ts +7 -16
  3. package/dist/business/types/shared.d.ts +3 -13
  4. package/dist/cashback/index.d.ts +0 -2
  5. package/dist/cashback/index.js +0 -3
  6. package/dist/cashback/user/types/resp-get-cashback.d.ts +14 -2
  7. package/dist/cashback/user/user-apis.d.ts +7 -2
  8. package/dist/cashback/user/user-apis.js +14 -36
  9. package/dist/deals/apis.d.ts +0 -1
  10. package/dist/deals/apis.js +12 -39
  11. package/dist/deals/index.d.ts +1 -0
  12. package/dist/deals/index.js +2 -0
  13. package/dist/deals/types.d.ts +7 -15
  14. package/dist/discounts/admin/admin-apis.d.ts +36 -0
  15. package/dist/{menus/preset/apis.js → discounts/admin/admin-apis.js} +57 -24
  16. package/dist/discounts/admin/types/get-available-datetimes.d.ts +7 -0
  17. package/dist/discounts/index.d.ts +2 -0
  18. package/dist/discounts/index.js +3 -0
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +5 -4
  21. package/dist/reservations/admin/admin-apis.d.ts +55 -18
  22. package/dist/reservations/admin/admin-apis.js +91 -48
  23. package/dist/reservations/admin/types.d.ts +19 -0
  24. package/dist/reservations/index.d.ts +3 -5
  25. package/dist/reservations/index.js +3 -5
  26. package/dist/reservations/shared/reservation-deal.d.ts +6 -5
  27. package/dist/reservations/shared/reservation.d.ts +7 -19
  28. package/dist/reservations/user/guest-apis.d.ts +84 -0
  29. package/dist/reservations/user/guest-apis.js +199 -0
  30. package/dist/reservations/user/types/response-api.d.ts +32 -0
  31. package/dist/reservations/user/user-apis.d.ts +43 -59
  32. package/dist/reservations/user/user-apis.js +58 -231
  33. package/dist/types.d.ts +1 -0
  34. package/dist/utils/date-utils.d.ts +2 -0
  35. package/dist/utils/date-utils.js +7 -1
  36. package/dist/utils/reservation-utils.d.ts +2 -0
  37. package/dist/utils/reservation-utils.js +6 -0
  38. package/package.json +2 -2
  39. package/dist/cashback/admin/admin-apis.d.ts +0 -7
  40. package/dist/cashback/admin/admin-apis.js +0 -85
  41. package/dist/cashback/admin/types/resp-get-cashback.d.ts +0 -12
  42. package/dist/menus/preset/admin-apis.d.ts +0 -8
  43. package/dist/menus/preset/admin-apis.js +0 -146
  44. package/dist/menus/preset/apis.d.ts +0 -11
  45. package/dist/menus/preset/discounts/admin-apis.d.ts +0 -7
  46. package/dist/menus/preset/discounts/admin-apis.js +0 -90
  47. package/dist/menus/preset/discounts/types/update-discount.d.ts +0 -9
  48. package/dist/menus/preset/index.d.ts +0 -7
  49. package/dist/menus/preset/index.js +0 -9
  50. package/dist/menus/preset/types/preset-menu.d.ts +0 -19
  51. package/dist/menus/preset/types/preset-menu.js +0 -1
  52. package/dist/menus/preset/types/special-discounts.d.ts +0 -12
  53. package/dist/menus/preset/types/special-discounts.js +0 -1
  54. package/dist/menus/preset/types/types.d.ts +0 -4
  55. package/dist/menus/preset/types/update-preset-menu.d.ts +0 -12
  56. package/dist/menus/preset/types/update-preset-menu.js +0 -1
  57. package/dist/reservations/admin/types/get-available-transitions.d.ts +0 -4
  58. package/dist/reservations/admin/types/get-available-transitions.js +0 -1
  59. package/dist/reservations/admin/types/get-id.d.ts +0 -4
  60. package/dist/reservations/admin/types/get-id.js +0 -1
  61. package/dist/reservations/user/types/resp-reservation-settings.d.ts +0 -22
  62. package/dist/reservations/user/types/resp-reservation-settings.js +0 -1
  63. package/dist/reservations/user/types/resp-save-reservation.d.ts +0 -3
  64. package/dist/reservations/user/types/resp-save-reservation.js +0 -1
  65. package/dist/utils/menu-utils.d.ts +0 -10
  66. package/dist/utils/menu-utils.js +0 -51
  67. /package/dist/{cashback/admin/types/resp-get-cashback.js → discounts/admin/types/get-available-datetimes.js} +0 -0
  68. /package/dist/{menus/preset/types → reservations/admin}/types.js +0 -0
  69. /package/dist/{menus/preset/discounts/types/update-discount.js → reservations/user/types/response-api.js} +0 -0
@@ -1,73 +1,57 @@
1
1
  import { ReservationDealKind } from "../../enum";
2
- import { LocalDate } from "../../types";
2
+ import { LocalDate, LocalTime } from "../../types";
3
+ import { AvailableDeals, GetPageRequest, ReservationResponse } from "../index";
3
4
  import { Reservation } from "../shared/reservation";
4
- import { AvailableMenu, GetByIdAdminRequest, GetPageRequest, ReservationPreviewResponse, ReservationSettings } from "../index";
5
- import { SaveReservationResponse } from "./types/resp-save-reservation";
6
5
  export declare class ReservationsUserAPIs {
6
+ /**
7
+ *
8
+ * @throws unauthorized, internal_error
9
+ * @returns
10
+ */
7
11
  static getPage({ token, page, size, direction }: GetPageRequest): Promise<Reservation[]>;
8
- static get({ id, token }: GetByIdAdminRequest): Promise<Reservation>;
9
- static cancel(id: string, token?: string): Promise<any>;
10
12
  /**
11
- *
12
- * @param businessId
13
- * @param date
14
- * @returns Available deals & menus for the given business and date.
15
- * Can fail with bellow errors code: unauthenticated, past_day, expired_licence, internal_error
16
- */
17
- static getSettings(props: {
13
+ *
14
+ * @param props
15
+ * @throws reservation_not_found, unauthorized, internal_error
16
+ * @returns
17
+ */
18
+ static get(props: {
18
19
  token?: string;
19
- businessId: string;
20
- date: LocalDate;
21
- }): Promise<ReservationSettings>;
20
+ id: string;
21
+ }): Promise<Reservation>;
22
+ /**
23
+ *
24
+ * @param id
25
+ * @param token
26
+ * @throws unauthorized, not_found, internal_error, unauthorized_action
27
+ * @returns
28
+ */
29
+ static cancel(id: string, token?: string): Promise<any>;
30
+ /**
31
+ *
32
+ * @param props
33
+ * @returns
34
+ * @throws unauthorized, internal_error, already_booked, unavailable_datetime, closed_hour, invalid_persons, cashback_apply_not_allowed,
35
+ * cashback_not_allowed, discount_not_allowed
36
+ */
22
37
  static reserve(props: {
23
38
  token?: string;
24
39
  businessId: string;
25
- date: Date;
26
- time: Date;
40
+ datetime: Date;
41
+ persons: number;
27
42
  deal: ReservationDealKind | undefined;
28
- specialCode?: string;
29
- commands: {
30
- menuId: string;
31
- adult: number;
32
- child?: number;
33
- }[];
34
- }): Promise<SaveReservationResponse>;
35
- static preview(props: {
43
+ notes: string | undefined;
44
+ }): Promise<ReservationResponse>;
45
+ /**
46
+ *
47
+ * @param props
48
+ * @throws invalid_datetime
49
+ * @returns
50
+ */
51
+ static getAvailableDeals(props: {
36
52
  token?: string;
37
- businessId: string;
38
- date: Date;
39
- time: Date;
40
- deal: ReservationDealKind | undefined;
41
- specialCode?: string;
42
- commands: {
43
- menuId: string;
44
- adult: number;
45
- child?: number;
46
- }[];
47
- }): Promise<ReservationPreviewResponse>;
48
- }
49
- export declare class ReservationsGuestAPIs {
50
- static reserve(props: {
51
- user: {
52
- firstName: string;
53
- lastName: string;
54
- phone: string;
55
- };
56
- businessId: string;
57
- date: Date;
58
- time: Date;
59
- specialCode?: string;
60
- commands: {
61
- menuId: string;
62
- adult: number;
63
- child?: number;
64
- }[];
65
- }): Promise<SaveReservationResponse>;
66
- static getSettings(props: {
67
53
  businessId: string;
68
54
  date: LocalDate;
69
- }): Promise<AvailableMenu[]>;
70
- static get(props: {
71
- id: string;
72
- }): Promise<Reservation>;
55
+ time: LocalTime;
56
+ }): Promise<AvailableDeals>;
73
57
  }
@@ -37,18 +37,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  import axios from "axios";
38
38
  import { format } from "date-fns";
39
39
  import { base } from "../../constants";
40
- import { ErrorWithMetadata } from "../../types";
41
- import { parseReservationDeal } from "../shared/reservation-deal";
42
40
  import { RequestUtils } from "../../utils/request-utils";
41
+ import { parseReservationDeal } from "../shared/reservation-deal";
43
42
  var ReservationsUserAPIs = /** @class */ (function () {
44
43
  function ReservationsUserAPIs() {
45
44
  }
45
+ /**
46
+ *
47
+ * @throws unauthorized, internal_error
48
+ * @returns
49
+ */
46
50
  ReservationsUserAPIs.getPage = function (_a) {
47
51
  var token = _a.token, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.size, size = _c === void 0 ? 10 : _c, direction = _a.direction;
48
52
  return __awaiter(this, void 0, void 0, function () {
49
53
  return __generator(this, function (_d) {
50
- switch (_d.label) {
51
- case 0: return [4 /*yield*/, axios.get(base + "/reservations/user?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
54
+ return [2 /*return*/, RequestUtils.send(function () {
55
+ return axios.get(base + "/reservations/user?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
52
56
  headers: {
53
57
  'Authorization': "".concat(token)
54
58
  }
@@ -59,27 +63,24 @@ var ReservationsUserAPIs = /** @class */ (function () {
59
63
  result[i].deal = result[i].deal ? parseReservationDeal(result[i].deal) : undefined;
60
64
  }
61
65
  return result;
62
- })
63
- .catch(function (error) {
64
- // handle error
65
- if (error.response.status == 401)
66
- throw new Error("unauthorized");
67
- else
68
- throw new Error('internal_error', error);
69
- })];
70
- case 1: return [2 /*return*/, _d.sent()];
71
- }
66
+ });
67
+ })];
72
68
  });
73
69
  });
74
70
  };
75
- ReservationsUserAPIs.get = function (_a) {
76
- var id = _a.id, token = _a.token;
71
+ /**
72
+ *
73
+ * @param props
74
+ * @throws reservation_not_found, unauthorized, internal_error
75
+ * @returns
76
+ */
77
+ ReservationsUserAPIs.get = function (props) {
77
78
  return __awaiter(this, void 0, void 0, function () {
78
- return __generator(this, function (_b) {
79
- switch (_b.label) {
80
- case 0: return [4 /*yield*/, axios.get(base + "/reservations/user/".concat(id), {
79
+ return __generator(this, function (_a) {
80
+ return [2 /*return*/, RequestUtils.send(function () {
81
+ return axios.get(base + "/reservations/user/".concat(props.id), {
81
82
  headers: {
82
- 'Authorization': "".concat(token),
83
+ 'Authorization': "".concat(props.token),
83
84
  'Content-Type': 'application/json'
84
85
  }
85
86
  })
@@ -87,218 +88,52 @@ var ReservationsUserAPIs = /** @class */ (function () {
87
88
  var result = response.data;
88
89
  result.deal = result.deal ? parseReservationDeal(result.deal) : undefined;
89
90
  return result;
90
- })
91
- .catch(function (error) {
92
- // handle error
93
- if (error.response.status == 401)
94
- throw new Error("unauthorized");
95
- else if (error.response.status == 404)
96
- throw new Error("not_found");
97
- else
98
- throw new Error('internal_error', error);
99
- })];
100
- case 1: return [2 /*return*/, _b.sent()];
101
- }
91
+ });
92
+ })];
102
93
  });
103
94
  });
104
95
  };
96
+ /**
97
+ *
98
+ * @param id
99
+ * @param token
100
+ * @throws unauthorized, not_found, internal_error, unauthorized_action
101
+ * @returns
102
+ */
105
103
  ReservationsUserAPIs.cancel = function (id, token) {
106
104
  return __awaiter(this, void 0, void 0, function () {
107
105
  return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0: return [4 /*yield*/, axios.patch(base + "/reservations/user/".concat(id, "/cancel"), {}, {
106
+ return [2 /*return*/, RequestUtils.send(function () {
107
+ return axios.patch(base + "/reservations/user/".concat(id, "/cancel"), {}, {
110
108
  headers: {
111
109
  'Authorization': "".concat(token)
112
110
  }
113
111
  })
114
- .then(function (response) { return response.data; })
115
- .catch(function (error) {
116
- // handle error
117
- if (error.response.status == 401)
118
- throw new Error("unauthorized");
119
- else if (error.response.status == 404)
120
- throw new Error("not_found");
121
- else if (error.response.status == 400) {
122
- //reservation_not_found
123
- var response = error.response.data;
124
- throw new Error(response.code);
125
- }
126
- else
127
- throw new Error('internal_error', error);
128
- })];
129
- case 1: return [2 /*return*/, _a.sent()];
130
- }
112
+ .then(function (response) { return response.data; });
113
+ })];
131
114
  });
132
115
  });
133
116
  };
134
117
  /**
135
- *
136
- * @param businessId
137
- * @param date
138
- * @returns Available deals & menus for the given business and date.
139
- * Can fail with bellow errors code: unauthenticated, past_day, expired_licence, internal_error
140
- */
141
- ReservationsUserAPIs.getSettings = function (props) {
142
- var _a, _b;
143
- return __awaiter(this, void 0, void 0, function () {
144
- var response, error_1, axiosError;
145
- return __generator(this, function (_c) {
146
- switch (_c.label) {
147
- case 0:
148
- _c.trys.push([0, 2, , 3]);
149
- return [4 /*yield*/, axios.get(base + "/reservations/user/settings?business=".concat(props.businessId, "&date=").concat(props.date), {
150
- headers: {
151
- 'Authorization': "".concat(props.token)
152
- }
153
- })];
154
- case 1:
155
- response = _c.sent();
156
- return [2 /*return*/, response.data];
157
- case 2:
158
- error_1 = _c.sent();
159
- axiosError = error_1;
160
- // The request was made and the server responded with a status code that falls out of the range of 2xx
161
- if (axiosError && axiosError.response) {
162
- switch (axiosError.response.status) {
163
- case 401:
164
- throw new Error("unauthorized");
165
- case 400:
166
- throw new Error((_b = (_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.code);
167
- default:
168
- throw new Error('internal_error');
169
- }
170
- }
171
- // The request was made but no response was received
172
- else if (axiosError && axiosError.request) {
173
- throw new Error('network_error');
174
- }
175
- // Something happened in setting up the request that triggered an Error
176
- else {
177
- throw new Error('client_request_setting_error');
178
- }
179
- return [3 /*break*/, 3];
180
- case 3: return [2 /*return*/];
181
- }
182
- });
183
- });
184
- };
118
+ *
119
+ * @param props
120
+ * @returns
121
+ * @throws unauthorized, internal_error, already_booked, unavailable_datetime, closed_hour, invalid_persons, cashback_apply_not_allowed,
122
+ * cashback_not_allowed, discount_not_allowed
123
+ */
185
124
  ReservationsUserAPIs.reserve = function (props) {
186
125
  return __awaiter(this, void 0, void 0, function () {
187
- var datetime;
188
- return __generator(this, function (_a) {
189
- switch (_a.label) {
190
- case 0:
191
- datetime = new Date(props.date);
192
- datetime.setHours(props.time.getHours(), props.time.getMinutes());
193
- return [4 /*yield*/, axios.post(base + "/reservations/user", {
194
- businessId: props.businessId,
195
- datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
196
- deal: props.deal,
197
- specialCode: props.specialCode,
198
- commands: props.commands
199
- }, {
200
- headers: {
201
- 'Authorization': "".concat(props.token),
202
- 'Content-Type': 'application/json'
203
- }
204
- })
205
- .then(function (response) { return response.data; })
206
- .catch(function (error) {
207
- // handle error
208
- if (error.response.status == 401)
209
- throw new Error("unauthorized");
210
- else if (error.response.status == 400) {
211
- // banned_user
212
- // already_booked
213
- // unavailable_day
214
- // expired_preview
215
- // invalid_guest_number
216
- // min_booking_amount
217
- var response = error.response.data;
218
- throw new ErrorWithMetadata(response.code, response.metadata);
219
- }
220
- else
221
- throw new Error('internal_error', error);
222
- })];
223
- case 1: return [2 /*return*/, _a.sent()];
224
- }
225
- });
226
- });
227
- };
228
- ReservationsUserAPIs.preview = function (props) {
229
- return __awaiter(this, void 0, void 0, function () {
230
- var datetime;
231
- return __generator(this, function (_a) {
232
- switch (_a.label) {
233
- case 0:
234
- datetime = new Date(props.date);
235
- datetime.setHours(props.time.getHours(), props.time.getMinutes());
236
- return [4 /*yield*/, axios.post(base + "/reservations/user/preview", {
237
- businessId: props.businessId,
238
- datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
239
- deal: props.deal,
240
- specialCode: props.specialCode,
241
- commands: props.commands
242
- }, {
243
- headers: {
244
- 'Authorization': "".concat(props.token),
245
- 'Content-Type': 'application/json'
246
- }
247
- })
248
- .then(function (response) {
249
- var result = response.data;
250
- result.deal = result.deal ? parseReservationDeal(result.deal) : undefined;
251
- return result;
252
- })
253
- .catch(function (error) {
254
- // handle error
255
- if (error.response.status == 401)
256
- throw new Error("unauthorized");
257
- else if (error.response.status == 400) {
258
- //expired_preview
259
- //min_booking_amount
260
- //invalid_guest_number
261
- var response = error.response.data;
262
- throw new ErrorWithMetadata(response.code, response.metadata);
263
- }
264
- else
265
- throw new Error('internal_error', error);
266
- })];
267
- case 1: return [2 /*return*/, _a.sent()];
268
- }
269
- });
270
- });
271
- };
272
- return ReservationsUserAPIs;
273
- }());
274
- export { ReservationsUserAPIs };
275
- // GUEST APIS
276
- var ReservationsGuestAPIs = /** @class */ (function () {
277
- function ReservationsGuestAPIs() {
278
- }
279
- ReservationsGuestAPIs.reserve = function (props) {
280
- return __awaiter(this, void 0, void 0, function () {
281
- var datetime;
282
126
  return __generator(this, function (_a) {
283
- datetime = new Date(props.date);
284
- datetime.setHours(props.time.getHours(), props.time.getMinutes());
285
- // unavailable_day
286
- // expired_preview
287
- // invalid_guest_number
288
- // invalid_special_code
289
127
  return [2 /*return*/, RequestUtils.send(function () {
290
- return axios.post(base + "/reservations/guest", {
291
- user: {
292
- firstName: props.user.firstName,
293
- lastName: props.user.lastName,
294
- phone: props.user.phone
295
- },
128
+ return axios.post(base + "/reservations/user", {
296
129
  businessId: props.businessId,
297
- datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
298
- specialCode: props.specialCode,
299
- commands: props.commands
130
+ datetime: format(props.datetime, "yyyy-MM-dd'T'HH:mm"),
131
+ deal: props.deal,
132
+ persons: props.persons,
133
+ notes: props.notes
300
134
  }, {
301
135
  headers: {
136
+ 'Authorization': "".concat(props.token),
302
137
  'Content-Type': 'application/json'
303
138
  }
304
139
  })
@@ -307,37 +142,29 @@ var ReservationsGuestAPIs = /** @class */ (function () {
307
142
  });
308
143
  });
309
144
  };
310
- // get available menus for the guest
311
- ReservationsGuestAPIs.getSettings = function (props) {
312
- return __awaiter(this, void 0, void 0, function () {
313
- return __generator(this, function (_a) {
314
- return [2 /*return*/, RequestUtils.send(function () {
315
- return axios.get(base + "/reservations/guest/settings?business=".concat(props.businessId, "&date=").concat(props.date), { headers: {} })
316
- .then(function (response) {
317
- return response.data;
318
- });
319
- })];
320
- });
321
- });
322
- };
323
- ReservationsGuestAPIs.get = function (props) {
145
+ /**
146
+ *
147
+ * @param props
148
+ * @throws invalid_datetime
149
+ * @returns
150
+ */
151
+ ReservationsUserAPIs.getAvailableDeals = function (props) {
324
152
  return __awaiter(this, void 0, void 0, function () {
325
153
  return __generator(this, function (_a) {
326
154
  return [2 /*return*/, RequestUtils.send(function () {
327
- return axios.get(base + "/reservations/guest/".concat(props.id), {
155
+ return axios.get(base + "/reservations/user/deals/available?business=".concat(props.businessId, "&date=").concat(props.date, "&time=").concat(props.time), {
328
156
  headers: {
157
+ 'Authorization': "".concat(props.token),
329
158
  'Content-Type': 'application/json'
330
159
  }
331
160
  })
332
161
  .then(function (response) {
333
- var result = response.data;
334
- result.deal = result.deal ? parseReservationDeal(result.deal) : undefined;
335
- return result;
162
+ return response.data;
336
163
  });
337
164
  })];
338
165
  });
339
166
  });
340
167
  };
341
- return ReservationsGuestAPIs;
168
+ return ReservationsUserAPIs;
342
169
  }());
343
- export { ReservationsGuestAPIs };
170
+ export { ReservationsUserAPIs };
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type LocalDate = string;
2
+ export type LocalTime = string;
2
3
  export interface ApiError {
3
4
  message: string;
4
5
  code?: string;
@@ -1,3 +1,4 @@
1
+ import { LocalTime } from "../types";
1
2
  /**
2
3
  *
3
4
  * @returns Get the seconds timestamp of the given date with truncated minutes and seconds (will be updated every one hour)
@@ -39,3 +40,4 @@ export declare class Time {
39
40
  toMinutes(): number;
40
41
  toString(): string;
41
42
  }
43
+ export declare function toLocalTime(time: string): LocalTime;
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { differenceInCalendarDays, getUnixTime, isSameDay, parseISO, setMinutes, setSeconds } from "date-fns";
12
+ import { differenceInCalendarDays, format, getUnixTime, isSameDay, parse, parseISO, setMinutes, setSeconds } from "date-fns";
13
13
  /**
14
14
  *
15
15
  * @returns Get the seconds timestamp of the given date with truncated minutes and seconds (will be updated every one hour)
@@ -128,3 +128,9 @@ var Time = /** @class */ (function () {
128
128
  return Time;
129
129
  }());
130
130
  export { Time };
131
+ // Format the string time like 15:10:00 to 15:10 (without seconds)
132
+ export function toLocalTime(time) {
133
+ // Parse the time string into a Date object
134
+ var date = parse(time, 'HH:mm:ss', new Date());
135
+ return format(date, 'HH:mm');
136
+ }
@@ -0,0 +1,2 @@
1
+ export declare class ReservationUtils {
2
+ }
@@ -0,0 +1,6 @@
1
+ var ReservationUtils = /** @class */ (function () {
2
+ function ReservationUtils() {
3
+ }
4
+ return ReservationUtils;
5
+ }());
6
+ export { ReservationUtils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "1.35.0",
3
+ "version": "1.37.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -25,6 +25,6 @@
25
25
  "dependencies": {
26
26
  "axios": "^1.6.7",
27
27
  "date-fns": "^3.3.1",
28
- "purify-ts": "^2.0.3"
28
+ "purify-ts": "^2.1.0"
29
29
  }
30
30
  }
@@ -1,7 +0,0 @@
1
- import { CashbackWithCustomerInfo } from "./types/resp-get-cashback";
2
- export declare class CashbackAdminAPIs {
3
- static get(props: {
4
- token: string | undefined;
5
- userId: string;
6
- }): Promise<CashbackWithCustomerInfo | undefined>;
7
- }
@@ -1,85 +0,0 @@
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
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import axios from "axios";
38
- import { base } from "../../constants";
39
- var CashbackAdminAPIs = /** @class */ (function () {
40
- function CashbackAdminAPIs() {
41
- }
42
- CashbackAdminAPIs.get = function (props) {
43
- return __awaiter(this, void 0, void 0, function () {
44
- var response, error_1, axiosError;
45
- return __generator(this, function (_a) {
46
- switch (_a.label) {
47
- case 0:
48
- _a.trys.push([0, 2, , 3]);
49
- return [4 /*yield*/, axios.get(base + "/cashback/admin?userId=".concat(props.userId), {
50
- headers: {
51
- 'Authorization': "".concat(props.token)
52
- }
53
- })];
54
- case 1:
55
- response = _a.sent();
56
- return [2 /*return*/, response.data];
57
- case 2:
58
- error_1 = _a.sent();
59
- axiosError = error_1;
60
- // The request was made and the server responded with a status code that falls out of the range of 2xx
61
- if (axiosError && axiosError.response) {
62
- switch (axiosError.response.status) {
63
- case 401:
64
- throw new Error("unauthorized");
65
- default:
66
- throw new Error('internal_error');
67
- }
68
- }
69
- // The request was made but no response was received
70
- else if (axiosError && axiosError.request) {
71
- throw new Error('network_error');
72
- }
73
- // Something happened in setting up the request that triggered an Error
74
- else {
75
- throw new Error('client_request_setting_error');
76
- }
77
- return [3 /*break*/, 3];
78
- case 3: return [2 /*return*/];
79
- }
80
- });
81
- });
82
- };
83
- return CashbackAdminAPIs;
84
- }());
85
- export { CashbackAdminAPIs };
@@ -1,12 +0,0 @@
1
- import { Cashback } from "../../user/types/resp-get-cashback";
2
- export interface CashbackWithCustomerInfo {
3
- user: CustomerInfo;
4
- cashback: Cashback | undefined;
5
- }
6
- export interface CustomerInfo {
7
- id: string;
8
- firstname: string;
9
- lastname: string;
10
- phone: string | undefined;
11
- verifiedPhone: boolean;
12
- }
@@ -1,8 +0,0 @@
1
- import { UpdatePresetMenuRequest } from "./types/update-preset-menu";
2
- import { Either } from "purify-ts";
3
- import { PresetMenu } from "./types/preset-menu";
4
- export declare class PresetMenusAdminAPIs {
5
- static getByBusiness(token?: string): Promise<PresetMenu[]>;
6
- static getByMenuID(menuId: string, token?: string): Promise<PresetMenu>;
7
- static update({ token, id, availability, minBookingTotal, title }: UpdatePresetMenuRequest): Promise<Either<Error, PresetMenu>>;
8
- }