@kiminix/tp-client 1.34.0 → 1.36.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.
- package/dist/business/types/get-all.d.ts +3 -19
- package/dist/business/types/get-id.d.ts +7 -16
- package/dist/business/types/shared.d.ts +3 -13
- package/dist/cashback/index.d.ts +0 -2
- package/dist/cashback/index.js +0 -3
- package/dist/cashback/user/types/resp-get-cashback.d.ts +14 -2
- package/dist/cashback/user/user-apis.d.ts +7 -2
- package/dist/cashback/user/user-apis.js +14 -36
- package/dist/deals/apis.d.ts +0 -1
- package/dist/deals/apis.js +12 -39
- package/dist/deals/index.d.ts +1 -0
- package/dist/deals/index.js +2 -0
- package/dist/deals/types.d.ts +7 -15
- package/dist/discounts/admin/admin-apis.d.ts +36 -0
- package/dist/{menus/preset/apis.js → discounts/admin/admin-apis.js} +57 -24
- package/dist/discounts/admin/types/get-available-datetimes.d.ts +7 -0
- package/dist/discounts/index.d.ts +2 -0
- package/dist/discounts/index.js +3 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -4
- package/dist/reservations/admin/admin-apis.d.ts +55 -18
- package/dist/reservations/admin/admin-apis.js +91 -48
- package/dist/reservations/admin/types.d.ts +19 -0
- package/dist/reservations/index.d.ts +3 -5
- package/dist/reservations/index.js +3 -5
- package/dist/reservations/shared/reservation-deal.d.ts +6 -5
- package/dist/reservations/shared/reservation.d.ts +7 -19
- package/dist/reservations/user/guest-apis.d.ts +84 -0
- package/dist/reservations/user/guest-apis.js +199 -0
- package/dist/reservations/user/types/response-api.d.ts +32 -0
- package/dist/reservations/user/user-apis.d.ts +43 -59
- package/dist/reservations/user/user-apis.js +58 -235
- package/dist/types.d.ts +1 -0
- package/dist/utils/date-utils.d.ts +2 -0
- package/dist/utils/date-utils.js +7 -1
- package/dist/utils/reservation-utils.d.ts +2 -0
- package/dist/utils/reservation-utils.js +6 -0
- package/package.json +2 -2
- package/dist/cashback/admin/admin-apis.d.ts +0 -7
- package/dist/cashback/admin/admin-apis.js +0 -85
- package/dist/cashback/admin/types/resp-get-cashback.d.ts +0 -12
- package/dist/menus/preset/admin-apis.d.ts +0 -8
- package/dist/menus/preset/admin-apis.js +0 -146
- package/dist/menus/preset/apis.d.ts +0 -11
- package/dist/menus/preset/discounts/admin-apis.d.ts +0 -7
- package/dist/menus/preset/discounts/admin-apis.js +0 -90
- package/dist/menus/preset/discounts/types/update-discount.d.ts +0 -9
- package/dist/menus/preset/index.d.ts +0 -7
- package/dist/menus/preset/index.js +0 -9
- package/dist/menus/preset/types/preset-menu.d.ts +0 -19
- package/dist/menus/preset/types/preset-menu.js +0 -1
- package/dist/menus/preset/types/special-discounts.d.ts +0 -12
- package/dist/menus/preset/types/special-discounts.js +0 -1
- package/dist/menus/preset/types/types.d.ts +0 -4
- package/dist/menus/preset/types/update-preset-menu.d.ts +0 -12
- package/dist/menus/preset/types/update-preset-menu.js +0 -1
- package/dist/reservations/admin/types/get-available-transitions.d.ts +0 -4
- package/dist/reservations/admin/types/get-available-transitions.js +0 -1
- package/dist/reservations/admin/types/get-id.d.ts +0 -4
- package/dist/reservations/admin/types/get-id.js +0 -1
- package/dist/reservations/user/types/resp-reservation-settings.d.ts +0 -22
- package/dist/reservations/user/types/resp-reservation-settings.js +0 -1
- package/dist/reservations/user/types/resp-save-reservation.d.ts +0 -3
- package/dist/reservations/user/types/resp-save-reservation.js +0 -1
- package/dist/utils/menu-utils.d.ts +0 -10
- package/dist/utils/menu-utils.js +0 -49
- /package/dist/{cashback/admin/types/resp-get-cashback.js → discounts/admin/types/get-available-datetimes.js} +0 -0
- /package/dist/{menus/preset/types → reservations/admin}/types.js +0 -0
- /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
|
-
|
|
168
|
-
|
|
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 (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
192
|
-
}
|
|
202
|
+
})
|
|
203
|
+
.then(function (_) { return undefined; });
|
|
204
|
+
})];
|
|
193
205
|
});
|
|
194
206
|
});
|
|
195
207
|
};
|
|
196
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
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/
|
|
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/
|
|
8
|
-
export * from "./admin/types
|
|
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/
|
|
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/
|
|
8
|
+
export { ReservationsGuestAPIs } from './user/guest-apis';
|
|
10
9
|
// admin module
|
|
11
|
-
export * from "./admin/types
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
total: number;
|
|
47
|
-
totalBeforeDeal?: number;
|
|
48
|
-
deposit?: number;
|
|
34
|
+
persons: number;
|
|
35
|
+
total: number | undefined;
|
|
49
36
|
deal: ReservationDeal | undefined;
|
|
50
|
-
|
|
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
|
+
}
|