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