@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 +15 -0
- package/dist/package.json +1 -1
- package/dist/src/resources/preferences/interfaces.d.ts +2 -3
- package/dist/src/resources/users/index.d.ts +2 -0
- package/dist/src/resources/users/index.js +19 -0
- package/package.json +1 -1
- package/dist/src/resources/identify/index.d.ts +0 -3
- package/dist/src/resources/identify/index.js +0 -22
- package/dist/src/resources/identify/interfaces.d.ts +0 -5
- package/dist/src/resources/identify/interfaces.js +0 -2
- package/dist/src/resources/notify/index.d.ts +0 -2
- package/dist/src/resources/notify/index.js +0 -8
- package/dist/src/resources/notify/interfaces.d.ts +0 -11
- package/dist/src/resources/notify/interfaces.js +0 -2
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,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
|
-
|
|
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,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;
|