shred-api-client 1.0.22 → 1.1.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,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;
@@ -1,5 +1,5 @@
1
1
  type Context = {
2
2
  token: string;
3
- requestId: string;
3
+ requestId?: string;
4
4
  };
5
5
  export default Context;
@@ -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;
@@ -6,6 +6,10 @@ const SubscriptionEndpoints = {
6
6
  uri: "/subscriptions/products/public/list",
7
7
  method: "GET",
8
8
  },
9
+ Checkout: {
10
+ uri: "/subscriptions/payment/checkout",
11
+ method: "POST",
12
+ },
9
13
  UpdateUser: {
10
14
  uri: "/api/user/update",
11
15
  method: "PUT",
@@ -10,7 +10,7 @@ const HOSTS = {
10
10
  };
11
11
  const OLD_HOSTS = {
12
12
  prod: "https://api.shredmedia.co",
13
- staging: "https://api.staging.shredmedia.co",
13
+ staging: "https://api-staging.shredmedia.co",
14
14
  };
15
15
  class HTTPClient {
16
16
  async makeRequest(uri, method, data, context, useLegacyApi) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.0.22",
3
+ "version": "1.1.0",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",