@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/objects_api.js
CHANGED
|
@@ -18,85 +18,69 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
18
18
|
(0, _classCallCheck2["default"])(this, ObjectsApi);
|
|
19
19
|
this.config = config;
|
|
20
20
|
this.list_url = "".concat(this.config.base_url, "v1/object/");
|
|
21
|
+
this.bulk_url = "".concat(this.config.base_url, "v1/bulk/object/");
|
|
21
22
|
}
|
|
22
23
|
(0, _createClass2["default"])(ObjectsApi, [{
|
|
23
|
-
key: "
|
|
24
|
-
value: function
|
|
24
|
+
key: "__get_headers",
|
|
25
|
+
value: function __get_headers() {
|
|
25
26
|
return {
|
|
26
27
|
"Content-Type": "application/json; charset=utf-8",
|
|
27
28
|
"User-Agent": this.config.user_agent,
|
|
28
|
-
Date: new Date().toISOString()
|
|
29
|
+
Date: new Date().toISOString()
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
}, {
|
|
32
|
-
key: "
|
|
33
|
-
value: function
|
|
34
|
-
if (!(0, _utils.is_string)(object_type)) {
|
|
35
|
-
throw new _utils.InputValueError("object_type must be a string");
|
|
36
|
-
}
|
|
37
|
-
object_type = object_type.trim();
|
|
38
|
-
if (!object_type) {
|
|
33
|
+
key: "_validate_object_type",
|
|
34
|
+
value: function _validate_object_type(object_type) {
|
|
35
|
+
if (!object_type || !(0, _utils.is_string)(object_type) || !object_type.trim()) {
|
|
39
36
|
throw new _utils.InputValueError("missing object_type");
|
|
40
37
|
}
|
|
41
|
-
return object_type;
|
|
38
|
+
return object_type.trim();
|
|
42
39
|
}
|
|
43
40
|
}, {
|
|
44
|
-
key: "
|
|
45
|
-
value: function
|
|
46
|
-
if (!(0, _utils.is_string)(object_id)) {
|
|
47
|
-
throw new _utils.InputValueError("object_id must be a string");
|
|
48
|
-
}
|
|
49
|
-
object_id = object_id.trim();
|
|
50
|
-
if (!object_id) {
|
|
41
|
+
key: "_validate_object_id",
|
|
42
|
+
value: function _validate_object_id(object_id) {
|
|
43
|
+
if (!object_id || !(0, _utils.is_string)(object_id) || !object_id.trim()) {
|
|
51
44
|
throw new _utils.InputValueError("missing object_id");
|
|
52
45
|
}
|
|
53
|
-
return object_id;
|
|
46
|
+
return object_id.trim();
|
|
54
47
|
}
|
|
55
48
|
}, {
|
|
56
49
|
key: "list",
|
|
57
50
|
value: function () {
|
|
58
|
-
var _list = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(object_type) {
|
|
59
|
-
var
|
|
60
|
-
params,
|
|
61
|
-
validated_type,
|
|
62
|
-
encoded_type,
|
|
63
|
-
url,
|
|
64
|
-
headers,
|
|
65
|
-
signature,
|
|
66
|
-
response,
|
|
67
|
-
_args = arguments;
|
|
51
|
+
var _list = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(object_type, options) {
|
|
52
|
+
var object_type_encoded, encoded_options, url, headers, sig, response;
|
|
68
53
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
69
54
|
while (1) {
|
|
70
55
|
switch (_context.prev = _context.next) {
|
|
71
56
|
case 0:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_context.
|
|
81
|
-
_context.next = 11;
|
|
57
|
+
object_type = this._validate_object_type(object_type);
|
|
58
|
+
object_type_encoded = encodeURIComponent(object_type);
|
|
59
|
+
encoded_options = options ? new URLSearchParams(options).toString() : "";
|
|
60
|
+
url = "".concat(this.list_url).concat(object_type_encoded, "/").concat(encoded_options ? "?".concat(encoded_options) : "");
|
|
61
|
+
headers = this.__get_headers();
|
|
62
|
+
sig = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
|
|
63
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(sig);
|
|
64
|
+
_context.prev = 7;
|
|
65
|
+
_context.next = 10;
|
|
82
66
|
return _axios["default"].get(url, {
|
|
83
67
|
headers: headers
|
|
84
68
|
});
|
|
85
|
-
case
|
|
69
|
+
case 10:
|
|
86
70
|
response = _context.sent;
|
|
87
71
|
return _context.abrupt("return", response.data);
|
|
88
|
-
case
|
|
89
|
-
_context.prev =
|
|
90
|
-
_context.t0 = _context["catch"](
|
|
72
|
+
case 14:
|
|
73
|
+
_context.prev = 14;
|
|
74
|
+
_context.t0 = _context["catch"](7);
|
|
91
75
|
throw new _utils.SuprsendApiError(_context.t0);
|
|
92
|
-
case
|
|
76
|
+
case 17:
|
|
93
77
|
case "end":
|
|
94
78
|
return _context.stop();
|
|
95
79
|
}
|
|
96
80
|
}
|
|
97
|
-
}, _callee, this, [[
|
|
81
|
+
}, _callee, this, [[7, 14]]);
|
|
98
82
|
}));
|
|
99
|
-
function list(_x) {
|
|
83
|
+
function list(_x, _x2) {
|
|
100
84
|
return _list.apply(this, arguments);
|
|
101
85
|
}
|
|
102
86
|
return list;
|
|
@@ -104,11 +88,11 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
104
88
|
}, {
|
|
105
89
|
key: "detail_url",
|
|
106
90
|
value: function detail_url(object_type, object_id) {
|
|
107
|
-
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
var
|
|
111
|
-
return "".concat(this.list_url).concat(
|
|
91
|
+
object_type = this._validate_object_type(object_type);
|
|
92
|
+
var object_type_encoded = encodeURIComponent(object_type);
|
|
93
|
+
object_id = this._validate_object_id(object_id);
|
|
94
|
+
var object_id_encoded = encodeURIComponent(object_id);
|
|
95
|
+
return "".concat(this.list_url).concat(object_type_encoded, "/").concat(object_id_encoded, "/");
|
|
112
96
|
}
|
|
113
97
|
}, {
|
|
114
98
|
key: "get",
|
|
@@ -120,7 +104,7 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
120
104
|
switch (_context2.prev = _context2.next) {
|
|
121
105
|
case 0:
|
|
122
106
|
url = this.detail_url(object_type, object_id);
|
|
123
|
-
headers = this.
|
|
107
|
+
headers = this.__get_headers();
|
|
124
108
|
signature = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
|
|
125
109
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
126
110
|
_context2.prev = 4;
|
|
@@ -142,7 +126,7 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
142
126
|
}
|
|
143
127
|
}, _callee2, this, [[4, 11]]);
|
|
144
128
|
}));
|
|
145
|
-
function get(
|
|
129
|
+
function get(_x3, _x4) {
|
|
146
130
|
return _get.apply(this, arguments);
|
|
147
131
|
}
|
|
148
132
|
return get;
|
|
@@ -151,7 +135,7 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
151
135
|
key: "upsert",
|
|
152
136
|
value: function () {
|
|
153
137
|
var _upsert = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(object_type, object_id) {
|
|
154
|
-
var
|
|
138
|
+
var payload,
|
|
155
139
|
url,
|
|
156
140
|
headers,
|
|
157
141
|
content_text,
|
|
@@ -162,32 +146,33 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
162
146
|
while (1) {
|
|
163
147
|
switch (_context3.prev = _context3.next) {
|
|
164
148
|
case 0:
|
|
165
|
-
|
|
149
|
+
payload = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
|
|
166
150
|
url = this.detail_url(object_type, object_id);
|
|
167
|
-
|
|
168
|
-
|
|
151
|
+
payload = payload || {};
|
|
152
|
+
headers = this.__get_headers();
|
|
153
|
+
content_text = JSON.stringify(payload || {});
|
|
169
154
|
signature = (0, _signature["default"])(url, "POST", content_text, headers, this.config.workspace_secret);
|
|
170
155
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
171
|
-
_context3.prev =
|
|
172
|
-
_context3.next =
|
|
156
|
+
_context3.prev = 7;
|
|
157
|
+
_context3.next = 10;
|
|
173
158
|
return _axios["default"].post(url, content_text, {
|
|
174
159
|
headers: headers
|
|
175
160
|
});
|
|
176
|
-
case
|
|
161
|
+
case 10:
|
|
177
162
|
response = _context3.sent;
|
|
178
163
|
return _context3.abrupt("return", response.data);
|
|
179
|
-
case
|
|
180
|
-
_context3.prev =
|
|
181
|
-
_context3.t0 = _context3["catch"](
|
|
164
|
+
case 14:
|
|
165
|
+
_context3.prev = 14;
|
|
166
|
+
_context3.t0 = _context3["catch"](7);
|
|
182
167
|
throw new _utils.SuprsendApiError(_context3.t0);
|
|
183
|
-
case
|
|
168
|
+
case 17:
|
|
184
169
|
case "end":
|
|
185
170
|
return _context3.stop();
|
|
186
171
|
}
|
|
187
172
|
}
|
|
188
|
-
}, _callee3, this, [[
|
|
173
|
+
}, _callee3, this, [[7, 14]]);
|
|
189
174
|
}));
|
|
190
|
-
function upsert(
|
|
175
|
+
function upsert(_x5, _x6) {
|
|
191
176
|
return _upsert.apply(this, arguments);
|
|
192
177
|
}
|
|
193
178
|
return upsert;
|
|
@@ -195,54 +180,46 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
195
180
|
}, {
|
|
196
181
|
key: "edit",
|
|
197
182
|
value: function () {
|
|
198
|
-
var _edit = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(
|
|
199
|
-
var
|
|
200
|
-
url,
|
|
201
|
-
payload,
|
|
202
|
-
edit_instance,
|
|
203
|
-
content_text,
|
|
204
|
-
headers,
|
|
205
|
-
signature,
|
|
206
|
-
response,
|
|
207
|
-
_args4 = arguments;
|
|
183
|
+
var _edit = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(edit_ins_or_object_type, object_id, edit_payload) {
|
|
184
|
+
var payload, url, edit_ins, object_type, content_text, headers, signature, response;
|
|
208
185
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
209
186
|
while (1) {
|
|
210
187
|
switch (_context4.prev = _context4.next) {
|
|
211
188
|
case 0:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
url = this.detail_url(
|
|
217
|
-
payload = edit_instance.get_payload();
|
|
189
|
+
if (edit_ins_or_object_type instanceof _object_edit["default"]) {
|
|
190
|
+
edit_ins = edit_ins_or_object_type;
|
|
191
|
+
edit_ins.validate_body();
|
|
192
|
+
payload = edit_ins.get_payload();
|
|
193
|
+
url = this.detail_url(edit_ins.object_type, edit_ins.object_id);
|
|
218
194
|
} else {
|
|
195
|
+
object_type = edit_ins_or_object_type;
|
|
196
|
+
payload = edit_payload || {};
|
|
219
197
|
url = this.detail_url(object_type, object_id);
|
|
220
|
-
payload = edit_payload;
|
|
221
198
|
}
|
|
222
199
|
content_text = JSON.stringify(payload || {});
|
|
223
|
-
headers = this.
|
|
200
|
+
headers = this.__get_headers();
|
|
224
201
|
signature = (0, _signature["default"])(url, "PATCH", content_text, headers, this.config.workspace_secret);
|
|
225
202
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
226
|
-
_context4.prev =
|
|
227
|
-
_context4.next =
|
|
203
|
+
_context4.prev = 5;
|
|
204
|
+
_context4.next = 8;
|
|
228
205
|
return _axios["default"].patch(url, content_text, {
|
|
229
206
|
headers: headers
|
|
230
207
|
});
|
|
231
|
-
case
|
|
208
|
+
case 8:
|
|
232
209
|
response = _context4.sent;
|
|
233
210
|
return _context4.abrupt("return", response.data);
|
|
234
|
-
case
|
|
235
|
-
_context4.prev =
|
|
236
|
-
_context4.t0 = _context4["catch"](
|
|
211
|
+
case 12:
|
|
212
|
+
_context4.prev = 12;
|
|
213
|
+
_context4.t0 = _context4["catch"](5);
|
|
237
214
|
throw new _utils.SuprsendApiError(_context4.t0);
|
|
238
|
-
case
|
|
215
|
+
case 15:
|
|
239
216
|
case "end":
|
|
240
217
|
return _context4.stop();
|
|
241
218
|
}
|
|
242
219
|
}
|
|
243
|
-
}, _callee4, this, [[
|
|
220
|
+
}, _callee4, this, [[5, 12]]);
|
|
244
221
|
}));
|
|
245
|
-
function edit(
|
|
222
|
+
function edit(_x7, _x8, _x9) {
|
|
246
223
|
return _edit.apply(this, arguments);
|
|
247
224
|
}
|
|
248
225
|
return edit;
|
|
@@ -257,7 +234,7 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
257
234
|
switch (_context5.prev = _context5.next) {
|
|
258
235
|
case 0:
|
|
259
236
|
url = this.detail_url(object_type, object_id);
|
|
260
|
-
headers = this.
|
|
237
|
+
headers = this.__get_headers();
|
|
261
238
|
signature = (0, _signature["default"])(url, "DELETE", "", headers, this.config.workspace_secret);
|
|
262
239
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
263
240
|
_context5.prev = 4;
|
|
@@ -291,86 +268,61 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
291
268
|
}
|
|
292
269
|
}, _callee5, this, [[4, 15]]);
|
|
293
270
|
}));
|
|
294
|
-
function _delete(
|
|
271
|
+
function _delete(_x10, _x11) {
|
|
295
272
|
return _delete2.apply(this, arguments);
|
|
296
273
|
}
|
|
297
274
|
return _delete;
|
|
298
275
|
}()
|
|
299
276
|
}, {
|
|
300
|
-
key: "
|
|
277
|
+
key: "bulk_delete",
|
|
301
278
|
value: function () {
|
|
302
|
-
var
|
|
303
|
-
var
|
|
279
|
+
var _bulk_delete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(object_type, payload) {
|
|
280
|
+
var object_type_encoded, url, headers, content_text, signature, response;
|
|
304
281
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
305
282
|
while (1) {
|
|
306
283
|
switch (_context6.prev = _context6.next) {
|
|
307
284
|
case 0:
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
case 3:
|
|
312
|
-
case "end":
|
|
313
|
-
return _context6.stop();
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}, _callee6, this);
|
|
317
|
-
}));
|
|
318
|
-
function bulk_ops_url(_x10) {
|
|
319
|
-
return _bulk_ops_url.apply(this, arguments);
|
|
320
|
-
}
|
|
321
|
-
return bulk_ops_url;
|
|
322
|
-
}()
|
|
323
|
-
}, {
|
|
324
|
-
key: "bulk_delete",
|
|
325
|
-
value: function () {
|
|
326
|
-
var _bulk_delete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(object_type, payload) {
|
|
327
|
-
var url, headers, content_text, signature, response;
|
|
328
|
-
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
329
|
-
while (1) {
|
|
330
|
-
switch (_context7.prev = _context7.next) {
|
|
331
|
-
case 0:
|
|
332
|
-
_context7.next = 2;
|
|
333
|
-
return this.bulk_ops_url(object_type);
|
|
334
|
-
case 2:
|
|
335
|
-
url = _context7.sent;
|
|
336
|
-
headers = this.get_headers();
|
|
285
|
+
object_type = this._validate_object_type(object_type);
|
|
286
|
+
object_type_encoded = encodeURIComponent(object_type);
|
|
287
|
+
url = "".concat(this.bulk_url).concat(object_type_encoded, "/");
|
|
337
288
|
payload = payload || {};
|
|
289
|
+
headers = this.__get_headers();
|
|
338
290
|
content_text = JSON.stringify(payload);
|
|
339
291
|
signature = (0, _signature["default"])(url, "DELETE", content_text, headers, this.config.workspace_secret);
|
|
340
292
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
341
|
-
|
|
342
|
-
|
|
293
|
+
_context6.prev = 8;
|
|
294
|
+
_context6.next = 11;
|
|
343
295
|
return _axios["default"]["delete"](url, {
|
|
344
296
|
headers: headers,
|
|
345
|
-
data:
|
|
297
|
+
data: content_text
|
|
346
298
|
});
|
|
347
299
|
case 11:
|
|
348
|
-
response =
|
|
300
|
+
response = _context6.sent;
|
|
349
301
|
if (!(response.status >= 200 && response.status < 300)) {
|
|
350
|
-
|
|
302
|
+
_context6.next = 16;
|
|
351
303
|
break;
|
|
352
304
|
}
|
|
353
|
-
return
|
|
305
|
+
return _context6.abrupt("return", {
|
|
354
306
|
success: true,
|
|
355
307
|
status_code: response.status
|
|
356
308
|
});
|
|
357
309
|
case 16:
|
|
358
310
|
throw new _utils.SuprsendApiError(response.statusText);
|
|
359
311
|
case 17:
|
|
360
|
-
|
|
312
|
+
_context6.next = 22;
|
|
361
313
|
break;
|
|
362
314
|
case 19:
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
throw new _utils.SuprsendApiError(
|
|
315
|
+
_context6.prev = 19;
|
|
316
|
+
_context6.t0 = _context6["catch"](8);
|
|
317
|
+
throw new _utils.SuprsendApiError(_context6.t0);
|
|
366
318
|
case 22:
|
|
367
319
|
case "end":
|
|
368
|
-
return
|
|
320
|
+
return _context6.stop();
|
|
369
321
|
}
|
|
370
322
|
}
|
|
371
|
-
},
|
|
323
|
+
}, _callee6, this, [[8, 19]]);
|
|
372
324
|
}));
|
|
373
|
-
function bulk_delete(
|
|
325
|
+
function bulk_delete(_x12, _x13) {
|
|
374
326
|
return _bulk_delete.apply(this, arguments);
|
|
375
327
|
}
|
|
376
328
|
return bulk_delete;
|
|
@@ -378,46 +330,38 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
378
330
|
}, {
|
|
379
331
|
key: "get_subscriptions",
|
|
380
332
|
value: function () {
|
|
381
|
-
var _get_subscriptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
382
|
-
var
|
|
383
|
-
|
|
384
|
-
url,
|
|
385
|
-
subscription_url,
|
|
386
|
-
headers,
|
|
387
|
-
signature,
|
|
388
|
-
response,
|
|
389
|
-
_args8 = arguments;
|
|
390
|
-
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
333
|
+
var _get_subscriptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(object_type, object_id, options) {
|
|
334
|
+
var encoded_options, _detail_url, url, headers, signature, response;
|
|
335
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
391
336
|
while (1) {
|
|
392
|
-
switch (
|
|
337
|
+
switch (_context7.prev = _context7.next) {
|
|
393
338
|
case 0:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
url =
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
signature = (0, _signature["default"])(subscription_url, "GET", "", headers, this.config.workspace_secret);
|
|
339
|
+
encoded_options = options ? new URLSearchParams(options).toString() : "";
|
|
340
|
+
_detail_url = this.detail_url(object_type, object_id);
|
|
341
|
+
url = "".concat(_detail_url, "subscription/").concat(encoded_options ? "?".concat(encoded_options) : "");
|
|
342
|
+
headers = this.__get_headers();
|
|
343
|
+
signature = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
|
|
400
344
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return _axios["default"].get(
|
|
345
|
+
_context7.prev = 6;
|
|
346
|
+
_context7.next = 9;
|
|
347
|
+
return _axios["default"].get(url, {
|
|
404
348
|
headers: headers
|
|
405
349
|
});
|
|
406
|
-
case
|
|
407
|
-
response =
|
|
408
|
-
return
|
|
409
|
-
case
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
throw new _utils.SuprsendApiError(
|
|
413
|
-
case
|
|
350
|
+
case 9:
|
|
351
|
+
response = _context7.sent;
|
|
352
|
+
return _context7.abrupt("return", response.data);
|
|
353
|
+
case 13:
|
|
354
|
+
_context7.prev = 13;
|
|
355
|
+
_context7.t0 = _context7["catch"](6);
|
|
356
|
+
throw new _utils.SuprsendApiError(_context7.t0);
|
|
357
|
+
case 16:
|
|
414
358
|
case "end":
|
|
415
|
-
return
|
|
359
|
+
return _context7.stop();
|
|
416
360
|
}
|
|
417
361
|
}
|
|
418
|
-
},
|
|
362
|
+
}, _callee7, this, [[6, 13]]);
|
|
419
363
|
}));
|
|
420
|
-
function get_subscriptions(
|
|
364
|
+
function get_subscriptions(_x14, _x15, _x16) {
|
|
421
365
|
return _get_subscriptions.apply(this, arguments);
|
|
422
366
|
}
|
|
423
367
|
return get_subscriptions;
|
|
@@ -425,39 +369,39 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
425
369
|
}, {
|
|
426
370
|
key: "create_subscriptions",
|
|
427
371
|
value: function () {
|
|
428
|
-
var _create_subscriptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
429
|
-
var url,
|
|
430
|
-
return _regenerator["default"].wrap(function
|
|
372
|
+
var _create_subscriptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(object_type, object_id, payload) {
|
|
373
|
+
var _detail_url, url, content_text, headers, signature, response;
|
|
374
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
431
375
|
while (1) {
|
|
432
|
-
switch (
|
|
376
|
+
switch (_context8.prev = _context8.next) {
|
|
433
377
|
case 0:
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
signature = (0, _signature["default"])(
|
|
378
|
+
_detail_url = this.detail_url(object_type, object_id);
|
|
379
|
+
url = "".concat(_detail_url, "subscription/");
|
|
380
|
+
payload = payload || {};
|
|
381
|
+
content_text = JSON.stringify(payload);
|
|
382
|
+
headers = this.__get_headers();
|
|
383
|
+
signature = (0, _signature["default"])(url, "POST", content_text, headers, this.config.workspace_secret);
|
|
440
384
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return _axios["default"].post(
|
|
385
|
+
_context8.prev = 7;
|
|
386
|
+
_context8.next = 10;
|
|
387
|
+
return _axios["default"].post(url, content_text, {
|
|
444
388
|
headers: headers
|
|
445
389
|
});
|
|
446
390
|
case 10:
|
|
447
|
-
response =
|
|
448
|
-
return
|
|
391
|
+
response = _context8.sent;
|
|
392
|
+
return _context8.abrupt("return", response.data);
|
|
449
393
|
case 14:
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
throw new _utils.SuprsendApiError(
|
|
394
|
+
_context8.prev = 14;
|
|
395
|
+
_context8.t0 = _context8["catch"](7);
|
|
396
|
+
throw new _utils.SuprsendApiError(_context8.t0);
|
|
453
397
|
case 17:
|
|
454
398
|
case "end":
|
|
455
|
-
return
|
|
399
|
+
return _context8.stop();
|
|
456
400
|
}
|
|
457
401
|
}
|
|
458
|
-
},
|
|
402
|
+
}, _callee8, this, [[7, 14]]);
|
|
459
403
|
}));
|
|
460
|
-
function create_subscriptions(
|
|
404
|
+
function create_subscriptions(_x17, _x18, _x19) {
|
|
461
405
|
return _create_subscriptions.apply(this, arguments);
|
|
462
406
|
}
|
|
463
407
|
return create_subscriptions;
|
|
@@ -465,52 +409,52 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
465
409
|
}, {
|
|
466
410
|
key: "delete_subscriptions",
|
|
467
411
|
value: function () {
|
|
468
|
-
var _delete_subscriptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
469
|
-
var url,
|
|
470
|
-
return _regenerator["default"].wrap(function
|
|
412
|
+
var _delete_subscriptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(object_type, object_id, payload) {
|
|
413
|
+
var _detail_url, url, content_text, headers, signature, response;
|
|
414
|
+
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
471
415
|
while (1) {
|
|
472
|
-
switch (
|
|
416
|
+
switch (_context9.prev = _context9.next) {
|
|
473
417
|
case 0:
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
signature = (0, _signature["default"])(
|
|
418
|
+
_detail_url = this.detail_url(object_type, object_id);
|
|
419
|
+
url = "".concat(_detail_url, "subscription/");
|
|
420
|
+
payload = payload || {};
|
|
421
|
+
content_text = JSON.stringify(payload);
|
|
422
|
+
headers = this.__get_headers();
|
|
423
|
+
signature = (0, _signature["default"])(url, "DELETE", content_text, headers, this.config.workspace_secret);
|
|
480
424
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return _axios["default"]["delete"](
|
|
425
|
+
_context9.prev = 7;
|
|
426
|
+
_context9.next = 10;
|
|
427
|
+
return _axios["default"]["delete"](url, {
|
|
484
428
|
headers: headers,
|
|
485
|
-
data:
|
|
429
|
+
data: content_text
|
|
486
430
|
});
|
|
487
431
|
case 10:
|
|
488
|
-
response =
|
|
432
|
+
response = _context9.sent;
|
|
489
433
|
if (!(response.status >= 200 && response.status < 300)) {
|
|
490
|
-
|
|
434
|
+
_context9.next = 15;
|
|
491
435
|
break;
|
|
492
436
|
}
|
|
493
|
-
return
|
|
437
|
+
return _context9.abrupt("return", {
|
|
494
438
|
success: true,
|
|
495
439
|
status_code: response.status
|
|
496
440
|
});
|
|
497
441
|
case 15:
|
|
498
442
|
throw new _utils.SuprsendApiError(response.statusText);
|
|
499
443
|
case 16:
|
|
500
|
-
|
|
444
|
+
_context9.next = 21;
|
|
501
445
|
break;
|
|
502
446
|
case 18:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
throw new _utils.SuprsendApiError(
|
|
447
|
+
_context9.prev = 18;
|
|
448
|
+
_context9.t0 = _context9["catch"](7);
|
|
449
|
+
throw new _utils.SuprsendApiError(_context9.t0);
|
|
506
450
|
case 21:
|
|
507
451
|
case "end":
|
|
508
|
-
return
|
|
452
|
+
return _context9.stop();
|
|
509
453
|
}
|
|
510
454
|
}
|
|
511
|
-
},
|
|
455
|
+
}, _callee9, this, [[7, 18]]);
|
|
512
456
|
}));
|
|
513
|
-
function delete_subscriptions(
|
|
457
|
+
function delete_subscriptions(_x20, _x21, _x22) {
|
|
514
458
|
return _delete_subscriptions.apply(this, arguments);
|
|
515
459
|
}
|
|
516
460
|
return delete_subscriptions;
|
|
@@ -518,46 +462,46 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
518
462
|
}, {
|
|
519
463
|
key: "get_objects_subscribed_to",
|
|
520
464
|
value: function () {
|
|
521
|
-
var _get_objects_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
465
|
+
var _get_objects_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(object_type, object_id) {
|
|
522
466
|
var options,
|
|
523
|
-
|
|
467
|
+
encoded_options,
|
|
468
|
+
_detail_url,
|
|
524
469
|
url,
|
|
525
|
-
subscription_url,
|
|
526
470
|
headers,
|
|
527
471
|
signature,
|
|
528
472
|
response,
|
|
529
|
-
|
|
530
|
-
return _regenerator["default"].wrap(function
|
|
473
|
+
_args10 = arguments;
|
|
474
|
+
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
531
475
|
while (1) {
|
|
532
|
-
switch (
|
|
476
|
+
switch (_context10.prev = _context10.next) {
|
|
533
477
|
case 0:
|
|
534
|
-
options =
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
headers = this.
|
|
539
|
-
signature = (0, _signature["default"])(
|
|
478
|
+
options = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : null;
|
|
479
|
+
encoded_options = options ? new URLSearchParams(options).toString() : "";
|
|
480
|
+
_detail_url = this.detail_url(object_type, object_id);
|
|
481
|
+
url = "".concat(_detail_url, "subscribed_to/object/").concat(encoded_options ? "?".concat(encoded_options) : "");
|
|
482
|
+
headers = this.__get_headers();
|
|
483
|
+
signature = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
|
|
540
484
|
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return _axios["default"].get(
|
|
485
|
+
_context10.prev = 7;
|
|
486
|
+
_context10.next = 10;
|
|
487
|
+
return _axios["default"].get(url, {
|
|
544
488
|
headers: headers
|
|
545
489
|
});
|
|
546
490
|
case 10:
|
|
547
|
-
response =
|
|
548
|
-
return
|
|
491
|
+
response = _context10.sent;
|
|
492
|
+
return _context10.abrupt("return", response.data);
|
|
549
493
|
case 14:
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
throw new _utils.SuprsendApiError(
|
|
494
|
+
_context10.prev = 14;
|
|
495
|
+
_context10.t0 = _context10["catch"](7);
|
|
496
|
+
throw new _utils.SuprsendApiError(_context10.t0);
|
|
553
497
|
case 17:
|
|
554
498
|
case "end":
|
|
555
|
-
return
|
|
499
|
+
return _context10.stop();
|
|
556
500
|
}
|
|
557
501
|
}
|
|
558
|
-
},
|
|
502
|
+
}, _callee10, this, [[7, 14]]);
|
|
559
503
|
}));
|
|
560
|
-
function get_objects_subscribed_to(
|
|
504
|
+
function get_objects_subscribed_to(_x23, _x24) {
|
|
561
505
|
return _get_objects_subscribed_to.apply(this, arguments);
|
|
562
506
|
}
|
|
563
507
|
return get_objects_subscribed_to;
|
|
@@ -565,9 +509,16 @@ var ObjectsApi = /*#__PURE__*/function () {
|
|
|
565
509
|
}, {
|
|
566
510
|
key: "get_instance",
|
|
567
511
|
value: function get_instance(object_type, object_id) {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
return new _object_edit["default"](this.config,
|
|
512
|
+
object_type = this._validate_object_type(object_type);
|
|
513
|
+
object_id = this._validate_object_id(object_id);
|
|
514
|
+
return new _object_edit["default"](this.config, object_type, object_id);
|
|
515
|
+
}
|
|
516
|
+
}, {
|
|
517
|
+
key: "get_edit_instance",
|
|
518
|
+
value: function get_edit_instance(object_type, object_id) {
|
|
519
|
+
object_type = this._validate_object_type(object_type);
|
|
520
|
+
object_id = this._validate_object_id(object_id);
|
|
521
|
+
return new _object_edit["default"](this.config, object_type, object_id);
|
|
571
522
|
}
|
|
572
523
|
}]);
|
|
573
524
|
return ObjectsApi;
|