@kiminix/tp-client 1.24.0 → 1.26.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,8 @@
1
1
  import { AllBusiness } from "./types/get-all";
2
2
  import { Business } from "./types/get-id";
3
+ import { MenuCategory } from "./types/get-carte-menus";
3
4
  export declare class BusinessAPIs {
4
5
  static getAll(timestamp: number, page?: number, size?: number): Promise<AllBusiness[]>;
5
6
  static get(identifier: string): Promise<Business | undefined>;
7
+ static getCarteMenus(identifier: string): Promise<MenuCategory[]>;
6
8
  }
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  import axios from "axios";
38
38
  import { base } from "../constants";
39
39
  import { parseISO } from "date-fns";
40
+ import { RequestUtils } from "../utils/request-utils";
40
41
  // business module APIs
41
42
  var BusinessAPIs = /** @class */ (function () {
42
43
  function BusinessAPIs() {
@@ -71,6 +72,24 @@ var BusinessAPIs = /** @class */ (function () {
71
72
  });
72
73
  });
73
74
  };
75
+ BusinessAPIs.getCarteMenus = function (identifier) {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ var _this = this;
78
+ return __generator(this, function (_a) {
79
+ return [2 /*return*/, RequestUtils.send(function () { return __awaiter(_this, void 0, void 0, function () {
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
82
+ case 0: return [4 /*yield*/, axios.get(base + "/business/".concat(identifier, "/carte-menus"))
83
+ .then(function (response) {
84
+ return response.data;
85
+ })];
86
+ case 1: return [2 /*return*/, _a.sent()];
87
+ }
88
+ });
89
+ }); })];
90
+ });
91
+ });
92
+ };
74
93
  return BusinessAPIs;
75
94
  }());
76
95
  export { BusinessAPIs };
