@suprsend/node-sdk 1.12.0 → 1.13.0

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.
Files changed (44) hide show
  1. package/dist/constants.js +2 -8
  2. package/dist/event.js +2 -2
  3. package/dist/events_bulk.js +2 -2
  4. package/dist/index.js +21 -0
  5. package/dist/object_edit.js +6 -12
  6. package/dist/object_edit_internal_helper.js +40 -301
  7. package/dist/objects_api.js +193 -242
  8. package/dist/request_json/workflow.json +7 -29
  9. package/dist/request_json/workflow_trigger.json +7 -29
  10. package/dist/subscriber.js +10 -27
  11. package/dist/subscriber_helper.js +33 -291
  12. package/dist/subscriber_list.js +2 -2
  13. package/dist/user_edit.js +412 -0
  14. package/dist/user_edit_internal_helper.js +363 -0
  15. package/dist/users_api.js +400 -98
  16. package/dist/users_edit_bulk.js +312 -0
  17. package/dist/workflow.js +2 -2
  18. package/dist/workflow_request.js +2 -2
  19. package/dist/workflow_trigger_bulk.js +2 -2
  20. package/dist/workflows_bulk.js +2 -2
  21. package/package.json +1 -1
  22. package/src/constants.js +0 -4
  23. package/src/event.js +4 -5
  24. package/src/events_bulk.js +3 -5
  25. package/src/index.js +6 -0
  26. package/src/object_edit.js +6 -6
  27. package/src/object_edit_internal_helper.js +37 -295
  28. package/src/objects_api.js +97 -93
  29. package/src/request_json/workflow.json +7 -29
  30. package/src/request_json/workflow_trigger.json +7 -29
  31. package/src/subscriber.js +8 -20
  32. package/src/subscriber_helper.js +34 -284
  33. package/src/subscriber_list.js +4 -4
  34. package/src/user_edit.js +360 -0
  35. package/src/user_edit_internal_helper.js +297 -0
  36. package/src/users_api.js +207 -27
  37. package/src/users_edit_bulk.js +211 -0
  38. package/src/workflow.js +4 -5
  39. package/src/workflow_request.js +4 -4
  40. package/src/workflow_trigger_bulk.js +2 -4
  41. package/src/workflows_bulk.js +3 -5
  42. package/types/index.d.ts +113 -8
  43. package/dist/language_codes.js +0 -197
  44. package/src/language_codes.js +0 -188
@@ -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: "get_headers",
24
- value: function get_headers() {
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() // Adjust to your header date format
29
+ Date: new Date().toISOString()
29
30
  };
30
31
  }
31
32
  }, {
32
- key: "validate_object_type",
33
- value: function validate_object_type(object_type) {
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: "validate_object_id",
45
- value: function validate_object_id(object_id) {
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 options,
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
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
73
- params = new URLSearchParams(options).toString();
74
- validated_type = this.validate_object_type(object_type);
75
- encoded_type = encodeURIComponent(validated_type);
76
- url = "".concat(this.list_url).concat(encoded_type, "/?").concat(params);
77
- headers = this.get_headers();
78
- signature = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
79
- headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
80
- _context.prev = 8;
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 11:
69
+ case 10:
86
70
  response = _context.sent;
87
71
  return _context.abrupt("return", response.data);
88
- case 15:
89
- _context.prev = 15;
90
- _context.t0 = _context["catch"](8);
72
+ case 14:
73
+ _context.prev = 14;
74
+ _context.t0 = _context["catch"](7);
91
75
  throw new _utils.SuprsendApiError(_context.t0);
92
- case 18:
76
+ case 17:
93
77
  case "end":
94
78
  return _context.stop();
95
79
  }
96
80
  }
97
- }, _callee, this, [[8, 15]]);
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
- var validated_type = this.validate_object_type(object_type);
108
- var encoded_type = encodeURIComponent(validated_type);
109
- var validated_id = this.validate_object_id(object_id);
110
- var encoded_id = encodeURIComponent(validated_id);
111
- return "".concat(this.list_url).concat(encoded_type, "/").concat(encoded_id, "/");
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.get_headers();
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(_x2, _x3) {
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 object_payload,
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
- object_payload = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
149
+ payload = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
166
150
  url = this.detail_url(object_type, object_id);
167
- headers = this.get_headers();
168
- content_text = JSON.stringify(object_payload || {});
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 = 6;
172
- _context3.next = 9;
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 9:
161
+ case 10:
177
162
  response = _context3.sent;
178
163
  return _context3.abrupt("return", response.data);
179
- case 13:
180
- _context3.prev = 13;
181
- _context3.t0 = _context3["catch"](6);
164
+ case 14:
165
+ _context3.prev = 14;
166
+ _context3.t0 = _context3["catch"](7);
182
167
  throw new _utils.SuprsendApiError(_context3.t0);
183
- case 16:
168
+ case 17:
184
169
  case "end":
185
170
  return _context3.stop();
186
171
  }
