@kiminix/tp-client 1.23.0 → 1.25.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.
@@ -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';
@@ -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,11 +1,10 @@
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
4
  export { NotifyAPIs } from './notify/apis';
7
5
  export { SitemapAPIs } from './sitemap/apis';
8
6
  export { StatisticsAdminAPIs } from './statistics/admin-apis';
7
+ export * from './iam/index';
9
8
  export * from './menus/preset/index';
10
9
  export * from './reservations/index';
11
10
  export * from './cashback/index';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
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
4
  export { NotifyAPIs } from './notify/apis';
7
5
  export { SitemapAPIs } from './sitemap/apis';
8
6
  export { StatisticsAdminAPIs } from './statistics/admin-apis';
7
+ // iam module
8
+ export * from './iam/index';
9
9
  // menus module
10
10
  export * from './menus/preset/index';
11
11
  // reservations module
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "1.23.0",
3
+ "version": "1.25.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [