shred-api-client 1.11.9 → 1.11.10

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,14 @@
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
4
  declare class NotificationAPI implements NotificationSchema {
5
5
  private env;
6
6
  private clientHTTP;
7
7
  constructor(env: Environment);
8
+ deleteTrigger(ctx: Context, triggerId: string): Promise<boolean>;
9
+ updateTrigger(ctx: Context, triggerId: string, t: Partial<Trigger>): Promise<Trigger>;
10
+ createTrigger(ctx: Context, t: Trigger): Promise<Trigger>;
11
+ getTriggers(ctx: Context): Promise<Trigger[]>;
8
12
  push(ctx: Context, notification: NotificationDetail): Promise<boolean>;
9
13
  }
10
14
  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);
@@ -1,9 +1,29 @@
1
1
  import Context from "./Context";
2
2
  import { Notification } from "./../namespace";
3
3
  interface NotificationSchema {
4
+ getTriggers: (ctx: Context) => Promise<Trigger[]>;
5
+ createTrigger: (ctx: Context, t: Trigger) => Promise<Trigger>;
6
+ deleteTrigger: (ctx: Context, triggerId: string) => Promise<boolean>;
7
+ updateTrigger: (ctx: Context, triggerId: string, trigger: Partial<Trigger>) => Promise<Trigger>;
4
8
  push: (context: Context, notification: NotificationDetail) => Promise<boolean>;
5
9
  }
6
10
  declare const NotificationEndpoints: {
11
+ Create: {
12
+ uri: string;
13
+ method: string;
14
+ };
15
+ List: {
16
+ uri: string;
17
+ method: string;
18
+ };
19
+ Update: {
20
+ uri: string;
21
+ method: string;
22
+ };
23
+ Delete: {
24
+ uri: string;
25
+ method: string;
26
+ };
7
27
  Push: {
8
28
  uri: string;
9
29
  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",
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.10",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",