@suprsend/node-sdk 1.11.0 → 1.12.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.
@@ -20,14 +20,12 @@ var IDENT_KEY_WEBPUSH = "$webpush";
20
20
  var IDENT_KEY_SLACK = "$slack";
21
21
  var IDENT_KEY_MS_TEAMS = "$ms_teams";
22
22
  var IDENT_KEYS_ALL = [IDENT_KEY_EMAIL, IDENT_KEY_SMS, IDENT_KEY_ANDROIDPUSH, IDENT_KEY_IOSPUSH, IDENT_KEY_WHATSAPP, IDENT_KEY_WEBPUSH, IDENT_KEY_SLACK, IDENT_KEY_MS_TEAMS];
23
- var KEY_PUSHVENDOR = "$pushvendor";
23
+ var KEY_ID_PROVIDER = "$id_provider";
24
24
  var KEY_PREFERRED_LANGUAGE = "$preferred_language";
25
25
  var KEY_TIMEZONE = "$timezone";
26
- var OTHER_RESERVED_KEYS = ["$messenger", "$inbox", KEY_PUSHVENDOR, "$device_id", "$insert_id", "$time", "$set", "$set_once", "$add", "$append", "$remove", "$unset", "$identify", "$anon_id", "$identified_id", KEY_PREFERRED_LANGUAGE, KEY_TIMEZONE, "$notification_delivered", "$notification_dismiss", "$notification_clicked"];
26
+ var OTHER_RESERVED_KEYS = ["$messenger", "$inbox", KEY_ID_PROVIDER, "$device_id", "$insert_id", "$time", "$set", "$set_once", "$add", "$append", "$remove", "$unset", "$identify", "$anon_id", "$identified_id", KEY_PREFERRED_LANGUAGE, KEY_TIMEZONE, "$notification_delivered", "$notification_dismiss", "$notification_clicked"];
27
27
  var SUPER_PROPERTY_KEYS = ["$app_version_string", "$app_build_number", "$brand", "$carrier", "$manufacturer", "$model", "$os", "$ss_sdk_version", "$insert_id", "$time"];
28
28
  var ALL_RESERVED_KEYS = [].concat(SUPER_PROPERTY_KEYS, OTHER_RESERVED_KEYS, IDENT_KEYS_ALL);
29
- var EMAIL_REGEX = /\S+@\S+\.\S+/;
30
- var MOBILE_REGEX = /^\+[0-9\s]+/;
31
29
  var _SubscriberInternalHelper = /*#__PURE__*/function () {
32
30
  function _SubscriberInternalHelper(distinct_id, workspace_key) {
33
31
  (0, _classCallCheck2["default"])(this, _SubscriberInternalHelper);
@@ -258,13 +256,13 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
258
256
  this._add_whatsapp(value, new_caller);
259
257
  break;
260
258
  case IDENT_KEY_ANDROIDPUSH:
261
- this._add_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
259
+ this._add_androidpush(value, args[KEY_ID_PROVIDER], new_caller);
262
260
  break;
263
261
  case IDENT_KEY_IOSPUSH:
264
- this._add_iospush(value, args[KEY_PUSHVENDOR], new_caller);
262
+ this._add_iospush(value, args[KEY_ID_PROVIDER], new_caller);
265
263
  break;
266
264
  case IDENT_KEY_WEBPUSH:
267
- this._add_webpush(value, args[KEY_PUSHVENDOR], new_caller);
265
+ this._add_webpush(value, args[KEY_ID_PROVIDER], new_caller);
268
266
  break;
269
267
  case IDENT_KEY_SLACK:
270
268
  this._add_slack(value, caller);
@@ -291,13 +289,13 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
291
289
  this._remove_whatsapp(value, new_caller);
292
290
  break;
293
291
  case IDENT_KEY_ANDROIDPUSH:
294
- this._remove_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
292
+ this._remove_androidpush(value, args[KEY_ID_PROVIDER], new_caller);
295
293
  break;
296
294
  case IDENT_KEY_IOSPUSH:
297
- this._remove_iospush(value, args[KEY_PUSHVENDOR], new_caller);
295
+ this._remove_iospush(value, args[KEY_ID_PROVIDER], new_caller);
298
296
  break;
299
297
  case IDENT_KEY_WEBPUSH:
300
- this._remove_webpush(value, args[KEY_PUSHVENDOR], new_caller);
298
+ this._remove_webpush(value, args[KEY_ID_PROVIDER], new_caller);
301
299
  break;
302
300
  case IDENT_KEY_SLACK:
303
301
  this._remove_slack(val, caller);
@@ -324,39 +322,13 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
324
322
  }
325
323
  return [value, true];
326
324
  }
327
-
328
- // email methods
329
- }, {
330
- key: "__validate_email",
331
- value: function __validate_email(value, caller) {
332
- var _this$__check_ident_v = this.__check_ident_val_string(value, caller),
333
- _this$__check_ident_v2 = (0, _slicedToArray2["default"])(_this$__check_ident_v, 2),
334
- email = _this$__check_ident_v2[0],
335
- is_valid = _this$__check_ident_v2[1];
336
- if (!is_valid) {
337
- return [email, false];
338
- }
339
- var message = "value in email format required. e.g. user@example.com";
340
- var min_length = 6;
341
- var max_length = 127;
342
- var is_valid_email = EMAIL_REGEX.test(email);
343
- if (!is_valid_email) {
344
- this.__errors.push("[".concat(caller, "] invalid value ").concat(email, ". ").concat(message));
345
- return [email, false];
346
- }
347
- if (email.length < min_length || email.length > max_length) {
348
- this.__errors.push("[".concat(caller, "] invalid value ").concat(email, ". must be 6 <= email.length <= 127"));
349
- return [email, false];
350
- }
351
- return [email, true];
352
- }
353
325
  }, {
354
326
  key: "_add_email",
355
327
  value: function _add_email(email, caller) {
356
- var _this$__validate_emai = this.__validate_email(email, caller),
357
- _this$__validate_emai2 = (0, _slicedToArray2["default"])(_this$__validate_emai, 2),
358
- value = _this$__validate_emai2[0],
359
- is_valid = _this$__validate_emai2[1];
328
+ var _this$__check_ident_v = this.__check_ident_val_string(email, caller),
329
+ _this$__check_ident_v2 = (0, _slicedToArray2["default"])(_this$__check_ident_v, 2),
330
+ value = _this$__check_ident_v2[0],
331
+ is_valid = _this$__check_ident_v2[1];
360
332
  if (!is_valid) {
361
333
  return;
362
334
  }
@@ -365,47 +337,22 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
365
337
  }, {
366
338
  key: "_remove_email",
367
339
  value: function _remove_email(email, caller) {
368
- var _this$__validate_emai3 = this.__validate_email(email, caller),
369
- _this$__validate_emai4 = (0, _slicedToArray2["default"])(_this$__validate_emai3, 2),
370
- value = _this$__validate_emai4[0],
371
- is_valid = _this$__validate_emai4[1];
372
- if (!is_valid) {
373
- return;
374
- }
375
- this.__dict_remove[IDENT_KEY_EMAIL] = value;
376
- }
377
-
378
- // mobile methods
379
- }, {
380
- key: "__validate_mobile_no",
381
- value: function __validate_mobile_no(value, caller) {
382
- var _this$__check_ident_v3 = this.__check_ident_val_string(value, caller),
340
+ var _this$__check_ident_v3 = this.__check_ident_val_string(email, caller),
383
341
  _this$__check_ident_v4 = (0, _slicedToArray2["default"])(_this$__check_ident_v3, 2),
384
- mobile = _this$__check_ident_v4[0],
342
+ value = _this$__check_ident_v4[0],
385
343
  is_valid = _this$__check_ident_v4[1];
386
344
  if (!is_valid) {
387
- return [mobile, false];
388
- }
389
- var message = "number must start with + and must contain country code. e.g. +41446681800";
390
- var min_length = 8;
391
- var is_valid_mobile = MOBILE_REGEX.test(mobile);
392
- if (!is_valid_mobile) {
393
- this.__errors.push("[".concat(caller, "] invalid value ").concat(mobile, ". ").concat(message));
394
- return [mobile, false];
395
- }
396
- if (mobile.length < min_length) {
397
- this.__errors.push("[".concat(caller, "] invalid value ").concat(mobile, ". mobile_no.length must be >= 8"));
398
- return [mobile, false];
345
+ return;
399
346
  }
400
- return [mobile, true];
347
+ this.__dict_remove[IDENT_KEY_EMAIL] = value;
401
348
  }
402
349
  }, {
403
350
  key: "_add_sms",
404
351
  value: function _add_sms(mobile_no, caller) {
405
- var _this$__validate_mobi = this.__validate_mobile_no(mobile_no, caller),
406
- _this$__validate_mobi2 = (0, _slicedToArray2["default"])(_this$__validate_mobi, 2),
407
- value = _this$__validate_mobi2[0],
408
- is_valid = _this$__validate_mobi2[1];
352
+ var _this$__check_ident_v5 = this.__check_ident_val_string(mobile_no, caller),
353
+ _this$__check_ident_v6 = (0, _slicedToArray2["default"])(_this$__check_ident_v5, 2),
354
+ value = _this$__check_ident_v6[0],
355
+ is_valid = _this$__check_ident_v6[1];
409
356
  if (!is_valid) {
410
357
  return;
411
358
  }
@@ -414,10 +361,10 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
414
361
  }, {
415
362
  key: "_remove_sms",
416
363
  value: function _remove_sms(mobile_no, caller) {
417
- var _this$__validate_mobi3 = this.__validate_mobile_no(mobile_no, caller),
418
- _this$__validate_mobi4 = (0, _slicedToArray2["default"])(_this$__validate_mobi3, 2),
419
- value = _this$__validate_mobi4[0],
420
- is_valid = _this$__validate_mobi4[1];
364
+ var _this$__check_ident_v7 = this.__check_ident_val_string(mobile_no, caller),
365
+ _this$__check_ident_v8 = (0, _slicedToArray2["default"])(_this$__check_ident_v7, 2),
366
+ value = _this$__check_ident_v8[0],
367
+ is_valid = _this$__check_ident_v8[1];
421
368
  if (!is_valid) {
422
369
  return;
423
370
  }
@@ -426,10 +373,10 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
426
373
  }, {
427
374
  key: "_add_whatsapp",
428
375
  value: function _add_whatsapp(mobile_no, caller) {
429
- var _this$__validate_mobi5 = this.__validate_mobile_no(mobile_no, caller),
430
- _this$__validate_mobi6 = (0, _slicedToArray2["default"])(_this$__validate_mobi5, 2),
431
- value = _this$__validate_mobi6[0],
432
- is_valid = _this$__validate_mobi6[1];
376
+ var _this$__check_ident_v9 = this.__check_ident_val_string(mobile_no, caller),
377
+ _this$__check_ident_v10 = (0, _slicedToArray2["default"])(_this$__check_ident_v9, 2),
378
+ value = _this$__check_ident_v10[0],
379
+ is_valid = _this$__check_ident_v10[1];
433
380
  if (!is_valid) {
434
381
  return;
435
382
  }
@@ -438,10 +385,10 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
438
385
  }, {
439
386
  key: "_remove_whatsapp",
440
387
  value: function _remove_whatsapp(mobile_no, caller) {
441
- var _this$__validate_mobi7 = this.__validate_mobile_no(mobile_no, caller),
442
- _this$__validate_mobi8 = (0, _slicedToArray2["default"])(_this$__validate_mobi7, 2),
443
- value = _this$__validate_mobi8[0],
444
- is_valid = _this$__validate_mobi8[1];
388
+ var _this$__check_ident_v11 = this.__check_ident_val_string(mobile_no, caller),
389
+ _this$__check_ident_v12 = (0, _slicedToArray2["default"])(_this$__check_ident_v11, 2),
390
+ value = _this$__check_ident_v12[0],
391
+ is_valid = _this$__check_ident_v12[1];
445
392
  if (!is_valid) {
446
393
  return;
447
394
  }
@@ -452,23 +399,19 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
452
399
  }, {
453
400
  key: "__check_androidpush_value",
454
401
  value: function __check_androidpush_value(value, provider, caller) {
455
- var _this$__check_ident_v5 = this.__check_ident_val_string(value, caller),
456
- _this$__check_ident_v6 = (0, _slicedToArray2["default"])(_this$__check_ident_v5, 2),
457
- push_token = _this$__check_ident_v6[0],
458
- is_valid = _this$__check_ident_v6[1];
402
+ var _this$__check_ident_v13 = this.__check_ident_val_string(value, caller),
403
+ _this$__check_ident_v14 = (0, _slicedToArray2["default"])(_this$__check_ident_v13, 2),
404
+ push_token = _this$__check_ident_v14[0],
405
+ is_valid = _this$__check_ident_v14[1];
459
406
  if (!is_valid) {
460
407
  return [push_token, provider, false];
461
408
  }
462
409
  if (!provider) {
463
- provider = "fcm";
410
+ provider = "";
464
411
  }
465
412
  if (typeof provider === "string") {
466
413
  provider = provider.toLocaleLowerCase();
467
414
  }
468
- if (!["fcm", "xiaomi", "oppo"].includes(provider)) {
469
- this.__errors.push("[".concat(caller, "] unsupported androidpush provider ").concat(provider));
470
- return [push_token, provider, false];
471
- }
472
415
  return [push_token, provider, true];
473
416
  }
474
417
  }, {
@@ -485,7 +428,7 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
485
428
  return;
486
429
  }
487
430
  this.__dict_append[IDENT_KEY_ANDROIDPUSH] = value;
488
- this.__dict_append[KEY_PUSHVENDOR] = vendor;
431
+ this.__dict_append[KEY_ID_PROVIDER] = vendor;
489
432
  }
490
433
  }, {
491
434
  key: "_remove_androidpush",
@@ -501,30 +444,26 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
501
444
  return;
502
445
  }
503
446
  this.__dict_remove[IDENT_KEY_ANDROIDPUSH] = value;
504
- this.__dict_remove[KEY_PUSHVENDOR] = vendor;
447
+ this.__dict_remove[KEY_ID_PROVIDER] = vendor;
505
448
  }
506
449
 
507
450
  // ios push methods
508
451
  }, {
509
452
  key: "__check_iospush_value",
510
453
  value: function __check_iospush_value(value, provider, caller) {
511
- var _this$__check_ident_v7 = this.__check_ident_val_string(value, caller),
512
- _this$__check_ident_v8 = (0, _slicedToArray2["default"])(_this$__check_ident_v7, 2),
513
- push_token = _this$__check_ident_v8[0],
514
- is_valid = _this$__check_ident_v8[1];
454
+ var _this$__check_ident_v15 = this.__check_ident_val_string(value, caller),
455
+ _this$__check_ident_v16 = (0, _slicedToArray2["default"])(_this$__check_ident_v15, 2),
456
+ push_token = _this$__check_ident_v16[0],
457
+ is_valid = _this$__check_ident_v16[1];
515
458
  if (!is_valid) {
516
459
  return [push_token, provider, false];
517
460
  }
518
461
  if (!provider) {
519
- provider = "apns";
462
+ provider = "";
520
463
  }
521
464
  if (typeof provider === "string") {
522
465
  provider = provider.toLocaleLowerCase();
523
466
  }
524
- if (!["apns"].includes(provider)) {
525
- this.__errors.push("[".concat(caller, "] unsupported iospush provider ").concat(provider));
526
- return [push_token, provider, false];
527
- }
528
467
  return [push_token, provider, true];
529
468
  }
530
469
  }, {
@@ -541,7 +480,7 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
541
480
  return;
542
481
  }
543
482
  this.__dict_append[IDENT_KEY_IOSPUSH] = value;
544
- this.__dict_append[KEY_PUSHVENDOR] = vendor;
483
+ this.__dict_append[KEY_ID_PROVIDER] = vendor;
545
484
  }
