shred-api-client 1.4.1 → 1.5.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,12 +1,12 @@
1
- import Context from "../src/model/Context";
1
+ import Context from "../model/Context";
2
2
  import { Product, SubscriptionAPISchema } from "../model/Subscription.schema";
3
3
  import Environment from "../model/Env";
4
4
  declare class SubscriptionAPI implements SubscriptionAPISchema {
5
5
  private env;
6
6
  private clientHTTP;
7
7
  constructor(env: Environment);
8
- getProduct(id: string): Promise<Product>;
9
- getProducts(): Promise<Product[]>;
8
+ getProduct(id: string, context?: Context): Promise<Product>;
9
+ getProducts(ctx?: Context): Promise<Product[]>;
10
10
  createCheckout(planId: string | null, ctx: Context): Promise<string>;
11
11
  }
12
12
  export default SubscriptionAPI;
@@ -10,14 +10,14 @@ class SubscriptionAPI {
10
10
  this.env = env;
11
11
  this.clientHTTP = new HTTPClient_1.default();
12
12
  }
13
- async getProduct(id) {
13
+ async getProduct(id, context) {
14
14
  const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetProduct;
15
- const data = await this.clientHTTP.makeRequest(this.env, `${endpointInfo.uri}/${id}`, endpointInfo.method, null);
15
+ const data = await this.clientHTTP.makeRequest(this.env, `${endpointInfo.uri}/${id}`, endpointInfo.method, null, context);
16
16
  return data;
17
17
  }
18
- async getProducts() {
18
+ async getProducts(ctx) {
19
19
  const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetProducts;
20
- const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, null);
20
+ const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, null, ctx);
21
21
  return data;
22
22
  }
23
23
  async createCheckout(planId, ctx) {
@@ -0,0 +1,10 @@
1
+ import Context from "../model/Context";
2
+ import { Tenant, TenantAPISchema } from "../model/Tenant.schema";
3
+ import Environment from "../model/Env";
4
+ declare class TenantAPI implements TenantAPISchema {
5
+ private env;
6
+ private clientHTTP;
7
+ constructor(env: Environment);
8
+ getByInviteCode(inviteCode: string, context?: Context): Promise<Tenant | null>;
9
+ }
10
+ export default TenantAPI;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Tenant_schema_1 = require("../model/Tenant.schema");
7
+ const HTTPClient_1 = __importDefault(require("../util/HTTPClient"));
8
+ class TenantAPI {
9
+ constructor(env) {
10
+ this.env = env;
11
+ this.clientHTTP = new HTTPClient_1.default();
12
+ }
13
+ async getByInviteCode(inviteCode, context) {
14
+ const endpointInfo = Tenant_schema_1.TenantEndpoints.GetByInviteCode;
15
+ const data = await this.clientHTTP.makeRequest(this.env, `${endpointInfo.uri}/${inviteCode}`, endpointInfo.method, null, context);
16
+ return data;
17
+ }
18
+ }
19
+ exports.default = TenantAPI;
@@ -4,11 +4,13 @@ import { SMSAPISchema } from "./SMS.schema";
4
4
  import { SubscriptionAPISchema } from "./Subscription.schema";
5
5
  import { UserAPISchema } from "./User.schema";
6
6
  import { EmailAPISchema } from "./Email.schema";
7
+ import { TenantAPISchema } from "./Tenant.schema";
7
8
  export declare class ShredAPI {
8
9
  user: UserAPISchema;
9
10
  subscription: SubscriptionAPISchema;
10
11
  prompt: PromptAPISchema;
11
12
  sms: SMSAPISchema;
12
13
  email: EmailAPISchema;
14
+ tenant: TenantAPISchema;
13
15
  constructor(env: Environment);
14
16
  }
package/dist/model/Api.js CHANGED
@@ -7,6 +7,7 @@ exports.ShredAPI = void 0;
7
7
  const SMS_api_1 = __importDefault(require("../api/SMS.api"));
8
8
  const Prompt_api_1 = __importDefault(require("../api/Prompt.api"));
9
9
  const Subscription_api_1 = __importDefault(require("../api/Subscription.api"));
10
+ const Tenant_api_1 = __importDefault(require("../api/Tenant.api"));
10
11
  const User_api_1 = __importDefault(require("../api/User.api"));
11
12
  const Email_api_1 = __importDefault(require("../api/Email.api"));
12
13
  class ShredAPI {
@@ -16,6 +17,7 @@ class ShredAPI {
16
17
  this.subscription = new Subscription_api_1.default(env);
17
18
  this.sms = new SMS_api_1.default(env);
18
19
  this.email = new Email_api_1.default(env);
20
+ this.tenant = new Tenant_api_1.default(env);
19
21
  }
20
22
  }
21
23
  exports.ShredAPI = ShredAPI;
@@ -1,7 +1,7 @@
1
1
  import Context from "./Context";
2
2
  interface SubscriptionAPISchema {
3
- getProduct: (id: string) => Promise<Product>;
4
- getProducts: () => Promise<Product[]>;
3
+ getProduct: (id: string, context?: Context) => Promise<Product>;
4
+ getProducts: (ctx?: Context) => Promise<Product[]>;
5
5
  createCheckout: (planId: string | null, ctx: Context) => Promise<string>;
6
6
  }
7
7
  declare const SubscriptionEndpoints: {
@@ -1,4 +1,14 @@
1
1
  import { Subscription } from "./Subscription.schema";
2
+ import Context from "./Context";
3
+ interface TenantAPISchema {
4
+ getByInviteCode: (code: string, context?: Context) => Promise<Tenant | null>;
5
+ }
6
+ declare const TenantEndpoints: {
7
+ GetByInviteCode: {
8
+ uri: string;
9
+ method: string;
10
+ };
11
+ };
2
12
  type Preferences = {
3
13
  iconUrl: string;
4
14
  logoUrl: string;
@@ -22,4 +32,4 @@ type Tenant = {
22
32
  useOwnScripts?: boolean;
23
33
  subscription?: Subscription;
24
34
  };
25
- export { Tenant };
35
+ export { Tenant, TenantEndpoints, TenantAPISchema };
@@ -1,2 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TenantEndpoints = void 0;
4
+ const TenantEndpoints = {
5
+ GetByInviteCode: {
6
+ uri: "/tenants/public/invitation/",
7
+ method: "GET",
8
+ },
9
+ };
10
+ exports.TenantEndpoints = TenantEndpoints;
@@ -32,12 +32,14 @@ declare const UserEndpoints: {
32
32
  declare enum Role {
33
33
  USER = "User",
34
34
  EDITOR = "Editor",
35
- QA = "QA"
35
+ QA = "QA",
36
+ ADMIN = "ADMIN"
36
37
  }
37
38
  declare enum System {
38
39
  APP = "APP",
39
40
  EDITOR = "EDITOR",
40
- QA = "QA"
41
+ QA = "QA",
42
+ ADMIN = "ADMIN"
41
43
  }
42
44
  type Preferences = {
43
45
  primaryColor?: string;
@@ -29,10 +29,12 @@ var Role;
29
29
  Role["USER"] = "User";
30
30
  Role["EDITOR"] = "Editor";
31
31
  Role["QA"] = "QA";
32
+ Role["ADMIN"] = "ADMIN";
32
33
  })(Role || (exports.Role = Role = {}));
33
34
  var System;
34
35
  (function (System) {
35
36
  System["APP"] = "APP";
36
37
  System["EDITOR"] = "EDITOR";
37
38
  System["QA"] = "QA";
39
+ System["ADMIN"] = "ADMIN";
38
40
  })(System || (exports.System = System = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",