@suprsend/node-sdk 1.11.0 → 1.11.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/object.js CHANGED
@@ -177,40 +177,47 @@ var ObjectsApi = /*#__PURE__*/function () {
177
177
  }, {
178
178
  key: "upsert",
179
179
  value: function () {
180
- var _upsert = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(objectType, objectId, objectPayload) {
181
- var url, headers, contentText, signature, response;
180
+ var _upsert = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(objectType, objectId) {
181
+ var objectPayload,
182
+ url,
183
+ headers,
184
+ contentText,
185
+ signature,
186
+ response,
187
+ _args4 = arguments;
182
188
  return _regenerator["default"].wrap(function _callee4$(_context4) {
183
189
  while (1) {
184
190
  switch (_context4.prev = _context4.next) {
185
191
  case 0:
186
- _context4.next = 2;
192
+ objectPayload = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
193
+ _context4.next = 3;
187
194
  return this.detail_url(objectType, objectId);
188
- case 2:
195
+ case 3:
189
196
  url = _context4.sent;
190
197
  headers = _objectSpread(_objectSpread({}, this.headers), this.dynamic_headers());
191
198
  contentText = JSON.stringify(objectPayload);
192
199
  signature = (0, _signature["default"])(url, "POST", contentText, headers, this.config.workspace_secret);
193
200
  headers['Authorization'] = "".concat(this.config.workspace_key, ":").concat(signature);
194
- _context4.prev = 7;
195
- _context4.next = 10;
201
+ _context4.prev = 8;
202
+ _context4.next = 11;
196
203
  return _axios["default"].post(url, contentText, {
197
204
  headers: headers
198
205
  });
199
- case 10:
206
+ case 11:
200
207
  response = _context4.sent;
201
208
  return _context4.abrupt("return", response.data);
202
- case 14:
203
- _context4.prev = 14;
204
- _context4.t0 = _context4["catch"](7);
209
+ case 15:
210
+ _context4.prev = 15;
211
+ _context4.t0 = _context4["catch"](8);
205
212
  throw new _utils.SuprsendApiError(_context4.t0);
206
- case 17:
213
+ case 18:
207
214
  case "end":
208
215
  return _context4.stop();
209
216
  }
210
217
  }
211
- }, _callee4, this, [[7, 14]]);
218
+ }, _callee4, this, [[8, 15]]);
212
219
  }));
213
- function upsert(_x6, _x7, _x8) {
220
+ function upsert(_x6, _x7) {
214
221
  return _upsert.apply(this, arguments);
215
222
  }
216
223
  return upsert;
@@ -218,40 +225,47 @@ var ObjectsApi = /*#__PURE__*/function () {
218
225
  }, {
219
226
  key: "edit",
220
227
  value: function () {
221
- var _edit = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(objectType, objectId, editPayload) {
222
- var url, headers, contentText, signature, response;
228
+ var _edit = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(objectType, objectId) {
229
+ var editPayload,
230
+ url,
231
+ headers,
232
+ contentText,
233
+ signature,
234
+ response,
235
+ _args5 = arguments;
223
236
  return _regenerator["default"].wrap(function _callee5$(_context5) {
224
237
  while (1) {
225
238
  switch (_context5.prev = _context5.next) {
226
239
  case 0:
227
- _context5.next = 2;
240
+ editPayload = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
241
+ _context5.next = 3;
228
242
  return this.detail_url(objectType, objectId);
229
- case 2:
243
+ case 3:
230
244
  url = _context5.sent;
231
245
  headers = _objectSpread(_objectSpread({}, this.headers), this.dynamic_headers());
232
246
  contentText = JSON.stringify(editPayload);
233
247
  signature = (0, _signature["default"])(url, "PATCH", contentText, headers, this.config.workspace_secret);
234
248
  headers['Authorization'] = "".concat(this.config.workspace_key, ":").concat(signature);
235
- _context5.prev = 7;
236
- _context5.next = 10;
249
+ _context5.prev = 8;
250
+ _context5.next = 11;
237
251
  return _axios["default"].patch(url, contentText, {
238
252
  headers: headers
239
253
  });
240
- case 10:
254
+ case 11:
241
255
  response = _context5.sent;
242
256
  return _context5.abrupt("return", response.data);
243
- case 14:
244
- _context5.prev = 14;
245
- _context5.t0 = _context5["catch"](7);
257
+ case 15:
258
+ _context5.prev = 15;
259
+ _context5.t0 = _context5["catch"](8);
246
260
  throw new _utils.SuprsendApiError(_context5.t0);
247
- case 17:
261
+ case 18:
248
262
  case "end":
249
263
  return _context5.stop();
250
264
  }
251
265
  }
252
- }, _callee5, this, [[7, 14]]);
266
+ }, _callee5, this, [[8, 15]]);
253
267
  }));
254
- function edit(_x9, _x10, _x11) {
268
+ function edit(_x8, _x9) {
255
269
  return _edit.apply(this, arguments);
256
270
  }
257
271
  return edit;
@@ -291,7 +305,7 @@ var ObjectsApi = /*#__PURE__*/function () {
291
305
  }
292
306
  }, _callee6, this, [[6, 13]]);
293
307
  }));
294
- function _delete(_x12, _x13) {
308
+ function _delete(_x10, _x11) {
295
309
  return _delete2.apply(this, arguments);
296
310
  }
297
311
  return _delete;
@@ -315,7 +329,7 @@ var ObjectsApi = /*#__PURE__*/function () {
315
329
  }
316
330
  }, _callee7, this);
317
331
  }));
318
- function bulk_ops_url(_x14) {
332
+ function bulk_ops_url(_x12) {
319
333
  return _bulk_ops_url.apply(this, arguments);
320
334
  }
321
335
  return bulk_ops_url;
@@ -334,30 +348,31 @@ var ObjectsApi = /*#__PURE__*/function () {
334
348
  case 2:
335
349
  url = _context8.sent;
336
350
  headers = _objectSpread(_objectSpread({}, this.headers), this.dynamic_headers());
351
+ payload = payload || {};
337
352
  contentText = JSON.stringify(payload);
338
353
  signature = (0, _signature["default"])(url, "DELETE", contentText, headers, this.config.workspace_secret);
339
354
  headers['Authorization'] = "".concat(this.config.workspace_key, ":").concat(signature);
340
- _context8.prev = 7;
341
- _context8.next = 10;
355
+ _context8.prev = 8;
356
+ _context8.next = 11;
342
357
  return _axios["default"]["delete"](url, {
343
358
  headers: headers,
344
359
  data: payload
345
360
  });
346
- case 10:
361
+ case 11:
347
362
  response = _context8.sent;
348
363
  return _context8.abrupt("return", response.data);
349
- case 14:
350
- _context8.prev = 14;
351
- _context8.t0 = _context8["catch"](7);
364
+ case 15:
365
+ _context8.prev = 15;
366
+ _context8.t0 = _context8["catch"](8);
352
367
  throw new _utils.SuprsendApiError(_context8.t0);
353
- case 17:
368
+ case 18:
354
369
  case "end":
355
370
  return _context8.stop();
356
371
  }
357
372
  }
358
- }, _callee8, this, [[7, 14]]);
373
+ }, _callee8, this, [[8, 15]]);
359
374
  }));
360
- function bulk_delete(_x15, _x16) {
375
+ function bulk_delete(_x13, _x14) {
361
376
  return _bulk_delete.apply(this, arguments);
362
377
  }
363
378
  return bulk_delete;
@@ -407,7 +422,7 @@ var ObjectsApi = /*#__PURE__*/function () {
407
422
  }
408
423
  }, _callee9, this, [[9, 16]]);
409
424
  }));
410
- function get_subscriptions(_x17, _x18) {
425
+ function get_subscriptions(_x15, _x16) {
411
426
  return _get_subscriptions.apply(this, arguments);
412
427
  }
413
428
  return get_subscriptions;
@@ -427,29 +442,30 @@ var ObjectsApi = /*#__PURE__*/function () {
427
442
  url = _context10.sent;
428
443
  subscription_url = "".concat(url, "subscription/");
429
444
  headers = _objectSpread(_objectSpread({}, this.headers), this.dynamic_headers());
445
+ subscriptions = subscriptions || {};
430
446
  contentText = JSON.stringify(subscriptions);
431
447
  signature = (0, _signature["default"])(subscription_url, "POST", contentText, headers, this.config.workspace_secret);
432
448
  headers['Authorization'] = "".concat(this.config.workspace_key, ":").concat(signature);
433
- _context10.prev = 8;
434
- _context10.next = 11;
449
+ _context10.prev = 9;
450
+ _context10.next = 12;
435
451
  return _axios["default"].post(subscription_url, contentText, {
436
452
  headers: headers
437
453
  });
438
- case 11:
454
+ case 12:
439
455
  response = _context10.sent;
440
456
  return _context10.abrupt("return", response.data);
441
- case 15:
442
- _context10.prev = 15;
443
- _context10.t0 = _context10["catch"](8);
457
+ case 16:
458
+ _context10.prev = 16;
459
+ _context10.t0 = _context10["catch"](9);
444
460
  throw new _utils.SuprsendApiError(_context10.t0);
445
- case 18:
461
+ case 19:
446
462
  case "end":
447
463
  return _context10.stop();
448
464
  }
449
465
  }