546
485
  }, {
547
486
  key: "_remove_iospush",
@@ -557,7 +496,7 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
557
496
  return;
558
497
  }
559
498
  this.__dict_remove[IDENT_KEY_IOSPUSH] = value;
560
- this.__dict_remove[KEY_PUSHVENDOR] = vendor;
499
+ this.__dict_remove[KEY_ID_PROVIDER] = vendor;
561
500
  }
562
501
 
563
502
  // web push methods
@@ -569,15 +508,11 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
569
508
  return [value, provider, false];
570
509
  }
571
510
  if (!provider) {
572
- provider = "vapid";
511
+ provider = "";
573
512
  }
574
513
  if (typeof provider === "string") {
575
514
  provider = provider.toLocaleLowerCase();
576
515
  }
577
- if (!["vapid"].includes(provider)) {
578
- this.__errors.push("[".concat(caller, "] unsupported webpush provider ").concat(provider));
579
- return [value, provider, false];
580
- }
581
516
  return [value, provider, true];
582
517
  }
583
518
  }, {
@@ -594,7 +529,7 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
594
529
  return;
595
530
  }
596
531
  this.__dict_append[IDENT_KEY_WEBPUSH] = value;
597
- this.__dict_append[KEY_PUSHVENDOR] = vendor;
532
+ this.__dict_append[KEY_ID_PROVIDER] = vendor;
598
533
  }
