@knocklabs/node 0.2.3 → 0.2.4

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.
package/README.md CHANGED
@@ -117,6 +117,21 @@ await knockClient.preferences.setWorkflow("jhammond", "dinosaurs-loose", {
117
117
  });
118
118
  ```
119
119
 
120
+ ### Getting and setting channel data
121
+
122
+ ```javascript
123
+ const { Knock } = require("@knocklabs/node");
124
+ const knockClient = new Knock("sk_12345");
125
+
126
+ // Setting channel data for an APNS
127
+ await knockClient.users.setChannelData("jhammond", KNOCK_APNS_CHANNEL_ID, {
128
+ tokens: [apnsToken],
129
+ });
130
+
131
+ // Getting channel data for the APNS channel
132
+ await knockClient.users.getChannelData("jhammond", KNOCK_APNS_CHANNEL_ID);
133
+ ```
134
+
120
135
  ### Canceling workflows
121
136
 
122
137
  ```javascript
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -1,7 +1,6 @@
1
- export declare type ChannelType = "email" | "in_app_feed";
1
+ export declare type ChannelType = "email" | "in_app_feed" | "sms" | "push";
2
2
  export declare type ChannelTypePreferences = {
3
- email: boolean;
4
- in_app_feed: boolean;
3
+ [K in ChannelType]: boolean;
5
4
  };
6
5
  export declare type WorkflowPreferenceSetting = boolean | {
7
6
  channel_types: ChannelTypePreferences;
@@ -6,4 +6,6 @@ export declare class Users {
6
6
  identify(userId: string, properties?: IdentifyProperties): Promise<any>;
7
7
  get(userId: string): Promise<any>;
8
8
  delete(userId: string): Promise<any>;
9
+ getChannelData(userId: string, channelId: string): Promise<any>;
10
+ setChannelData(userId: string, channelId: string, channelData: Record<string, string>): Promise<any>;
9
11
  }
@@ -41,5 +41,24 @@ class Users {
41
41
  return data;
42
42
  });
43
43
  }
44
+ getChannelData(userId, channelId) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ if (!userId || !channelId) {
47
+ throw new Error(`Incomplete arguments. You must provide a 'userId' and a 'channelId'`);
48
+ }
49
+ const { data } = yield this.knock.get(`/v1/users/${userId}/channel_data/${channelId}`);
50
+ return data;
51
+ });
52
+ }
53
+ setChannelData(userId, channelId, channelData) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ if (!userId || !channelId) {
56
+ throw new Error(`Incomplete arguments. You must provide a 'userId' and a 'channelId'`);
57
+ }
58
+ const args = { data: channelData };
59
+ const { data } = yield this.knock.put(`/v1/users/${userId}/channel_data/${channelId}`, args);
60
+ return data;
61
+ });
62
+ }
44
63
  }
45
64
  exports.Users = Users;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -1,3 +0,0 @@
1
- import { Knock } from "../../knock";
2
- import { IdentifyProperties } from "./interfaces";
3
- export declare function identify(knock: Knock): (userId: string, properties?: IdentifyProperties) => Promise<any>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.identify = void 0;
13
- function identify(knock) {
14
- return (userId, properties = {}) => __awaiter(this, void 0, void 0, function* () {
15
- if (!userId) {
16
- throw new Error(`Incomplete arguments. At a minimum you need to specify 'userId'.`);
17
- }
18
- const { data } = yield knock.put(`/v1/users/${userId}`, properties);
19
- return data;
20
- });
21
- }
22
- exports.identify = identify;
@@ -1,5 +0,0 @@
1
- export interface IdentifyProperties {
2
- name?: string;
3
- email?: string;
4
- [key: string]: any;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- import { Knock } from "../../knock";
2
- export declare function notify(knock: Knock): (workflowKey: string, { actor, recipients, cancellationKey, data: notifyData, }: import("../..").TriggerWorkflowProperties) => Promise<import("../..").WorkflowRun>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.notify = void 0;
4
- function notify(knock) {
5
- // This is just an alias to triggering the workflow
6
- return knock.workflows.trigger;
7
- }
8
- exports.notify = notify;
@@ -1,11 +0,0 @@
1
- export interface NotifyProperties {
2
- actor: string;
3
- recipients?: string[];
4
- cancelationKey?: string;
5
- data?: {
6
- [key: string]: any;
7
- };
8
- }
9
- export interface CancelNotifyProperties {
10
- recipients?: string[];
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });