@suprsend/node-sdk 1.8.2 → 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.
package/dist/event.js CHANGED
@@ -27,6 +27,7 @@ var Event = /*#__PURE__*/function () {
27
27
  this.event_name = event_name;
28
28
  this.properties = properties;
29
29
  this.idempotency_key = kwargs === null || kwargs === void 0 ? void 0 : kwargs.idempotency_key;
30
+ this.tenant_id = kwargs === null || kwargs === void 0 ? void 0 : kwargs.tenant_id;
30
31
  this.brand_id = kwargs === null || kwargs === void 0 ? void 0 : kwargs.brand_id;
31
32
 
32
33
  // default values
@@ -120,6 +121,9 @@ var Event = /*#__PURE__*/function () {
120
121
  if (this.idempotency_key) {
121
122
  event_dict["$idempotency_key"] = this.idempotency_key;
122
123
  }
124
+ if (this.tenant_id) {
125
+ event_dict["tenant_id"] = this.tenant_id;
126
+ }
123
127
  if (this.brand_id) {
124
128
  event_dict["brand_id"] = this.brand_id;
125
129
  }
@@ -141,6 +145,9 @@ var Event = /*#__PURE__*/function () {
141
145
  if (this.idempotency_key) {
142
146
  event_dict["$idempotency_key"] = this.idempotency_key;
143
147
  }
148
+ if (this.tenant_id) {
149
+ event_dict["tenant_id"] = this.tenant_id;
150
+ }
144
151
  if (this.brand_id) {
145
152
  event_dict["brand_id"] = this.brand_id;
146
153
  }
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ var _subscriber = _interopRequireDefault(require("./subscriber"));
36
36
  var _subscribers_bulk = _interopRequireDefault(require("./subscribers_bulk"));
37
37
  var _subscriber_list = require("./subscriber_list");
38
38
  var _brands = _interopRequireDefault(require("./brands"));
39
+ var _tenant = _interopRequireDefault(require("./tenant"));
39
40
  var _constants = require("./constants");
40
41
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -56,6 +57,7 @@ var Suprsend = /*#__PURE__*/function () {
56
57
  this._bulk_users = new _subscribers_bulk["default"](this);
57
58
  this._user = new _subscriber["default"](this);
58
59
  this.brands = new _brands["default"](this);
60
+ this.tenants = new _tenant["default"](this);
59
61
  this.subscriber_lists = new _subscriber_list.SubscriberListsApi(this);
60
62
  this._validate();
61
63
  }
@@ -11,6 +11,11 @@
11
11
  "maxLength": 255,
12
12
  "description": "unique id provided by client for request"
13
13
  },
14
+ "tenant_id": {
15
+ "type": ["string", "null"],
16
+ "maxLength": 64,
17
+ "description": "tenant id for workflow to be run in context of a tenant"
18
+ },
14
19
  "brand_id": {
15
20
  "type": ["string", "null"],
16
21
  "maxLength": 64,
@@ -11,6 +11,11 @@
11
11
  "maxLength": 255,
12
12
  "description": "unique id provided by client for request"
13
13
  },
14
+ "tenant_id": {
15
+ "type": ["string", "null"],
16
+ "maxLength": 64,
17
+ "description": "tenant id for workflow to be run in context of a tenant"
18
+ },
14
19
  "brand_id": {
15
20
  "type": ["string", "null"],
16
21
  "maxLength": 64,
@@ -44,7 +49,8 @@
44
49
  "whatsapp",
45
50
  "slack",
46
51
  "inbox",
47
- "messenger"
52
+ "messenger",
53
+ "ms_teams"
48
54
  ]
49
55
  },
50
56
  "minItems": 0,
@@ -11,6 +11,11 @@
11
11
  "maxLength": 255,
12
12
  "description": "unique id provided by client for request"
13
13
  },
14
+ "tenant_id": {
15
+ "type": ["string", "null"],
16
+ "maxLength": 64,
17
+ "description": "tenant id for workflow to be run in context of a tenant"
18
+ },
14
19
  "brand_id": {
15
20
  "type": ["string", "null"],
16
21
  "maxLength": 64,
@@ -124,6 +129,40 @@
124
129
  },
125
130
  "additionalProperties": false
126
131
  },
