@kiminix/tp-client 1.22.0 → 1.23.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 +17 -0
- package/dist/business/types/get-id.d.ts +7 -5
- package/dist/cashback/admin/admin-apis.d.ts +7 -0
- package/dist/{menus/preset/user-apis.js → cashback/admin/admin-apis.js} +37 -33
- package/dist/cashback/admin/types/resp-get-cashback.d.ts +12 -0
- package/dist/cashback/index.d.ts +4 -0
- package/dist/cashback/index.js +6 -0
- package/dist/cashback/user/types/resp-get-cashback.d.ts +10 -0
- package/dist/cashback/user/user-apis.d.ts +7 -0
- package/dist/cashback/user/user-apis.js +87 -0
- package/dist/deals/types.d.ts +2 -1
- package/dist/enum.d.ts +11 -5
- package/dist/enum.js +14 -7
- package/dist/index.d.ts +5 -8
- package/dist/index.js +9 -9
- package/dist/menus/preset/index.d.ts +7 -0
- package/dist/menus/preset/index.js +9 -0
- package/dist/reservations/{admin-apis.d.ts → admin/admin-apis.d.ts} +11 -5
- package/dist/reservations/{admin-apis.js → admin/admin-apis.js} +42 -4
- package/dist/reservations/admin/types/get-id.d.ts +4 -0
- package/dist/reservations/index.d.ts +11 -0
- package/dist/reservations/index.js +14 -0
- package/dist/reservations/shared/reservation-deal.d.ts +19 -0
- package/dist/reservations/shared/reservation-deal.js +13 -0
- package/dist/reservations/{types/shared.d.ts → shared/reservation.d.ts} +7 -6
- package/dist/reservations/{types/user/reservation-preview.d.ts → user/types/resp-reservation-preview.d.ts} +4 -2
- package/dist/reservations/user/types/resp-reservation-preview.js +2 -0
- package/dist/reservations/user/types/resp-reservation-settings.d.ts +22 -0
- package/dist/reservations/user/types/resp-save-reservation.d.ts +3 -0
- package/dist/reservations/user/user-apis.d.ts +21 -7
- package/dist/reservations/user/user-apis.js +71 -5
- package/dist/statistics/admin-apis.d.ts +2 -2
- package/dist/statistics/admin-apis.js +37 -30
- package/dist/statistics/types/menus-statistic.d.ts +2 -0
- package/dist/utils/request-utils.d.ts +3 -0
- package/dist/utils/request-utils.js +81 -0
- package/package.json +3 -1
- package/dist/deals/types/get-id.d.ts +0 -49
- package/dist/deals/types/get-pages.d.ts +0 -30
- package/dist/menus/discounts/admin-apis.d.ts +0 -7
- package/dist/menus/discounts/admin-apis.js +0 -90
- package/dist/menus/discounts/types/update-discount.d.ts +0 -9
- package/dist/menus/preset/types/available-menu.d.ts +0 -12
- package/dist/menus/preset/user-apis.d.ts +0 -16
- package/dist/menus/types/preset-menu.d.ts +0 -22
- package/dist/reservations/types/admin/get-page.js +0 -1
- package/dist/reservations/types/admin/patch-status.d.ts +0 -6
- package/dist/reservations/types/admin/patch-status.js +0 -1
- package/dist/reservations/types/admin/reserve-onmenu.d.ts +0 -17
- package/dist/reservations/types/admin/reserve-onmenu.js +0 -1
- package/dist/reservations/types/shared.js +0 -1
- package/dist/reservations/types/types.d.ts +0 -27
- package/dist/reservations/types/types.js +0 -2
- package/dist/reservations/types/user/get-id.d.ts +0 -4
- package/dist/reservations/types/user/get-id.js +0 -1
- package/dist/reservations/types/user/get-page.d.ts +0 -7
- package/dist/reservations/types/user/get-page.js +0 -1
- package/dist/reservations/types/user/reservation-preview.js +0 -1
- package/dist/reservations/types/user/reserve-onmenu.d.ts +0 -13
- package/dist/reservations/types/user/reserve-onmenu.js +0 -1
- package/dist/reservations/types/user/reserve-response.d.ts +0 -3
- package/dist/reservations/types/user/reserve-response.js +0 -1
- package/dist/reservations/types.d.ts +0 -27
- package/dist/reservations/user/types.d.ts +0 -31
- package/dist/reservations/user-apis.d.ts +0 -30
- package/dist/reservations/user-apis.js +0 -206
- /package/dist/{deals/types/get-id.js → cashback/admin/types/resp-get-cashback.js} +0 -0
- /package/dist/{deals/types/get-pages.js → cashback/user/types/resp-get-cashback.js} +0 -0
- /package/dist/reservations/{types/admin → admin/types}/get-available-transitions.d.ts +0 -0
- /package/dist/reservations/{types/admin → admin/types}/get-available-transitions.js +0 -0
- /package/dist/reservations/{types/admin → admin/types}/get-id.js +0 -0
- /package/dist/{menus/discounts/types/update-discount.js → reservations/shared/reservation.js} +0 -0
- /package/dist/reservations/{types/admin/get-id.d.ts → user/types/req-get-by-id.d.ts} +0 -0
- /package/dist/reservations/user/{types.js → types/req-get-by-id.js} +0 -0
- /package/dist/reservations/{types/admin/get-page.d.ts → user/types/req-get-page-reservation.d.ts} +0 -0
- /package/dist/reservations/{types.js → user/types/req-get-page-reservation.js} +0 -0
- /package/dist/{menus/preset/types/available-menu.js → reservations/user/types/resp-reservation-settings.js} +0 -0
- /package/dist/{menus/types/preset-menu.js → reservations/user/types/resp-save-reservation.js} +0 -0
|
@@ -1,90 +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
|
-
import { Left, Right } from "purify-ts";
|
|
40
|
-
// preset-menus module admin APIs
|
|
41
|
-
var PresetMenusDiscountAdminAPIs = /** @class */ (function () {
|
|
42
|
-
function PresetMenusDiscountAdminAPIs() {
|
|
43
|
-
}
|
|
44
|
-
PresetMenusDiscountAdminAPIs.update = function (_a) {
|
|
45
|
-
var token = _a.token, id = _a.id, // preset menu id
|
|
46
|
-
day = _a.day, isAvailable = _a.isAvailable, adultPrice = _a.adultPrice, childPrice = _a.childPrice, minBookingTotal = _a.minBookingTotal;
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
return __generator(this, function (_b) {
|
|
49
|
-
switch (_b.label) {
|
|
50
|
-
case 0: return [4 /*yield*/, axios.patch(base + "/preset-menus/admin/discounts", {
|
|
51
|
-
id: id,
|
|
52
|
-
day: day,
|
|
53
|
-
isAvailable: isAvailable,
|
|
54
|
-
adultPrice: adultPrice,
|
|
55
|
-
childPrice: childPrice,
|
|
56
|
-
minBookingTotal: minBookingTotal
|
|
57
|
-
}, {
|
|
58
|
-
headers: {
|
|
59
|
-
'Authorization': "".concat(token)
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
.then(function (response) {
|
|
63
|
-
return Right(response.data);
|
|
64
|
-
})
|
|
65
|
-
// handled error
|
|
66
|
-
.catch(function (error) {
|
|
67
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
68
|
-
// unavailable_business
|
|
69
|
-
// unauthorized
|
|
70
|
-
// unauthenticated
|
|
71
|
-
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401)
|
|
72
|
-
return (Left(new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
|
|
73
|
-
else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) == 404)
|
|
74
|
-
return (Left(new Error("not_found")));
|
|
75
|
-
//invalid_child_discount
|
|
76
|
-
//invalid_adult_discount
|
|
77
|
-
//unauthorized_disable_discount
|
|
78
|
-
else if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) == 400)
|
|
79
|
-
return (Left(new Error((_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.code)));
|
|
80
|
-
else
|
|
81
|
-
throw new Error('internal_error', error);
|
|
82
|
-
})];
|
|
83
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
return PresetMenusDiscountAdminAPIs;
|
|
89
|
-
}());
|
|
90
|
-
export { PresetMenusDiscountAdminAPIs };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Price } from "./types";
|
|
2
|
-
export interface Discount {
|
|
3
|
-
price: Price;
|
|
4
|
-
minBookingTotal: number | undefined;
|
|
5
|
-
}
|
|
6
|
-
export interface AvailablePresetMenu {
|
|
7
|
-
id: string;
|
|
8
|
-
title: string;
|
|
9
|
-
price: Price;
|
|
10
|
-
minBookingTotal: number | undefined;
|
|
11
|
-
discount: Discount | undefined;
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { LocalDate } from "../../types";
|
|
2
|
-
import { AvailablePresetMenu } from "./types/available-menu";
|
|
3
|
-
import { Either } from "purify-ts";
|
|
4
|
-
export declare class PresetMenusUserAPIs {
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param businessId
|
|
8
|
-
* @param date
|
|
9
|
-
* @returns available preset menus for the given business and date. can fail with bellow errors code: unauthenticated, past_day, expired_licence, internal_error
|
|
10
|
-
*/
|
|
11
|
-
static getAvailableMenus(props: {
|
|
12
|
-
token?: string;
|
|
13
|
-
businessId: string;
|
|
14
|
-
date: LocalDate;
|
|
15
|
-
}): Promise<Either<Error, AvailablePresetMenu[]>>;
|
|
16
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Available, LocalDate } from "../../types";
|
|
2
|
-
export interface Price {
|
|
3
|
-
adult: number;
|
|
4
|
-
child?: number;
|
|
5
|
-
}
|
|
6
|
-
export interface DailyDiscount {
|
|
7
|
-
isAvailable: boolean;
|
|
8
|
-
price: Price;
|
|
9
|
-
minBookingTotal?: number;
|
|
10
|
-
minPublishedDiscount: number;
|
|
11
|
-
canDisableAfter?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface PresetMenu {
|
|
14
|
-
id: string;
|
|
15
|
-
available?: Available;
|
|
16
|
-
excludedDays?: LocalDate[];
|
|
17
|
-
title: string;
|
|
18
|
-
description: string;
|
|
19
|
-
price: Price;
|
|
20
|
-
minBookingTotal?: number;
|
|
21
|
-
discount?: Map<LocalDate, DailyDiscount>;
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface ReserveOnMenuResponse {
|
|
2
|
-
id: string;
|
|
3
|
-
}
|
|
4
|
-
export interface ReserveOnMenuRequest {
|
|
5
|
-
token?: string;
|
|
6
|
-
id: string;
|
|
7
|
-
user: {
|
|
8
|
-
firstname: string;
|
|
9
|
-
lastname: string;
|
|
10
|
-
phone?: string;
|
|
11
|
-
};
|
|
12
|
-
date: Date;
|
|
13
|
-
time: Date;
|
|
14
|
-
children: number;
|
|
15
|
-
adults: number;
|
|
16
|
-
notes?: string;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { TimelineDirection } from "../../enum";
|
|
2
|
-
export interface ReservationPreviewResponse {
|
|
3
|
-
datetime: Date;
|
|
4
|
-
total: number;
|
|
5
|
-
totalBeforeDeal: number | undefined;
|
|
6
|
-
commands: CommandPreview[];
|
|
7
|
-
}
|
|
8
|
-
export interface CommandPreview {
|
|
9
|
-
menuId: string;
|
|
10
|
-
title: string;
|
|
11
|
-
adult: CommandEntryPreview;
|
|
12
|
-
child: CommandEntryPreview | undefined;
|
|
13
|
-
}
|
|
14
|
-
export interface CommandEntryPreview {
|
|
15
|
-
number: number;
|
|
16
|
-
price: number;
|
|
17
|
-
priceBeforeDeal: number | undefined;
|
|
18
|
-
}
|
|
19
|
-
export interface ReservationResponse {
|
|
20
|
-
id: string;
|
|
21
|
-
}
|
|
22
|
-
export interface GetPageRequest {
|
|
23
|
-
token?: string;
|
|
24
|
-
page: number;
|
|
25
|
-
size: number;
|
|
26
|
-
direction: TimelineDirection;
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DealKind } from "../../../enum";
|
|
2
|
-
export interface ReserveOnMenuResponse {
|
|
3
|
-
id: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ReserveOnMenuRequest {
|
|
6
|
-
token?: string;
|
|
7
|
-
id: string;
|
|
8
|
-
date: Date;
|
|
9
|
-
time: Date;
|
|
10
|
-
children: number;
|
|
11
|
-
adults: number;
|
|
12
|
-
dealKind?: DealKind;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { TimelineDirection } from "../enum";
|
|
2
|
-
export interface ReservationPreviewResponse {
|
|
3
|
-
datetime: Date;
|
|
4
|
-
total: number;
|
|
5
|
-
totalBeforeDeal: number | undefined;
|
|
6
|
-
commands: CommandPreview[];
|
|
7
|
-
}
|
|
8
|
-
export interface CommandPreview {
|
|
9
|
-
menuId: string;
|
|
10
|
-
title: string;
|
|
11
|
-
adult: CommandEntryPreview;
|
|
12
|
-
child: CommandEntryPreview | undefined;
|
|
13
|
-
}
|
|
14
|
-
export interface CommandEntryPreview {
|
|
15
|
-
number: number;
|
|
16
|
-
price: number;
|
|
17
|
-
priceBeforeDeal: number | undefined;
|
|
18
|
-
}
|
|
19
|
-
export interface ReservationResponse {
|
|
20
|
-
id: string;
|
|
21
|
-
}
|
|
22
|
-
export interface GetPageRequest {
|
|
23
|
-
token?: string;
|
|
24
|
-
page: number;
|
|
25
|
-
size: number;
|
|
26
|
-
direction: TimelineDirection;
|
|
27
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { TimelineDirection } from "../../enum";
|
|
2
|
-
export interface ReservationPreviewResponse {
|
|
3
|
-
datetime: Date;
|
|
4
|
-
total: number;
|
|
5
|
-
totalBeforeDeal: number;
|
|
6
|
-
commands: CommandPreview[];
|
|
7
|
-
}
|
|
8
|
-
export interface CommandPreview {
|
|
9
|
-
menuId: string;
|
|
10
|
-
title: string;
|
|
11
|
-
adult: CommandEntryPreview;
|
|
12
|
-
child: CommandEntryPreview | undefined;
|
|
13
|
-
}
|
|
14
|
-
export interface CommandEntryPreview {
|
|
15
|
-
number: number;
|
|
16
|
-
price: number;
|
|
17
|
-
priceBeforeDeal: number;
|
|
18
|
-
}
|
|
19
|
-
export interface ReservationResponse {
|
|
20
|
-
id: string;
|
|
21
|
-
}
|
|
22
|
-
export interface GetPageRequest {
|
|
23
|
-
token?: string;
|
|
24
|
-
page: number;
|
|
25
|
-
size: number;
|
|
26
|
-
direction: TimelineDirection;
|
|
27
|
-
}
|
|
28
|
-
export interface GetByIdRequest {
|
|
29
|
-
token?: string;
|
|
30
|
-
id: string;
|
|
31
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Reservation } from "./types/shared";
|
|
2
|
-
import { GetByIdRequest } from "./types/user/get-id";
|
|
3
|
-
import { DealKind } from "../enum";
|
|
4
|
-
import { GetPageRequest, ReservationPreviewResponse, ReservationResponse } from "./types";
|
|
5
|
-
export declare class ReservationsUserAPIs {
|
|
6
|
-
static getPage({ token, page, size, direction }: GetPageRequest): Promise<Reservation[]>;
|
|
7
|
-
static get({ id, token }: GetByIdRequest): Promise<Reservation>;
|
|
8
|
-
static cancel(id: string, token?: string): Promise<any>;
|
|
9
|
-
static reserve(props: {
|
|
10
|
-
token?: string;
|
|
11
|
-
id: string;
|
|
12
|
-
date: Date;
|
|
13
|
-
time: Date;
|
|
14
|
-
children: number;
|
|
15
|
-
adults: number;
|
|
16
|
-
dealKind?: DealKind;
|
|
17
|
-
}): Promise<ReservationResponse>;
|
|
18
|
-
static preview(props: {
|
|
19
|
-
token?: string;
|
|
20
|
-
businessId: string;
|
|
21
|
-
date: Date;
|
|
22
|
-
time: Date;
|
|
23
|
-
dealKind?: DealKind;
|
|
24
|
-
commands: {
|
|
25
|
-
menuId: string;
|
|
26
|
-
adult: number;
|
|
27
|
-
child?: number;
|
|
28
|
-
}[];
|
|
29
|
-
}): Promise<ReservationPreviewResponse>;
|
|
30
|
-
}
|
|
@@ -1,206 +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 { format } from "date-fns";
|
|
39
|
-
import { base } from "../constants";
|
|
40
|
-
import { ErrorWithMetadata } from "../types";
|
|
41
|
-
var ReservationsUserAPIs = /** @class */ (function () {
|
|
42
|
-
function ReservationsUserAPIs() {
|
|
43
|
-
}
|
|
44
|
-
ReservationsUserAPIs.getPage = function (_a) {
|
|
45
|
-
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;
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
return __generator(this, function (_d) {
|
|
48
|
-
switch (_d.label) {
|
|
49
|
-
case 0: return [4 /*yield*/, axios.get(base + "/reservations/user?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
|
|
50
|
-
headers: {
|
|
51
|
-
'Authorization': "".concat(token)
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
.then(function (response) { return response.data; })
|
|
55
|
-
.catch(function (error) {
|
|
56
|
-
// handle error
|
|
57
|
-
if (error.response.status == 401)
|
|
58
|
-
throw new Error("unauthorized");
|
|
59
|
-
else
|
|
60
|
-
throw new Error('internal_error', error);
|
|
61
|
-
})];
|
|
62
|
-
case 1: return [2 /*return*/, _d.sent()];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
ReservationsUserAPIs.get = function (_a) {
|
|
68
|
-
var id = _a.id, token = _a.token;
|
|
69
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
return __generator(this, function (_b) {
|
|
71
|
-
switch (_b.label) {
|
|
72
|
-
case 0: return [4 /*yield*/, axios.get(base + "/reservations/user/".concat(id), {
|
|
73
|
-
headers: {
|
|
74
|
-
'Authorization': "".concat(token),
|
|
75
|
-
'Content-Type': 'application/json'
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
.then(function (response) { return response.data; })
|
|
79
|
-
.catch(function (error) {
|
|
80
|
-
// handle error
|
|
81
|
-
if (error.response.status == 401)
|
|
82
|
-
throw new Error("unauthorized");
|
|
83
|
-
else if (error.response.status == 404)
|
|
84
|
-
throw new Error("not_found");
|
|
85
|
-
else
|
|
86
|
-
throw new Error('internal_error', error);
|
|
87
|
-
})];
|
|
88
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
ReservationsUserAPIs.cancel = function (id, token) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
switch (_a.label) {
|
|
97
|
-
case 0: return [4 /*yield*/, axios.patch(base + "/reservations/user/".concat(id, "/cancel"), {}, {
|
|
98
|
-
headers: {
|
|
99
|
-
'Authorization': "".concat(token)
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
.then(function (response) { return response.data; })
|
|
103
|
-
.catch(function (error) {
|
|
104
|
-
// handle error
|
|
105
|
-
if (error.response.status == 401)
|
|
106
|
-
throw new Error("unauthorized");
|
|
107
|
-
else if (error.response.status == 404)
|
|
108
|
-
throw new Error("not_found");
|
|
109
|
-
else if (error.response.status == 400) {
|
|
110
|
-
//reservation_not_found
|
|
111
|
-
var response = error.response.data;
|
|
112
|
-
throw new Error(response.code);
|
|
113
|
-
}
|
|
114
|
-
else
|
|
115
|
-
throw new Error('internal_error', error);
|
|
116
|
-
})];
|
|
117
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
ReservationsUserAPIs.reserve = function (props) {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
-
var datetime;
|
|
125
|
-
return __generator(this, function (_a) {
|
|
126
|
-
switch (_a.label) {
|
|
127
|
-
case 0:
|
|
128
|
-
datetime = new Date(props.date);
|
|
129
|
-
datetime.setHours(props.time.getHours(), props.time.getMinutes());
|
|
130
|
-
return [4 /*yield*/, axios.post(base + "/reservations/user", {
|
|
131
|
-
id: props.id,
|
|
132
|
-
datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
133
|
-
children: props.children,
|
|
134
|
-
adults: props.adults,
|
|
135
|
-
dealKind: props.dealKind
|
|
136
|
-
}, {
|
|
137
|
-
headers: {
|
|
138
|
-
'Authorization': "".concat(props.token),
|
|
139
|
-
'Content-Type': 'application/json'
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
.then(function (response) { return response.data; })
|
|
143
|
-
.catch(function (error) {
|
|
144
|
-
// handle error
|
|
145
|
-
if (error.response.status == 401)
|
|
146
|
-
throw new Error("unauthorized");
|
|
147
|
-
else if (error.response.status == 404)
|
|
148
|
-
throw new Error("not_found");
|
|
149
|
-
else if (error.response.status == 400) {
|
|
150
|
-
//banned_user
|
|
151
|
-
//unavailable_day
|
|
152
|
-
//unavailable_deal
|
|
153
|
-
//min_booking_amount
|
|
154
|
-
//date_already_used
|
|
155
|
-
var response = error.response.data;
|
|
156
|
-
throw new Error(response.code);
|
|
157
|
-
}
|
|
158
|
-
else
|
|
159
|
-
throw new Error('internal_error', error);
|
|
160
|
-
})];
|
|
161
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
ReservationsUserAPIs.preview = function (props) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
-
var datetime;
|
|
169
|
-
return __generator(this, function (_a) {
|
|
170
|
-
switch (_a.label) {
|
|
171
|
-
case 0:
|
|
172
|
-
datetime = new Date(props.date);
|
|
173
|
-
datetime.setHours(props.time.getHours(), props.time.getMinutes());
|
|
174
|
-
return [4 /*yield*/, axios.post(base + "/reservations/user/preview", {
|
|
175
|
-
businessId: props.businessId,
|
|
176
|
-
datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
177
|
-
dealKind: props.dealKind,
|
|
178
|
-
commands: props.commands
|
|
179
|
-
}, {
|
|
180
|
-
headers: {
|
|
181
|
-
'Authorization': "".concat(props.token),
|
|
182
|
-
'Content-Type': 'application/json'
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
.then(function (response) { return response.data; })
|
|
186
|
-
.catch(function (error) {
|
|
187
|
-
// handle error
|
|
188
|
-
if (error.response.status == 401)
|
|
189
|
-
throw new Error("unauthorized");
|
|
190
|
-
else if (error.response.status == 400) {
|
|
191
|
-
//expired_preview
|
|
192
|
-
//min_booking_amount
|
|
193
|
-
var response = error.response.data;
|
|
194
|
-
throw new ErrorWithMetadata(response.code, response.metadata);
|
|
195
|
-
}
|
|
196
|
-
else
|
|
197
|
-
throw new Error('internal_error', error);
|
|
198
|
-
})];
|
|
199
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
return ReservationsUserAPIs;
|
|
205
|
-
}());
|
|
206
|
-
export { ReservationsUserAPIs };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{menus/discounts/types/update-discount.js → reservations/shared/reservation.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/reservations/{types/admin/get-page.d.ts → user/types/req-get-page-reservation.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{menus/types/preset-menu.js → reservations/user/types/resp-save-reservation.js}
RENAMED
|
File without changes
|