@knocklabs/client 0.8.14 → 0.8.16
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 +22 -13
- package/dist/cjs/api.js +33 -56
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/clients/feed/feed.js +492 -624
- package/dist/cjs/clients/feed/feed.js.map +1 -1
- package/dist/cjs/clients/feed/index.js +1 -10
- package/dist/cjs/clients/feed/index.js.map +1 -1
- package/dist/cjs/clients/feed/interfaces.js.map +1 -1
- package/dist/cjs/clients/feed/store.js +4 -15
- package/dist/cjs/clients/feed/store.js.map +1 -1
- package/dist/cjs/clients/feed/types.js.map +1 -1
- package/dist/cjs/clients/feed/utils.js +0 -5
- package/dist/cjs/clients/feed/utils.js.map +1 -1
- package/dist/cjs/clients/preferences/index.js +216 -249
- package/dist/cjs/clients/preferences/index.js.map +1 -1
- package/dist/cjs/clients/preferences/interfaces.js.map +1 -1
- package/dist/cjs/clients/users/index.js +185 -0
- package/dist/cjs/clients/users/index.js.map +1 -0
- package/dist/cjs/clients/users/interfaces.js +6 -0
- package/dist/cjs/clients/users/interfaces.js.map +1 -0
- package/dist/cjs/index.js +15 -21
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces.js.map +1 -1
- package/dist/cjs/knock.js +11 -21
- package/dist/cjs/knock.js.map +1 -1
- package/dist/cjs/networkStatus.js +3 -6
- package/dist/cjs/networkStatus.js.map +1 -1
- package/dist/esm/api.js +9 -21
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/clients/feed/feed.js +69 -149
- package/dist/esm/clients/feed/feed.js.map +1 -1
- package/dist/esm/clients/feed/index.js +0 -5
- package/dist/esm/clients/feed/index.js.map +1 -1
- package/dist/esm/clients/feed/interfaces.js.map +1 -1
- package/dist/esm/clients/feed/store.js +2 -8
- package/dist/esm/clients/feed/store.js.map +1 -1
- package/dist/esm/clients/feed/types.js.map +1 -1
- package/dist/esm/clients/feed/utils.js +0 -1
- package/dist/esm/clients/feed/utils.js.map +1 -1
- package/dist/esm/clients/preferences/index.js +35 -25
- package/dist/esm/clients/preferences/index.js.map +1 -1
- package/dist/esm/clients/preferences/interfaces.js.map +1 -1
- package/dist/esm/clients/users/index.js +84 -0
- package/dist/esm/clients/users/index.js.map +1 -0
- package/dist/esm/clients/users/interfaces.js +2 -0
- package/dist/esm/clients/users/interfaces.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/knock.js +10 -22
- package/dist/esm/knock.js.map +1 -1
- package/dist/esm/networkStatus.js +3 -5
- package/dist/esm/networkStatus.js.map +1 -1
- package/dist/types/api.d.ts +1 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/clients/feed/feed.d.ts +1 -1
- package/dist/types/clients/feed/feed.d.ts.map +1 -1
- package/dist/types/clients/feed/interfaces.d.ts +2 -1
- package/dist/types/clients/feed/interfaces.d.ts.map +1 -1
- package/dist/types/clients/feed/types.d.ts +10 -10
- package/dist/types/clients/feed/types.d.ts.map +1 -1
- package/dist/types/clients/preferences/index.d.ts +27 -0
- package/dist/types/clients/preferences/index.d.ts.map +1 -1
- package/dist/types/clients/preferences/interfaces.d.ts +7 -4
- package/dist/types/clients/preferences/interfaces.d.ts.map +1 -1
- package/dist/types/clients/users/index.d.ts +16 -0
- package/dist/types/clients/users/index.d.ts.map +1 -0
- package/dist/types/clients/users/interfaces.d.ts +8 -0
- package/dist/types/clients/users/interfaces.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces.d.ts +6 -2
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/types/knock.d.ts +2 -0
- package/dist/types/knock.d.ts.map +1 -1
- package/package.json +15 -10
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
13
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
21
|
-
|
|
22
14
|
var DEFAULT_PREFERENCE_SET_ID = "default";
|
|
23
|
-
|
|
24
15
|
function buildUpdateParam(param) {
|
|
25
16
|
if ((0, _typeof2["default"])(param) === "object") {
|
|
26
17
|
return param;
|
|
27
18
|
}
|
|
28
|
-
|
|
29
19
|
return {
|
|
30
20
|
subscribed: param
|
|
31
21
|
};
|
|
32
22
|
}
|
|
33
|
-
|
|
34
23
|
var Preferences = /*#__PURE__*/function () {
|
|
35
24
|
function Preferences(instance) {
|
|
36
25
|
(0, _classCallCheck2["default"])(this, Preferences);
|
|
@@ -38,369 +27,347 @@ var Preferences = /*#__PURE__*/function () {
|
|
|
38
27
|
this.instance = instance;
|
|
39
28
|
}
|
|
40
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use `user.getAllPreferences()` instead
|
|
32
|
+
*/
|
|
41
33
|
(0, _createClass2["default"])(Preferences, [{
|
|
42
34
|
key: "getAll",
|
|
43
|
-
value: function () {
|
|
35
|
+
value: (function () {
|
|
44
36
|
var _getAll = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
45
37
|
var result;
|
|
46
38
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
47
|
-
while (1) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
case 4:
|
|
61
|
-
case "end":
|
|
62
|
-
return _context.stop();
|
|
63
|
-
}
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context.next = 2;
|
|
42
|
+
return this.instance.client().makeRequest({
|
|
43
|
+
method: "GET",
|
|
44
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences")
|
|
45
|
+
});
|
|
46
|
+
case 2:
|
|
47
|
+
result = _context.sent;
|
|
48
|
+
return _context.abrupt("return", this.handleResponse(result));
|
|
49
|
+
case 4:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
64
52
|
}
|
|
65
53
|
}, _callee, this);
|
|
66
54
|
}));
|
|
67
|
-
|
|
68
55
|
function getAll() {
|
|
69
56
|
return _getAll.apply(this, arguments);
|
|
70
57
|
}
|
|
71
|
-
|
|
72
58
|
return getAll;
|
|
73
59
|
}()
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use `user.getPreferences()` instead
|
|
62
|
+
*/
|
|
63
|
+
)
|
|
74
64
|
}, {
|
|
75
65
|
key: "get",
|
|
76
|
-
value: function () {
|
|
66
|
+
value: (function () {
|
|
77
67
|
var _get = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
78
68
|
var options,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
preferenceSetId,
|
|
70
|
+
result,
|
|
71
|
+
_args2 = arguments;
|
|
82
72
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
83
|
-
while (1) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
case 6:
|
|
99
|
-
case "end":
|
|
100
|
-
return _context2.stop();
|
|
101
|
-
}
|
|
73
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
76
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
77
|
+
_context2.next = 4;
|
|
78
|
+
return this.instance.client().makeRequest({
|
|
79
|
+
method: "GET",
|
|
80
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId)
|
|
81
|
+
});
|
|
82
|
+
case 4:
|
|
83
|
+
result = _context2.sent;
|
|
84
|
+
return _context2.abrupt("return", this.handleResponse(result));
|
|
85
|
+
case 6:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context2.stop();
|
|
102
88
|
}
|
|
103
89
|
}, _callee2, this);
|
|
104
90
|
}));
|
|
105
|
-
|
|
106
91
|
function get() {
|
|
107
92
|
return _get.apply(this, arguments);
|
|
108
93
|
}
|
|
109
|
-
|
|
110
94
|
return get;
|
|
111
95
|
}()
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Use `user.setPreferences(preferenceSet, options)` instead
|
|
98
|
+
*/
|
|
99
|
+
)
|
|
112
100
|
}, {
|
|
113
101
|
key: "set",
|
|
114
|
-
value: function () {
|
|
102
|
+
value: (function () {
|
|
115
103
|
var _set = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(preferenceSet) {
|
|
116
104
|
var options,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
preferenceSetId,
|
|
106
|
+
result,
|
|
107
|
+
_args3 = arguments;
|
|
120
108
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
121
|
-
while (1) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
case 6:
|
|
138
|
-
case "end":
|
|
139
|
-
return _context3.stop();
|
|
140
|
-
}
|
|
109
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
112
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
113
|
+
_context3.next = 4;
|
|
114
|
+
return this.instance.client().makeRequest({
|
|
115
|
+
method: "PUT",
|
|
116
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId),
|
|
117
|
+
data: preferenceSet
|
|
118
|
+
});
|
|
119
|
+
case 4:
|
|
120
|
+
result = _context3.sent;
|
|
121
|
+
return _context3.abrupt("return", this.handleResponse(result));
|
|
122
|
+
case 6:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context3.stop();
|
|
141
125
|
}
|
|
142
126
|
}, _callee3, this);
|
|
143
127
|
}));
|
|
144
|
-
|
|
145
128
|
function set(_x) {
|
|
146
129
|
return _set.apply(this, arguments);
|
|
147
130
|
}
|
|
148
|
-
|
|
149
131
|
return set;
|
|
150
132
|
}()
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Use `user.setPreferences(preferenceSet, options)` instead
|
|
135
|
+
*/
|
|
136
|
+
)
|
|
151
137
|
}, {
|
|
152
138
|
key: "setChannelTypes",
|
|
153
|
-
value: function () {
|
|
139
|
+
value: (function () {
|
|
154
140
|
var _setChannelTypes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(channelTypePreferences) {
|
|
155
141
|
var options,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
142
|
+
preferenceSetId,
|
|
143
|
+
result,
|
|
144
|
+
_args4 = arguments;
|
|
159
145
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
160
|
-
while (1) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
case 6:
|
|
177
|
-
case "end":
|
|
178
|
-
return _context4.stop();
|
|
179
|
-
}
|
|
146
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
147
|
+
case 0:
|
|
148
|
+
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
149
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
150
|
+
_context4.next = 4;
|
|
151
|
+
return this.instance.client().makeRequest({
|
|
152
|
+
method: "PUT",
|
|
153
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId, "/channel_types"),
|
|
154
|
+
data: channelTypePreferences
|
|
155
|
+
});
|
|
156
|
+
case 4:
|
|
157
|
+
result = _context4.sent;
|
|
158
|
+
return _context4.abrupt("return", this.handleResponse(result));
|
|
159
|
+
case 6:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context4.stop();
|
|
180
162
|
}
|
|
181
163
|
}, _callee4, this);
|
|
182
164
|
}));
|
|
183
|
-
|
|
184
165
|
function setChannelTypes(_x2) {
|
|
185
166
|
return _setChannelTypes.apply(this, arguments);
|
|
186
167
|
}
|
|
187
|
-
|
|
188
168
|
return setChannelTypes;
|
|
189
169
|
}()
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Use `user.setPreferences(preferenceSet, options)` instead
|
|
172
|
+
*/
|
|
173
|
+
)
|
|
190
174
|
}, {
|
|
191
175
|
key: "setChannelType",
|
|
192
|
-
value: function () {
|
|
176
|
+
value: (function () {
|
|
193
177
|
var _setChannelType = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(channelType, setting) {
|
|
194
178
|
var options,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
179
|
+
preferenceSetId,
|
|
180
|
+
result,
|
|
181
|
+
_args5 = arguments;
|
|
198
182
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
199
|
-
while (1) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
case 6:
|
|
218
|
-
case "end":
|
|
219
|
-
return _context5.stop();
|
|
220
|
-
}
|
|
183
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
184
|
+
case 0:
|
|
185
|
+
options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
|
186
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
187
|
+
_context5.next = 4;
|
|
188
|
+
return this.instance.client().makeRequest({
|
|
189
|
+
method: "PUT",
|
|
190
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId, "/channel_types/").concat(channelType),
|
|
191
|
+
data: {
|
|
192
|
+
subscribed: setting
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
case 4:
|
|
196
|
+
result = _context5.sent;
|
|
197
|
+
return _context5.abrupt("return", this.handleResponse(result));
|
|
198
|
+
case 6:
|
|
199
|
+
case "end":
|
|
200
|
+
return _context5.stop();
|
|
221
201
|
}
|
|
222
202
|
}, _callee5, this);
|
|
223
203
|
}));
|
|
224
|
-
|
|
225
204
|
function setChannelType(_x3, _x4) {
|
|
226
205
|
return _setChannelType.apply(this, arguments);
|
|
227
206
|
}
|
|
228
|
-
|
|
229
207
|
return setChannelType;
|
|
230
208
|
}()
|
|
209
|
+
/**
|
|
210
|
+
* @deprecated Use `user.setPreferences(preferenceSet, options)` instead
|
|
211
|
+
*/
|
|
212
|
+
)
|
|
231
213
|
}, {
|
|
232
214
|
key: "setWorkflows",
|
|
233
|
-
value: function () {
|
|
215
|
+
value: (function () {
|
|
234
216
|
var _setWorkflows = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(workflowPreferences) {
|
|
235
217
|
var options,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
218
|
+
preferenceSetId,
|
|
219
|
+
result,
|
|
220
|
+
_args6 = arguments;
|
|
239
221
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
240
|
-
while (1) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
case 6:
|
|
257
|
-
case "end":
|
|
258
|
-
return _context6.stop();
|
|
259
|
-
}
|
|
222
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
223
|
+
case 0:
|
|
224
|
+
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
225
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
226
|
+
_context6.next = 4;
|
|
227
|
+
return this.instance.client().makeRequest({
|
|
228
|
+
method: "PUT",
|
|
229
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId, "/workflows"),
|
|
230
|
+
data: workflowPreferences
|
|
231
|
+
});
|
|
232
|
+
case 4:
|
|
233
|
+
result = _context6.sent;
|
|
234
|
+
return _context6.abrupt("return", this.handleResponse(result));
|
|
235
|
+
case 6:
|
|
236
|
+
case "end":
|
|
237
|
+
return _context6.stop();
|
|
260
238
|
}
|
|
261
239
|
}, _callee6, this);
|
|
262
240
|
}));
|
|
263
|
-
|
|
264
241
|
function setWorkflows(_x5) {
|
|
265
242
|
return _setWorkflows.apply(this, arguments);
|
|
266
243
|
}
|
|
267
|
-
|
|
268
244
|
return setWorkflows;
|
|
269
245
|
}()
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Use `user.setPreferences(preferenceSet, options)` instead
|
|
248
|
+
*/
|
|
249
|
+
)
|
|
270
250
|
}, {
|
|
271
251
|
key: "setWorkflow",
|
|
272
|
-
value: function () {
|
|
252
|
+
value: (function () {
|
|
273
253
|
var _setWorkflow = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(workflowKey, setting) {
|
|
274
254
|
var options,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
255
|
+
preferenceSetId,
|
|
256
|
+
params,
|
|
257
|
+
result,
|
|
258
|
+
_args7 = arguments;
|
|
279
259
|
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
280
|
-
while (1) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
case 7:
|
|
298
|
-
case "end":
|
|
299
|
-
return _context7.stop();
|
|
300
|
-
}
|
|
260
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
261
|
+
case 0:
|
|
262
|
+
options = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
|
|
263
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
264
|
+
params = buildUpdateParam(setting);
|
|
265
|
+
_context7.next = 5;
|
|
266
|
+
return this.instance.client().makeRequest({
|
|
267
|
+
method: "PUT",
|
|
268
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId, "/workflows/").concat(workflowKey),
|
|
269
|
+
data: params
|
|
270
|
+
});
|
|
271
|
+
case 5:
|
|
272
|
+
result = _context7.sent;
|
|
273
|
+
return _context7.abrupt("return", this.handleResponse(result));
|
|
274
|
+
case 7:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context7.stop();
|
|
301
277
|
}
|
|
302
278
|
}, _callee7, this);
|
|
303
279
|
}));
|
|
304
|
-
|
|
305
280
|
function setWorkflow(_x6, _x7) {
|
|
306
281
|
return _setWorkflow.apply(this, arguments);
|
|
307
282
|
}
|
|
308
|
-
|
|
309
283
|
return setWorkflow;
|
|
310
284
|
}()
|
|
285
|
+
/**
|
|
286
|
+
* @deprecated Use `user.setPreferences(preferenceSet, options)` instead
|
|
287
|
+
*/
|
|
288
|
+
)
|
|
311
289
|
}, {
|
|
312
290
|
key: "setCategories",
|
|
313
|
-
value: function () {
|
|
291
|
+
value: (function () {
|
|
314
292
|
var _setCategories = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(categoryPreferences) {
|
|
315
293
|
var options,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
294
|
+
preferenceSetId,
|
|
295
|
+
result,
|
|
296
|
+
_args8 = arguments;
|
|
319
297
|
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
320
|
-
while (1) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
case 6:
|
|
337
|
-
case "end":
|
|
338
|
-
return _context8.stop();
|
|
339
|
-
}
|
|
298
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
299
|
+
case 0:
|
|
300
|
+
options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
|
|
301
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
302
|
+
_context8.next = 4;
|
|
303
|
+
return this.instance.client().makeRequest({
|
|
304
|
+
method: "PUT",
|
|
305
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId, "/categories"),
|
|
306
|
+
data: categoryPreferences
|
|
307
|
+
});
|
|
308
|
+
case 4:
|
|
309
|
+
result = _context8.sent;
|
|
310
|
+
return _context8.abrupt("return", this.handleResponse(result));
|
|
311
|
+
case 6:
|
|
312
|
+
case "end":
|
|
313
|
+
return _context8.stop();
|
|
340
314
|
}
|
|
341
315
|
}, _callee8, this);
|
|
342
316
|
}));
|
|
343
|
-
|
|
344
317
|
function setCategories(_x8) {
|
|
345
318
|
return _setCategories.apply(this, arguments);
|
|
346
319
|
}
|
|
347
|
-
|
|
348
320
|
return setCategories;
|
|
349
321
|
}()
|
|
322
|
+
/**
|
|
323
|
+
* @deprecated Use `user.setPreferences(preferenceSet, options)` instead
|
|
324
|
+
*/
|
|
325
|
+
)
|
|
350
326
|
}, {
|
|
351
327
|
key: "setCategory",
|
|
352
|
-
value: function () {
|
|
328
|
+
value: (function () {
|
|
353
329
|
var _setCategory = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(categoryKey, setting) {
|
|
354
330
|
var options,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
331
|
+
preferenceSetId,
|
|
332
|
+
params,
|
|
333
|
+
result,
|
|
334
|
+
_args9 = arguments;
|
|
359
335
|
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
360
|
-
while (1) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
case 7:
|
|
378
|
-
case "end":
|
|
379
|
-
return _context9.stop();
|
|
380
|
-
}
|
|
336
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
337
|
+
case 0:
|
|
338
|
+
options = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : {};
|
|
339
|
+
preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;
|
|
340
|
+
params = buildUpdateParam(setting);
|
|
341
|
+
_context9.next = 5;
|
|
342
|
+
return this.instance.client().makeRequest({
|
|
343
|
+
method: "PUT",
|
|
344
|
+
url: "/v1/users/".concat(this.instance.userId, "/preferences/").concat(preferenceSetId, "/categories/").concat(categoryKey),
|
|
345
|
+
data: params
|
|
346
|
+
});
|
|
347
|
+
case 5:
|
|
348
|
+
result = _context9.sent;
|
|
349
|
+
return _context9.abrupt("return", this.handleResponse(result));
|
|
350
|
+
case 7:
|
|
351
|
+
case "end":
|
|
352
|
+
return _context9.stop();
|
|
381
353
|
}
|
|
382
354
|
}, _callee9, this);
|
|
383
355
|
}));
|
|
384
|
-
|
|
385
356
|
function setCategory(_x9, _x10) {
|
|
386
357
|
return _setCategory.apply(this, arguments);
|
|
387
358
|
}
|
|
388
|
-
|
|
389
359
|
return setCategory;
|
|
390
|
-
}()
|
|
360
|
+
}())
|
|
391
361
|
}, {
|
|
392
362
|
key: "handleResponse",
|
|
393
363
|
value: function handleResponse(response) {
|
|
394
364
|
if (response.statusCode === "error") {
|
|
395
365
|
throw new Error(response.error || response.body);
|
|
396
366
|
}
|
|
397
|
-
|
|
398
367
|
return response.body;
|
|
399
368
|
}
|
|
400
369
|
}]);
|
|
401
370
|
return Preferences;
|
|
402
371
|
}();
|
|
403
|
-
|
|
404
|
-
var _default = Preferences;
|
|
405
|
-
exports["default"] = _default;
|
|
372
|
+
var _default = exports["default"] = Preferences;
|
|
406
373
|
//# sourceMappingURL=index.js.map
|