450
- }, _callee10, this, [[8, 15]]);
466
+ }, _callee10, this, [[9, 16]]);
451
467
  }));
452
- function create_subscriptions(_x19, _x20, _x21) {
468
+ function create_subscriptions(_x17, _x18, _x19) {
453
469
  return _create_subscriptions.apply(this, arguments);
454
470
  }
455
471
  return create_subscriptions;
@@ -469,30 +485,31 @@ var ObjectsApi = /*#__PURE__*/function () {
469
485
  url = _context11.sent;
470
486
  subscription_url = "".concat(url, "subscription/");
471
487
  headers = _objectSpread(_objectSpread({}, this.headers), this.dynamic_headers());
488
+ subscriptions = subscriptions || {};
472
489
  contentText = JSON.stringify(subscriptions);
473
490
  signature = (0, _signature["default"])(subscription_url, "DELETE", contentText, headers, this.config.workspace_secret);
474
491
  headers['Authorization'] = "".concat(this.config.workspace_key, ":").concat(signature);
475
- _context11.prev = 8;
476
- _context11.next = 11;
492
+ _context11.prev = 9;
493
+ _context11.next = 12;
477
494
  return _axios["default"]["delete"](subscription_url, {
478
495
  headers: headers,
479
496
  data: subscriptions
480
497
  });
481
- case 11:
498
+ case 12:
482
499
  response = _context11.sent;
483
500
  return _context11.abrupt("return", response.data);
484
- case 15:
485
- _context11.prev = 15;
486
- _context11.t0 = _context11["catch"](8);
501
+ case 16:
502
+ _context11.prev = 16;
503
+ _context11.t0 = _context11["catch"](9);
487
504
  throw new _utils.SuprsendApiError(_context11.t0);
488
- case 18:
505
+ case 19:
489
506
  case "end":
490
507
  return _context11.stop();
491
508
  }
492
509
  }
493
- }, _callee11, this, [[8, 15]]);
510
+ }, _callee11, this, [[9, 16]]);
494
511
  }));
495
- function delete_subscriptions(_x22, _x23, _x24) {
512
+ function delete_subscriptions(_x20, _x21, _x22) {
496
513
  return _delete_subscriptions.apply(this, arguments);
497
514
  }
498
515
  return delete_subscriptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/node-sdk",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "Suprsend Node SDK to trigger workflow from backend",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/object.js CHANGED
@@ -99,7 +99,7 @@ class ObjectsApi {
99
99
  }
100
100
  }
101
101
 
102
- async upsert(objectType, objectId, objectPayload) {
102
+ async upsert(objectType, objectId, objectPayload = {}) {
103
103
  const url = await this.detail_url(objectType, objectId);
104
104
  const headers = { ...this.headers, ...this.dynamic_headers() };
105
105
  const contentText = JSON.stringify(objectPayload);
@@ -120,7 +120,7 @@ class ObjectsApi {
120
120
  }
121
121
  }
122
122
 
123
- async edit(objectType, objectId, editPayload) {
123
+ async edit(objectType, objectId, editPayload = {}) {
124
124
  const url = await this.detail_url(objectType, objectId);
125
125
  const headers = { ...this.headers, ...this.dynamic_headers() };
126
126
  const contentText = JSON.stringify(editPayload);
@@ -171,6 +171,7 @@ class ObjectsApi {
171
171
  async bulk_delete(objectType, payload) {
172
172
  const url = await this.bulk_ops_url(objectType);
173
173
  const headers = { ...this.headers, ...this.dynamic_headers() };
174
+ payload = payload || {}
174
175
  const contentText = JSON.stringify(payload);
175
176
  const signature = get_request_signature(
176
177
  url,
@@ -218,6 +219,7 @@ class ObjectsApi {
218
219
  const url = await this.detail_url(objectType, objectId);
219
220
  const subscription_url = `${url}subscription/`;
220
221
  const headers = { ...this.headers, ...this.dynamic_headers() };
222
+ subscriptions = subscriptions || {}
221
223
  const contentText = JSON.stringify(subscriptions);
222
224
  const signature = get_request_signature(
223
225
  subscription_url,
@@ -240,6 +242,7 @@ class ObjectsApi {
240
242
  const url = await this.detail_url(objectType, objectId);
241
243
  const subscription_url = `${url}subscription/`;
242
244
  const headers = { ...this.headers, ...this.dynamic_headers() };
245
+ subscriptions = subscriptions || {}
243
246
  const contentText = JSON.stringify(subscriptions);
244
247
  const signature = get_request_signature(
245
248
  subscription_url,