@kiminix/tp-client 1.22.0 → 1.24.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.
Files changed (80) hide show
  1. package/dist/business/types/get-all.d.ts +17 -0
  2. package/dist/business/types/get-id.d.ts +7 -5
  3. package/dist/cashback/admin/admin-apis.d.ts +7 -0
  4. package/dist/{menus/preset/user-apis.js → cashback/admin/admin-apis.js} +37 -33
  5. package/dist/cashback/admin/types/resp-get-cashback.d.ts +12 -0
  6. package/dist/cashback/index.d.ts +4 -0
  7. package/dist/cashback/index.js +6 -0
  8. package/dist/cashback/user/types/resp-get-cashback.d.ts +10 -0
  9. package/dist/cashback/user/user-apis.d.ts +7 -0
  10. package/dist/cashback/user/user-apis.js +87 -0
  11. package/dist/deals/types.d.ts +2 -1
  12. package/dist/enum.d.ts +11 -5
  13. package/dist/enum.js +14 -7
  14. package/dist/iam/index.d.ts +9 -0
  15. package/dist/iam/index.js +9 -0
  16. package/dist/index.d.ts +6 -10
  17. package/dist/index.js +11 -11
  18. package/dist/menus/preset/index.d.ts +7 -0
  19. package/dist/menus/preset/index.js +9 -0
  20. package/dist/reservations/{admin-apis.d.ts → admin/admin-apis.d.ts} +11 -5
  21. package/dist/reservations/{admin-apis.js → admin/admin-apis.js} +42 -4
  22. package/dist/reservations/admin/types/get-id.d.ts +4 -0
  23. package/dist/reservations/index.d.ts +11 -0
  24. package/dist/reservations/index.js +14 -0
  25. package/dist/reservations/shared/reservation-deal.d.ts +19 -0
  26. package/dist/reservations/shared/reservation-deal.js +13 -0
  27. package/dist/reservations/{types/shared.d.ts → shared/reservation.d.ts} +7 -6
  28. package/dist/reservations/{types/user/reservation-preview.d.ts → user/types/resp-reservation-preview.d.ts} +4 -2
  29. package/dist/reservations/user/types/resp-reservation-preview.js +2 -0
  30. package/dist/reservations/user/types/resp-reservation-settings.d.ts +22 -0
  31. package/dist/reservations/user/types/resp-save-reservation.d.ts +3 -0
  32. package/dist/reservations/user/user-apis.d.ts +21 -7
  33. package/dist/reservations/user/user-apis.js +71 -5
  34. package/dist/statistics/admin-apis.d.ts +2 -2
  35. package/dist/statistics/admin-apis.js +37 -30
  36. package/dist/statistics/types/menus-statistic.d.ts +2 -0
  37. package/dist/utils/request-utils.d.ts +3 -0
  38. package/dist/utils/request-utils.js +81 -0
  39. package/package.json +3 -1
  40. package/dist/deals/types/get-id.d.ts +0 -49
  41. package/dist/deals/types/get-pages.d.ts +0 -30
  42. package/dist/menus/discounts/admin-apis.d.ts +0 -7
  43. package/dist/menus/discounts/admin-apis.js +0 -90
  44. package/dist/menus/discounts/types/update-discount.d.ts +0 -9
  45. package/dist/menus/preset/types/available-menu.d.ts +0 -12
  46. package/dist/menus/preset/user-apis.d.ts +0 -16
  47. package/dist/menus/types/preset-menu.d.ts +0 -22
  48. package/dist/reservations/types/admin/get-page.js +0 -1
  49. package/dist/reservations/types/admin/patch-status.d.ts +0 -6
  50. package/dist/reservations/types/admin/patch-status.js +0 -1
  51. package/dist/reservations/types/admin/reserve-onmenu.d.ts +0 -17
  52. package/dist/reservations/types/admin/reserve-onmenu.js +0 -1
  53. package/dist/reservations/types/shared.js +0 -1
  54. package/dist/reservations/types/types.d.ts +0 -27
  55. package/dist/reservations/types/types.js +0 -2
  56. package/dist/reservations/types/user/get-id.d.ts +0 -4
  57. package/dist/reservations/types/user/get-id.js +0 -1
  58. package/dist/reservations/types/user/get-page.d.ts +0 -7
  59. package/dist/reservations/types/user/get-page.js +0 -1
  60. package/dist/reservations/types/user/reservation-preview.js +0 -1
  61. package/dist/reservations/types/user/reserve-onmenu.d.ts +0 -13
  62. package/dist/reservations/types/user/reserve-onmenu.js +0 -1
  63. package/dist/reservations/types/user/reserve-response.d.ts +0 -3
  64. package/dist/reservations/types/user/reserve-response.js +0 -1
  65. package/dist/reservations/types.d.ts +0 -27
  66. package/dist/reservations/user/types.d.ts +0 -31
  67. package/dist/reservations/user-apis.d.ts +0 -30
  68. package/dist/reservations/user-apis.js +0 -206
  69. /package/dist/{deals/types/get-id.js → cashback/admin/types/resp-get-cashback.js} +0 -0
  70. /package/dist/{deals/types/get-pages.js → cashback/user/types/resp-get-cashback.js} +0 -0
  71. /package/dist/reservations/{types/admin → admin/types}/get-available-transitions.d.ts +0 -0
  72. /package/dist/reservations/{types/admin → admin/types}/get-available-transitions.js +0 -0
  73. /package/dist/reservations/{types/admin → admin/types}/get-id.js +0 -0
  74. /package/dist/{menus/discounts/types/update-discount.js → reservations/shared/reservation.js} +0 -0
  75. /package/dist/reservations/{types/admin/get-id.d.ts → user/types/req-get-by-id.d.ts} +0 -0
  76. /package/dist/reservations/user/{types.js → types/req-get-by-id.js} +0 -0
  77. /package/dist/reservations/{types/admin/get-page.d.ts → user/types/req-get-page-reservation.d.ts} +0 -0
  78. /package/dist/reservations/{types.js → user/types/req-get-page-reservation.js} +0 -0
  79. /package/dist/{menus/preset/types/available-menu.js → reservations/user/types/resp-reservation-settings.js} +0 -0
  80. /package/dist/{menus/types/preset-menu.js → reservations/user/types/resp-save-reservation.js} +0 -0
