@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
@@ -35,10 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import axios from "axios";
38
- import { format } from "date-fns";
39
- import { Left, Right } from "purify-ts";
40
38
  import { base } from "../../constants";
41
- import { ErrorWithMetadata } from "../../types";
42
39
  import { RequestUtils } from "../../utils/request-utils";
43
40
  import { parseReservationDeal } from "../shared/reservation-deal";
44
41
  var ReservationsAdminAPIs = /** @class */ (function () {
@@ -161,11 +158,17 @@ var ReservationsAdminAPIs = /** @class */ (function () {
161
158
  });
162
159
  });
163
160
  };
161
+ /**
162
+ *
163
+ * @param props
164
+ * @throws invalid_total, unauthorized_action, not_found, unauthorized, internal_error
165
+ * @returns
166
+ */
164
167
  ReservationsAdminAPIs.patchStatus = function (props) {
165
168
  return __awaiter(this, void 0, void 0, function () {
166
169
  return __generator(this, function (_a) {
167
- switch (_a.label) {
168
- case 0: return [4 /*yield*/, axios.patch(base + "/reservations/admin", {
170
+ return [2 /*return*/, RequestUtils.send(function () {
171
+ return axios.patch(base + "/reservations/admin", {
169
172
  id: props.id,
170
173
  status: props.status,
171
174
  cancellation: props.cancellation
@@ -174,63 +177,103 @@ var ReservationsAdminAPIs = /** @class */ (function () {
174
177
  'Authorization': "".concat(props.token)
175
178
  }
176
179
  })
177
- .then(function (response) { return Right(response.data); })
178
- .catch(function (error) {
179
- // handle error
180
- if (error.response.status == 401)
181
- return Left(Error("unauthorized"));
182
- else if (error.response.status == 404)
183
- return Left(Error("not_found"));
184
- else if (error.response.status == 400) {
185
- var response = error.response.data;
186
- return Left(Error(response.code));
180
+ .then(function (_) { return undefined; });
181
+ })];
182
+ });
183
+ });
184
+ };
185
+ /**
186
+ *
187
+ * @param props
188
+ * @throws unauthorized_action, not_found, unauthorized, internal_error
189
+ * @returns
190
+ */
191
+ ReservationsAdminAPIs.patchTotal = function (props) {
192
+ return __awaiter(this, void 0, void 0, function () {
193
+ return __generator(this, function (_a) {
194
+ return [2 /*return*/, RequestUtils.send(function () {
195
+ return axios.patch(base + "/reservations/admin/total", {
196
+ id: props.id,
197
+ total: props.total
198
+ }, {
199
+ headers: {
200
+ 'Authorization': "".concat(props.token)
187
201
  }
188
- else
189
- return Left(Error('internal_error'));
190
- })];
191
- case 1: return [2 /*return*/, _a.sent()];
192
- }
202
+ })
203
+ .then(function (_) { return undefined; });
204
+ })];
193
205
  });
194
206
  });
195
207
  };
196
- ReservationsAdminAPIs.reserve = function (props) {
208
+ /**
209
+ *
210
+ * @param props
211
+ * @throws unauthorized, internal_error
212
+ * @returns
213
+ */
214
+ ReservationsAdminAPIs.updateClosingDays = function (props) {
197
215
  return __awaiter(this, void 0, void 0, function () {
198
216
  return __generator(this, function (_a) {
199
- switch (_a.label) {
200
- case 0: return [4 /*yield*/, axios.post(base + "/reservations/admin", {
201
- user: props.user,
202
- datetime: format(props.datetime, "yyyy-MM-dd'T'HH:mm"),
203
- notes: props.notes,
204
- commands: props.commands
217
+ return [2 /*return*/, RequestUtils.send(function () {
218
+ return axios.patch(base + "/reservations/admin/closing-days", {
219
+ date: props.date,
220
+ time: props.time,
221
+ isOpen: props.isOpen
205
222
  }, {
206
223
  headers: {
207
- 'Authorization': "".concat(props.token),
208
- 'Content-Type': 'application/json'
224
+ 'Authorization': "".concat(props.token)
209
225
  }
210
226
  })
211
- .then(function (_) { return Right(undefined); })
212
- .catch(function (error) {
213
- // handle error
214
- if (error.response.status == 401)
215
- return Left(Error("unauthorized"));
216
- else if (error.response.status == 400) {
217
- // unavailable_day
218
- // inactive_manual_booking
219
- // expired_preview
220
- // invalid_guest_number
221
- // min_booking_amount
222
- var response = error.response.data;
223
- return Left(new ErrorWithMetadata(response.code, response.metadata));
227
+ .then(function (_) { return undefined; });
228
+ })];
229
+ });
230
+ });
231
+ };
232
+ /**
233
+ *
234
+ * @param props
235
+ * @throws unauthorized, internal_error
236
+ * @returns
237
+ */
238
+ ReservationsAdminAPIs.getClosingDays = function (props) {
239
+ return __awaiter(this, void 0, void 0, function () {
240
+ return __generator(this, function (_a) {
241
+ return [2 /*return*/, RequestUtils.send(function () {
242
+ return axios.get(base + "/reservations/admin/closing-days", {
243
+ headers: {
244
+ 'Authorization': "".concat(props.token)
224
245
  }
225
- else
226
- return Left(Error('internal_error'));
227
- })];
228
- case 1: return [2 /*return*/, _a.sent()];
229
- }
246
+ })
247
+ .then(function (response) { return response.data; });
248
+ })];
249
+ });
250
+ });
251
+ };
252
+ /**
253
+ *
254
+ * @param props
255
+ * @throws closed_business, unauthorized, internal_error
256
+ * @returns
257
+ */
258
+ ReservationsAdminAPIs.getTimeSlots = function (props) {
259
+ return __awaiter(this, void 0, void 0, function () {
260
+ return __generator(this, function (_a) {
261
+ return [2 /*return*/, RequestUtils.send(function () {
262
+ return axios.get(base + "/reservations/admin/date/".concat(props.date, "/time-slots"), {
263
+ headers: {
264
+ 'Authorization': "".concat(props.token)
265
+ }
266
+ })
267
+ .then(function (response) { return response.data; });
268
+ })];
230
269
  });
231
270
  });
232
271
  };
233
- // API for private admins
272
+ /**
273
+ *
274
+ * API for private admins
275
+ *
276
+ * */
234
277
  ReservationsAdminAPIs.getByIdPrivate = function (props) {
235
278
  return __awaiter(this, void 0, void 0, function () {
236
279
  return __generator(this, function (_a) {
@@ -0,0 +1,19 @@
1
+ import { LocalDate, LocalTime } from "../../types";
2
+ export interface GetTransitionsRequest {
3
+ token?: string;
4
+ reservationId: string;
5
+ }
6
+ export interface GetByIdAdminRequest {
7
+ token?: string;
8
+ id: string;
9
+ }
10
+ export interface TimeSlot {
11
+ hour: LocalTime;
12
+ isClosed: boolean;
13
+ }
14
+ export interface ClosingDays {
15
+ from: LocalDate;
16
+ to: LocalDate;
17
+ fullyClosedDays: LocalDate[];
18
+ partiallyClosedDays: LocalDate[];
19
+ }
@@ -1,12 +1,10 @@
1
- export * from "./user/types/resp-reservation-settings";
1
+ export * from "./user/types/response-api";
2
2
  export * from './user/types/resp-reservation-preview';
3
- export * from "./user/types/resp-save-reservation";
4
3
  export * from "./user/types/req-get-by-id";
5
4
  export * from "./user/types/req-get-page-reservation";
6
5
  export { ReservationsUserAPIs } from './user/user-apis';
7
- export { ReservationsGuestAPIs } from './user/user-apis';
8
- export * from "./admin/types/get-available-transitions";
9
- export * from "./admin/types/get-id";
6
+ export { ReservationsGuestAPIs } from './user/guest-apis';
7
+ export * from "./admin/types";
10
8
  export { ReservationsAdminAPIs } from './admin/admin-apis';
11
9
  export * from './shared/reservation';
12
10
  export * from './shared/reservation-deal';
@@ -1,15 +1,13 @@
1
1
  // user module
2
- export * from "./user/types/resp-reservation-settings";
2
+ export * from "./user/types/response-api";
3
3
  export * from './user/types/resp-reservation-preview';
4
- export * from "./user/types/resp-save-reservation";
5
4
  export * from "./user/types/req-get-by-id";
6
5
  export * from "./user/types/req-get-page-reservation";
7
6
  export { ReservationsUserAPIs } from './user/user-apis';
8
7
  // guest module
9
- export { ReservationsGuestAPIs } from './user/user-apis';
8
+ export { ReservationsGuestAPIs } from './user/guest-apis';
10
9
  // admin module
11
- export * from "./admin/types/get-available-transitions";
12
- export * from "./admin/types/get-id";
10
+ export * from "./admin/types";
13
11
  export { ReservationsAdminAPIs } from './admin/admin-apis';
14
12
  // shared module
15
13
  export * from './shared/reservation';
@@ -1,20 +1,21 @@
1
1
  import { CashbackStatus, Level, ReservationDealKind } from "../../enum";
2
2
  export interface Discount {
3
3
  type: ReservationDealKind.Discount;
4
- value: number;
5
- specialCode: string | undefined;
4
+ rate: number;
6
5
  }
7
6
  export interface CashbackEarn {
8
7
  type: ReservationDealKind.CashbackEarn;
9
- value: number;
10
- level: Level;
11
8
  rate: number;
9
+ level: Level;
10
+ value: number | undefined;
12
11
  status: CashbackStatus;
13
12
  }
14
13
  export interface CashbackApply {
15
14
  type: ReservationDealKind.CashBackApply;
16
- value: number;
15
+ rate: number;
17
16
  status: CashbackStatus;
17
+ wanted: number;
18
+ applied: number | undefined;
18
19
  }
19
20
  export type ReservationDeal = Discount | CashbackEarn | CashbackApply;
20
21
  export declare function parseReservationDeal(json: any): ReservationDeal;
@@ -6,6 +6,8 @@ export interface BusinessOfReservation {
6
6
  name: string;
7
7
  phones: string[];
8
8
  address: string;
9
+ googleMapUrl: string;
10
+ maxCashbackApply: number | undefined;
9
11
  }
10
12
  export interface User {
11
13
  id: string | undefined;
@@ -15,18 +17,6 @@ export interface User {
15
17
  email: string | undefined;
16
18
  verifiedPhone: boolean;
17
19
  }
18
- export interface GuestDetails {
19
- number: number;
20
- price: number;
21
- priceBeforeDeal?: number;
22
- }
23
- export interface OnMenuCommand {
24
- id: string;
25
- presetMenuId: string;
26
- title: string;
27
- adults: GuestDetails;
28
- children?: GuestDetails;
29
- }
30
20
  export interface ReservationEvent {
31
21
  kind: ReservationEventKind;
32
22
  at: string;
@@ -37,18 +27,16 @@ export interface Cancellation {
37
27
  }
38
28
  export interface Reservation {
39
29
  id: string;
40
- isSetByAdmin: boolean;
41
30
  createdAt: string;
42
31
  business: BusinessOfReservation;
43
32
  user: User;
44
33
  datetime: string;
45
- status: ReservationStatus;
46
- total: number;
47
- totalBeforeDeal?: number;
48
- deposit?: number;
34
+ persons: number;
35
+ total: number | undefined;
49
36
  deal: ReservationDeal | undefined;
50
- onMenuCommands: OnMenuCommand[];
37
+ status: ReservationStatus;
38
+ notesAdmin: string | undefined;
39
+ notesUser: string | undefined;
51
40
  events?: ReservationEvent[];
52
- notes?: string;
53
41
  cancellation?: Cancellation;
54
42
  }
@@ -0,0 +1,84 @@
1
+ import { ReservationDealKind, TimelineDirection } from "../../enum";
2
+ import { LocalDate, LocalTime } from "../../types";
3
+ import { AvailableDeals, DaysInfo, HourInfo, ReservationResponse } from "../index";
4
+ import { Reservation } from "../shared/reservation";
5
+ export declare class ReservationsGuestAPIs {
6
+ /**
7
+ *
8
+ * @throws unauthorized, internal_error
9
+ * @returns
10
+ */
11
+ static getPage(props: {
12
+ deviceId: string;
13
+ page: number;
14
+ size: number;
15
+ direction: TimelineDirection;
16
+ }): Promise<Reservation[]>;
17
+ /**
18
+ *
19
+ * @param props
20
+ * @throws invalid_guest_number, unavailable_day, closed_hour, discount_not_allowed
21
+ * @returns
22
+ */
23
+ static reserve(props: {
24
+ guest: {
25
+ deviceId: string;
26
+ firstName: string;
27
+ lastName: string;
28
+ phone: string;
29
+ email: string | undefined;
30
+ };
31
+ businessId: string;
32
+ datetime: Date;
33
+ persons: number;
34
+ deal: ReservationDealKind | undefined;
35
+ notes: string | undefined;
36
+ }): Promise<ReservationResponse>;
37
+ /**
38
+ *
39
+ * @param props
40
+ * @throws closed_business
41
+ * @returns get closed days and discounts by business
42
+ */
43
+ static getDays(props: {
44
+ businessId: string;
45
+ }): Promise<DaysInfo>;
46
+ /**
47
+ *
48
+ * @param props
49
+ * @throws closed_business, invalid_day, unavailable_slots
50
+ * @returns
51
+ */
52
+ static getHours(props: {
53
+ businessId: string;
54
+ day: LocalDate;
55
+ }): Promise<HourInfo[]>;
56
+ /**
57
+ *
58
+ * @param props
59
+ * @throws reservation_not_found, internal_error
60
+ * @returns
61
+ */
62
+ static get(props: {
63
+ id: string;
64
+ }): Promise<Reservation>;
65
+ /**
66
+ *
67
+ * @param props
68
+ * @throws invalid_datetime
69
+ * @returns
70
+ */
71
+ static getAvailableDeals(props: {
72
+ businessId: string;
73
+ date: LocalDate;
74
+ time: LocalTime;
75
+ }): Promise<AvailableDeals>;
76
+ /**
77
+ *
78
+ * @param id
79
+ * @param token
80
+ * @throws not_found, internal_error, unauthorized_action
81
+ * @returns
82
+ */
83
+ static cancel(id: string, device_id: string): Promise<any>;
84
+ }
@@ -0,0 +1,199 @@
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 { format } from "date-fns";
39
+ import { base } from "../../constants";
40
+ import { RequestUtils } from "../../utils/request-utils";
41
+ import { parseReservationDeal } from "../shared/reservation-deal";
42
+ // GUEST APIS
43
+ var ReservationsGuestAPIs = /** @class */ (function () {
44
+ function ReservationsGuestAPIs() {
45
+ }
46
+ /**
47
+ *
48
+ * @throws unauthorized, internal_error
49
+ * @returns
50
+ */
51
+ ReservationsGuestAPIs.getPage = function (props) {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ return __generator(this, function (_a) {
54
+ return [2 /*return*/, RequestUtils.send(function () {
55
+ return axios.get(base + "/reservations/guest?device_id=".concat(props.deviceId, "&page=").concat(props.page, "&size=").concat(props.size, "&direction=").concat(props.direction), {
56
+ headers: {}
57
+ })
58
+ .then(function (response) {
59
+ var result = response.data;
60
+ for (var i = 0; i < result.length; i++) {
61
+ result[i].deal = result[i].deal ? parseReservationDeal(result[i].deal) : undefined;
62
+ }
63
+ return result;
64
+ });
65
+ })];
66
+ });
67
+ });
68
+ };
69
+ /**
70
+ *
71
+ * @param props
72
+ * @throws invalid_guest_number, unavailable_day, closed_hour, discount_not_allowed
73
+ * @returns
74
+ */
75
+ ReservationsGuestAPIs.reserve = function (props) {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ return __generator(this, function (_a) {
78
+ return [2 /*return*/, RequestUtils.send(function () {
79
+ return axios.post(base + "/reservations/guest", {
80
+ guest: {
81
+ deviceId: props.guest.deviceId,
82
+ firstName: props.guest.firstName,
83
+ lastName: props.guest.lastName,
84
+ phone: props.guest.phone,
85
+ email: props.guest.email,
86
+ },
87
+ businessId: props.businessId,
88
+ datetime: format(props.datetime, "yyyy-MM-dd'T'HH:mm"),
89
+ persons: props.persons,
90
+ deal: props.deal,
91
+ notes: props.notes
92
+ }, {
93
+ headers: {
94
+ 'Content-Type': 'application/json'
95
+ }
96
+ })
97
+ .then(function (response) { return response.data; });
98
+ })];
99
+ });
100
+ });
101
+ };
102
+ /**
103
+ *
104
+ * @param props
105
+ * @throws closed_business
106
+ * @returns get closed days and discounts by business
107
+ */
108
+ ReservationsGuestAPIs.getDays = function (props) {
109
+ return __awaiter(this, void 0, void 0, function () {
110
+ return __generator(this, function (_a) {
111
+ return [2 /*return*/, RequestUtils.send(function () {
112
+ return axios.get(base + "/reservations/guest/days?business=".concat(props.businessId), { headers: {} })
113
+ .then(function (response) {
114
+ return response.data;
115
+ });
116
+ })];
117
+ });
118
+ });
119
+ };
120
+ /**
121
+ *
122
+ * @param props
123
+ * @throws closed_business, invalid_day, unavailable_slots
124
+ * @returns
125
+ */
126
+ ReservationsGuestAPIs.getHours = function (props) {
127
+ return __awaiter(this, void 0, void 0, function () {
128
+ return __generator(this, function (_a) {
129
+ return [2 /*return*/, RequestUtils.send(function () {
130
+ return axios.get(base + "/reservations/guest/hours?business=".concat(props.businessId, "&day=").concat(props.day), { headers: {} })
131
+ .then(function (response) {
132
+ return response.data;
133
+ });
134
+ })];
135
+ });
136
+ });
137
+ };
138
+ /**
139
+ *
140
+ * @param props
141
+ * @throws reservation_not_found, internal_error
142
+ * @returns
143
+ */
144
+ ReservationsGuestAPIs.get = function (props) {
145
+ return __awaiter(this, void 0, void 0, function () {
146
+ return __generator(this, function (_a) {
147
+ return [2 /*return*/, RequestUtils.send(function () {
148
+ return axios.get(base + "/reservations/guest/".concat(props.id), {
149
+ headers: {
150
+ 'Content-Type': 'application/json'
151
+ }
152
+ })
153
+ .then(function (response) {
154
+ var result = response.data;
155
+ result.deal = result.deal ? parseReservationDeal(result.deal) : undefined;
156
+ return result;
157
+ });
158
+ })];
159
+ });
160
+ });
161
+ };
162
+ /**
163
+ *
164
+ * @param props
165
+ * @throws invalid_datetime
166
+ * @returns
167
+ */
168
+ ReservationsGuestAPIs.getAvailableDeals = function (props) {
169
+ return __awaiter(this, void 0, void 0, function () {
170
+ return __generator(this, function (_a) {
171
+ return [2 /*return*/, RequestUtils.send(function () {
172
+ return axios.get(base + "/reservations/guest/deals/available?business=".concat(props.businessId, "&date=").concat(props.date, "&time=").concat(props.time), { headers: {} })
173
+ .then(function (response) {
174
+ return response.data;
175
+ });
176
+ })];
177
+ });
178
+ });
179
+ };
180
+ /**
181
+ *
182
+ * @param id
183
+ * @param token
184
+ * @throws not_found, internal_error, unauthorized_action
185
+ * @returns
186
+ */
187
+ ReservationsGuestAPIs.cancel = function (id, device_id) {
188
+ return __awaiter(this, void 0, void 0, function () {
189
+ return __generator(this, function (_a) {
190
+ return [2 /*return*/, RequestUtils.send(function () {
191
+ return axios.patch(base + "/reservations/guest/".concat(id, "/cancel?device_id=").concat(device_id), {}, {})
192
+ .then(function (response) { return response.data; });
193
+ })];
194
+ });
195
+ });
196
+ };
197
+ return ReservationsGuestAPIs;
198
+ }());
199
+ export { ReservationsGuestAPIs };
@@ -0,0 +1,32 @@
1
+ import { Level } from "../../../enum";
2
+ import { LocalDate, LocalTime } from "../../../types";
3
+ export interface ReservationResponse {
4
+ id: string;
5
+ }
6
+ export interface DaysInfo {
7
+ from: LocalDate;
8
+ to: LocalDate;
9
+ closed: LocalDate[];
10
+ discounts: Record<LocalDate, number>;
11
+ }
12
+ export interface HourInfo {
13
+ time: LocalTime;
14
+ discount: number | undefined;
15
+ }
16
+ export interface AvailableDeals {
17
+ discount: AvailableDiscount | undefined;
18
+ cashbackApply: AvailableCashbackApply | undefined;
19
+ cashbackEarn: AvailableCashbackEarn | undefined;
20
+ }
21
+ export interface AvailableDiscount {
22
+ rate: number;
23
+ terms: string[];
24
+ }
25
+ export interface AvailableCashbackApply {
26
+ max: number;
27
+ value: number;
28
+ }
29
+ export interface AvailableCashbackEarn {
30
+ rate: number;
31
+ level: Level;
32
+ }