shred-api-client 1.0.23 → 1.1.1
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/Subscription.api.d.ts +2 -0
- package/dist/api/Subscription.api.js +5 -0
- package/dist/api/User.api.js +7 -0
- package/dist/model/Context.d.ts +1 -1
- package/dist/model/Subscription.schema.d.ts +6 -0
- package/dist/model/Subscription.schema.js +4 -0
- package/dist/model/User.schema.d.ts +4 -0
- package/dist/model/User.schema.js +4 -0
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import Context from "../src/model/Context";
|
|
1
2
|
import { Product, SubscriptionAPISchema } from "../model/Subscription.schema";
|
|
2
3
|
declare class SubscriptionAPI implements SubscriptionAPISchema {
|
|
3
4
|
private clientHTTP;
|
|
4
5
|
constructor();
|
|
5
6
|
getProducts(): Promise<Product[]>;
|
|
7
|
+
createCheckout(planId: string, ctx: Context): Promise<string>;
|
|
6
8
|
}
|
|
7
9
|
export default SubscriptionAPI;
|
|
@@ -14,5 +14,10 @@ class SubscriptionAPI {
|
|
|
14
14
|
const data = await this.clientHTTP.makeRequest(endpointInfo.uri, endpointInfo.method, null);
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
|
+
async createCheckout(planId, ctx) {
|
|
18
|
+
const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.Checkout;
|
|
19
|
+
const data = await this.clientHTTP.makeRequest(endpointInfo.uri, endpointInfo.method, { planId }, ctx);
|
|
20
|
+
return data.url;
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
exports.default = SubscriptionAPI;
|
package/dist/api/User.api.js
CHANGED
|
@@ -13,6 +13,13 @@ class UserAPI {
|
|
|
13
13
|
const endpointData = User_schema_1.UserEndpoints.GetUserInfo;
|
|
14
14
|
const data = await this.clientHTTP.makeRequest(endpointData.uri, endpointData.method, null, context, true //Use legacy api (old endpoints)
|
|
15
15
|
);
|
|
16
|
+
if (!data.registered) {
|
|
17
|
+
//Login by 3rd party and don't have register yet
|
|
18
|
+
const enableEndpointData = User_schema_1.UserEndpoints.EnableUser;
|
|
19
|
+
const user = await this.clientHTTP.makeRequest(enableEndpointData.uri, enableEndpointData.method, null, context, true //Use legacy api (old endpoints)
|
|
20
|
+
);
|
|
21
|
+
return user;
|
|
22
|
+
}
|
|
16
23
|
return data;
|
|
17
24
|
}
|
|
18
25
|
}
|
package/dist/model/Context.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import Context from "./Context";
|
|
1
2
|
interface SubscriptionAPISchema {
|
|
2
3
|
getProducts: () => Promise<Product[]>;
|
|
4
|
+
createCheckout: (planId: string, ctx: Context) => Promise<string>;
|
|
3
5
|
}
|
|
4
6
|
declare const SubscriptionEndpoints: {
|
|
5
7
|
GetProducts: {
|
|
6
8
|
uri: string;
|
|
7
9
|
method: string;
|
|
8
10
|
};
|
|
11
|
+
Checkout: {
|
|
12
|
+
uri: string;
|
|
13
|
+
method: string;
|
|
14
|
+
};
|
|
9
15
|
UpdateUser: {
|
|
10
16
|
uri: string;
|
|
11
17
|
method: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shred-api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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",
|