187
172
  }
188
- }, _callee3, this, [[6, 13]]);
173
+ }, _callee3, this, [[7, 14]]);
189
174
  }));
190
- function upsert(_x4, _x5) {
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(object_type, object_id) {
199
- var edit_payload,
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
- edit_payload = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
213
- if (object_type instanceof _object_edit["default"]) {
214
- edit_instance = object_type;
215
- edit_instance.validate_body();
216
- url = this.detail_url(edit_instance.get_object_type(), edit_instance.get_object_id());
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.get_headers();
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 = 6;
227
- _context4.next = 9;
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 9:
208
+ case 8:
232
209
  response = _context4.sent;
233
210
  return _context4.abrupt("return", response.data);
234
- case 13:
235
- _context4.prev = 13;
236
- _context4.t0 = _context4["catch"](6);
211
+ case 12:
212
+ _context4.prev = 12;
213
+ _context4.t0 = _context4["catch"](5);
237
214
  throw new _utils.SuprsendApiError(_context4.t0);
238
- case 16:
215
+ case 15:
239
216
  case "end":
240
217
  return _context4.stop();
241
218
  }
242
219
  }
243
- }, _callee4, this, [[6, 13]]);
220
+ }, _callee4, this, [[5, 12]]);
244
221
  }));
245
- function edit(_x6, _x7) {
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.get_headers();
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(_x8, _x9) {
271
+ function _delete(_x10, _x11) {
295
272
  return _delete2.apply(this, arguments);
296
273
  }
297
274
  return _delete;
298
275
  }()
299
276
  }, {
300
- key: "bulk_ops_url",
277
+ key: "bulk_delete",
301
278
  value: function () {
302
- var _bulk_ops_url = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(object_type) {
303
- var validatedType, encodedType;
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
- validatedType = this.validate_object_type(object_type);
309
- encodedType = encodeURIComponent(validatedType);
310
- return _context6.abrupt("return", "".concat(this.config.base_url, "v1/bulk/object/").concat(encodedType, "/"));
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
- _context7.prev = 8;
342
- _context7.next = 11;
293
+ _context6.prev = 8;
294
+ _context6.next = 11;
343
295
  return _axios["default"]["delete"](url, {
344
296
  headers: headers,
345
- data: payload
297
+ data: content_text
346
298
  });
347
299
  case 11:
348
- response = _context7.sent;
300
+ response = _context6.sent;
349
301
  if (!(response.status >= 200 && response.status < 300)) {
350
- _context7.next = 16;
302
+ _context6.next = 16;
351
303
  break;
352
304
  }
353
- return _context7.abrupt("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
- _context7.next = 22;
312
+ _context6.next = 22;
361
313
  break;
362
314
  case 19:
363
- _context7.prev = 19;
364
- _context7.t0 = _context7["catch"](8);
365
- throw new _utils.SuprsendApiError(_context7.t0);
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 _context7.stop();
320
+ return _context6.stop();
369
321
  }
370
322
  }
371
- }, _callee7, this, [[8, 19]]);
323
+ }, _callee6, this, [[8, 19]]);
372
324
  }));
373
- function bulk_delete(_x11, _x12) {
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 _callee8(object_type, object_id) {
382
- var options,
383
- params,
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 (_context8.prev = _context8.next) {
337
+ switch (_context7.prev = _context7.next) {
393
338
  case 0:
394
- options = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : {};
395
- params = new URLSearchParams(options).toString();
396
- url = this.detail_url(object_type, object_id);
397
- subscription_url = "".concat(url, "subscription/?").concat(params);
398
- headers = this.get_headers();
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
- _context8.prev = 7;
402
- _context8.next = 10;
403
- return _axios["default"].get(subscription_url, {
345
+ _context7.prev = 6;
346
+ _context7.next = 9;
347
+ return _axios["default"].get(url, {
404
348
  headers: headers
405
349
  });
406
- case 10:
407
- response = _context8.sent;
408
- return _context8.abrupt("return", response.data);
409
- case 14:
410
- _context8.prev = 14;
411
- _context8.t0 = _context8["catch"](7);
412
- throw new _utils.SuprsendApiError(_context8.t0);
413
- case 17:
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 _context8.stop();
359
+ return _context7.stop();
416
360
  }
417
361
  }
418
- }, _callee8, this, [[7, 14]]);
362
+ }, _callee7, this, [[6, 13]]);
419
363
  }));