@@ -10,4 +10,21 @@ export interface AllBusiness {
10
10
  address: string;
11
11
  review: Review;
12
12
  images: string[];
13
+ cashback: CashbackSettings | undefined;
13
14
  }
15
+ export interface CashbackSettings {
16
+ isActive: boolean;
17
+ rates: CashbackRates;
18
+ thresholds: Thresholds;
19
+ resetAtSeasonStart: boolean;
20
+ }
21
+ interface CashbackRates {
22
+ bronze: number;
23
+ silver: number;
24
+ gold: number;
25
+ }
26
+ interface Thresholds {
27
+ silver: number;
28
+ gold: number;
29
+ }
30
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { Licence } from "../../types";
2
+ import { CashbackSettings } from "./get-all";
2
3
  export interface GoogleMap {
3
4
  link: string;
4
5
  image: string;
@@ -17,14 +18,15 @@ export interface Business {
17
18
  id: string;
18
19
  identifier: string;
19
20
  name: string;
20
- licence?: Licence;
21
+ licence: Licence | undefined;
21
22
  createdAt: Date;
22
23
  address: string;
23
- googleMap?: GoogleMap;
24
+ googleMap: GoogleMap | undefined;
24
25
  review: Review;
25
26
  phones: string[];
26
- socialNetworks?: SocialNetworks;
27
+ socialNetworks: SocialNetworks | undefined;
27
28
  images: string[];
28
- email?: string;
29
- description?: string;
29
+ email: string | undefined;
30
+ description: string | undefined;
31
+ cashback: CashbackSettings | undefined;
30
32
  }
@@ -0,0 +1,7 @@
1
+ import { CashbackWithCustomerInfo } from "./types/resp-get-cashback";
2
+ export declare class CashbackAdminAPIs {
3
+ static get(props: {
4
+ token: string | undefined;
5
+ userId: string;
6
+ }): Promise<CashbackWithCustomerInfo | undefined>;
7
+ }
@@ -36,46 +36,50 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import axios from "axios";
38
38
  import { base } from "../../constants";
39
- import { Left, Right } from "purify-ts";
40
- // preset-menus module public APIs
41
- var PresetMenusUserAPIs = /** @class */ (function () {
42
- function PresetMenusUserAPIs() {
39
+ var CashbackAdminAPIs = /** @class */ (function () {
40
+ function CashbackAdminAPIs() {
43
41
  }
44
- /**
45
- *
46
- * @param businessId
47
- * @param date
48
- * @returns available preset menus for the given business and date. can fail with bellow errors code: unauthenticated, past_day, expired_licence, internal_error
49
- */
50
- PresetMenusUserAPIs.getAvailableMenus = function (props) {
42
+ CashbackAdminAPIs.get = function (props) {
51
43
  return __awaiter(this, void 0, void 0, function () {
44
+ var response, error_1, axiosError;
52
45
  return __generator(this, function (_a) {
53
46
  switch (_a.label) {
54
- case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/user/available?business=".concat(props.businessId, "&date=").concat(props.date), {
55
- headers: {
56
- 'Authorization': "".concat(props.token)
47
+ case 0:
48
+ _a.trys.push([0, 2, , 3]);
49
+ return [4 /*yield*/, axios.get(base + "/cashback/admin?userId=".concat(props.userId), {
50
+ headers: {
51
+ 'Authorization': "".concat(props.token)
52
+ }
53
+ })];
54
+ case 1:
55
+ response = _a.sent();
56
+ return [2 /*return*/, response.data];
57
+ case 2:
58
+ error_1 = _a.sent();
59
+ axiosError = error_1;
60
+ // The request was made and the server responded with a status code that falls out of the range of 2xx
61
+ if (axiosError && axiosError.response) {
62
+ switch (axiosError.response.status) {
63
+ case 401:
64
+ throw new Error("unauthorized");
65
+ default:
66
+ throw new Error('internal_error');
57
67
  }
58
- })
59
- .then(function (response) {
60
- return Right(response.data);
61
- })
62
- // handled error
63
- .catch(function (error) {
64
- var _a, _b, _c, _d, _e, _f;
65
- // unauthenticated
66
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401)
67
- return (Left(new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
68
- //past_day
69
- else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) == 400)
70
- return (Left(new Error((_f = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.code)));
71
- else
72
- throw new Error('internal_error', error);
73
- })];
74
- case 1: return [2 /*return*/, _a.sent()];
68
+ }
69
+ // The request was made but no response was received
70
+ else if (axiosError && axiosError.request) {
71
+ throw new Error('network_error');
72
+ }
73
+ // Something happened in setting up the request that triggered an Error
74
+ else {
75
+ throw new Error('client_request_setting_error');
76
+ }
77
+ return [3 /*break*/, 3];
78
+ case 3: return [2 /*return*/];
75
79
  }
76
80
  });
77
81
  });
78
82
  };
79
- return PresetMenusUserAPIs;
83
+ return CashbackAdminAPIs;
80
84
  }());
81
- export { PresetMenusUserAPIs };
85
+ export { CashbackAdminAPIs };
@@ -0,0 +1,12 @@
1
+ import { Cashback } from "../../user/types/resp-get-cashback";
2
+ export interface CashbackWithCustomerInfo {
3
+ user: CustomerInfo;
4
+ cashback: Cashback | undefined;
5
+ }
6
+ export interface CustomerInfo {
7
+ id: string;
8
+ firstname: string;
9
+ lastname: string;
10
+ phone: string | undefined;
11
+ verifiedPhone: boolean;
12
+ }
@@ -0,0 +1,4 @@
1
+ export * from './user/types/resp-get-cashback';
2
+ export { CashbackUserAPIs } from './user/user-apis';
3
+ export * from './admin/types/resp-get-cashback';
4
+ export { CashbackAdminAPIs } from './admin/admin-apis';
@@ -0,0 +1,6 @@
1
+ // cashback module
2
+ export * from './user/types/resp-get-cashback';
3
+ export { CashbackUserAPIs } from './user/user-apis';
4
+ // admin module
5
+ export * from './admin/types/resp-get-cashback';
6
+ export { CashbackAdminAPIs } from './admin/admin-apis';
@@ -0,0 +1,10 @@
1
+ import { Level } from "../../../enum";
2
+ export interface Cashback {
3
+ id: string;
4
+ businessId: string;
5
+ value: number;
6
+ level: Level;
7
+ score: number;
8
+ createdAt: string;
9
+ lastResetAt: string | undefined;
10
+ }
@@ -0,0 +1,7 @@
1
+ import { Cashback } from "./types/resp-get-cashback";
2
+ export declare class CashbackUserAPIs {
3
+ static get(props: {
4
+ token: string | undefined;
5
+ businessId: string;
6
+ }): Promise<Cashback | undefined>;
7
+ }
@@ -0,0 +1,87 @@
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
+ var CashbackUserAPIs = /** @class */ (function () {
40
+ function CashbackUserAPIs() {
41
+ }
42
+ CashbackUserAPIs.get = function (props) {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var response, error_1, axiosError;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ _a.trys.push([0, 2, , 3]);
49
+ return [4 /*yield*/, axios.get(base + "/cashback/user?businessId=".concat(props.businessId), {
50
+ headers: {
51
+ 'Authorization': "".concat(props.token)
52
+ }
53
+ })];
54
+ case 1:
55
+ response = _a.sent();
56
+ return [2 /*return*/, response.data];
57
+ case 2:
58
+ error_1 = _a.sent();
59
+ axiosError = error_1;
60
+ // The request was made and the server responded with a status code that falls out of the range of 2xx
61
+ if (axiosError && axiosError.response) {
62
+ switch (axiosError.response.status) {
63
+ case 401:
64
+ throw new Error("unauthorized");
65
+ case 404:
66
+ return [2 /*return*/, undefined];
67
+ default:
68
+ throw new Error('internal_error');
69
+ }
70
+ }
71
+ // The request was made but no response was received
72
+ else if (axiosError && axiosError.request) {
73
+ throw new Error('network_error');
74
+ }
75
+ // Something happened in setting up the request that triggered an Error
76
+ else {
77
+ throw new Error('client_request_setting_error');
78
+ }
79
+ return [3 /*break*/, 3];
80
+ case 3: return [2 /*return*/];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ return CashbackUserAPIs;
86
+ }());
87
+ export { CashbackUserAPIs };
@@ -13,7 +13,8 @@ export interface Business {
13
13
  identifier: string;
14
14
  name: string;
15
15
  address: string;
16
- licence?: Licence;
16
+ licence: Licence | undefined;
17
+ maxCashback: number | undefined;
17
18
  }
18
19
  export interface Deal {
19
20
  id: string;
package/dist/enum.d.ts CHANGED
@@ -1,14 +1,20 @@
1
1
  export declare enum ReservationStatus {
2
2
  Pending = "pending",
3
3
  Confirmed = "confirmed",
4
+ Validated = "validated",
4
5
  Missed = "missed",
5
6
  CanceledUser = "canceled_user",
6
7
  CanceledBusiness = "canceled_business"
7
8
  }
8
- export declare enum DealKind {
9
+ export declare enum ReservationDealKind {
9
10
  Discount = "discount",
10
- CashbackUse = "cashback_use",
11
- CashBackSave = "cashback_save"
11
+ CashbackEarn = "cashback_earn",
12
+ CashBackApply = "cashback_apply"
13
+ }
14
+ export declare enum Level {
15
+ Bronze = "bronze",
16
+ Silver = "silver",
17
+ Gold = "gold"
12
18
  }
13
19
  export declare enum TimelineDirection {
14
20
  Past = "past",
@@ -16,10 +22,10 @@ export declare enum TimelineDirection {
16
22
  }
17
23
  export declare enum ReservationEventKind {
18
24
  Confirmed = "confirmed",
25
+ Validated = "validated",
19
26
  Missed = "missed",
20
27
  CanceledUser = "canceled_user",
21
- CanceledBusiness = "canceled_business",
22
- Updated = "updated"
28
+ CanceledBusiness = "canceled_business"
23
29
  }
24
30
  export declare enum CancellationReason {
25
31
  UnavailablePlace = "unavailable_place",
package/dist/enum.js CHANGED
@@ -2,16 +2,23 @@ export var ReservationStatus;
2
2
  (function (ReservationStatus) {
3
3
  ReservationStatus["Pending"] = "pending";
4
4
  ReservationStatus["Confirmed"] = "confirmed";
5
+ ReservationStatus["Validated"] = "validated";
5
6
  ReservationStatus["Missed"] = "missed";
6
7
  ReservationStatus["CanceledUser"] = "canceled_user";
7
8
  ReservationStatus["CanceledBusiness"] = "canceled_business";
8
9
  })(ReservationStatus || (ReservationStatus = {}));
9
- export var DealKind;
10
- (function (DealKind) {
11
- DealKind["Discount"] = "discount";
12
- DealKind["CashbackUse"] = "cashback_use";
13
- DealKind["CashBackSave"] = "cashback_save";
14
- })(DealKind || (DealKind = {}));
10
+ export var ReservationDealKind;
11
+ (function (ReservationDealKind) {
12
+ ReservationDealKind["Discount"] = "discount";
13
+ ReservationDealKind["CashbackEarn"] = "cashback_earn";
14
+ ReservationDealKind["CashBackApply"] = "cashback_apply";
15
+ })(ReservationDealKind || (ReservationDealKind = {}));
16
+ export var Level;
17
+ (function (Level) {
18
+ Level["Bronze"] = "bronze";
19
+ Level["Silver"] = "silver";
20
+ Level["Gold"] = "gold";
21
+ })(Level || (Level = {}));
15
22
  export var TimelineDirection;
16
23
  (function (TimelineDirection) {
17
24
  TimelineDirection["Past"] = "past";
@@ -20,10 +27,10 @@ export var TimelineDirection;
20
27
  export var ReservationEventKind;
21
28
  (function (ReservationEventKind) {
22
29
  ReservationEventKind["Confirmed"] = "confirmed";
30
+ ReservationEventKind["Validated"] = "validated";
23
31
  ReservationEventKind["Missed"] = "missed";
24
32
  ReservationEventKind["CanceledUser"] = "canceled_user";
25
33
  ReservationEventKind["CanceledBusiness"] = "canceled_business";
26
- ReservationEventKind["Updated"] = "updated";
27
34
  })(ReservationEventKind || (ReservationEventKind = {}));
28
35
  export var CancellationReason;
29
36
  (function (CancellationReason) {
@@ -0,0 +1,9 @@
1
+ export * from './types/business-signin';
2
+ export * from './types/me';
3
+ export * from './types/reset-password';
4
+ export * from './types/update-profile';
5
+ export * from './types/user-signin';
6
+ export * from './types/user-signup-validate';
7
+ export * from './types/user-signup';
8
+ export { IamAdminAPIs } from './admin-apis';
9
+ export { IamUserAPIs } from './user-apis';
@@ -0,0 +1,9 @@
1
+ export * from './types/business-signin';
2
+ export * from './types/me';
3
+ export * from './types/reset-password';
4
+ export * from './types/update-profile';
5
+ export * from './types/user-signin';
6
+ export * from './types/user-signup-validate';
7
+ export * from './types/user-signup';
8
+ export { IamAdminAPIs } from './admin-apis';
9
+ export { IamUserAPIs } from './user-apis';
package/dist/index.d.ts CHANGED
@@ -1,19 +1,15 @@
1
1
  export { BusinessAPIs } from './business/apis';
2
2
  export { BusinessAdminAPIs } from './business/admin-apis';
3
3
  export { DealsAPIs } from './deals/apis';
4
- export { IamAdminAPIs } from './iam/admin-apis';
5
- export { IamUserAPIs } from './iam/user-apis';
6
- export { PresetMenusAPIs } from './menus/preset/apis';
7
- export { PresetMenusAdminAPIs } from './menus/preset/admin-apis';
8
4
  export { NotifyAPIs } from './notify/apis';
9
- export { ReservationsUserAPIs } from './reservations/user/user-apis';
10
- export * from './reservations/user/types';
11
- export { ReservationsAdminAPIs } from './reservations/admin-apis';
12
5
  export { SitemapAPIs } from './sitemap/apis';
13
6
  export { StatisticsAdminAPIs } from './statistics/admin-apis';
14
- export { PresetMenusUserAPIs } from './menus/preset/user-apis';
15
- export { MenuUtils } from './utils/menu-utils';
16
- export { BusinessUtils } from './utils/business-utils';
7
+ export * from './iam/index';
8
+ export * from './menus/preset/index';
9
+ export * from './reservations/index';
10
+ export * from './cashback/index';
11
+ export * from './utils/menu-utils';
12
+ export * from './utils/business-utils';
17
13
  export * from './utils/date-utils';
18
14
  export * from './enum';
19
15
  export * from './types';
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  export { BusinessAPIs } from './business/apis';
2
2
  export { BusinessAdminAPIs } from './business/admin-apis';
3
3
  export { DealsAPIs } from './deals/apis';
4
- export { IamAdminAPIs } from './iam/admin-apis';
5
- export { IamUserAPIs } from './iam/user-apis';
6
- export { PresetMenusAPIs } from './menus/preset/apis';
7
- export { PresetMenusAdminAPIs } from './menus/preset/admin-apis';
8
4
  export { NotifyAPIs } from './notify/apis';
9
- export { ReservationsUserAPIs } from './reservations/user/user-apis';
10
- export * from './reservations/user/types';
11
- export { ReservationsAdminAPIs } from './reservations/admin-apis';
12
5
  export { SitemapAPIs } from './sitemap/apis';
13
6
  export { StatisticsAdminAPIs } from './statistics/admin-apis';
14
- export { PresetMenusUserAPIs } from './menus/preset/user-apis';
15
- //
16
- export { MenuUtils } from './utils/menu-utils';
17
- export { BusinessUtils } from './utils/business-utils';
7
+ // iam module
8
+ export * from './iam/index';
9
+ // menus module
10
+ export * from './menus/preset/index';
11
+ // reservations module
12
+ export * from './reservations/index';
13
+ // cashback module
14
+ export * from './cashback/index';
15
+ //utils
16
+ export * from './utils/menu-utils';
17
+ export * from './utils/business-utils';
18
18
  export * from './utils/date-utils';
19
19
  export * from './enum';
20
20
  export * from './types';
@@ -0,0 +1,7 @@
1
+ export * from './types/preset-menu';
2
+ export * from './types/types';
3
+ export * from './types/update-preset-menu';
4
+ export { PresetMenusAPIs } from './apis';
5
+ export { PresetMenusAdminAPIs } from './admin-apis';
6
+ export * from './discounts/types/update-discount';
7
+ export { PresetMenusDiscountAdminAPIs } from './discounts/admin-apis';
@@ -0,0 +1,9 @@
1
+ // preset-menus module
2
+ export * from './types/preset-menu';
3
+ export * from './types/types';
4
+ export * from './types/update-preset-menu';
5
+ export { PresetMenusAPIs } from './apis';
6
+ export { PresetMenusAdminAPIs } from './admin-apis';
7
+ // discount module
8
+ export * from './discounts/types/update-discount';
9
+ export { PresetMenusDiscountAdminAPIs } from './discounts/admin-apis';
@@ -1,7 +1,7 @@
1
- import { CancellationReason, ReservationStatus, TimelineDirection } from "../enum";
2
- import { GetTransitionsRequest } from "../reservations/types/admin/get-available-transitions";
3
- import { GetByIdRequest } from "./types/admin/get-id";
4
- import { Reservation } from "./types/shared";
1
+ import { CancellationReason, ReservationStatus, TimelineDirection } from "../../enum";
2
+ import { GetTransitionsRequest } from "./types/get-available-transitions";
3
+ import { GetByIdAdminRequest } from "./types/get-id";
4
+ import { Reservation } from "../shared/reservation";
5
5
  import { Either } from "purify-ts";
6
6
  export declare class ReservationsAdminAPIs {
7
7
  static getPage(props: {
@@ -11,7 +11,13 @@ export declare class ReservationsAdminAPIs {
11
11
  status?: ReservationStatus;
12
12
  direction?: TimelineDirection;
13
13
  }): Promise<Reservation[]>;
14
- static getById({ token, id }: GetByIdRequest): Promise<Reservation>;
14
+ static getUserHistoryPage(props: {
15
+ token?: string;
16
+ user: string;
17
+ page: number;
18
+ size: number;
19
+ }): Promise<Reservation[]>;
20
+ static getById({ token, id }: GetByIdAdminRequest): Promise<Reservation>;
15
21
  static getAvailableTransitions({ token, reservationId }: GetTransitionsRequest): Promise<ReservationStatus[]>;
16
22
  static patchStatus(props: {
17
23
  token?: string;
@@ -35,10 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import axios from "axios";
38
- import { base } from "../constants";
39
- import { ErrorWithMetadata } from "../types";
38
+ import { base } from "../../constants";
39
+ import { ErrorWithMetadata } from "../../types";
40
40
  import { format } from "date-fns";
41
41
  import { Left, Right } from "purify-ts";
42
+ import { parseReservationDeal } from "../shared/reservation-deal";
43
+ import { RequestUtils } from "../../utils/request-utils";
42
44
  var ReservationsAdminAPIs = /** @class */ (function () {
43
45
  function ReservationsAdminAPIs() {
44
46
  }
@@ -61,7 +63,13 @@ var ReservationsAdminAPIs = /** @class */ (function () {
61
63
  'Authorization': "".concat(props.token)
62
64
  }
63
65
  })
64
- .then(function (response) { return response.data; })
66
+ .then(function (response) {
67
+ var result = response.data;
68
+ for (var i = 0; i < result.length; i++) {
69
+ result[i].deal = result[i].deal ? parseReservationDeal(result[i].deal) : undefined;
70
+ }
71
+ return result;
72
+ })
65
73
  .catch(function (error) {
66
74
  // handle error
67
75
  if (error.response.status == 401)
@@ -74,6 +82,32 @@ var ReservationsAdminAPIs = /** @class */ (function () {
74
82
  });
75
83
  });
76
84
  };
85
+ ReservationsAdminAPIs.getUserHistoryPage = function (props) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ return __generator(this, function (_a) {
88
+ return [2 /*return*/, RequestUtils.send(function () {
89
+ var queryParams = [
90
+ "page=".concat(props.page),
91
+ "size=".concat(props.size)
92
+ ]
93
+ .filter(function (value) { return value; })
94
+ .join("&");
95
+ return axios.get(base + "/reservations/admin/users/".concat(props.user, "?").concat(queryParams), {
96
+ headers: {
97
+ 'Authorization': "".concat(props.token)
98
+ }
99
+ })
100
+ .then(function (response) {
101
+ var result = response.data;
102
+ for (var i = 0; i < result.length; i++) {
103
+ result[i].deal = result[i].deal ? parseReservationDeal(result[i].deal) : undefined;
104
+ }
105
+ return result;
106
+ });
107
+ })];
108
+ });
109
+ });
110
+ };
77
111
  ReservationsAdminAPIs.getById = function (_a) {
78
112
  var token = _a.token, id = _a.id;
79
113
  return __awaiter(this, void 0, void 0, function () {
@@ -85,7 +119,11 @@ var ReservationsAdminAPIs = /** @class */ (function () {
85
119
  'Content-Type': 'application/json'
86
120
  }
87
121
  })
88
- .then(function (response) { return response.data; })
122
+ .then(function (response) {
123
+ var result = response.data;
124
+ result.deal = result.deal ? parseReservationDeal(result.deal) : undefined;
125
+ return result;
126
+ })
89
127
  .catch(function (error) {
90
128
  // handle error
91
129
  if (error.response.status == 401)
@@ -0,0 +1,4 @@
1
+ export interface GetByIdAdminRequest {
2
+ token?: string;
3
+ id: string;
4
+ }
@@ -0,0 +1,11 @@
1
+ export * from "./user/types/resp-reservation-settings";
2
+ export * from './user/types/resp-reservation-preview';
3
+ export * from "./user/types/resp-save-reservation";
4
+ export * from "./user/types/req-get-by-id";
5
+ export * from "./user/types/req-get-page-reservation";
6
+ export { ReservationsUserAPIs } from './user/user-apis';
7
+ export * from "./admin/types/get-available-transitions";
8
+ export * from "./admin/types/get-id";
9
+ export { ReservationsAdminAPIs } from './admin/admin-apis';
10
+ export * from './shared/reservation';
11
+ export * from './shared/reservation-deal';
@@ -0,0 +1,14 @@
1
+ // user module
2
+ export * from "./user/types/resp-reservation-settings";
3
+ export * from './user/types/resp-reservation-preview';
4
+ export * from "./user/types/resp-save-reservation";
5
+ export * from "./user/types/req-get-by-id";
6
+ export * from "./user/types/req-get-page-reservation";
7
+ export { ReservationsUserAPIs } from './user/user-apis';
8
+ // admin module
9
+ export * from "./admin/types/get-available-transitions";
10
+ export * from "./admin/types/get-id";
11
+ export { ReservationsAdminAPIs } from './admin/admin-apis';
12
+ // shared module
13
+ export * from './shared/reservation';
14
+ export * from './shared/reservation-deal';
@@ -0,0 +1,19 @@
1
+ import { Level, ReservationDealKind } from "../../enum";
2
+ export interface Discount {
3
+ type: ReservationDealKind.Discount;
4
+ value: number;
5
+ }
6
+ export interface CashbackEarn {
7
+ type: ReservationDealKind.CashbackEarn;
8
+ value: number;
9
+ level: Level;
10
+ rate: number;
11
+ isInProgress: boolean;
12
+ }
13
+ export interface CashbackApply {
14
+ type: ReservationDealKind.CashBackApply;
15
+ value: number;
16
+ isInProgress: boolean;
17
+ }
18
+ export type ReservationDeal = Discount | CashbackEarn | CashbackApply;
19
+ export declare function parseReservationDeal(json: any): ReservationDeal;
@@ -0,0 +1,13 @@
1
+ import { ReservationDealKind } from "../../enum";
2
+ export function parseReservationDeal(json) {
3
+ switch (json.type) {
4
+ case ReservationDealKind.Discount:
5
+ return json;
6
+ case ReservationDealKind.CashbackEarn:
7
+ return json;
8
+ case ReservationDealKind.CashBackApply:
9
+ return json;
10
+ default:
11
+ throw new Error("Unknown reservation's deal type: ".concat(json.type));
12
+ }
13
+ }