shred-api-client 1.11.9 → 1.11.11

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,10 +1,15 @@
1
1
  import Environment from "../model/Env";
2
- import { NotificationSchema, NotificationDetail } from "../model/Notification.schema";
2
+ import { NotificationSchema, NotificationDetail, Trigger } from "../model/Notification.schema";
3
3
  import Context from "../model/Context";
4
+ import { APIResponse } from "../model/Api";
4
5
  declare class NotificationAPI implements NotificationSchema {
5
6
  private env;
6
7
  private clientHTTP;
7
8
  constructor(env: Environment);
9
+ deleteTrigger(ctx: Context, triggerId: string): Promise<boolean>;
10
+ updateTrigger(ctx: Context, triggerId: string, t: Partial<Trigger>): Promise<Trigger>;
11
+ createTrigger(ctx: Context, t: Trigger): Promise<Trigger>;
12
+ getTriggers(ctx: Context): Promise<APIResponse<Trigger[]>>;
8
13
  push(ctx: Context, notification: NotificationDetail): Promise<boolean>;
9
14
  }
10
15
  export default NotificationAPI;
@@ -10,6 +10,28 @@ class NotificationAPI {
10
10
  this.env = env;
11
11
  this.clientHTTP = new HTTPClient_1.default();
12
12
  }
13
+ async deleteTrigger(ctx, triggerId) {
14
+ const endpointData = Notification_schema_1.NotificationEndpoints.Delete;
15
+ const endpoint = endpointData.uri.replace(":id", triggerId);
16
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, null, ctx);
17
+ return data;
18
+ }
19
+ async updateTrigger(ctx, triggerId, t) {
20
+ const endpointData = Notification_schema_1.NotificationEndpoints.Update;
21
+ const endpoint = endpointData.uri.replace(":id", triggerId);
22
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, t, ctx);
23
+ return data;
24
+ }
25
+ async createTrigger(ctx, t) {
26
+ const endpointData = Notification_schema_1.NotificationEndpoints.Create;
27
+ const data = await this.clientHTTP.makeRequest(this.env, endpointData.uri, endpointData.method, t, ctx);
28
+ return data;
29
+ }
30
+ async getTriggers(ctx) {
31
+ const endpointInfo = Notification_schema_1.NotificationEndpoints.List;
32
+ const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, null, ctx);
33
+ return data;
34
+ }
13
35
  async push(ctx, notification) {
14
36
  const endpointInfo = Notification_schema_1.NotificationEndpoints.Push;
15
37
  const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, notification, ctx);
@@ -8,6 +8,12 @@ import { TenantAPISchema } from "./Tenant.schema";
8
8
  import { ProjectAPISchema } from "./Project.schema";
9
9
  import { APPConfigSchema } from "./AppConfig.schema";
10
10
  import { TrackAPISchema } from "./Track.schema";
11
+ export type APIResponse<T> = {
12
+ perPage: number;
13
+ last?: T;
14
+ data: T[];
15
+ count: number;
16
+ };
11
17
  export declare class ShredAPI {
12
18
  user: UserAPISchema;
13
19
  subscription: SubscriptionAPISchema;
@@ -1,9 +1,30 @@
1
1
  import Context from "./Context";
2
2
  import { Notification } from "./../namespace";
3
+ import { APIResponse } from "./Api";
3
4
  interface NotificationSchema {
5
+ getTriggers: (ctx: Context) => Promise<APIResponse<Trigger[]>>;
6
+ createTrigger: (ctx: Context, t: Trigger) => Promise<Trigger>;
7
+ deleteTrigger: (ctx: Context, triggerId: string) => Promise<boolean>;
8
+ updateTrigger: (ctx: Context, triggerId: string, trigger: Partial<Trigger>) => Promise<Trigger>;
4
9
  push: (context: Context, notification: NotificationDetail) => Promise<boolean>;
5
10
  }
6
11
  declare const NotificationEndpoints: {
12
+ Create: {
13
+ uri: string;
14
+ method: string;
15
+ };
16
+ List: {
17
+ uri: string;
18
+ method: string;
19
+ };
20
+ Update: {
21
+ uri: string;
22
+ method: string;
23
+ };
24
+ Delete: {
25
+ uri: string;
26
+ method: string;
27
+ };
7
28
  Push: {
8
29
  uri: string;
9
30
  method: string;
@@ -2,6 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NotificationEndpoints = void 0;
4
4
  const NotificationEndpoints = {
5
+ Create: {
6
+ uri: "/notifications/trigger/",
7
+ method: "POST",
8
+ },
9
+ List: {
10
+ uri: "/notifications/trigger/list/",
11
+ method: "GET",
12
+ },
13
+ Update: {
14
+ uri: "/notifications/trigger/:id/",
15
+ method: "PUT",
16
+ },
17
+ Delete: {
18
+ uri: "/notifications/trigger/:id/",
19
+ method: "DELETE",
20
+ },
5
21
  Push: {
6
22
  uri: "/notifications/push/",
7
23
  method: "POST",
@@ -1,5 +1,6 @@
1
1
  import { Product as TProduct, Subscription as TSubscription, Charge as TCharge } from "./model/Subscription.schema";
2
2
  import { Trigger as TTrigger, Criteria as TCriteria, NotificationDetail as TNContent, RecurrenceRule as TRRule, History as THistory } from "./model/Notification.schema";
3
+ import { APIResponse } from "./model/Api";
3
4
  import { System as TSystem, User as TUser, Preferences as UserPreferences, Role as TRole } from "./model/User.schema";
4
5
  import { Email as TEmail } from "./model/Email.schema";
5
6
  import { Asset as TAsset } from "./model/Asset.schema";
@@ -11,6 +12,7 @@ export declare namespace Permissions {
11
12
  type Role = TRole;
12
13
  }
13
14
  export declare namespace Shred {
15
+ type Response<T> = APIResponse<T>;
14
16
  type Tenant = TTenant;
15
17
  type Product = TProduct;
16
18
  type Subscription = TSubscription;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.11.9",
3
+ "version": "1.11.11",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",