@@ -0,0 +1,5 @@
1
+ export * from "./types/get-carte-menus";
2
+ export * from "./types/get-all";
3
+ export * from "./types/get-id";
4
+ export { BusinessAPIs } from './apis';
5
+ export { BusinessAdminAPIs } from './admin-apis';
@@ -0,0 +1,5 @@
1
+ export * from "./types/get-carte-menus";
2
+ export * from "./types/get-all";
3
+ export * from "./types/get-id";
4
+ export { BusinessAPIs } from './apis';
5
+ export { BusinessAdminAPIs } from './admin-apis';
@@ -1,8 +1,4 @@
1
- export interface Review {
2
- stars: number;
3
- count: number;
4
- link?: string;
5
- }
1
+ import { Review } from "./shared";
6
2
  export interface AllBusiness {
7
3
  id: string;
8
4
  identifier: string;
@@ -0,0 +1,9 @@
1
+ export interface MenuItem {
2
+ name: string;
3
+ description?: string;
4
+ price: number;
5
+ }
6
+ export interface MenuCategory {
7
+ name: string;
8
+ items: MenuItem[];
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,10 @@
1
1
  import { Licence } from "../../types";
2
2
  import { CashbackSettings } from "./get-all";
3
+ import { Review } from "./shared";
3
4
  export interface GoogleMap {
4
5
  link: string;
5
6
  image: string;
6
7
  }
7
- export interface Review {
8
- stars: number;
9
- count: number;
10
- link?: string;
11
- }
12
8
  export interface SocialNetworks {
13
9
  facebook?: string;
14
10
  instagram?: string;
@@ -0,0 +1,14 @@
1
+ export interface GoogleMap {
2
+ link: string;
3
+ image: string;
4
+ }
5
+ export interface SocialNetworks {
6
+ facebook?: string;
7
+ instagram?: string;
8
+ twitter?: string;
9
+ }
10
+ export interface Review {
11
+ stars: number;
12
+ count: number;
13
+ link?: string;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -13,7 +13,6 @@ export interface UpdatePassword {
13
13
  updated: string;
14
14
  }
15
15
  export interface UpdateProfileResponse {
16
- token: string;
17
16
  id: string;
18
17
  firstName: string;
19
18
  lastName: string;
@@ -11,6 +11,18 @@ 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 }: UpdateProfileRequest): Promise<Either<Error, UpdateProfileResponse>>;
14
+ /**
15
+ *
16
+ * @errors
17
+ * email_already_used
18
+ * phone_already_used
19
+ * invalid_email_format
20
+ * invalid_phone_format
21
+ * user_not_found
22
+ * invalid_actual_password
23
+ * weak_password
24
+ * @returns
25
+ */
26
+ static updateProfile({ token, firstName, lastName, phone, email, birthday, gender, password }: UpdateProfileRequest): Promise<UpdateProfileResponse>;
15
27
  static validatePhone(token: string | undefined, phone: string, code: string): Promise<Either<Error, void>>;
16
28
  }
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  import axios from "axios";
38
38
  import { Left, Right } from "purify-ts";
39
39
  import { base } from "../constants";
40
+ import { RequestUtils } from "../utils/request-utils";
40
41
  // iam module APIs
41
42
  var IamUserAPIs = /** @class */ (function () {
42
43
  function IamUserAPIs() {
@@ -191,52 +192,42 @@ var IamUserAPIs = /** @class */ (function () {
191
192
  });
192
193
  });
193
194
  };
195
+ /**
196
+ *
197
+ * @errors
198
+ * email_already_used
199
+ * phone_already_used
200
+ * invalid_email_format
201
+ * invalid_phone_format
202
+ * user_not_found
203
+ * invalid_actual_password
204
+ * weak_password
205
+ * @returns
206
+ */
194
207
  IamUserAPIs.updateProfile = function (_a) {
195
208
  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
209
  return __awaiter(this, void 0, void 0, function () {
197
210
  return __generator(this, function (_b) {
198
- switch (_b.label) {
199
- case 0:
200
- if (!token) return [3 /*break*/, 2];
201
- return [4 /*yield*/, axios.patch(base + "/iam/users/me", {
202
- firstName: firstName,
203
- lastName: lastName,
204
- phone: phone,
205
- email: email,
206
- birthday: birthday,
207
- gender: gender,
208
- password: password
209
- }, {
210
- headers: {
211
- 'Authorization': "".concat(token),
212
- 'Content-Type': 'application/json'
213
- }
214
- })
215
- .then(function (response) {
216
- return Right(response.data);
217
- })
218
- .catch(function (error) {
219
- if (error.response.status == 400) {
220
- //email_already_used
221
- //phone_already_used
222
- //invalid_email_format
223
- //invalid_phone_format
224
- //user_not_found
225
- //invalid_actual_password
226
- //weak_password
227
- var response = error.response.data.code;
228
- return Left(Error(response));
229
- }
230
- else {
231
- console.error(error);
232
- return Left(Error('internal_error'));
233
- }
234
- })];
235
- case 1:
236
- // Send the data to the server in JSON format.
237
- return [2 /*return*/, _b.sent()];
238
- case 2: return [2 /*return*/, Left(Error("unauthorized"))];
239
- }
211
+ return [2 /*return*/, RequestUtils.send(function () {
212
+ // Send the data to the server in JSON format.
213
+ return axios.patch(base + "/iam/users/me", {
214
+ firstName: firstName,
215
+ lastName: lastName,
216
+ phone: phone,
217
+ email: email,
218
+ birthday: birthday,
219
+ gender: gender,
220
+ password: password
221
+ }, {
222
+ headers: {
223
+ 'Authorization': "".concat(token),
224
+ 'Content-Type': 'application/json'
225
+ }
226
+ })
227
+ .then(function (response) {
228
+ return response.data;
229
+ });
230
+ })];
240
231
  });
241
232
  });
242
233
  };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- export { BusinessAPIs } from './business/apis';
2
- export { BusinessAdminAPIs } from './business/admin-apis';
3
1
  export { DealsAPIs } from './deals/apis';
4
2
  export { NotifyAPIs } from './notify/apis';
5
3
  export { SitemapAPIs } from './sitemap/apis';
6
4
  export { StatisticsAdminAPIs } from './statistics/admin-apis';
7
5
  export * from './iam/index';
6
+ export * from './business/index';
8
7
  export * from './menus/preset/index';
9
8
  export * from './reservations/index';
10
9
  export * from './cashback/index';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- export { BusinessAPIs } from './business/apis';
2
- export { BusinessAdminAPIs } from './business/admin-apis';
3
1
  export { DealsAPIs } from './deals/apis';
4
2
  export { NotifyAPIs } from './notify/apis';
5
3
  export { SitemapAPIs } from './sitemap/apis';
6
4
  export { StatisticsAdminAPIs } from './statistics/admin-apis';
7
5
  // iam module
8
6
  export * from './iam/index';
7
+ // business module
8
+ export * from './business/index';
9
9
  // menus module
10
10
  export * from './menus/preset/index';
11
11
  // reservations module
@@ -1,8 +1,8 @@
1
+ import { Either } from "purify-ts";
1
2
  import { CancellationReason, ReservationStatus, TimelineDirection } from "../../enum";
3
+ import { Reservation } from "../shared/reservation";
2
4
  import { GetTransitionsRequest } from "./types/get-available-transitions";
3
5
  import { GetByIdAdminRequest } from "./types/get-id";
4
- import { Reservation } from "../shared/reservation";
5
- import { Either } from "purify-ts";
6
6
  export declare class ReservationsAdminAPIs {
7
7
  static getPage(props: {
8
8
  token?: string;
@@ -35,12 +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";
40
38
  import { format } from "date-fns";
41
39
  import { Left, Right } from "purify-ts";
42
- import { parseReservationDeal } from "../shared/reservation-deal";
40
+ import { base } from "../../constants";
41
+ import { ErrorWithMetadata } from "../../types";
43
42
  import { RequestUtils } from "../../utils/request-utils";
43
+ import { parseReservationDeal } from "../shared/reservation-deal";
44
44
  var ReservationsAdminAPIs = /** @class */ (function () {
45
45
  function ReservationsAdminAPIs() {
46
46
  }
@@ -1,6 +1,6 @@
1
1
  import { CancellationReason, ReservationEventKind, ReservationStatus } from "../../enum";
2
2
  import { ReservationDeal } from "./reservation-deal";
3
- export interface Business {
3
+ export interface BusinessOfReservation {
4
4
  id: string;
5
5
  identifier: string;
6
6
  name: string;
@@ -38,7 +38,7 @@ export interface Reservation {
38
38
  id: string;
39
39
  isSetByAdmin: boolean;
40
40
  createdAt: string;
41
- business: Business;
41
+ business: BusinessOfReservation;
42
42
  user: User;
43
43
  datetime: string;
44
44
  status: ReservationStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "1.24.0",
3
+ "version": "1.26.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [