@kiminix/tp-client 1.13.0 → 1.14.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.
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { CountReservationByStatusRequest, CountReservationByStatusResponse } from "./types/reservations-by-status";
|
|
2
2
|
import { MenuStatisticResponse, MenusStatisticRequest } from "./types/menus-statistic";
|
|
3
|
+
import { CountByDay } from "./types/count-day";
|
|
4
|
+
import { LocalDate } from "../types";
|
|
5
|
+
import { ReservationStatus } from "../enum";
|
|
3
6
|
export declare class StatisticsAdminAPIs {
|
|
4
7
|
static countReservationByStatus({ token, date }: CountReservationByStatusRequest): Promise<CountReservationByStatusResponse[]>;
|
|
5
8
|
static menusStatistic({ token, date }: MenusStatisticRequest): Promise<MenuStatisticResponse[]>;
|
|
9
|
+
static countReservationsByMonth(props: {
|
|
10
|
+
token?: string;
|
|
11
|
+
date: LocalDate;
|
|
12
|
+
status?: ReservationStatus;
|
|
13
|
+
}): Promise<CountByDay[]>;
|
|
14
|
+
static lastReservations(props: {
|
|
15
|
+
token?: string;
|
|
16
|
+
limit: number;
|
|
17
|
+
}): Promise<CountByDay[]>;
|
|
6
18
|
}
|
|
@@ -85,6 +85,50 @@ var StatisticsAdminAPIs = /** @class */ (function () {
|
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
|
+
StatisticsAdminAPIs.countReservationsByMonth = function (props) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0: return [4 /*yield*/, axios.get(base + "/statistics/reservations-by-month/".concat(props.date, "?").concat(props.status ? "status=".concat(props.status) : ''), {
|
|
93
|
+
headers: {
|
|
94
|
+
'Authorization': "".concat(props.token)
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
.then(function (response) { return response.data; })
|
|
98
|
+
.catch(function (error) {
|
|
99
|
+
// handle error
|
|
100
|
+
if (error.response.status == 401)
|
|
101
|
+
throw new Error("unauthorized");
|
|
102
|
+
else
|
|
103
|
+
throw new Error('internal_error', error);
|
|
104
|
+
})];
|
|
105
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
StatisticsAdminAPIs.lastReservations = function (props) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, axios.get(base + "/statistics/last-reservations?limit=".concat(props.limit), {
|
|
115
|
+
headers: {
|
|
116
|
+
'Authorization': "".concat(props.token)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
.then(function (response) { return response.data; })
|
|
120
|
+
.catch(function (error) {
|
|
121
|
+
// handle error
|
|
122
|
+
if (error.response.status == 401)
|
|
123
|
+
throw new Error("unauthorized");
|
|
124
|
+
else
|
|
125
|
+
throw new Error('internal_error', error);
|
|
126
|
+
})];
|
|
127
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
88
132
|
return StatisticsAdminAPIs;
|
|
89
133
|
}());
|
|
90
134
|
export { StatisticsAdminAPIs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|