@kiminix/tp-client 1.4.0 → 1.6.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/admin-apis.d.ts +4 -0
- package/dist/business/admin-apis.js +72 -0
- package/dist/business/apis.js +9 -16
- package/dist/business/types/get-id.d.ts +1 -0
- package/dist/iam/admin-apis.js +1 -1
- package/dist/iam/user-apis.d.ts +1 -1
- package/dist/iam/user-apis.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/menus/preset/admin-apis.d.ts +8 -0
- package/dist/menus/preset/admin-apis.js +142 -0
- package/dist/menus/preset/apis.d.ts +4 -0
- package/dist/menus/preset/apis.js +61 -0
- package/dist/menus/preset/types/get-by-business.d.ts +20 -0
- package/dist/menus/preset/types/get-by-business.js +1 -0
- package/dist/menus/preset/types/update-preset-menu.d.ts +12 -0
- package/dist/menus/preset/types/update-preset-menu.js +1 -0
- package/dist/reservations/admin-apis.js +45 -45
- package/dist/reservations/user-apis.js +38 -40
- package/dist/utils/menu-utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
// business module admin APIs
|
|
40
|
+
var BusinessAdminAPIs = /** @class */ (function () {
|
|
41
|
+
function BusinessAdminAPIs() {
|
|
42
|
+
}
|
|
43
|
+
BusinessAdminAPIs.get = function (token) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/business/admin", {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) {
|
|
53
|
+
var data = response.data;
|
|
54
|
+
data.createdAt = new Date(data.createdAt);
|
|
55
|
+
// data.availableUntil = new Date(data.availableUntil)
|
|
56
|
+
return data;
|
|
57
|
+
})
|
|
58
|
+
.catch(function (error) {
|
|
59
|
+
// handle error
|
|
60
|
+
if (error.response.status == 401)
|
|
61
|
+
throw new Error("unauthorized");
|
|
62
|
+
else
|
|
63
|
+
throw new Error('internal_error', error);
|
|
64
|
+
})];
|
|
65
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return BusinessAdminAPIs;
|
|
71
|
+
}());
|
|
72
|
+
export { BusinessAdminAPIs };
|
package/dist/business/apis.js
CHANGED
|
@@ -57,22 +57,15 @@ var BusinessAPIs = /** @class */ (function () {
|
|
|
57
57
|
};
|
|
58
58
|
BusinessAPIs.get = function (identifier) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return data;
|
|
70
|
-
})];
|
|
71
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
72
|
-
case 2:
|
|
73
|
-
_a = _b.sent();
|
|
74
|
-
throw new Error("internal_error");
|
|
75
|
-
case 3: return [2 /*return*/];
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0: return [4 /*yield*/, axios.get(base + "/business/".concat(identifier))
|
|
63
|
+
.then(function (response) {
|
|
64
|
+
var data = response.data;
|
|
65
|
+
data.createdAt = new Date(data.createdAt);
|
|
66
|
+
return data;
|
|
67
|
+
})];
|
|
68
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
76
69
|
}
|
|
77
70
|
});
|
|
78
71
|
});
|
package/dist/iam/admin-apis.js
CHANGED
|
@@ -44,7 +44,7 @@ var IamAdminAPIs = /** @class */ (function () {
|
|
|
44
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
45
|
return __generator(this, function (_a) {
|
|
46
46
|
switch (_a.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, axios.post(base + "/iam/
|
|
47
|
+
case 0: return [4 /*yield*/, axios.post(base + "/iam/admin/sign-in", { identifier: identifier, password: password }, {
|
|
48
48
|
headers: {
|
|
49
49
|
// 'Authorization': `${user.token}`,
|
|
50
50
|
'Content-Type': 'application/json'
|
package/dist/iam/user-apis.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare class IamUserAPIs {
|
|
|
11
11
|
static signUpValidate({ phone, email, password }: SignUpValidateRequest): Promise<Either<Error, void>>;
|
|
12
12
|
static me(token?: string): Promise<MeResponse>;
|
|
13
13
|
static resetPassword({ code, email, password }: ResetPasswordRequest): Promise<Either<Error, void>>;
|
|
14
|
-
static updateProfile({ token, firstName, lastName, phone, email, birthday, gender, password
|
|
14
|
+
static updateProfile({ token, firstName, lastName, phone, email, birthday, gender, password }: UpdateProfileRequest): Promise<Either<Error, UpdateProfileResponse>>;
|
|
15
15
|
static validatePhone(token: string | undefined, phone: string, code: string): Promise<Either<Error, void>>;
|
|
16
16
|
}
|
package/dist/iam/user-apis.js
CHANGED
|
@@ -192,7 +192,7 @@ var IamUserAPIs = /** @class */ (function () {
|
|
|
192
192
|
});
|
|
193
193
|
};
|
|
194
194
|
IamUserAPIs.updateProfile = function (_a) {
|
|
195
|
-
var token = _a.token, firstName = _a.firstName, lastName = _a.lastName, phone = _a.phone, email = _a.email, birthday = _a.birthday, gender = _a.gender,
|
|
195
|
+
var token = _a.token, firstName = _a.firstName, lastName = _a.lastName, phone = _a.phone, email = _a.email, birthday = _a.birthday, gender = _a.gender, password = _a.password;
|
|
196
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
197
197
|
return __generator(this, function (_b) {
|
|
198
198
|
switch (_b.label) {
|
|
@@ -205,7 +205,7 @@ var IamUserAPIs = /** @class */ (function () {
|
|
|
205
205
|
email: email,
|
|
206
206
|
birthday: birthday,
|
|
207
207
|
gender: gender,
|
|
208
|
-
password:
|
|
208
|
+
password: password
|
|
209
209
|
}, {
|
|
210
210
|
headers: {
|
|
211
211
|
'Authorization': "".concat(token),
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { IamAdminAPIs } from './iam/admin-apis';
|
|
|
4
4
|
export { IamUserAPIs } from './iam/user-apis';
|
|
5
5
|
export { NotifyAPIs } from './notify/apis';
|
|
6
6
|
export { SitemapAPIs } from './sitemap/apis';
|
|
7
|
-
export { MenusAPIs } from './menus/apis';
|
|
7
|
+
export { PresetMenusAPIs as MenusAPIs } from './menus/preset/apis';
|
|
8
8
|
export { ReservationsUserAPIs } from './reservations/user-apis';
|
|
9
9
|
export { ReservationsAdminAPIs } from './reservations/admin-apis';
|
|
10
10
|
export { MenuUtils } from './utils/menu-utils';
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { IamAdminAPIs } from './iam/admin-apis';
|
|
|
4
4
|
export { IamUserAPIs } from './iam/user-apis';
|
|
5
5
|
export { NotifyAPIs } from './notify/apis';
|
|
6
6
|
export { SitemapAPIs } from './sitemap/apis';
|
|
7
|
-
export { MenusAPIs } from './menus/apis';
|
|
7
|
+
export { PresetMenusAPIs as MenusAPIs } from './menus/preset/apis';
|
|
8
8
|
export { ReservationsUserAPIs } from './reservations/user-apis';
|
|
9
9
|
export { ReservationsAdminAPIs } from './reservations/admin-apis';
|
|
10
10
|
//
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PresetMenu } from "./types/get-by-business";
|
|
2
|
+
import { UpdatePresetMenuRequest } from "./types/update-preset-menu";
|
|
3
|
+
import { Either } from "purify-ts";
|
|
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
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
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 PresetMenusAdminAPIs = /** @class */ (function () {
|
|
42
|
+
function PresetMenusAdminAPIs() {
|
|
43
|
+
}
|
|
44
|
+
PresetMenusAdminAPIs.getByBusiness = function (token) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/admin", {
|
|
49
|
+
headers: {
|
|
50
|
+
'Authorization': "".concat(token)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.then(function (response) {
|
|
54
|
+
return response.data;
|
|
55
|
+
})
|
|
56
|
+
.catch(function (error) {
|
|
57
|
+
var _a;
|
|
58
|
+
// handle error
|
|
59
|
+
if (error.response.status == 401) {
|
|
60
|
+
// unauthorized
|
|
61
|
+
// unauthenticated
|
|
62
|
+
throw ((new Error((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.code)));
|
|
63
|
+
}
|
|
64
|
+
else
|
|
65
|
+
throw new Error('internal_error', error);
|
|
66
|
+
})];
|
|
67
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
PresetMenusAdminAPIs.getByMenuID = function (menuId, token) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/admin/id/".concat(menuId), {
|
|
77
|
+
headers: {
|
|
78
|
+
'Authorization': "".concat(token)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
.then(function (response) {
|
|
82
|
+
return response.data;
|
|
83
|
+
})
|
|
84
|
+
.catch(function (error) {
|
|
85
|
+
var _a;
|
|
86
|
+
// handle error
|
|
87
|
+
if (error.response.status == 401) {
|
|
88
|
+
// unauthorized
|
|
89
|
+
// unauthenticated
|
|
90
|
+
throw ((new Error((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.code)));
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
throw new Error('internal_error', error);
|
|
94
|
+
})];
|
|
95
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
PresetMenusAdminAPIs.update = function (_a) {
|
|
101
|
+
var token = _a.token, id = _a.id, availability = _a.availability, minBookingTotal = _a.minBookingTotal, title = _a.title;
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_b) {
|
|
104
|
+
switch (_b.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/preset-menus/admin", {
|
|
106
|
+
id: id,
|
|
107
|
+
availability: availability,
|
|
108
|
+
minBookingTotal: minBookingTotal,
|
|
109
|
+
title: title
|
|
110
|
+
}, {
|
|
111
|
+
headers: {
|
|
112
|
+
'Authorization': "".concat(token)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
.then(function (response) {
|
|
116
|
+
return Right(response.data);
|
|
117
|
+
})
|
|
118
|
+
.catch(function (error) {
|
|
119
|
+
var _a;
|
|
120
|
+
// handled error
|
|
121
|
+
if (error.response.status == 401) {
|
|
122
|
+
// unavailable_business
|
|
123
|
+
// unauthorized
|
|
124
|
+
// unauthenticated
|
|
125
|
+
return (Left(new Error((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.code)));
|
|
126
|
+
}
|
|
127
|
+
else if (error.response.status == 404)
|
|
128
|
+
return (Left(new Error("not_found")));
|
|
129
|
+
else if (error.response.status == 400) {
|
|
130
|
+
return (Left(new Error("invalid_input")));
|
|
131
|
+
}
|
|
132
|
+
else
|
|
133
|
+
throw new Error('internal_error', error);
|
|
134
|
+
})];
|
|
135
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
return PresetMenusAdminAPIs;
|
|
141
|
+
}());
|
|
142
|
+
export { PresetMenusAdminAPIs };
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
// preset-menus module APIs
|
|
40
|
+
var PresetMenusAPIs = /** @class */ (function () {
|
|
41
|
+
function PresetMenusAPIs() {
|
|
42
|
+
}
|
|
43
|
+
PresetMenusAPIs.getByBusiness = function (businessId) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/user?business=".concat(businessId))
|
|
48
|
+
.then(function (response) {
|
|
49
|
+
return response.data;
|
|
50
|
+
})
|
|
51
|
+
.catch(function (error) {
|
|
52
|
+
throw new Error('internal_error', error);
|
|
53
|
+
})];
|
|
54
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return PresetMenusAPIs;
|
|
60
|
+
}());
|
|
61
|
+
export { PresetMenusAPIs };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type LocalDate = string;
|
|
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
|
+
}
|
|
11
|
+
export interface PresetMenu {
|
|
12
|
+
id: string;
|
|
13
|
+
availableUntil?: LocalDate;
|
|
14
|
+
excludedDays?: LocalDate[];
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
price: Price;
|
|
18
|
+
minBookingTotal?: number;
|
|
19
|
+
discount?: Map<LocalDate, DailyDiscount>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type LocalDate = string;
|
|
2
|
+
export interface UpdatePresetMenuRequest {
|
|
3
|
+
id: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
minBookingTotal?: number;
|
|
6
|
+
availability?: Availability;
|
|
7
|
+
token?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Availability {
|
|
10
|
+
isAvailable: boolean;
|
|
11
|
+
date: LocalDate;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -44,20 +44,20 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
44
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
45
|
return __generator(this, function (_d) {
|
|
46
46
|
switch (_d.label) {
|
|
47
|
-
case 0:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/admin?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) { return response.data; })
|
|
53
|
+
.catch(function (error) {
|
|
54
|
+
// handle error
|
|
55
|
+
if (error.response.status == 401)
|
|
56
|
+
throw new Error("unauthorized");
|
|
57
|
+
else
|
|
57
58
|
throw new Error('internal_error', error);
|
|
58
|
-
|
|
59
|
+
})];
|
|
59
60
|
case 1: return [2 /*return*/, _d.sent()];
|
|
60
|
-
case 2: throw Error('unauthorized');
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
});
|
|
@@ -67,24 +67,23 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
67
67
|
return __awaiter(this, void 0, void 0, function () {
|
|
68
68
|
return __generator(this, function (_b) {
|
|
69
69
|
switch (_b.label) {
|
|
70
|
-
case 0:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/admin/".concat(id), {
|
|
71
|
+
headers: {
|
|
72
|
+
'Authorization': "".concat(token),
|
|
73
|
+
'Content-Type': 'application/json'
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.then(function (response) { return response.data; })
|
|
77
|
+
.catch(function (error) {
|
|
78
|
+
// handle error
|
|
79
|
+
if (error.response.status == 401)
|
|
80
|
+
throw new Error("unauthorized");
|
|
81
|
+
else if (error.response.status == 404)
|
|
82
|
+
throw new Error("not_found");
|
|
83
|
+
else
|
|
84
|
+
throw new Error('internal_error', error);
|
|
85
|
+
})];
|
|
86
86
|
case 1: return [2 /*return*/, _b.sent()];
|
|
87
|
-
case 2: throw new Error("unauthorized");
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
89
|
});
|
|
@@ -94,20 +93,20 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
94
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
95
94
|
return __generator(this, function (_b) {
|
|
96
95
|
switch (_b.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/admin/".concat(reservationId, "/available-transitions"), {
|
|
97
|
+
headers: {
|
|
98
|
+
'Authorization': "".concat(token)
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
.then(function (response) { return response.data; })
|
|
102
|
+
.catch(function (error) {
|
|
103
|
+
// handle error
|
|
104
|
+
if (error.response.status == 401)
|
|
105
|
+
throw new Error("unauthorized");
|
|
106
|
+
else
|
|
107
107
|
throw new Error('internal_error', error);
|
|
108
|
-
|
|
108
|
+
})];
|
|
109
109
|
case 1: return [2 /*return*/, _b.sent()];
|
|
110
|
-
case 2: throw new Error("unauthorized");
|
|
111
110
|
}
|
|
112
111
|
});
|
|
113
112
|
});
|
|
@@ -117,7 +116,7 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
117
116
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
117
|
return __generator(this, function (_b) {
|
|
119
118
|
switch (_b.label) {
|
|
120
|
-
case 0: return [4 /*yield*/, axios.patch(base + "/
|
|
119
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/reservations/admin/".concat(id, "/").concat(status), {}, {
|
|
121
120
|
headers: {
|
|
122
121
|
'Authorization': "".concat(token)
|
|
123
122
|
}
|
|
@@ -125,10 +124,11 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
125
124
|
.then(function (response) { return response.data; })
|
|
126
125
|
.catch(function (error) {
|
|
127
126
|
// handle error
|
|
128
|
-
if (error.response.status ==
|
|
129
|
-
throw new Error("
|
|
127
|
+
if (error.response.status == 401)
|
|
128
|
+
throw new Error("unauthorized");
|
|
129
|
+
else if (error.response.status == 404)
|
|
130
|
+
throw new Error("not_found");
|
|
130
131
|
else if (error.response.status == 400) {
|
|
131
|
-
// unauthorized_action
|
|
132
132
|
var response = error.response.data;
|
|
133
133
|
throw new Error(response.code);
|
|
134
134
|
}
|
|
@@ -45,22 +45,20 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
45
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
46
|
return __generator(this, function (_d) {
|
|
47
47
|
switch (_d.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/user?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
|
|
49
|
+
headers: {
|
|
50
|
+
'Authorization': "".concat(token)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.then(function (response) { return response.data; })
|
|
54
|
+
.catch(function (error) {
|
|
55
|
+
// handle error
|
|
56
|
+
if (error.response.status == 401)
|
|
57
|
+
throw new Error("unauthorized");
|
|
58
|
+
else
|
|
58
59
|
throw new Error('internal_error', error);
|
|
59
|
-
|
|
60
|
+
})];
|
|
60
61
|
case 1: return [2 /*return*/, _d.sent()];
|
|
61
|
-
case 2:
|
|
62
|
-
console.log('unauthorized');
|
|
63
|
-
return [2 /*return*/, []];
|
|
64
62
|
}
|
|
65
63
|
});
|
|
66
64
|
});
|
|
@@ -70,24 +68,23 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
70
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
69
|
return __generator(this, function (_b) {
|
|
72
70
|
switch (_b.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/user/".concat(id), {
|
|
72
|
+
headers: {
|
|
73
|
+
'Authorization': "".concat(token),
|
|
74
|
+
'Content-Type': 'application/json'
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.then(function (response) { return response.data; })
|
|
78
|
+
.catch(function (error) {
|
|
79
|
+
// handle error
|
|
80
|
+
if (error.response.status == 401)
|
|
81
|
+
throw new Error("unauthorized");
|
|
82
|
+
else if (error.response.status == 404)
|
|
83
|
+
throw new Error("not_found");
|
|
84
|
+
else
|
|
85
|
+
throw new Error('internal_error', error);
|
|
86
|
+
})];
|
|
89
87
|
case 1: return [2 /*return*/, _b.sent()];
|
|
90
|
-
case 2: throw new Error("unauthorized");
|
|
91
88
|
}
|
|
92
89
|
});
|
|
93
90
|
});
|
|
@@ -96,7 +93,7 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
96
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
97
94
|
return __generator(this, function (_a) {
|
|
98
95
|
switch (_a.label) {
|
|
99
|
-
case 0: return [4 /*yield*/, axios.patch(base + "/user/
|
|
96
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/reservations/user/".concat(id, "/cancel"), {}, {
|
|
100
97
|
headers: {
|
|
101
98
|
'Authorization': "".concat(token)
|
|
102
99
|
}
|
|
@@ -104,10 +101,11 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
104
101
|
.then(function (response) { return response.data; })
|
|
105
102
|
.catch(function (error) {
|
|
106
103
|
// handle error
|
|
107
|
-
if (error.response.status ==
|
|
108
|
-
throw new Error("
|
|
104
|
+
if (error.response.status == 401)
|
|
105
|
+
throw new Error("unauthorized");
|
|
106
|
+
else if (error.response.status == 404)
|
|
107
|
+
throw new Error("not_found");
|
|
109
108
|
else if (error.response.status == 400) {
|
|
110
|
-
//unauthorized_action
|
|
111
109
|
//reservation_not_found
|
|
112
110
|
var response = error.response.data;
|
|
113
111
|
throw new Error(response.code);
|
|
@@ -127,10 +125,9 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
127
125
|
return __generator(this, function (_b) {
|
|
128
126
|
switch (_b.label) {
|
|
129
127
|
case 0:
|
|
130
|
-
if (!token) return [3 /*break*/, 2];
|
|
131
128
|
datetime = new Date(date);
|
|
132
129
|
datetime.setHours(time.getHours(), time.getMinutes());
|
|
133
|
-
return [4 /*yield*/, axios.post(base + "/user/
|
|
130
|
+
return [4 /*yield*/, axios.post(base + "/reservations/user/onmenu", {
|
|
134
131
|
id: id,
|
|
135
132
|
datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
136
133
|
children: children,
|
|
@@ -145,8 +142,10 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
145
142
|
.then(function (response) { return response.data; })
|
|
146
143
|
.catch(function (error) {
|
|
147
144
|
// handle error
|
|
148
|
-
if (error.response.status ==
|
|
149
|
-
throw new 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");
|
|
150
149
|
else if (error.response.status == 400) {
|
|
151
150
|
//banned_user
|
|
152
151
|
//unavailable_day
|
|
@@ -160,7 +159,6 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
160
159
|
throw new Error('internal_error', error);
|
|
161
160
|
})];
|
|
162
161
|
case 1: return [2 /*return*/, _b.sent()];
|
|
163
|
-
case 2: throw new Error("unauthorized");
|
|
164
162
|
}
|
|
165
163
|
});
|
|
166
164
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DailyDiscount, LocalDate, PresetMenu } from "../menus/types/get-
|
|
1
|
+
import { DailyDiscount, LocalDate, PresetMenu } from "../menus/preset/types/get-by-business";
|
|
2
2
|
export declare class MenuUtils {
|
|
3
3
|
static isMenuAvailable(menu: PresetMenu): boolean;
|
|
4
4
|
static isMenuAvailableByDay(menu: PresetMenu, date: Date): boolean;
|