@kiminix/tp-client 1.33.0 → 1.35.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.
@@ -4,7 +4,6 @@ import { SpecialDiscount } from "./types/special-discounts";
4
4
  export declare class PresetMenusAPIs {
5
5
  static getByBusiness(businessId: string): Promise<PresetMenu[]>;
6
6
  static getSpecialDiscounts(props: {
7
- token?: string;
8
7
  businessId: string;
9
8
  code: string;
10
9
  date: LocalDate;
@@ -65,9 +65,7 @@ var PresetMenusAPIs = /** @class */ (function () {
65
65
  .filter(function (value) { return value; })
66
66
  .join("&");
67
67
  return axios.get(base + "/preset-menus/user/special-discounts?".concat(queryParams), {
68
- headers: {
69
- 'Authorization': "".concat(props.token)
70
- }
68
+ headers: {}
71
69
  })
72
70
  .then(function (response) {
73
71
  var result = response.data;
@@ -4,6 +4,7 @@ export * from "./user/types/resp-save-reservation";
4
4
  export * from "./user/types/req-get-by-id";
5
5
  export * from "./user/types/req-get-page-reservation";
6
6
  export { ReservationsUserAPIs } from './user/user-apis';
7
+ export { ReservationsGuestAPIs } from './user/user-apis';
7
8
  export * from "./admin/types/get-available-transitions";
8
9
  export * from "./admin/types/get-id";
9
10
  export { ReservationsAdminAPIs } from './admin/admin-apis';
@@ -5,6 +5,8 @@ export * from "./user/types/resp-save-reservation";
5
5
  export * from "./user/types/req-get-by-id";
6
6
  export * from "./user/types/req-get-page-reservation";
7
7
  export { ReservationsUserAPIs } from './user/user-apis';
8
+ // guest module
9
+ export { ReservationsGuestAPIs } from './user/user-apis';
8
10
  // admin module
9
11
  export * from "./admin/types/get-available-transitions";
10
12
  export * from "./admin/types/get-id";
@@ -1,7 +1,7 @@
1
1
  import { ReservationDealKind } from "../../enum";
2
2
  import { LocalDate } from "../../types";
3
3
  import { Reservation } from "../shared/reservation";
4
- import { GetByIdAdminRequest, GetPageRequest, ReservationPreviewResponse, ReservationSettings } from "../index";
4
+ import { AvailableMenu, GetByIdAdminRequest, GetPageRequest, ReservationPreviewResponse, ReservationSettings } from "../index";
5
5
  import { SaveReservationResponse } from "./types/resp-save-reservation";
6
6
  export declare class ReservationsUserAPIs {
7
7
  static getPage({ token, page, size, direction }: GetPageRequest): Promise<Reservation[]>;
@@ -46,3 +46,28 @@ export declare class ReservationsUserAPIs {
46
46
  }[];
47
47
  }): Promise<ReservationPreviewResponse>;
48
48
  }
49
+ export declare class ReservationsGuestAPIs {
50
+ static reserve(props: {
51
+ user: {
52
+ firstName: string;
53
+ lastName: string;
54
+ phone: string;
55
+ };
56
+ businessId: string;
57
+ date: Date;
58
+ time: Date;
59
+ specialCode?: string;
60
+ commands: {
61
+ menuId: string;
62
+ adult: number;
63
+ child?: number;
64
+ }[];
65
+ }): Promise<SaveReservationResponse>;
66
+ static getSettings(props: {
67
+ businessId: string;
68
+ date: LocalDate;
69
+ }): Promise<AvailableMenu[]>;
70
+ static get(props: {
71
+ id: string;
72
+ }): Promise<Reservation>;
73
+ }
@@ -39,6 +39,7 @@ import { format } from "date-fns";
39
39
  import { base } from "../../constants";
40
40
  import { ErrorWithMetadata } from "../../types";
41
41
  import { parseReservationDeal } from "../shared/reservation-deal";
42
+ import { RequestUtils } from "../../utils/request-utils";
42
43
  var ReservationsUserAPIs = /** @class */ (function () {
43
44
  function ReservationsUserAPIs() {
44
45
  }
@@ -271,3 +272,72 @@ var ReservationsUserAPIs = /** @class */ (function () {
271
272
  return ReservationsUserAPIs;
272
273
  }());
273
274
  export { ReservationsUserAPIs };
275
+ // GUEST APIS
276
+ var ReservationsGuestAPIs = /** @class */ (function () {
277
+ function ReservationsGuestAPIs() {
278
+ }
279
+ ReservationsGuestAPIs.reserve = function (props) {
280
+ return __awaiter(this, void 0, void 0, function () {
281
+ var datetime;
282
+ return __generator(this, function (_a) {
283
+ datetime = new Date(props.date);
284
+ datetime.setHours(props.time.getHours(), props.time.getMinutes());
285
+ // unavailable_day
286
+ // expired_preview
287
+ // invalid_guest_number
288
+ // invalid_special_code
289
+ return [2 /*return*/, RequestUtils.send(function () {
290
+ return axios.post(base + "/reservations/guest", {
291
+ user: {
292
+ firstName: props.user.firstName,
293
+ lastName: props.user.lastName,
294
+ phone: props.user.phone
295
+ },
296
+ businessId: props.businessId,
297
+ datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
298
+ specialCode: props.specialCode,
299
+ commands: props.commands
300
+ }, {
301
+ headers: {
302
+ 'Content-Type': 'application/json'
303
+ }
304
+ })
305
+ .then(function (response) { return response.data; });
306
+ })];
307
+ });
308
+ });
309
+ };
310
+ // get available menus for the guest
311
+ ReservationsGuestAPIs.getSettings = function (props) {
312
+ return __awaiter(this, void 0, void 0, function () {
313
+ return __generator(this, function (_a) {
314
+ return [2 /*return*/, RequestUtils.send(function () {
315
+ return axios.get(base + "/reservations/guest/settings?business=".concat(props.businessId, "&date=").concat(props.date), { headers: {} })
316
+ .then(function (response) {
317
+ return response.data;
318
+ });
319
+ })];
320
+ });
321
+ });
322
+ };
323
+ ReservationsGuestAPIs.get = function (props) {
324
+ return __awaiter(this, void 0, void 0, function () {
325
+ return __generator(this, function (_a) {
326
+ return [2 /*return*/, RequestUtils.send(function () {
327
+ return axios.get(base + "/reservations/guest/".concat(props.id), {
328
+ headers: {
329
+ 'Content-Type': 'application/json'
330
+ }
331
+ })
332
+ .then(function (response) {
333
+ var result = response.data;
334
+ result.deal = result.deal ? parseReservationDeal(result.deal) : undefined;
335
+ return result;
336
+ });
337
+ })];
338
+ });
339
+ });
340
+ };
341
+ return ReservationsGuestAPIs;
342
+ }());
343
+ export { ReservationsGuestAPIs };
@@ -20,8 +20,10 @@ var MenuUtils = /** @class */ (function () {
20
20
  // filter available discounts
21
21
  var result = Array.from(discounts.entries())
22
22
  .filter(function (entry) {
23
+ var _a;
23
24
  var dateAsString = entry[0], dailyDiscount = entry[1];
24
- return dailyDiscount.isAvailable;
25
+ var isDayExcluded = (_a = menu.excludedDays) === null || _a === void 0 ? void 0 : _a.includes(dateAsString);
26
+ return dailyDiscount.isAvailable && !isDayExcluded;
25
27
  });
26
28
  return new Map(result);
27
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "1.33.0",
3
+ "version": "1.35.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [