shred-api-client 1.0.19 → 1.0.21

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.
@@ -11,7 +11,8 @@ class UserAPI {
11
11
  }
12
12
  async getUserInfo(context) {
13
13
  const endpointData = User_schema_1.UserEndpoints.GetUserInfo;
14
- const data = await this.clientHTTP.makeRequest(endpointData.uri, endpointData.method, null, context);
14
+ const data = await this.clientHTTP.makeRequest(endpointData.uri, endpointData.method, null, context, true //Use legacy api (old endpoints)
15
+ );
15
16
  return data;
16
17
  }
17
18
  }
@@ -33,4 +33,21 @@ type Product = {
33
33
  metadata: any;
34
34
  plans: Plan[];
35
35
  };
36
- export { SubscriptionAPISchema, Product, SubscriptionEndpoints };
36
+ export declare enum SubscriptionType {
37
+ CUSTOMER_SUBSCRIPTION = 0,
38
+ TENANT_SUBSCRIPTION = 1
39
+ }
40
+ type Subscription = {
41
+ id: string;
42
+ status: string;
43
+ startDate?: number;
44
+ daysUntilDue?: number;
45
+ renewAutomatically?: boolean;
46
+ currentPeriodStart?: number;
47
+ currentPeriodEnd?: number;
48
+ paymentMethodId?: string;
49
+ product: Product;
50
+ type?: SubscriptionType;
51
+ plan?: Plan;
52
+ };
53
+ export { SubscriptionAPISchema, Product, Subscription, SubscriptionEndpoints };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionEndpoints = void 0;
3
+ exports.SubscriptionEndpoints = exports.SubscriptionType = void 0;
4
4
  const SubscriptionEndpoints = {
5
5
  GetProducts: {
6
6
  uri: "/subscriptions/products/public/list",
@@ -16,3 +16,8 @@ const SubscriptionEndpoints = {
16
16
  },
17
17
  };
18
18
  exports.SubscriptionEndpoints = SubscriptionEndpoints;
19
+ var SubscriptionType;
20
+ (function (SubscriptionType) {
21
+ SubscriptionType[SubscriptionType["CUSTOMER_SUBSCRIPTION"] = 0] = "CUSTOMER_SUBSCRIPTION";
22
+ SubscriptionType[SubscriptionType["TENANT_SUBSCRIPTION"] = 1] = "TENANT_SUBSCRIPTION";
23
+ })(SubscriptionType || (exports.SubscriptionType = SubscriptionType = {}));
@@ -1,4 +1,5 @@
1
- import { Product as TProduct } from "./model/Subscription.schema";
1
+ import { Product as TProduct, Subscription as TSubscription } from "./model/Subscription.schema";
2
2
  export declare namespace Shred {
3
3
  type Product = TProduct;
4
+ type Subscription = TSubscription;
4
5
  }
@@ -1,6 +1,4 @@
1
1
  import Context from "./../model/Context";
2
2
  export default class HTTPClient {
3
- private host;
4
- constructor();
5
- makeRequest(uri: string, method: string, data: any, context?: Context): Promise<any>;
3
+ makeRequest(uri: string, method: string, data: any, context?: Context, useLegacyApi?: boolean): Promise<any>;
6
4
  }
@@ -8,15 +8,18 @@ const HOSTS = {
8
8
  prod: "https://api.shredmedia.co",
9
9
  staging: "https://api.staging.shreditapp.com",
10
10
  };
11
+ const OLD_HOSTS = {
12
+ prod: "https://api.shredmedia.co",
13
+ staging: "https://api.staging.shredmedia.co",
14
+ };
11
15
  class HTTPClient {
12
- constructor() {
16
+ async makeRequest(uri, method, data, context, useLegacyApi) {
13
17
  const env = process.env.ENV;
14
- this.host = HOSTS[env] || HOSTS.staging;
15
- }
16
- async makeRequest(uri, method, data, context) {
18
+ const hostDict = useLegacyApi ? OLD_HOSTS : HOSTS;
19
+ const host = hostDict[env] || hostDict.staging;
17
20
  const config = {
18
21
  method: method,
19
- url: this.host + uri,
22
+ url: host + uri,
20
23
  headers: {
21
24
  Authorization: (context === null || context === void 0 ? void 0 : context.token) && `Bearer ${context.token}`,
22
25
  "X-Request-ID": (context === null || context === void 0 ? void 0 : context.requestId) && context.requestId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",