shred-api-client 1.7.6 → 1.7.7

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,5 +1,5 @@
1
1
  import Context from "../model/Context";
2
- import { System, User, UserAPISchema } from "../model/User.schema";
2
+ import { System, Update, User, UserAPISchema } from "../model/User.schema";
3
3
  import Environment from "../model/Env";
4
4
  declare class UserAPI implements UserAPISchema {
5
5
  private env;
@@ -8,6 +8,7 @@ declare class UserAPI implements UserAPISchema {
8
8
  sendValidationCode(email: string): Promise<boolean>;
9
9
  confirmCode(email: string, code: number): Promise<boolean>;
10
10
  isEmailAvaliable(email: string): Promise<boolean>;
11
+ update(context: Context, update: Update): Promise<boolean>;
11
12
  authenticate(context: Context, system: System): Promise<string>;
12
13
  createUser(email: string, name: string, password: string, passwordConfirmation: string, profession: string | null, invitationCode: string | null): Promise<any>;
13
14
  getUserInfo(context: Context): Promise<User>;
@@ -25,6 +25,11 @@ class UserAPI {
25
25
  const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}?email=${email}`, endpointData.method);
26
26
  return data.isValid;
27
27
  }
28
+ async update(context, update) {
29
+ const endpointData = User_schema_1.UserEndpoints.UpdateUser;
30
+ const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}`, endpointData.method, Object.assign({}, update), context);
31
+ return data.isValid;
32
+ }
28
33
  async authenticate(context, system) {
29
34
  const endpointData = User_schema_1.UserEndpoints.Authenticate;
30
35
  const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}`, endpointData.method, { system }, context);
@@ -1,10 +1,12 @@
1
1
  import Context from "./Context";
2
+ export type Update = Pick<User, "name" | "profession" | "preferences" | "photoUrl" | "fcmToken">;
2
3
  interface UserAPISchema {
3
4
  getUserInfo: (context: Context) => Promise<User>;
4
5
  isEmailAvaliable: (email: string) => Promise<boolean>;
5
6
  sendValidationCode: (email: string) => Promise<boolean>;
6
7
  confirmCode: (email: string, code: number) => Promise<boolean>;
7
8
  authenticate: (context: Context, system: System) => Promise<string>;
9
+ update: (context: Context, update: Update) => Promise<boolean>;
8
10
  createUser: (email: string, name: string, password: string, passwordConfirmation: string, profession: string | null, invitationCode: string | null) => Promise<User>;
9
11
  }
10
12
  declare const UserEndpoints: {
@@ -36,6 +38,10 @@ declare const UserEndpoints: {
36
38
  uri: string;
37
39
  method: string;
38
40
  };
41
+ UpdateUser: {
42
+ uri: string;
43
+ method: string;
44
+ };
39
45
  };
40
46
  declare enum Role {
41
47
  USER = "User",
@@ -30,6 +30,10 @@ const UserEndpoints = {
30
30
  uri: "/accounts/public/create",
31
31
  method: "POST",
32
32
  },
33
+ UpdateUser: {
34
+ uri: "/accounts/user/update",
35
+ method: "PUT",
36
+ },
33
37
  };
34
38
  exports.UserEndpoints = UserEndpoints;
35
39
  var Role;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",