420
- function get_subscriptions(_x13, _x14) {
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 _callee9(object_type, object_id, subscriptions) {
429
- var url, subscription_url, headers, content_text, signature, response;
430
- return _regenerator["default"].wrap(function _callee9$(_context9) {
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 (_context9.prev = _context9.next) {
376
+ switch (_context8.prev = _context8.next) {
433
377
  case 0:
434
- url = this.detail_url(object_type, object_id);
435
- subscription_url = "".concat(url, "subscription/");
436
- headers = this.get_headers();
437
- subscriptions = subscriptions || {};
438
- content_text = JSON.stringify(subscriptions);
439
- signature = (0, _signature["default"])(subscription_url, "POST", content_text, headers, this.config.workspace_secret);
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
- _context9.prev = 7;
442
- _context9.next = 10;
443
- return _axios["default"].post(subscription_url, content_text, {
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 = _context9.sent;
448
- return _context9.abrupt("return", response.data);
391
+ response = _context8.sent;
392
+ return _context8.abrupt("return", response.data);
449
393
  case 14:
450
- _context9.prev = 14;
451
- _context9.t0 = _context9["catch"](7);
452
- throw new _utils.SuprsendApiError(_context9.t0);
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 _context9.stop();
399
+ return _context8.stop();
456
400
  }
457
401
  }
458
- }, _callee9, this, [[7, 14]]);
402
+ }, _callee8, this, [[7, 14]]);
459
403
  }));
460
- function create_subscriptions(_x15, _x16, _x17) {
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 _callee10(object_type, object_id, subscriptions) {
469
- var url, subscription_url, headers, content_text, signature, response;
470
- return _regenerator["default"].wrap(function _callee10$(_context10) {
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 (_context10.prev = _context10.next) {
416
+ switch (_context9.prev = _context9.next) {
473
417
  case 0:
474
- url = this.detail_url(object_type, object_id);
475
- subscription_url = "".concat(url, "subscription/");
476
- headers = this.get_headers();
477
- subscriptions = subscriptions || {};
478
- content_text = JSON.stringify(subscriptions);
479
- signature = (0, _signature["default"])(subscription_url, "DELETE", content_text, headers, this.config.workspace_secret);
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
- _context10.prev = 7;
482
- _context10.next = 10;
483
- return _axios["default"]["delete"](subscription_url, {
425
+ _context9.prev = 7;
426
+ _context9.next = 10;
427
+ return _axios["default"]["delete"](url, {
484
428
  headers: headers,
485
- data: subscriptions
429
+ data: content_text
486
430
  });
487
431
  case 10:
488
- response = _context10.sent;
432
+ response = _context9.sent;
489
433
  if (!(response.status >= 200 && response.status < 300)) {
490
- _context10.next = 15;
434
+ _context9.next = 15;
491
435
  break;
492
436
  }
493
- return _context10.abrupt("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
- _context10.next = 21;
444
+ _context9.next = 21;
501
445
  break;
502
446
  case 18:
503
- _context10.prev = 18;
504
- _context10.t0 = _context10["catch"](7);
505
- throw new _utils.SuprsendApiError(_context10.t0);
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 _context10.stop();
452
+ return _context9.stop();
509
453
  }
510
454
  }
511
- }, _callee10, this, [[7, 18]]);
455
+ }, _callee9, this, [[7, 18]]);
512
456
  }));
513
- function delete_subscriptions(_x18, _x19, _x20) {
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 _callee11(object_type, object_id) {
465
+ var _get_objects_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(object_type, object_id) {
522
466
  var options,
523
- params,
467
+ encoded_options,
468
+ _detail_url,
524
469
  url,
525
- subscription_url,
526
470
  headers,
527
471
  signature,
528
472
  response,
529
- _args11 = arguments;
530
- return _regenerator["default"].wrap(function _callee11$(_context11) {
473
+ _args10 = arguments;
474
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
531
475
  while (1) {
532
- switch (_context11.prev = _context11.next) {
476
+ switch (_context10.prev = _context10.next) {
533
477
  case 0:
534
- options = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
535
- params = new URLSearchParams(options).toString();
536
- url = this.detail_url(object_type, object_id);
537
- subscription_url = "".concat(url, "subscribed_to/object/?").concat(params);
538
- headers = this.get_headers();
539
- signature = (0, _signature["default"])(subscription_url, "GET", "", headers, this.config.workspace_secret);
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
- _context11.prev = 7;
542
- _context11.next = 10;
543
- return _axios["default"].get(subscription_url, {
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 = _context11.sent;
548
- return _context11.abrupt("return", response.data);
491
+ response = _context10.sent;
492
+ return _context10.abrupt("return", response.data);
549
493
  case 14:
550
- _context11.prev = 14;
551
- _context11.t0 = _context11["catch"](7);
552
- throw new _utils.SuprsendApiError(_context11.t0);
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 _context11.stop();
499
+ return _context10.stop();
556
500
  }
557
501
  }
558
- }, _callee11, this, [[7, 14]]);
502
+ }, _callee10, this, [[7, 14]]);
559
503
  }));
560
- function get_objects_subscribed_to(_x21, _x22) {
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
- var validated_type = this.validate_object_type(object_type);
569
- var validated_id = this.validate_object_id(object_id);
570
- return new _object_edit["default"](this.config, validated_type, validated_id);
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;