@suprsend/node-sdk 1.10.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.
@@ -0,0 +1,659 @@
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _utils = require("./utils");
12
+ var _language_codes = _interopRequireDefault(require("./language_codes"));
13
+ // ---------- Identity keys
14
+ var IDENT_KEY_EMAIL = "$email";
15
+ var IDENT_KEY_SMS = "$sms";
16
+ var IDENT_KEY_ANDROIDPUSH = "$androidpush";
17
+ var IDENT_KEY_IOSPUSH = "$iospush";
18
+ var IDENT_KEY_WHATSAPP = "$whatsapp";
19
+ var IDENT_KEY_WEBPUSH = "$webpush";
20
+ var IDENT_KEY_SLACK = "$slack";
21
+ var IDENT_KEY_MS_TEAMS = "$ms_teams";
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";
24
+ var KEY_PREFERRED_LANGUAGE = "$preferred_language";
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"];
27
+ var SUPER_PROPERTY_KEYS = ["$app_version_string", "$app_build_number", "$brand", "$carrier", "$manufacturer", "$model", "$os", "$ss_sdk_version", "$insert_id", "$time"];
28
+ var ALL_RESERVED_KEYS = [].concat(SUPER_PROPERTY_KEYS, OTHER_RESERVED_KEYS, IDENT_KEYS_ALL);
29
+ var _ObjectInternalHelper = /*#__PURE__*/function () {
30
+ function _ObjectInternalHelper(object_type, object_id, workspace_key) {
31
+ (0, _classCallCheck2["default"])(this, _ObjectInternalHelper);
32
+ this.object_type = object_type;
33
+ this.object_id = object_id;
34
+ this.workspace_key = workspace_key;
35
+ this.__dict_set = {};
36
+ this.__dict_set_once = {};
37
+ this.__dict_increment = {};
38
+ this.__dict_append = {};
39
+ this.__dict_remove = {};
40
+ this.__list_unset = [];
41
+ this.__errors = [];
42
+ this.__info = [];
43
+ }
44
+ (0, _createClass2["default"])(_ObjectInternalHelper, [{
45
+ key: "reset",
46
+ value: function reset() {
47
+ this.__dict_set = {};
48
+ this.__dict_set_once = {};
49
+ this.__dict_increment = {};
50
+ this.__dict_append = {};
51
+ this.__dict_remove = {};
52
+ this.__list_unset = [];
53
+ this.__errors = [];
54
+ this.__info = [];
55
+ }
56
+ }, {
57
+ key: "get_identity_events",
58
+ value: function get_identity_events() {
59
+ var payload = this.__form_payload();
60
+ var ret_val = {
61
+ errors: this.__errors,
62
+ info: this.__info,
63
+ payload: payload
64
+ };
65
+ this.reset();
66
+ return ret_val;
67
+ }
68
+ }, {
69
+ key: "__form_payload",
70
+ value: function __form_payload() {
71
+ var payload = {};
72
+ if (!(0, _utils.is_empty)(this.__dict_set)) {
73
+ payload["$set"] = this.__dict_set;
74
+ }
75
+ if (!(0, _utils.is_empty)(this.__dict_set_once)) {
76
+ payload["$set_once"] = this.__dict_set_once;
77
+ }
78
+ if (!(0, _utils.is_empty)(this.__dict_increment)) {
79
+ payload["$add"] = this.__dict_increment;
80
+ }
81
+ if (!(0, _utils.is_empty)(this.__dict_append)) {
82
+ payload["$append"] = this.__dict_append;
83
+ }
84
+ if (!(0, _utils.is_empty)(this.__dict_remove)) {
85
+ payload["$remove"] = this.__dict_remove;
86
+ }
87
+ if (!(0, _utils.is_empty)(this.__list_unset)) {
88
+ payload["$unset"] = this.__list_unset;
89
+ }
90
+ return payload;
91
+ }
92
+ }, {
93
+ key: "__validate_key_basic",
94
+ value: function __validate_key_basic(key, caller) {
95
+ if (!(0, _utils.is_string)(key)) {
96
+ this.__info.push("[".concat(caller, "] skipping key: ").concat(key, ". key must be a string"));
97
+ return [key, false];
98
+ }
99
+ key = key.trim();
100
+ if (!key) {
101
+ this.__info.push("[".concat(caller, "] skipping key: empty string"));
102
+ return [key, false];
103
+ }
104
+ return [key, true];
105
+ }
106
+ }, {
107
+ key: "__validate_key_prefix",
108
+ value: function __validate_key_prefix(key, caller) {
109
+ if (!ALL_RESERVED_KEYS.includes(key)) {
110
+ if ((0, _utils.has_special_char)(key)) {
111
+ this.__info.push("[".concat(caller, "] skipping key: ").concat(key, ". key starting with [$,ss_] are reserved"));
112
+ return false;
113
+ }
114
+ }
115
+ return true;
116
+ }
117
+ }, {
118
+ key: "__is_identity_key",
119
+ value: function __is_identity_key(key) {
120
+ return IDENT_KEYS_ALL.includes(key);
121
+ }
122
+ }, {
123
+ key: "_append_kv",
124
+ value: function _append_kv(key, value) {
125
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
126
+ var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "append";
127
+ var _this$__validate_key_ = this.__validate_key_basic(key, caller),
128
+ _this$__validate_key_2 = (0, _slicedToArray2["default"])(_this$__validate_key_, 2),
129
+ validated_key = _this$__validate_key_2[0],
130
+ is_k_valid = _this$__validate_key_2[1];
131
+ if (!is_k_valid) {
132
+ return;
133
+ }
134
+ if (this.__is_identity_key(validated_key)) {
135
+ this.__add_identity(validated_key, value, args, caller);
136
+ } else {
137
+ var _is_k_valid = this.__validate_key_prefix(validated_key, caller);
138
+ if (_is_k_valid) {
139
+ this.__dict_append[validated_key] = value;
140
+ }
141
+ }
142
+ }
143
+ }, {
144
+ key: "_set_kv",
145
+ value: function _set_kv(key, value) {
146
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
147
+ var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "set";
148
+ var _this$__validate_key_3 = this.__validate_key_basic(key, caller),
149
+ _this$__validate_key_4 = (0, _slicedToArray2["default"])(_this$__validate_key_3, 2),
150
+ validated_key = _this$__validate_key_4[0],
151
+ is_k_valid = _this$__validate_key_4[1];
152
+ if (!is_k_valid) {
153
+ return;
154
+ } else {
155
+ var _is_k_valid2 = this.__validate_key_prefix(validated_key, caller);
156
+ if (_is_k_valid2) {
157
+ this.__dict_set[validated_key] = value;
158
+ }
159
+ }
160
+ }
161
+ }, {
162
+ key: "_set_once_kv",
163
+ value: function _set_once_kv(key, value) {
164
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
165
+ var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "set_once";
166
+ var _this$__validate_key_5 = this.__validate_key_basic(key, caller),
167
+ _this$__validate_key_6 = (0, _slicedToArray2["default"])(_this$__validate_key_5, 2),
168
+ validated_key = _this$__validate_key_6[0],
169
+ is_k_valid = _this$__validate_key_6[1];
170
+ if (!is_k_valid) {
171
+ return;
172
+ } else {
173
+ var _is_k_valid3 = this.__validate_key_prefix(validated_key, caller);
174
+ if (_is_k_valid3) {
175
+ this.__dict_set_once[validated_key] = value;
176
+ }
177
+ }
178
+ }
179
+ }, {
180
+ key: "_increment_kv",
181
+ value: function _increment_kv(key, value) {
182
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
183
+ var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "increment";
184
+ var _this$__validate_key_7 = this.__validate_key_basic(key, caller),
185
+ _this$__validate_key_8 = (0, _slicedToArray2["default"])(_this$__validate_key_7, 2),
186
+ validated_key = _this$__validate_key_8[0],
187
+ is_k_valid = _this$__validate_key_8[1];
188
+ if (!is_k_valid) {
189
+ return;
190
+ } else {
191
+ var _is_k_valid4 = this.__validate_key_prefix(validated_key, caller);
192
+ if (_is_k_valid4) {
193
+ this.__dict_increment[validated_key] = value;
194
+ }
195
+ }
196
+ }
197
+ }, {
198
+ key: "_remove_kv",
199
+ value: function _remove_kv(key, value) {
200
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
201
+ var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "remove";
202
+ var _this$__validate_key_9 = this.__validate_key_basic(key, caller),
203
+ _this$__validate_key_10 = (0, _slicedToArray2["default"])(_this$__validate_key_9, 2),
204
+ validated_key = _this$__validate_key_10[0],
205
+ is_k_valid = _this$__validate_key_10[1];
206
+ if (!is_k_valid) {
207
+ return;
208
+ }
209
+ if (this.__is_identity_key(validated_key)) {
210
+ this.__remove_identity(validated_key, value, args, caller);
211
+ } else {
212
+ var _is_k_valid5 = this.__validate_key_prefix(validated_key, caller);
213
+ if (_is_k_valid5) {
214
+ this.__dict_remove[validated_key] = value;
215
+ }
216
+ }
217
+ }
218
+ }, {
219
+ key: "_unset_k",
220
+ value: function _unset_k(key) {
221
+ var caller = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unset";
222
+ var _this$__validate_key_11 = this.__validate_key_basic(key, caller),
223
+ _this$__validate_key_12 = (0, _slicedToArray2["default"])(_this$__validate_key_11, 2),
224
+ validated_key = _this$__validate_key_12[0],
225
+ is_k_valid = _this$__validate_key_12[1];
226
+ if (!is_k_valid) {
227
+ return;
228
+ }
229
+ this.__list_unset.push(validated_key);
230
+ }
231
+ }, {
232
+ key: "_set_preferred_language",
233
+ value: function _set_preferred_language(lang_code, caller) {
234
+ if (!_language_codes["default"].includes(lang_code)) {
235
+ this.__info.push("[".concat(caller, "] invalid value ").concat(lang_code));
236
+ return;
237
+ }
238
+ this.__dict_set[KEY_PREFERRED_LANGUAGE] = lang_code;
239
+ }
240
+ }, {
241
+ key: "_set_timezone",
242
+ value: function _set_timezone(timezone, caller) {
243
+ this.__dict_set[KEY_TIMEZONE] = timezone;
244
+ }
245
+ }, {
246
+ key: "__add_identity",
247
+ value: function __add_identity(key, value, args, caller) {
248
+ var new_caller = "".concat(caller, ":").concat(key);
249
+ switch (key) {
250
+ case IDENT_KEY_EMAIL:
251
+ this._add_email(value, new_caller);
252
+ break;
253
+ case IDENT_KEY_SMS:
254
+ this._add_sms(value, new_caller);
255
+ break;
256
+ case IDENT_KEY_WHATSAPP:
257
+ this._add_whatsapp(value, new_caller);
258
+ break;
259
+ case IDENT_KEY_ANDROIDPUSH:
260
+ this._add_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
261
+ break;
262
+ case IDENT_KEY_IOSPUSH:
263
+ this._add_iospush(value, args[KEY_PUSHVENDOR], new_caller);
264
+ break;
265
+ case IDENT_KEY_WEBPUSH:
266
+ this._add_webpush(value, args[KEY_PUSHVENDOR], new_caller);
267
+ break;
268
+ case IDENT_KEY_SLACK:
269
+ this._add_slack(value, caller);
270
+ break;
271
+ case IDENT_KEY_MS_TEAMS:
272
+ this._add_ms_teams(value, caller);
273
+ break;
274
+ default:
275
+ break;
276
+ }
277
+ }
278
+ }, {
279
+ key: "__remove_identity",
280
+ value: function __remove_identity(key, value, args, caller) {
281
+ var new_caller = "".concat(caller, ":").concat(key);
282
+ switch (key) {
283
+ case IDENT_KEY_EMAIL:
284
+ this._remove_email(value, new_caller);
285
+ break;
286
+ case IDENT_KEY_SMS:
287
+ this._remove_sms(value, new_caller);
288
+ break;
289
+ case IDENT_KEY_WHATSAPP:
290
+ this._remove_whatsapp(value, new_caller);
291
+ break;
292
+ case IDENT_KEY_ANDROIDPUSH:
293
+ this._remove_androidpush(value, args[KEY_PUSHVENDOR], new_caller);
294
+ break;
295
+ case IDENT_KEY_IOSPUSH:
296
+ this._remove_iospush(value, args[KEY_PUSHVENDOR], new_caller);
297
+ break;
298
+ case IDENT_KEY_WEBPUSH:
299
+ this._remove_webpush(value, args[KEY_PUSHVENDOR], new_caller);
300
+ break;
301
+ case IDENT_KEY_SLACK:
302
+ this._remove_slack(val, caller);
303
+ break;
304
+ case IDENT_KEY_MS_TEAMS:
305
+ this._remove_ms_teams(val, caller);
306
+ break;
307
+ default:
308
+ break;
309
+ }
310
+ }
311
+ }, {
312
+ key: "__check_ident_val_string",
313
+ value: function __check_ident_val_string(value, caller) {
314
+ var message = "value must be a string with proper value";
315
+ if (!(0, _utils.is_string)(value)) {
316
+ this.__errors.push("[".concat(caller, "] ").concat(message));
317
+ return [value, false];
318
+ }
319
+ value = value.trim();
320
+ if (!value) {
321
+ this.__errors.push("[".concat(caller, "] ").concat(message));
322
+ return [value, false];
323
+ }
324
+ return [value, true];
325
+ }
326
+
327
+ // email methods
328
+ }, {
329
+ key: "__validate_email",
330
+ value: function __validate_email(value, caller) {
331
+ var _this$__check_ident_v = this.__check_ident_val_string(value, caller),
332
+ _this$__check_ident_v2 = (0, _slicedToArray2["default"])(_this$__check_ident_v, 2),
333
+ email = _this$__check_ident_v2[0],
334
+ is_valid = _this$__check_ident_v2[1];
335
+ if (!is_valid) {
336
+ return [email, false];
337
+ }
338
+ return [email, true];
339
+ }
340
+ }, {
341
+ key: "_add_email",
342
+ value: function _add_email(email, caller) {
343
+ var _this$__validate_emai = this.__validate_email(email, caller),
344
+ _this$__validate_emai2 = (0, _slicedToArray2["default"])(_this$__validate_emai, 2),
345
+ value = _this$__validate_emai2[0],
346
+ is_valid = _this$__validate_emai2[1];
347
+ if (!is_valid) {
348
+ return;
349
+ }
350
+ this.__dict_append[IDENT_KEY_EMAIL] = value;
351
+ }
352
+ }, {
353
+ key: "_remove_email",
354
+ value: function _remove_email(email, caller) {
355
+ var _this$__validate_emai3 = this.__validate_email(email, caller),
356
+ _this$__validate_emai4 = (0, _slicedToArray2["default"])(_this$__validate_emai3, 2),
357
+ value = _this$__validate_emai4[0],
358
+ is_valid = _this$__validate_emai4[1];
359
+ if (!is_valid) {
360
+ return;
361
+ }
362
+ this.__dict_remove[IDENT_KEY_EMAIL] = value;
363
+ }
364
+
365
+ // mobile methods
366
+ }, {
367
+ key: "__validate_mobile_no",
368
+ value: function __validate_mobile_no(value, caller) {
369
+ var _this$__check_ident_v3 = this.__check_ident_val_string(value, caller),
370
+ _this$__check_ident_v4 = (0, _slicedToArray2["default"])(_this$__check_ident_v3, 2),
371
+ mobile = _this$__check_ident_v4[0],
372
+ is_valid = _this$__check_ident_v4[1];
373
+ if (!is_valid) {
374
+ return [mobile, false];
375
+ }
376
+ return [mobile, true];
377
+ }
378
+ }, {
379
+ key: "_add_sms",
380
+ value: function _add_sms(mobile_no, caller) {
381
+ var _this$__validate_mobi = this.__validate_mobile_no(mobile_no, caller),
382
+ _this$__validate_mobi2 = (0, _slicedToArray2["default"])(_this$__validate_mobi, 2),
383
+ value = _this$__validate_mobi2[0],
384
+ is_valid = _this$__validate_mobi2[1];
385
+ if (!is_valid) {
386
+ return;
387
+ }
388
+ this.__dict_append[IDENT_KEY_SMS] = value;
389
+ }
390
+ }, {
391
+ key: "_remove_sms",
392
+ value: function _remove_sms(mobile_no, caller) {
393
+ var _this$__validate_mobi3 = this.__validate_mobile_no(mobile_no, caller),
394
+ _this$__validate_mobi4 = (0, _slicedToArray2["default"])(_this$__validate_mobi3, 2),
395
+ value = _this$__validate_mobi4[0],
396
+ is_valid = _this$__validate_mobi4[1];
397
+ if (!is_valid) {
398
+ return;
399
+ }
400
+ this.__dict_remove[IDENT_KEY_SMS] = value;
401
+ }
402
+ }, {
403
+ key: "_add_whatsapp",
404
+ value: function _add_whatsapp(mobile_no, caller) {
405
+ var _this$__validate_mobi5 = this.__validate_mobile_no(mobile_no, caller),
406
+ _this$__validate_mobi6 = (0, _slicedToArray2["default"])(_this$__validate_mobi5, 2),
407
+ value = _this$__validate_mobi6[0],
408
+ is_valid = _this$__validate_mobi6[1];
409
+ if (!is_valid) {
410
+ return;
411
+ }
412
+ this.__dict_append[IDENT_KEY_WHATSAPP] = value;
413
+ }
414
+ }, {
415
+ key: "_remove_whatsapp",
416
+ value: function _remove_whatsapp(mobile_no, caller) {
417
+ var _this$__validate_mobi7 = this.__validate_mobile_no(mobile_no, caller),
418
+ _this$__validate_mobi8 = (0, _slicedToArray2["default"])(_this$__validate_mobi7, 2),
419
+ value = _this$__validate_mobi8[0],
420
+ is_valid = _this$__validate_mobi8[1];
421
+ if (!is_valid) {
422
+ return;
423
+ }
424
+ this.__dict_remove[IDENT_KEY_WHATSAPP] = value;
425
+ }
426
+
427
+ // android push methods
428
+ }, {
429
+ key: "__check_androidpush_value",
430
+ value: function __check_androidpush_value(value, provider, caller) {
431
+ var _this$__check_ident_v5 = this.__check_ident_val_string(value, caller),
432
+ _this$__check_ident_v6 = (0, _slicedToArray2["default"])(_this$__check_ident_v5, 2),
433
+ push_token = _this$__check_ident_v6[0],
434
+ is_valid = _this$__check_ident_v6[1];
435
+ if (!is_valid) {
436
+ return [push_token, provider, false];
437
+ }
438
+ var _this$__check_ident_v7 = this.__check_ident_val_string(value, caller),
439
+ _this$__check_ident_v8 = (0, _slicedToArray2["default"])(_this$__check_ident_v7, 2),
440
+ validated_provider = _this$__check_ident_v8[0],
441
+ is_provider_valid = _this$__check_ident_v8[1];
442
+ if (!is_provider_valid) {
443
+ return [push_token, provider, false];
444
+ }
445
+ provider = validated_provider.toLocaleLowerCase();
446
+ return [push_token, provider, true];
447
+ }
448
+ }, {
449
+ key: "_add_androidpush",
450
+ value: function _add_androidpush(push_token) {
451
+ var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "fcm";
452
+ var caller = arguments.length > 2 ? arguments[2] : undefined;
453
+ var _this$__check_android = this.__check_androidpush_value(push_token, provider, caller),
454
+ _this$__check_android2 = (0, _slicedToArray2["default"])(_this$__check_android, 3),
455
+ value = _this$__check_android2[0],
456
+ vendor = _this$__check_android2[1],
457
+ is_valid = _this$__check_android2[2];
458
+ if (!is_valid) {
459
+ return;
460
+ }
461
+ this.__dict_append[IDENT_KEY_ANDROIDPUSH] = value;
462
+ this.__dict_append[KEY_PUSHVENDOR] = vendor;
463
+ }
464
+ }, {
465
+ key: "_remove_androidpush",
466
+ value: function _remove_androidpush(push_token) {
467
+ var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "fcm";
468
+ var caller = "remove_androidpush";
469
+ var _this$__check_android3 = this.__check_androidpush_value(push_token, provider, caller),
470
+ _this$__check_android4 = (0, _slicedToArray2["default"])(_this$__check_android3, 3),
471
+ value = _this$__check_android4[0],
472
+ vendor = _this$__check_android4[1],
473
+ is_valid = _this$__check_android4[2];
474
+ if (!is_valid) {
475
+ return;
476
+ }
477
+ this.__dict_remove[IDENT_KEY_ANDROIDPUSH] = value;
478
+ this.__dict_remove[KEY_PUSHVENDOR] = vendor;
479
+ }
480
+
481
+ // ios push methods
482
+ }, {
483
+ key: "__check_iospush_value",
484
+ value: function __check_iospush_value(value, provider, caller) {
485
+ var _this$__check_ident_v9 = this.__check_ident_val_string(value, caller),
486
+ _this$__check_ident_v10 = (0, _slicedToArray2["default"])(_this$__check_ident_v9, 2),
487
+ push_token = _this$__check_ident_v10[0],
488
+ is_valid = _this$__check_ident_v10[1];
489
+ if (!is_valid) {
490
+ return [push_token, provider, false];
491
+ }
492
+ var _this$__check_ident_v11 = this.__check_ident_val_string(value, caller),
493
+ _this$__check_ident_v12 = (0, _slicedToArray2["default"])(_this$__check_ident_v11, 2),
494
+ validated_provider = _this$__check_ident_v12[0],
495
+ is_provider_valid = _this$__check_ident_v12[1];
496
+ if (!is_provider_valid) {
497
+ return [push_token, provider, false];
498
+ }
499
+ provider = validated_provider.toLocaleLowerCase();
500
+ return [push_token, provider, true];
501
+ }
502
+ }, {
503
+ key: "_add_iospush",
504
+ value: function _add_iospush(push_token) {
505
+ var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "apns";
506
+ var caller = arguments.length > 2 ? arguments[2] : undefined;
507
+ var _this$__check_iospush = this.__check_iospush_value(push_token, provider, caller),
508
+ _this$__check_iospush2 = (0, _slicedToArray2["default"])(_this$__check_iospush, 3),
509
+ value = _this$__check_iospush2[0],
510
+ vendor = _this$__check_iospush2[1],
511
+ is_valid = _this$__check_iospush2[2];
512
+ if (!is_valid) {
513
+ return;
514
+ }
515
+ this.__dict_append[IDENT_KEY_IOSPUSH] = value;
516
+ this.__dict_append[KEY_PUSHVENDOR] = vendor;
517
+ }
518
+ }, {
519
+ key: "_remove_iospush",
520
+ value: function _remove_iospush(push_token) {
521
+ var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "apns";
522
+ var caller = arguments.length > 2 ? arguments[2] : undefined;
523
+ var _this$__check_iospush3 = this.__check_iospush_value(push_token, provider, caller),
524
+ _this$__check_iospush4 = (0, _slicedToArray2["default"])(_this$__check_iospush3, 3),
525
+ value = _this$__check_iospush4[0],
526
+ vendor = _this$__check_iospush4[1],
527
+ is_valid = _this$__check_iospush4[2];
528
+ if (!is_valid) {
529
+ return;
530
+ }
531
+ this.__dict_remove[IDENT_KEY_IOSPUSH] = value;
532
+ this.__dict_remove[KEY_PUSHVENDOR] = vendor;
533
+ }
534
+
535
+ // web push methods
536
+ }, {
537
+ key: "__check_webpush_dict",
538
+ value: function __check_webpush_dict(value, provider, caller) {
539
+ if (!(0, _utils.is_object)(value)) {
540
+ this.__errors.push("[".concat(caller, "] value must be a valid dict representing webpush-token"));
541
+ return [value, provider, false];
542
+ }
543
+ var _this$__check_ident_v13 = this.__check_ident_val_string(value, caller),
544
+ _this$__check_ident_v14 = (0, _slicedToArray2["default"])(_this$__check_ident_v13, 2),
545
+ validated_provider = _this$__check_ident_v14[0],
546
+ is_provider_valid = _this$__check_ident_v14[1];
547
+ if (!is_provider_valid) {
548
+ return [value, provider, false];
549
+ }
550
+ provider = validated_provider.toLocaleLowerCase();
551
+ return [value, provider, true];
552
+ }
553
+ }, {
554
+ key: "_add_webpush",
555
+ value: function _add_webpush(push_token) {
556
+ var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "vapid";
557
+ var caller = arguments.length > 2 ? arguments[2] : undefined;
558
+ var _this$__check_webpush = this.__check_webpush_dict(push_token, provider, caller),
559
+ _this$__check_webpush2 = (0, _slicedToArray2["default"])(_this$__check_webpush, 3),
560
+ value = _this$__check_webpush2[0],
561
+ vendor = _this$__check_webpush2[1],
562
+ is_valid = _this$__check_webpush2[2];
563
+ if (!is_valid) {
564
+ return;
565
+ }
566
+ this.__dict_append[IDENT_KEY_WEBPUSH] = value;
567
+ this.__dict_append[KEY_PUSHVENDOR] = vendor;
568
+ }
569
+ }, {
570
+ key: "_remove_webpush",
571
+ value: function _remove_webpush(push_token) {
572
+ var provider = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "vapid";
573
+ var caller = arguments.length > 2 ? arguments[2] : undefined;
574
+ var _this$__check_webpush3 = this.__check_webpush_dict(push_token, provider, caller),
575
+ _this$__check_webpush4 = (0, _slicedToArray2["default"])(_this$__check_webpush3, 3),
576
+ value = _this$__check_webpush4[0],
577
+ vendor = _this$__check_webpush4[1],
578
+ is_valid = _this$__check_webpush4[2];
579
+ if (!is_valid) {
580
+ return;
581
+ }
582
+ this.__dict_remove[IDENT_KEY_WEBPUSH] = value;
583
+ this.__dict_remove[KEY_PUSHVENDOR] = vendor;
584
+ }
585
+ }, {
586
+ key: "__check_slack_dict",
587
+ value: function __check_slack_dict(value, caller) {
588
+ var msg = "value must be a valid dict/json with proper keys";
589
+ if (!(value && value instanceof Object)) {
590
+ this.__errors.push("[".concat(caller, "] ").concat(msg));
591
+ return [value, false];
592
+ } else {
593
+ return [value, true];
594
+ }
595
+ }
596
+ }, {
597
+ key: "_add_slack",
598
+ value: function _add_slack(value, caller) {
599
+ var _this$__check_slack_d = this.__check_slack_dict(value, caller),
600
+ _this$__check_slack_d2 = (0, _slicedToArray2["default"])(_this$__check_slack_d, 2),
601
+ validated_value = _this$__check_slack_d2[0],
602
+ is_valid = _this$__check_slack_d2[1];
603
+ if (!is_valid) {
604
+ return;
605
+ }
606
+ this.__dict_append[IDENT_KEY_SLACK] = validated_value;
607
+ }
608
+ }, {
609
+ key: "_remove_slack",
610
+ value: function _remove_slack(value, caller) {
611
+ var _this$__check_slack_d3 = this.__check_slack_dict(value, caller),
612
+ _this$__check_slack_d4 = (0, _slicedToArray2["default"])(_this$__check_slack_d3, 2),
613
+ validated_value = _this$__check_slack_d4[0],
614
+ is_valid = _this$__check_slack_d4[1];
615
+ if (!is_valid) {
616
+ return;
617
+ }
618
+ this.__dict_remove[IDENT_KEY_SLACK] = validated_value;
619
+ }
620
+ }, {
621
+ key: "__check_ms_teams_dict",
622
+ value: function __check_ms_teams_dict(value, caller) {
623
+ var msg = "value must be a valid dict/json with proper keys";
624
+ if (!(value && value instanceof Object)) {
625
+ this.__errors.push("[".concat(caller, "] ").concat(msg));
626
+ return [value, false];
627
+ } else {
628
+ return [value, true];
629
+ }
630
+ }
631
+ }, {
632
+ key: "_add_ms_teams",
633
+ value: function _add_ms_teams(value, caller) {
634
+ var _this$__check_ms_team = this.__check_ms_teams_dict(value, caller),
635
+ _this$__check_ms_team2 = (0, _slicedToArray2["default"])(_this$__check_ms_team, 2),
636
+ validated_value = _this$__check_ms_team2[0],
637
+ is_valid = _this$__check_ms_team2[1];
638
+ if (!is_valid) {
639
+ return;
640
+ }
641
+ this.__dict_append[IDENT_KEY_MS_TEAMS] = validated_value;
642
+ }
643
+ }, {
644
+ key: "_remove_ms_teams",
645
+ value: function _remove_ms_teams(value, caller) {
646
+ var _this$__check_ms_team3 = this.__check_ms_teams_dict(value, caller),
647
+ _this$__check_ms_team4 = (0, _slicedToArray2["default"])(_this$__check_ms_team3, 2),
648
+ validated_value = _this$__check_ms_team4[0],
649
+ is_valid = _this$__check_ms_team4[1];
650
+ if (!is_valid) {
651
+ return;
652
+ }
653
+ this.__dict_remove[IDENT_KEY_MS_TEAMS] = validated_value;
654
+ }
655
+ }]);
656
+ return _ObjectInternalHelper;
657
+ }();
658
+ exports["default"] = _ObjectInternalHelper;
659
+ module.exports = exports.default;
@@ -312,7 +312,7 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
312
312
  }, {
313
313
  key: "__check_ident_val_string",
314
314
  value: function __check_ident_val_string(value, caller) {
315
- var message = "value must a string with proper value";
315
+ var message = "value must be a string with proper value";
316
316
  if (!(0, _utils.is_string)(value)) {
317
317
  this.__errors.push("[".concat(caller, "] ").concat(message));
318
318
  return [value, false];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/node-sdk",
3
- "version": "1.10.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/index.js CHANGED
@@ -11,6 +11,7 @@ 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
15
  import { DEFAULT_URL } from "./constants";
15
16
 
16
17
  const package_json = require("../package.json");
@@ -38,6 +39,7 @@ class Suprsend {
38
39
  this.brands = new BrandsApi(this);
39
40
  this.tenants = new TenantsApi(this);
40
41
  this.workflows = new WorkflowsApi(this);
42
+ this.objects = new ObjectsApi(this);
41
43
 
42
44
  this.subscriber_lists = new SubscriberListsApi(this);
43
45