shred-api-client 1.1.0 → 1.1.2
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.
package/dist/api/User.api.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { User, UserAPISchema } from "../model/User.schema";
|
|
|
3
3
|
declare class UserAPI implements UserAPISchema {
|
|
4
4
|
private clientHTTP;
|
|
5
5
|
constructor();
|
|
6
|
+
createUser(email: string, name: string, newPassword: string, newPasswordConfirmation: string, profession: string | null, invitationCode: string | null): Promise<any>;
|
|
6
7
|
getUserInfo(context: Context): Promise<User>;
|
|
7
8
|
}
|
|
8
9
|
export default UserAPI;
|
package/dist/api/User.api.js
CHANGED
|
@@ -9,10 +9,30 @@ class UserAPI {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
this.clientHTTP = new HTTPClient_1.default();
|
|
11
11
|
}
|
|
12
|
+
async createUser(email, name, newPassword, newPasswordConfirmation, profession, invitationCode) {
|
|
13
|
+
const endpointData = User_schema_1.UserEndpoints.CreateUser;
|
|
14
|
+
const data = await this.clientHTTP.makeRequest(endpointData.uri, endpointData.method, {
|
|
15
|
+
email,
|
|
16
|
+
name,
|
|
17
|
+
newPassword,
|
|
18
|
+
newPasswordConfirmation,
|
|
19
|
+
profession,
|
|
20
|
+
invitationCode,
|
|
21
|
+
}, null, true //Use legacy api (old endpoints)
|
|
22
|
+
);
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
12
25
|
async getUserInfo(context) {
|
|
13
26
|
const endpointData = User_schema_1.UserEndpoints.GetUserInfo;
|
|
14
27
|
const data = await this.clientHTTP.makeRequest(endpointData.uri, endpointData.method, null, context, true //Use legacy api (old endpoints)
|
|
15
28
|
);
|
|
29
|
+
if (!data.registered) {
|
|
30
|
+
//Login by 3rd party and don't have register yet
|
|
31
|
+
const enableEndpointData = User_schema_1.UserEndpoints.EnableUser;
|
|
32
|
+
const user = await this.clientHTTP.makeRequest(enableEndpointData.uri, enableEndpointData.method, null, context, true //Use legacy api (old endpoints)
|
|
33
|
+
);
|
|
34
|
+
return user;
|
|
35
|
+
}
|
|
16
36
|
return data;
|
|
17
37
|
}
|
|
18
38
|
}
|
|
@@ -3,12 +3,21 @@ import { Subscription } from "./Subscription.schema";
|
|
|
3
3
|
import { Tenant } from "./Tenant.schema";
|
|
4
4
|
interface UserAPISchema {
|
|
5
5
|
getUserInfo: (context: Context) => Promise<User>;
|
|
6
|
+
createUser: (email: string, name: string, newPassword: string, newPasswordConfirmation: string, profession: string | null, invitationCode: string | null) => Promise<User>;
|
|
6
7
|
}
|
|
7
8
|
declare const UserEndpoints: {
|
|
8
9
|
GetUserInfo: {
|
|
9
10
|
uri: string;
|
|
10
11
|
method: string;
|
|
11
12
|
};
|
|
13
|
+
EnableUser: {
|
|
14
|
+
uri: string;
|
|
15
|
+
method: string;
|
|
16
|
+
};
|
|
17
|
+
CreateUser: {
|
|
18
|
+
uri: string;
|
|
19
|
+
method: string;
|
|
20
|
+
};
|
|
12
21
|
};
|
|
13
22
|
type Preferences = {
|
|
14
23
|
primaryColor?: string;
|
|
@@ -6,5 +6,13 @@ const UserEndpoints = {
|
|
|
6
6
|
uri: "/api/user/info",
|
|
7
7
|
method: "GET",
|
|
8
8
|
},
|
|
9
|
+
EnableUser: {
|
|
10
|
+
uri: "/api/user/register",
|
|
11
|
+
method: "POST",
|
|
12
|
+
},
|
|
13
|
+
CreateUser: {
|
|
14
|
+
uri: "/api/user/public/createAccount",
|
|
15
|
+
method: "POST",
|
|
16
|
+
},
|
|
9
17
|
};
|
|
10
18
|
exports.UserEndpoints = UserEndpoints;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import Context from "./../model/Context";
|
|
2
2
|
export default class HTTPClient {
|
|
3
|
-
makeRequest(uri: string, method: string, data: any, context?: Context, useLegacyApi?: boolean): Promise<any>;
|
|
3
|
+
makeRequest(uri: string, method: string, data: any, context?: Context | null, useLegacyApi?: boolean): Promise<any>;
|
|
4
4
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shred-api-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "API Client for Shred",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
12
|
"build": "tsc --project tsconfig.json && tscpaths -p tsconfig.json -s . -o ./dist",
|
|
13
|
-
"build:watch": "tsc -w"
|
|
13
|
+
"build:watch": "tsc -w --project tsconfig.json && tscpaths -p tsconfig.json -s . -o ./dist"
|
|
14
14
|
},
|
|
15
15
|
"author": "Marcus Cartágenes",
|
|
16
16
|
"license": "ISC",
|