@kiminix/tp-client 1.30.0 → 1.31.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/menus/preset/apis.d.ts +8 -0
- package/dist/menus/preset/apis.js +28 -7
- package/dist/menus/preset/types/special-discounts.d.ts +12 -0
- package/dist/menus/preset/types/special-discounts.js +1 -0
- package/dist/reservations/shared/reservation-deal.d.ts +1 -0
- package/dist/reservations/user/user-apis.d.ts +2 -0
- package/dist/reservations/user/user-apis.js +2 -0
- package/dist/utils/request-utils.js +9 -8
- package/package.json +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { PresetMenu } from "./types/preset-menu";
|
|
2
|
+
import { LocalDate } from "../../types";
|
|
3
|
+
import { SpecialDiscount } from "./types/special-discounts";
|
|
2
4
|
export declare class PresetMenusAPIs {
|
|
3
5
|
static getByBusiness(businessId: string): Promise<PresetMenu[]>;
|
|
6
|
+
static getSpecialDiscounts(props: {
|
|
7
|
+
token?: string;
|
|
8
|
+
businessId: string;
|
|
9
|
+
code: string;
|
|
10
|
+
date: LocalDate;
|
|
11
|
+
}): Promise<SpecialDiscount[]>;
|
|
4
12
|
}
|
|
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import axios from "axios";
|
|
38
38
|
import { base } from "../../constants";
|
|
39
|
+
import { RequestUtils } from "../../utils/request-utils";
|
|
39
40
|
// preset-menus module public APIs
|
|
40
41
|
var PresetMenusAPIs = /** @class */ (function () {
|
|
41
42
|
function PresetMenusAPIs() {
|
|
@@ -43,16 +44,36 @@ var PresetMenusAPIs = /** @class */ (function () {
|
|
|
43
44
|
PresetMenusAPIs.getByBusiness = function (businessId) {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
46
|
return __generator(this, function (_a) {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
48
|
+
return axios.get(base + "/preset-menus/user?business=".concat(businessId))
|
|
48
49
|
.then(function (response) {
|
|
49
50
|
return response.data;
|
|
51
|
+
});
|
|
52
|
+
})];
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
PresetMenusAPIs.getSpecialDiscounts = function (props) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
60
|
+
var queryParams = [
|
|
61
|
+
"business=".concat(props.businessId),
|
|
62
|
+
"code=".concat(props.code),
|
|
63
|
+
"date=".concat(props.date)
|
|
64
|
+
]
|
|
65
|
+
.filter(function (value) { return value; })
|
|
66
|
+
.join("&");
|
|
67
|
+
return axios.get(base + "/preset-menus/user/special-discounts?".concat(queryParams), {
|
|
68
|
+
headers: {
|
|
69
|
+
'Authorization': "".concat(props.token)
|
|
70
|
+
}
|
|
50
71
|
})
|
|
51
|
-
.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
.then(function (response) {
|
|
73
|
+
var result = response.data;
|
|
74
|
+
return result;
|
|
75
|
+
});
|
|
76
|
+
})];
|
|
56
77
|
});
|
|
57
78
|
});
|
|
58
79
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import { CashbackStatus, Level, ReservationDealKind } from "../../enum";
|
|
|
2
2
|
export interface Discount {
|
|
3
3
|
type: ReservationDealKind.Discount;
|
|
4
4
|
value: number;
|
|
5
|
+
specialCode: string | undefined;
|
|
5
6
|
}
|
|
6
7
|
export interface CashbackEarn {
|
|
7
8
|
type: ReservationDealKind.CashbackEarn;
|
|
@@ -25,6 +25,7 @@ export declare class ReservationsUserAPIs {
|
|
|
25
25
|
date: Date;
|
|
26
26
|
time: Date;
|
|
27
27
|
deal: ReservationDealKind | undefined;
|
|
28
|
+
specialCode?: string;
|
|
28
29
|
commands: {
|
|
29
30
|
menuId: string;
|
|
30
31
|
adult: number;
|
|
@@ -37,6 +38,7 @@ export declare class ReservationsUserAPIs {
|
|
|
37
38
|
date: Date;
|
|
38
39
|
time: Date;
|
|
39
40
|
deal: ReservationDealKind | undefined;
|
|
41
|
+
specialCode?: string;
|
|
40
42
|
commands: {
|
|
41
43
|
menuId: string;
|
|
42
44
|
adult: number;
|
|
@@ -193,6 +193,7 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
193
193
|
businessId: props.businessId,
|
|
194
194
|
datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
195
195
|
deal: props.deal,
|
|
196
|
+
specialCode: props.specialCode,
|
|
196
197
|
commands: props.commands
|
|
197
198
|
}, {
|
|
198
199
|
headers: {
|
|
@@ -235,6 +236,7 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
235
236
|
businessId: props.businessId,
|
|
236
237
|
datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
237
238
|
deal: props.deal,
|
|
239
|
+
specialCode: props.specialCode,
|
|
238
240
|
commands: props.commands
|
|
239
241
|
}, {
|
|
240
242
|
headers: {
|
|
@@ -52,14 +52,15 @@ var RequestUtils = /** @class */ (function () {
|
|
|
52
52
|
axiosError = error_1;
|
|
53
53
|
// The request was made and the server responded with a status code that falls out of the range of 2xx
|
|
54
54
|
if (axiosError && axiosError.response) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
if (axiosError.response.status === 401) {
|
|
56
|
+
throw new Error("unauthorized");
|
|
57
|
+
}
|
|
58
|
+
else if (axiosError.response.status === 404 || axiosError.response.status === 400) {
|
|
59
|
+
response = axiosError.response.data;
|
|
60
|
+
throw new ErrorWithMetadata(response.code, response.metadata);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error('internal_error');
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
// The request was made but no response was received
|