@suprsend/node-sdk 1.12.0 → 1.13.1
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/dist/constants.js +2 -8
- package/dist/event.js +2 -2
- package/dist/events_bulk.js +2 -2
- package/dist/index.js +21 -0
- package/dist/object_edit.js +6 -12
- package/dist/object_edit_internal_helper.js +40 -301
- package/dist/objects_api.js +193 -242
- package/dist/request_json/workflow.json +7 -29
- package/dist/request_json/workflow_trigger.json +7 -29
- package/dist/subscriber.js +10 -27
- package/dist/subscriber_helper.js +33 -291
- package/dist/subscriber_list.js +2 -2
- package/dist/user_edit.js +412 -0
- package/dist/user_edit_internal_helper.js +363 -0
- package/dist/users_api.js +400 -98
- package/dist/users_edit_bulk.js +312 -0
- package/dist/workflow.js +2 -2
- package/dist/workflow_request.js +2 -2
- package/dist/workflow_trigger_bulk.js +2 -2
- package/dist/workflows_bulk.js +2 -2
- package/package.json +1 -1
- package/src/constants.js +0 -4
- package/src/event.js +4 -5
- package/src/events_bulk.js +3 -5
- package/src/index.js +6 -0
- package/src/object_edit.js +6 -6
- package/src/object_edit_internal_helper.js +37 -295
- package/src/objects_api.js +97 -93
- package/src/request_json/workflow.json +7 -29
- package/src/request_json/workflow_trigger.json +7 -29
- package/src/subscriber.js +8 -20
- package/src/subscriber_helper.js +34 -284
- package/src/subscriber_list.js +4 -4
- package/src/user_edit.js +360 -0
- package/src/user_edit_internal_helper.js +297 -0
- package/src/users_api.js +208 -28
- package/src/users_edit_bulk.js +211 -0
- package/src/workflow.js +4 -5
- package/src/workflow_request.js +4 -4
- package/src/workflow_trigger_bulk.js +2 -4
- package/src/workflows_bulk.js +3 -5
- package/types/index.d.ts +113 -8
- package/dist/language_codes.js +0 -197
- package/src/language_codes.js +0 -188
package/dist/users_api.js
CHANGED
|
@@ -12,25 +12,73 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
12
12
|
var _signature = _interopRequireDefault(require("./signature"));
|
|
13
13
|
var _utils = require("./utils");
|
|
14
14
|
var _axios = _interopRequireDefault(require("axios"));
|
|
15
|
+
var _user_edit = _interopRequireDefault(require("./user_edit"));
|
|
16
|
+
var _users_edit_bulk = _interopRequireDefault(require("./users_edit_bulk"));
|
|
15
17
|
var UsersApi = /*#__PURE__*/function () {
|
|
16
18
|
function UsersApi(config) {
|
|
17
19
|
(0, _classCallCheck2["default"])(this, UsersApi);
|
|
18
20
|
this.config = config;
|
|
19
21
|
this.list_url = "".concat(this.config.base_url, "v1/user/");
|
|
22
|
+
this.bulk_url = "".concat(this.config.base_url, "v1/bulk/user/");
|
|
20
23
|
}
|
|
21
24
|
(0, _createClass2["default"])(UsersApi, [{
|
|
22
|
-
key: "
|
|
23
|
-
value: function
|
|
25
|
+
key: "__get_headers",
|
|
26
|
+
value: function __get_headers() {
|
|
24
27
|
return {
|
|
25
28
|
"Content-Type": "application/json; charset=utf-8",
|
|
26
29
|
"User-Agent": this.config.user_agent,
|
|
27
|
-
Date: new Date().toISOString()
|
|
30
|
+
Date: new Date().toISOString()
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
}, {
|
|
31
|
-
key: "
|
|
32
|
-
value: function
|
|
33
|
-
|
|
34
|
+
key: "list",
|
|
35
|
+
value: function () {
|
|
36
|
+
var _list = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
37
|
+
var options,
|
|
38
|
+
encoded_options,
|
|
39
|
+
url,
|
|
40
|
+
headers,
|
|
41
|
+
sig,
|
|
42
|
+
resp,
|
|
43
|
+
_args = arguments;
|
|
44
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
45
|
+
while (1) {
|
|
46
|
+
switch (_context.prev = _context.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
options = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
|
|
49
|
+
encoded_options = options ? new URLSearchParams(options).toString() : "";
|
|
50
|
+
url = "".concat(this.list_url).concat(encoded_options ? "?".concat(encoded_options) : "");
|
|
51
|
+
headers = this.__get_headers(); // Signature and Authorization-header
|
|
52
|
+
sig = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
|
|
53
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
54
|
+
_context.prev = 6;
|
|
55
|
+
_context.next = 9;
|
|
56
|
+
return _axios["default"].get(url, {
|
|
57
|
+
headers: headers
|
|
58
|
+
});
|
|
59
|
+
case 9:
|
|
60
|
+
resp = _context.sent;
|
|
61
|
+
return _context.abrupt("return", resp.data);
|
|
62
|
+
case 13:
|
|
63
|
+
_context.prev = 13;
|
|
64
|
+
_context.t0 = _context["catch"](6);
|
|
65
|
+
throw new _utils.SuprsendApiError(_context.t0);
|
|
66
|
+
case 16:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context.stop();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, _callee, this, [[6, 13]]);
|
|
72
|
+
}));
|
|
73
|
+
function list() {
|
|
74
|
+
return _list.apply(this, arguments);
|
|
75
|
+
}
|
|
76
|
+
return list;
|
|
77
|
+
}()
|
|
78
|
+
}, {
|
|
79
|
+
key: "_validate_distinct_id",
|
|
80
|
+
value: function _validate_distinct_id(distinct_id) {
|
|
81
|
+
if (!distinct_id || !distinct_id.trim()) {
|
|
34
82
|
throw new Error("missing distinct_id");
|
|
35
83
|
}
|
|
36
84
|
return distinct_id.trim();
|
|
@@ -38,141 +86,386 @@ var UsersApi = /*#__PURE__*/function () {
|
|
|
38
86
|
}, {
|
|
39
87
|
key: "detail_url",
|
|
40
88
|
value: function detail_url(distinct_id) {
|
|
41
|
-
|
|
89
|
+
distinct_id = this._validate_distinct_id(distinct_id);
|
|
90
|
+
var distinct_id_encoded = encodeURIComponent(distinct_id);
|
|
91
|
+
return "".concat(this.list_url).concat(distinct_id_encoded, "/");
|
|
42
92
|
}
|
|
43
93
|
}, {
|
|
44
94
|
key: "get",
|
|
45
95
|
value: function () {
|
|
46
|
-
var _get = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
47
|
-
var
|
|
48
|
-
return _regenerator["default"].wrap(function
|
|
96
|
+
var _get = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(distinct_id) {
|
|
97
|
+
var url, headers, sig, resp;
|
|
98
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
49
99
|
while (1) {
|
|
50
|
-
switch (
|
|
100
|
+
switch (_context2.prev = _context2.next) {
|
|
51
101
|
case 0:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_context.next = 8;
|
|
102
|
+
url = this.detail_url(distinct_id);
|
|
103
|
+
headers = this.__get_headers(); // Signature and Authorization-header
|
|
104
|
+
sig = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
|
|
105
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
106
|
+
_context2.prev = 4;
|
|
107
|
+
_context2.next = 7;
|
|
59
108
|
return _axios["default"].get(url, {
|
|
60
109
|
headers: headers
|
|
61
110
|
});
|
|
62
|
-
case
|
|
63
|
-
|
|
64
|
-
return
|
|
65
|
-
case
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
throw new _utils.SuprsendApiError(
|
|
69
|
-
case
|
|
111
|
+
case 7:
|
|
112
|
+
resp = _context2.sent;
|
|
113
|
+
return _context2.abrupt("return", resp.data);
|
|
114
|
+
case 11:
|
|
115
|
+
_context2.prev = 11;
|
|
116
|
+
_context2.t0 = _context2["catch"](4);
|
|
117
|
+
throw new _utils.SuprsendApiError(_context2.t0);
|
|
118
|
+
case 14:
|
|
70
119
|
case "end":
|
|
71
|
-
return
|
|
120
|
+
return _context2.stop();
|
|
72
121
|
}
|
|
73
122
|
}
|
|
74
|
-
},
|
|
123
|
+
}, _callee2, this, [[4, 11]]);
|
|
75
124
|
}));
|
|
76
125
|
function get(_x) {
|
|
77
126
|
return _get.apply(this, arguments);
|
|
78
127
|
}
|
|
79
128
|
return get;
|
|
80
129
|
}()
|
|
130
|
+
}, {
|
|
131
|
+
key: "upsert",
|
|
132
|
+
value: function () {
|
|
133
|
+
var _upsert = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(distinct_id) {
|
|
134
|
+
var payload,
|
|
135
|
+
url,
|
|
136
|
+
headers,
|
|
137
|
+
content_text,
|
|
138
|
+
sig,
|
|
139
|
+
resp,
|
|
140
|
+
_args3 = arguments;
|
|
141
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
142
|
+
while (1) {
|
|
143
|
+
switch (_context3.prev = _context3.next) {
|
|
144
|
+
case 0:
|
|
145
|
+
payload = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : null;
|
|
146
|
+
url = this.detail_url(distinct_id);
|
|
147
|
+
payload = payload || {};
|
|
148
|
+
headers = this.__get_headers();
|
|
149
|
+
content_text = JSON.stringify(payload);
|
|
150
|
+
sig = (0, _signature["default"])(url, "POST", content_text, headers, this.config.workspace_secret);
|
|
151
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
152
|
+
_context3.prev = 7;
|
|
153
|
+
_context3.next = 10;
|
|
154
|
+
return _axios["default"].post(url, content_text, {
|
|
155
|
+
headers: headers
|
|
156
|
+
});
|
|
157
|
+
case 10:
|
|
158
|
+
resp = _context3.sent;
|
|
159
|
+
return _context3.abrupt("return", resp.data);
|
|
160
|
+
case 14:
|
|
161
|
+
_context3.prev = 14;
|
|
162
|
+
_context3.t0 = _context3["catch"](7);
|
|
163
|
+
throw new _utils.SuprsendApiError(_context3.t0);
|
|
164
|
+
case 17:
|
|
165
|
+
case "end":
|
|
166
|
+
return _context3.stop();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}, _callee3, this, [[7, 14]]);
|
|
170
|
+
}));
|
|
171
|
+
function upsert(_x2) {
|
|
172
|
+
return _upsert.apply(this, arguments);
|
|
173
|
+
}
|
|
174
|
+
return upsert;
|
|
175
|
+
}()
|
|
176
|
+
}, {
|
|
177
|
+
key: "async_edit",
|
|
178
|
+
value: function () {
|
|
179
|
+
var _async_edit = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(edit_instance) {
|
|
180
|
+
var a_payload, content_text, url, headers, sig, resp;
|
|
181
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
182
|
+
while (1) {
|
|
183
|
+
switch (_context4.prev = _context4.next) {
|
|
184
|
+
case 0:
|
|
185
|
+
if (edit_instance) {
|
|
186
|
+
_context4.next = 2;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
throw new _utils.InputValueError("instance is required");
|
|
190
|
+
case 2:
|
|
191
|
+
edit_instance.validate_body();
|
|
192
|
+
a_payload = edit_instance.get_async_payload();
|
|
193
|
+
edit_instance.validate_payload_size(a_payload);
|
|
194
|
+
content_text = JSON.stringify(a_payload);
|
|
195
|
+
url = "".concat(this.config.base_url, "event/");
|
|
196
|
+
headers = this.__get_headers();
|
|
197
|
+
sig = (0, _signature["default"])(url, "POST", content_text, headers, this.config.workspace_secret);
|
|
198
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
199
|
+
_context4.prev = 10;
|
|
200
|
+
_context4.next = 13;
|
|
201
|
+
return _axios["default"].post(url, content_text, {
|
|
202
|
+
headers: headers
|
|
203
|
+
});
|
|
204
|
+
case 13:
|
|
205
|
+
resp = _context4.sent;
|
|
206
|
+
if (!(resp.status >= 200 && resp.status < 300)) {
|
|
207
|
+
_context4.next = 18;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
return _context4.abrupt("return", {
|
|
211
|
+
success: true,
|
|
212
|
+
status: "success",
|
|
213
|
+
status_code: resp.status,
|
|
214
|
+
message: resp.data
|
|
215
|
+
});
|
|
216
|
+
case 18:
|
|
217
|
+
throw new _utils.SuprsendApiError(resp.statusText);
|
|
218
|
+
case 19:
|
|
219
|
+
_context4.next = 24;
|
|
220
|
+
break;
|
|
221
|
+
case 21:
|
|
222
|
+
_context4.prev = 21;
|
|
223
|
+
_context4.t0 = _context4["catch"](10);
|
|
224
|
+
throw new _utils.SuprsendApiError(_context4.t0);
|
|
225
|
+
case 24:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context4.stop();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, _callee4, this, [[10, 21]]);
|
|
231
|
+
}));
|
|
232
|
+
function async_edit(_x3) {
|
|
233
|
+
return _async_edit.apply(this, arguments);
|
|
234
|
+
}
|
|
235
|
+
return async_edit;
|
|
236
|
+
}()
|
|
237
|
+
}, {
|
|
238
|
+
key: "edit",
|
|
239
|
+
value: function () {
|
|
240
|
+
var _edit = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(edit_ins_or_distinct_id, edit_payload) {
|
|
241
|
+
var payload, url, edit_ins, distinct_id, headers, content_text, sig, resp;
|
|
242
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
243
|
+
while (1) {
|
|
244
|
+
switch (_context5.prev = _context5.next) {
|
|
245
|
+
case 0:
|
|
246
|
+
if (edit_ins_or_distinct_id instanceof _user_edit["default"]) {
|
|
247
|
+
edit_ins = edit_ins_or_distinct_id;
|
|
248
|
+
edit_ins.validate_body();
|
|
249
|
+
payload = edit_ins.get_payload();
|
|
250
|
+
url = this.detail_url(edit_ins.distinct_id);
|
|
251
|
+
} else {
|
|
252
|
+
distinct_id = edit_ins_or_distinct_id;
|
|
253
|
+
payload = edit_payload || {};
|
|
254
|
+
url = this.detail_url(distinct_id);
|
|
255
|
+
}
|
|
256
|
+
headers = this.__get_headers();
|
|
257
|
+
content_text = JSON.stringify(payload); // Signature and Authorization-header
|
|
258
|
+
sig = (0, _signature["default"])(url, "PATCH", content_text, headers, this.config.workspace_secret);
|
|
259
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
260
|
+
_context5.prev = 5;
|
|
261
|
+
_context5.next = 8;
|
|
262
|
+
return _axios["default"].patch(url, content_text, {
|
|
263
|
+
headers: headers
|
|
264
|
+
});
|
|
265
|
+
case 8:
|
|
266
|
+
resp = _context5.sent;
|
|
267
|
+
return _context5.abrupt("return", resp.data);
|
|
268
|
+
case 12:
|
|
269
|
+
_context5.prev = 12;
|
|
270
|
+
_context5.t0 = _context5["catch"](5);
|
|
271
|
+
throw new _utils.SuprsendApiError(_context5.t0);
|
|
272
|
+
case 15:
|
|
273
|
+
case "end":
|
|
274
|
+
return _context5.stop();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}, _callee5, this, [[5, 12]]);
|
|
278
|
+
}));
|
|
279
|
+
function edit(_x4, _x5) {
|
|
280
|
+
return _edit.apply(this, arguments);
|
|
281
|
+
}
|
|
282
|
+
return edit;
|
|
283
|
+
}()
|
|
284
|
+
}, {
|
|
285
|
+
key: "merge",
|
|
286
|
+
value: function () {
|
|
287
|
+
var _merge = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(distinct_id, from_user_id) {
|
|
288
|
+
var url, payload, headers, content_text, sig, resp;
|
|
289
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
290
|
+
while (1) {
|
|
291
|
+
switch (_context6.prev = _context6.next) {
|
|
292
|
+
case 0:
|
|
293
|
+
url = "".concat(this.detail_url(distinct_id), "merge/");
|
|
294
|
+
payload = {
|
|
295
|
+
from_user_id: from_user_id
|
|
296
|
+
};
|
|
297
|
+
headers = this.__get_headers();
|
|
298
|
+
content_text = JSON.stringify(payload);
|
|
299
|
+
sig = (0, _signature["default"])(url, "POST", content_text, headers, this.config.workspace_secret);
|
|
300
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
301
|
+
_context6.prev = 6;
|
|
302
|
+
_context6.next = 9;
|
|
303
|
+
return _axios["default"].post(url, content_text, {
|
|
304
|
+
headers: headers
|
|
305
|
+
});
|
|
306
|
+
case 9:
|
|
307
|
+
resp = _context6.sent;
|
|
308
|
+
return _context6.abrupt("return", resp.data);
|
|
309
|
+
case 13:
|
|
310
|
+
_context6.prev = 13;
|
|
311
|
+
_context6.t0 = _context6["catch"](6);
|
|
312
|
+
throw new _utils.SuprsendApiError(_context6.t0);
|
|
313
|
+
case 16:
|
|
314
|
+
case "end":
|
|
315
|
+
return _context6.stop();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}, _callee6, this, [[6, 13]]);
|
|
319
|
+
}));
|
|
320
|
+
function merge(_x6, _x7) {
|
|
321
|
+
return _merge.apply(this, arguments);
|
|
322
|
+
}
|
|
323
|
+
return merge;
|
|
324
|
+
}()
|
|
81
325
|
}, {
|
|
82
326
|
key: "delete",
|
|
83
327
|
value: function () {
|
|
84
|
-
var _delete2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
85
|
-
var
|
|
86
|
-
return _regenerator["default"].wrap(function
|
|
328
|
+
var _delete2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(distinct_id) {
|
|
329
|
+
var url, headers, sig, response;
|
|
330
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
87
331
|
while (1) {
|
|
88
|
-
switch (
|
|
332
|
+
switch (_context7.prev = _context7.next) {
|
|
89
333
|
case 0:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
_context2.next = 8;
|
|
334
|
+
url = this.detail_url(distinct_id);
|
|
335
|
+
headers = this.__get_headers();
|
|
336
|
+
sig = (0, _signature["default"])(url, "DELETE", "", headers, this.config.workspace_secret);
|
|
337
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
338
|
+
_context7.prev = 4;
|
|
339
|
+
_context7.next = 7;
|
|
97
340
|
return _axios["default"]["delete"](url, {
|
|
98
341
|
headers: headers
|
|
99
342
|
});
|
|
100
|
-
case
|
|
101
|
-
response =
|
|
343
|
+
case 7:
|
|
344
|
+
response = _context7.sent;
|
|
102
345
|
if (!(response.status >= 200 && response.status < 300)) {
|
|
103
|
-
|
|
346
|
+
_context7.next = 12;
|
|
104
347
|
break;
|
|
105
348
|
}
|
|
106
|
-
return
|
|
349
|
+
return _context7.abrupt("return", {
|
|
107
350
|
success: true,
|
|
108
351
|
status_code: response.status
|
|
109
352
|
});
|
|
110
|
-
case
|
|
353
|
+
case 12:
|
|
111
354
|
throw new _utils.SuprsendApiError(response.statusText);
|
|
112
|
-
case
|
|
113
|
-
|
|
355
|
+
case 13:
|
|
356
|
+
_context7.next = 18;
|
|
114
357
|
break;
|
|
115
|
-
case
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
throw new _utils.SuprsendApiError(
|
|
119
|
-
case
|
|
358
|
+
case 15:
|
|
359
|
+
_context7.prev = 15;
|
|
360
|
+
_context7.t0 = _context7["catch"](4);
|
|
361
|
+
throw new _utils.SuprsendApiError(_context7.t0);
|
|
362
|
+
case 18:
|
|
120
363
|
case "end":
|
|
121
|
-
return
|
|
364
|
+
return _context7.stop();
|
|
122
365
|
}
|
|
123
366
|
}
|
|
124
|
-
},
|
|
367
|
+
}, _callee7, this, [[4, 15]]);
|
|
125
368
|
}));
|
|
126
|
-
function _delete(
|
|
369
|
+
function _delete(_x8) {
|
|
127
370
|
return _delete2.apply(this, arguments);
|
|
128
371
|
}
|
|
129
372
|
return _delete;
|
|
130
373
|
}()
|
|
374
|
+
}, {
|
|
375
|
+
key: "bulk_delete",
|
|
376
|
+
value: function () {
|
|
377
|
+
var _bulk_delete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(payload) {
|
|
378
|
+
var url, headers, content_text, sig, resp;
|
|
379
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
380
|
+
while (1) {
|
|
381
|
+
switch (_context8.prev = _context8.next) {
|
|
382
|
+
case 0:
|
|
383
|
+
payload = payload || {};
|
|
384
|
+
url = this.bulk_url;
|
|
385
|
+
headers = this.__get_headers();
|
|
386
|
+
content_text = JSON.stringify(payload);
|
|
387
|
+
sig = (0, _signature["default"])(url, "DELETE", content_text, headers, this.config.workspace_secret);
|
|
388
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
389
|
+
_context8.prev = 6;
|
|
390
|
+
_context8.next = 9;
|
|
391
|
+
return _axios["default"]["delete"](url, {
|
|
392
|
+
data: content_text,
|
|
393
|
+
headers: headers
|
|
394
|
+
});
|
|
395
|
+
case 9:
|
|
396
|
+
resp = _context8.sent;
|
|
397
|
+
if (!(resp.status >= 200 && resp.status < 300)) {
|
|
398
|
+
_context8.next = 14;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
return _context8.abrupt("return", {
|
|
402
|
+
success: true,
|
|
403
|
+
status_code: resp.status
|
|
404
|
+
});
|
|
405
|
+
case 14:
|
|
406
|
+
throw new _utils.SuprsendApiError(resp.statusText);
|
|
407
|
+
case 15:
|
|
408
|
+
_context8.next = 20;
|
|
409
|
+
break;
|
|
410
|
+
case 17:
|
|
411
|
+
_context8.prev = 17;
|
|
412
|
+
_context8.t0 = _context8["catch"](6);
|
|
413
|
+
throw new _utils.SuprsendApiError(_context8.t0);
|
|
414
|
+
case 20:
|
|
415
|
+
case "end":
|
|
416
|
+
return _context8.stop();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}, _callee8, this, [[6, 17]]);
|
|
420
|
+
}));
|
|
421
|
+
function bulk_delete(_x9) {
|
|
422
|
+
return _bulk_delete.apply(this, arguments);
|
|
423
|
+
}
|
|
424
|
+
return bulk_delete;
|
|
425
|
+
}()
|
|
131
426
|
}, {
|
|
132
427
|
key: "get_objects_subscribed_to",
|
|
133
428
|
value: function () {
|
|
134
|
-
var _get_objects_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
429
|
+
var _get_objects_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(distinct_id) {
|
|
135
430
|
var options,
|
|
136
|
-
validated_distinct_id,
|
|
137
431
|
params,
|
|
138
432
|
url,
|
|
139
433
|
subscription_url,
|
|
140
434
|
headers,
|
|
141
435
|
signature,
|
|
142
436
|
response,
|
|
143
|
-
|
|
144
|
-
return _regenerator["default"].wrap(function
|
|
437
|
+
_args9 = arguments;
|
|
438
|
+
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
145
439
|
while (1) {
|
|
146
|
-
switch (
|
|
440
|
+
switch (_context9.prev = _context9.next) {
|
|
147
441
|
case 0:
|
|
148
|
-
options =
|
|
149
|
-
validated_distinct_id = this.validate_distinct_id(distinct_id);
|
|
442
|
+
options = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {};
|
|
150
443
|
params = new URLSearchParams(options).toString();
|
|
151
|
-
url = this.detail_url(
|
|
444
|
+
url = this.detail_url(distinct_id);
|
|
152
445
|
subscription_url = "".concat(url, "subscribed_to/object/?").concat(params);
|
|
153
|
-
headers = this.
|
|
446
|
+
headers = this.__get_headers();
|
|
154
447
|
signature = (0, _signature["default"])(subscription_url, "GET", "", headers, this.config.workspace_secret);
|
|
155
448
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
156
|
-
|
|
157
|
-
|
|
449
|
+
_context9.prev = 7;
|
|
450
|
+
_context9.next = 10;
|
|
158
451
|
return _axios["default"].get(subscription_url, {
|
|
159
452
|
headers: headers
|
|
160
453
|
});
|
|
161
|
-
case
|
|
162
|
-
response =
|
|
163
|
-
return
|
|
164
|
-
case
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
throw new _utils.SuprsendApiError(
|
|
168
|
-
case
|
|
454
|
+
case 10:
|
|
455
|
+
response = _context9.sent;
|
|
456
|
+
return _context9.abrupt("return", response.data);
|
|
457
|
+
case 14:
|
|
458
|
+
_context9.prev = 14;
|
|
459
|
+
_context9.t0 = _context9["catch"](7);
|
|
460
|
+
throw new _utils.SuprsendApiError(_context9.t0);
|
|
461
|
+
case 17:
|
|
169
462
|
case "end":
|
|
170
|
-
return
|
|
463
|
+
return _context9.stop();
|
|
171
464
|
}
|
|
172
465
|
}
|
|
173
|
-
},
|
|
466
|
+
}, _callee9, this, [[7, 14]]);
|
|
174
467
|
}));
|
|
175
|
-
function get_objects_subscribed_to(
|
|
468
|
+
function get_objects_subscribed_to(_x10) {
|
|
176
469
|
return _get_objects_subscribed_to.apply(this, arguments);
|
|
177
470
|
}
|
|
178
471
|
return get_objects_subscribed_to;
|
|
@@ -180,52 +473,61 @@ var UsersApi = /*#__PURE__*/function () {
|
|
|
180
473
|
}, {
|
|
181
474
|
key: "get_lists_subscribed_to",
|
|
182
475
|
value: function () {
|
|
183
|
-
var _get_lists_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
476
|
+
var _get_lists_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(distinct_id) {
|
|
184
477
|
var options,
|
|
185
|
-
validated_distinct_id,
|
|
186
478
|
params,
|
|
187
479
|
url,
|
|
188
480
|
subscription_url,
|
|
189
481
|
headers,
|
|
190
482
|
signature,
|
|
191
483
|
response,
|
|
192
|
-
|
|
193
|
-
return _regenerator["default"].wrap(function
|
|
484
|
+
_args10 = arguments;
|
|
485
|
+
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
194
486
|
while (1) {
|
|
195
|
-
switch (
|
|
487
|
+
switch (_context10.prev = _context10.next) {
|
|
196
488
|
case 0:
|
|
197
|
-
options =
|
|
198
|
-
validated_distinct_id = this.validate_distinct_id(distinct_id);
|
|
489
|
+
options = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
|
|
199
490
|
params = new URLSearchParams(options).toString();
|
|
200
|
-
url = this.detail_url(
|
|
491
|
+
url = this.detail_url(distinct_id);
|
|
201
492
|
subscription_url = "".concat(url, "subscribed_to/list/?").concat(params);
|
|
202
|
-
headers = this.
|
|
493
|
+
headers = this.__get_headers();
|
|
203
494
|
signature = (0, _signature["default"])(subscription_url, "GET", "", headers, this.config.workspace_secret);
|
|
204
495
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
205
|
-
|
|
206
|
-
|
|
496
|
+
_context10.prev = 7;
|
|
497
|
+
_context10.next = 10;
|
|
207
498
|
return _axios["default"].get(subscription_url, {
|
|
208
499
|
headers: headers
|
|
209
500
|
});
|
|
210
|
-
case
|
|
211
|
-
response =
|
|
212
|
-
return
|
|
213
|
-
case
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
throw new _utils.SuprsendApiError(
|
|
217
|
-
case
|
|
501
|
+
case 10:
|
|
502
|
+
response = _context10.sent;
|
|
503
|
+
return _context10.abrupt("return", response.data);
|
|
504
|
+
case 14:
|
|
505
|
+
_context10.prev = 14;
|
|
506
|
+
_context10.t0 = _context10["catch"](7);
|
|
507
|
+
throw new _utils.SuprsendApiError(_context10.t0);
|
|
508
|
+
case 17:
|
|
218
509
|
case "end":
|
|
219
|
-
return
|
|
510
|
+
return _context10.stop();
|
|
220
511
|
}
|
|
221
512
|
}
|
|
222
|
-
},
|
|
513
|
+
}, _callee10, this, [[7, 14]]);
|
|
223
514
|
}));
|
|
224
|
-
function get_lists_subscribed_to(
|
|
515
|
+
function get_lists_subscribed_to(_x11) {
|
|
225
516
|
return _get_lists_subscribed_to.apply(this, arguments);
|
|
226
517
|
}
|
|
227
518
|
return get_lists_subscribed_to;
|
|
228
519
|
}()
|
|
520
|
+
}, {
|
|
521
|
+
key: "get_edit_instance",
|
|
522
|
+
value: function get_edit_instance(distinct_id) {
|
|
523
|
+
distinct_id = this._validate_distinct_id(distinct_id);
|
|
524
|
+
return new _user_edit["default"](this.config, distinct_id);
|
|
525
|
+
}
|
|
526
|
+
}, {
|
|
527
|
+
key: "get_bulk_edit_instance",
|
|
528
|
+
value: function get_bulk_edit_instance() {
|
|
529
|
+
return new _users_edit_bulk["default"](this.config);
|
|
530
|
+
}
|
|
229
531
|
}]);
|
|
230
532
|
return UsersApi;
|
|
231
533
|
}();
|