shred-api-client 1.0.20 → 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
  }
@@ -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.20",
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",