599
534
  }, {
600
535
  key: "_remove_webpush",
@@ -610,7 +545,7 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
610
545
  return;
611
546
  }
612
547
  this.__dict_remove[IDENT_KEY_WEBPUSH] = value;
613
- this.__dict_remove[KEY_PUSHVENDOR] = vendor;
548
+ this.__dict_remove[KEY_ID_PROVIDER] = vendor;
614
549
  }
615
550
  }, {
616
551
  key: "__check_slack_dict",
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _signature = _interopRequireDefault(require("./signature"));
13
+ var _utils = require("./utils");
14
+ var _axios = _interopRequireDefault(require("axios"));
15
+ var UsersApi = /*#__PURE__*/function () {
16
+ function UsersApi(config) {
17
+ (0, _classCallCheck2["default"])(this, UsersApi);
18
+ this.config = config;
19
+ this.list_url = "".concat(this.config.base_url, "v1/user/");
20
+ }
21
+ (0, _createClass2["default"])(UsersApi, [{
22
+ key: "get_headers",
23
+ value: function get_headers() {
24
+ return {
25
+ "Content-Type": "application/json; charset=utf-8",
26
+ "User-Agent": this.config.user_agent,
27
+ Date: new Date().toISOString() // Adjust to your header date format
28
+ };
29
+ }
30
+ }, {
31
+ key: "validate_distinct_id",
32
+ value: function validate_distinct_id(distinct_id) {
33
+ if (!distinct_id || distinct_id.trim() === "") {
34
+ throw new Error("missing distinct_id");
35
+ }
36
+ return distinct_id.trim();
37
+ }
38
+ }, {
39
+ key: "detail_url",
40
+ value: function detail_url(distinct_id) {
41
+ return "".concat(this.list_url).concat(encodeURIComponent(distinct_id), "/");
42
+ }
43
+ }, {
44
+ key: "get",
45
+ value: function () {
46
+ var _get = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(distinct_id) {
47
+ var validated_distinct_id, url, headers, signature, response;
48
+ return _regenerator["default"].wrap(function _callee$(_context) {
49
+ while (1) {
50
+ switch (_context.prev = _context.next) {
51
+ case 0:
52
+ validated_distinct_id = this.validate_distinct_id(distinct_id);
53
+ url = this.detail_url(validated_distinct_id);
54
+ headers = this.get_headers();
55
+ signature = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
56
+ headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
57
+ _context.prev = 5;
58
+ _context.next = 8;
59
+ return _axios["default"].get(url, {
60
+ headers: headers
61
+ });
62
+ case 8:
63
+ response = _context.sent;
64
+ return _context.abrupt("return", response.data);
65
+ case 12:
66
+ _context.prev = 12;
67
+ _context.t0 = _context["catch"](5);
68
+ throw new _utils.SuprsendApiError(_context.t0);
69
+ case 15:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }
74
+ }, _callee, this, [[5, 12]]);
75
+ }));
76
+ function get(_x) {
77
+ return _get.apply(this, arguments);
78
+ }
79
+ return get;
80
+ }()
81
+ }, {
82
+ key: "delete",
83
+ value: function () {
84
+ var _delete2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(distinct_id) {
85
+ var validated_distinct_id, url, headers, signature, response;
86
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
87
+ while (1) {
88
+ switch (_context2.prev = _context2.next) {
89
+ case 0:
90
+ validated_distinct_id = this.validate_distinct_id(distinct_id);
91
+ url = this.detail_url(validated_distinct_id);
92
+ headers = this.get_headers();
93
+ signature = (0, _signature["default"])(url, "DELETE", "", headers, this.config.workspace_secret);
94
+ headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
95
+ _context2.prev = 5;
96
+ _context2.next = 8;
97
+ return _axios["default"]["delete"](url, {
98
+ headers: headers
99
+ });
100
+ case 8:
101
+ response = _context2.sent;
102
+ if (!(response.status >= 200 && response.status < 300)) {
103
+ _context2.next = 13;
104
+ break;
105
+ }
106
+ return _context2.abrupt("return", {
107
+ success: true,
108
+ status_code: response.status
109
+ });
110
+ case 13:
111
+ throw new _utils.SuprsendApiError(response.statusText);
112
+ case 14:
113
+ _context2.next = 19;
114
+ break;
115
+ case 16:
116
+ _context2.prev = 16;
117
+ _context2.t0 = _context2["catch"](5);
118
+ throw new _utils.SuprsendApiError(_context2.t0);
119
+ case 19:
120
+ case "end":
121
+ return _context2.stop();
122
+ }
123
+ }
124
+ }, _callee2, this, [[5, 16]]);
125
+ }));
126
+ function _delete(_x2) {
127
+ return _delete2.apply(this, arguments);
128
+ }
129
+ return _delete;
130
+ }()
131
+ }, {
132
+ key: "get_objects_subscribed_to",
133
+ value: function () {
134
+ var _get_objects_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(distinct_id) {
135
+ var options,
136
+ validated_distinct_id,
137
+ params,
138
+ url,
139
+ subscription_url,
140
+ headers,
141
+ signature,
142
+ response,
143
+ _args3 = arguments;
144
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
145
+ while (1) {
146
+ switch (_context3.prev = _context3.next) {
147
+ case 0:
148
+ options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
149
+ validated_distinct_id = this.validate_distinct_id(distinct_id);
150
+ params = new URLSearchParams(options).toString();
151
+ url = this.detail_url(validated_distinct_id);
152
+ subscription_url = "".concat(url, "subscribed_to/object/?").concat(params);
153
+ headers = this.get_headers();
154
+ signature = (0, _signature["default"])(subscription_url, "GET", "", headers, this.config.workspace_secret);
155
+ headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
156
+ _context3.prev = 8;
157
+ _context3.next = 11;
158
+ return _axios["default"].get(subscription_url, {
159
+ headers: headers
160
+ });
161
+ case 11:
162
+ response = _context3.sent;
163
+ return _context3.abrupt("return", response.data);
164
+ case 15:
165
+ _context3.prev = 15;
166
+ _context3.t0 = _context3["catch"](8);
167
+ throw new _utils.SuprsendApiError(_context3.t0);
168
+ case 18:
169
+ case "end":
170
+ return _context3.stop();
171
+ }
172
+ }
173
+ }, _callee3, this, [[8, 15]]);
174
+ }));
175
+ function get_objects_subscribed_to(_x3) {
176
+ return _get_objects_subscribed_to.apply(this, arguments);
177
+ }
178
+ return get_objects_subscribed_to;
179
+ }()
180
+ }, {
181
+ key: "get_lists_subscribed_to",
182
+ value: function () {
183
+ var _get_lists_subscribed_to = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(distinct_id) {
184
+ var options,
185
+ validated_distinct_id,
186
+ params,
187
+ url,
188
+ subscription_url,
189
+ headers,
190
+ signature,
191
+ response,
192
+ _args4 = arguments;
193
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
194
+ while (1) {
195
+ switch (_context4.prev = _context4.next) {
196
+ case 0:
197
+ options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
198
+ validated_distinct_id = this.validate_distinct_id(distinct_id);
199
+ params = new URLSearchParams(options).toString();
200
+ url = this.detail_url(validated_distinct_id);
201
+ subscription_url = "".concat(url, "subscribed_to/list/?").concat(params);
202
+ headers = this.get_headers();
203
+ signature = (0, _signature["default"])(subscription_url, "GET", "", headers, this.config.workspace_secret);
204
+ headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
205
+ _context4.prev = 8;
206
+ _context4.next = 11;
207
+ return _axios["default"].get(subscription_url, {
208
+ headers: headers
209
+ });
210
+ case 11:
211
+ response = _context4.sent;
212
+ return _context4.abrupt("return", response.data);
213
+ case 15:
214
+ _context4.prev = 15;
215
+ _context4.t0 = _context4["catch"](8);
216
+ throw new _utils.SuprsendApiError(_context4.t0);
217
+ case 18:
218
+ case "end":
219
+ return _context4.stop();
220
+ }
221
+ }
222
+ }, _callee4, this, [[8, 15]]);
223
+ }));
224
+ function get_lists_subscribed_to(_x4) {
225
+ return _get_lists_subscribed_to.apply(this, arguments);
226
+ }
227
+ return get_lists_subscribed_to;
228
+ }()
229
+ }]);
230
+ return UsersApi;
231
+ }();
232
+ exports["default"] = UsersApi;
233
+ module.exports = exports.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/node-sdk",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Suprsend Node SDK to trigger workflow from backend",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -11,8 +11,9 @@ import BulkSubscribersFactory from "./subscribers_bulk";
11
11
  import { SubscriberListsApi, SubscriberListBroadcast } from "./subscriber_list";
12
12
  import BrandsApi from "./brands";
13
13
  import TenantsApi from "./tenant";
14
- import ObjectsApi from "./object";
14
+ import ObjectsApi from "./objects_api";
15
15
  import { DEFAULT_URL } from "./constants";
16
+ import UsersApi from "./users_api";
16
17
 
17
18
  const package_json = require("../package.json");
18
19
 
@@ -40,6 +41,7 @@ class Suprsend {
40
41
  this.tenants = new TenantsApi(this);
41
42
  this.workflows = new WorkflowsApi(this);
42
43
  this.objects = new ObjectsApi(this);
44
+ this.users = new UsersApi(this);
43
45
 
44
46
  this.subscriber_lists = new SubscriberListsApi(this);
45
47