132
+ "ms_teams_setting": {
133
+ "type": "object",
134
+ "properties": {
135
+ "tenant_id": {
136
+ "type": "string",
137
+ "description": "ms teams tenant id"
138
+ },
139
+ "service_url": {
140
+ "type": "string",
141
+ "format": "uri",
142
+ "pattern": "^https://smba.trafficmanager.net/",
143
+ "description": "service webhook url. e.g https://smba.trafficmanager.net/XXXXXXXXXX"
144
+ },
145
+ "conversation_id": {
146
+ "type": "string",
147
+ "description": "ms team conversation id"
148
+ },
149
+ "user_id": {
150
+ "type": "string",
151
+ "description": "ms team user id"
152
+ },
153
+ "incoming_webhook": {
154
+ "type": "object",
155
+ "properties": {
156
+ "url": {
157
+ "type": "string",
158
+ "format": "uri",
159
+ "description": "incoming webhook url. e.g https://XXXXX.webhook.office.com/webhookb2/XXXXXXXXXX@XXXXXXXXXX/IncomingWebhook/XXXXXXXXXX/XXXXXXXXXX"
160
+ }
161
+ }
162
+ }
163
+ },
164
+ "additionalProperties": false
165
+ },
127
166
  "androidpush_settings": {
128
167
  "type": "object",
129
168
  "properties": {
@@ -184,7 +223,8 @@
184
223
  "whatsapp",
185
224
  "slack",
186
225
  "inbox",
187
- "messenger"
226
+ "messenger",
227
+ "ms_teams"
188
228
  ]
189
229
  },
190
230
  "minItems": 0,
@@ -290,6 +330,18 @@
290
330
  }
291
331
  ]
292
332
  },
333
+ "$ms_teams": {
334
+ "oneOf": [
335
+ { "$ref": "#/definitions/ms_teams_setting" },
336
+ {
337
+ "type": "array",
338
+ "uniqueItems": false,
339
+ "maxItems": 10,
340
+ "minItems": 1,
341
+ "items": { "$ref": "#/definitions/ms_teams_setting" }
342
+ }
343
+ ]
344
+ },
293
345
  "$inbox": {
294
346
  "oneOf": [
295
347
  { "$ref": "#/definitions/non_empty_string" },
@@ -349,7 +401,8 @@
349
401
  "whatsapp",
350
402
  "slack",
351
403
  "inbox",
352
- "messenger"
404
+ "messenger",
405
+ "ms_teams"
353
406
  ]
354
407
  },
355
408
  "minItems": 0,
@@ -236,6 +236,75 @@ var Subscriber = /*#__PURE__*/function () {
236
236
  this._collect_event();
237
237
  }
238
238
  }
239
+ }, {
240
+ key: "set",
241
+ value: function set(key, value) {
242
+ var caller = "set";
243
+ if (!(0, _utils.is_string)(key) && !(0, _utils.is_object)(key)) {
244
+ this.__errors.push("[".concat(caller, "] arg1 must be either string or a dict"));
245
+ return;
246
+ }
247
+ if ((0, _utils.is_string)(key)) {
248
+ if (value === null || value === undefined) {
249
+ this.__errors.push("[".concat(caller, "] if arg1 is a string, then arg2 must be passed"));
250
+ return;
251
+ } else {
252
+ this._helper._set_kv(key, value, {}, caller);
253
+ this._collect_event();
254
+ }
255
+ } else {
256
+ for (var item in key) {
257
+ this._helper._set_kv(item, key[item], key, caller);
258
+ }
259
+ this._collect_event();
260
+ }
261
+ }
262
+ }, {
263
+ key: "set_once",
264
+ value: function set_once(key, value) {
265
+ var caller = "set_once";
266
+ if (!(0, _utils.is_string)(key) && !(0, _utils.is_object)(key)) {
267
+ this.__errors.push("[".concat(caller, "] arg1 must be either string or a dict"));
268
+ return;
269
+ }
270
+ if ((0, _utils.is_string)(key)) {
271
+ if (value === null || value === undefined) {
272
+ this.__errors.push("[".concat(caller, "] if arg1 is a string, then arg2 must be passed"));
273
+ return;
274
+ } else {
275
+ this._helper._set_once_kv(key, value, {}, caller);
276
+ this._collect_event();
277
+ }
278
+ } else {
279
+ for (var item in key) {
280
+ this._helper._set_once_kv(item, key[item], key, caller);
281
+ }
282
+ this._collect_event();
283
+ }
284
+ }
285
+ }, {
286
+ key: "increment",
287
+ value: function increment(key, value) {
288
+ var caller = "increment";
289
+ if (!(0, _utils.is_string)(key) && !(0, _utils.is_object)(key)) {
290
+ this.__errors.push("[".concat(caller, "] arg1 must be either string or a dict"));
291
+ return;
292
+ }
293
+ if ((0, _utils.is_string)(key)) {
294
+ if (value === null || value === undefined) {
295
+ this.__errors.push("[".concat(caller, "] if arg1 is a string, then arg2 must be passed"));
296
+ return;
297
+ } else {
298
+ this._helper._increment_kv(key, value, {}, caller);
299
+ this._collect_event();
300
+ }
301
+ } else {
302
+ for (var item in key) {
303
+ this._helper._increment_kv(item, key[item], key, caller);
304
+ }
305
+ this._collect_event();
306
+ }
307
+ }
239
308
  }, {
240
309
  key: "remove",
241
310
  value: function remove(key, value) {
@@ -397,6 +466,20 @@ var Subscriber = /*#__PURE__*/function () {
397
466
  this._helper._remove_slack(value, caller);
398
467
  this._collect_event();
399
468
  }
469
+ }, {
470
+ key: "add_ms_teams",
471
+ value: function add_ms_teams(value) {
472
+ var caller = "add_ms_teams";
473
+ this._helper._add_ms_teams(value, caller);
474
+ this._collect_event();
475
+ }
476
+ }, {
477
+ key: "remove_ms_teams",
478
+ value: function remove_ms_teams(value) {
479
+ var caller = "remove_ms_teams";
480
+ this._helper._remove_ms_teams(value, caller);
481
+ this._collect_event();
482
+ }
400
483
  }, {
401
484
  key: "add_slack_email",
402
485
  value: function add_slack_email(value) {
@@ -18,7 +18,8 @@ var IDENT_KEY_IOSPUSH = "$iospush";
18
18
  var IDENT_KEY_WHATSAPP = "$whatsapp";
19
19
  var IDENT_KEY_WEBPUSH = "$webpush";
20
20
  var IDENT_KEY_SLACK = "$slack";
21
- 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];
22
23
  var KEY_PUSHVENDOR = "$pushvendor";
23
24
  var KEY_PREFERRED_LANGUAGE = "$preferred_language";
24
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"];
@@ -32,6 +33,8 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
32
33
  this.distinct_id = distinct_id;
33
34
  this.workspace_key = workspace_key;
34
35
  this.__dict_set = {};
36
+ this.__dict_set_once = {};
37
+ this.__dict_increment = {};
35
38
  this.__dict_append = {};
36
39
  this.__dict_remove = {};
37
40
  this.__list_unset = [];
@@ -42,6 +45,8 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
42
45
  key: "reset",
43
46
  value: function reset() {
44
47
  this.__dict_set = {};
48
+ this.__dict_set_once = {};
49
+ this.__dict_increment = {};
45
50
  this.__dict_append = {};
46
51
  this.__dict_remove = {};
47
52
  this.__list_unset = [];
@@ -67,6 +72,12 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
67
72
  if (!(0, _utils.is_empty)(this.__dict_set)) {
68
73
  event["$set"] = this.__dict_set;
69
74
  }
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
+ }
70
81
  if (!(0, _utils.is_empty)(this.__dict_append)) {
71
82
  event["$append"] = this.__dict_append;
72
83
  }
@@ -130,22 +141,76 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
130
141
  }
131
142
  }
132
143
  }, {
133
- key: "_remove_kv",
134
- value: function _remove_kv(key, value) {
144
+ key: "_set_kv",
145
+ value: function _set_kv(key, value) {
135
146
  var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
136
- var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "remove";
147
+ var caller = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "set";
137
148
  var _this$__validate_key_3 = this.__validate_key_basic(key, caller),
138
149
  _this$__validate_key_4 = (0, _slicedToArray2["default"])(_this$__validate_key_3, 2),
139
150
  validated_key = _this$__validate_key_4[0],
140
151
  is_k_valid = _this$__validate_key_4[1];
141
152
  if (!is_k_valid) {
142
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;
143
208
  }
144
209
  if (this.__is_identity_key(validated_key)) {
145
210
  this.__remove_identity(validated_key, value, args, caller);
146
211
  } else {
147
- var _is_k_valid2 = this.__validate_key_prefix(validated_key, caller);
148
- if (_is_k_valid2) {
212
+ var _is_k_valid5 = this.__validate_key_prefix(validated_key, caller);
213
+ if (_is_k_valid5) {
149
214
  this.__dict_remove[validated_key] = value;
150
215
  }
151
216
  }
@@ -154,10 +219,10 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
154
219
  key: "_unset_k",
155
220
  value: function _unset_k(key) {
156
221
  var caller = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unset";
157
- var _this$__validate_key_5 = this.__validate_key_basic(key, caller),
158
- _this$__validate_key_6 = (0, _slicedToArray2["default"])(_this$__validate_key_5, 2),
159
- validated_key = _this$__validate_key_6[0],
160
- is_k_valid = _this$__validate_key_6[1];
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];
161
226
  if (!is_k_valid) {
162
227
  return;
163
228
  }
@@ -198,6 +263,9 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
198
263
  case IDENT_KEY_SLACK:
199
264
  this._add_slack(value, caller);
200
265
  break;
266
+ case IDENT_KEY_MS_TEAMS:
267
+ this._add_ms_teams(value, caller);
268
+ break;
201
269
  default:
202
270
  break;
203
271
  }
@@ -228,6 +296,9 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
228
296
  case IDENT_KEY_SLACK:
229
297
  this._remove_slack(val, caller);
230
298
  break;
299
+ case IDENT_KEY_MS_TEAMS:
300
+ this._remove_ms_teams(val, caller);
301
+ break;
231
302
  default:
232
303
  break;
233
304
  }
@@ -570,6 +641,41 @@ var _SubscriberInternalHelper = /*#__PURE__*/function () {
570
641
  }
571
642
  this.__dict_remove[IDENT_KEY_SLACK] = validated_value;
572
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
+ }
573
679
  }]);
574
680
  return _SubscriberInternalHelper;
575
681
  }();