@suprsend/node-sdk 1.3.0 → 1.5.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/README.md +1 -1
- package/dist/index.js +4 -4
- package/dist/request_json/list_broadcast.json +19 -0
- package/dist/{subscribers_list.js → subscriber_list.js} +94 -61
- package/dist/subscribers_bulk.js +1 -1
- package/package.json +2 -1
- package/src/index.js +3 -6
- package/src/request_json/list_broadcast.json +19 -0
- package/src/{subscribers_list.js → subscriber_list.js} +53 -53
- package/src/subscribers_bulk.js +1 -1
- package/types/index.d.ts +194 -0
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -13,10 +13,10 @@ Object.defineProperty(exports, "Event", {
|
|
|
13
13
|
return _event["default"];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
Object.defineProperty(exports, "
|
|
16
|
+
Object.defineProperty(exports, "SubscriberListBroadcast", {
|
|
17
17
|
enumerable: true,
|
|
18
18
|
get: function get() {
|
|
19
|
-
return
|
|
19
|
+
return _subscriber_list.SubscriberListBroadcast;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
exports.Suprsend = void 0;
|
|
@@ -47,7 +47,7 @@ var _subscriber = _interopRequireDefault(require("./subscriber"));
|
|
|
47
47
|
|
|
48
48
|
var _subscribers_bulk = _interopRequireDefault(require("./subscribers_bulk"));
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _subscriber_list = require("./subscriber_list");
|
|
51
51
|
|
|
52
52
|
var _brands = _interopRequireDefault(require("./brands"));
|
|
53
53
|
|
|
@@ -75,7 +75,7 @@ var Suprsend = /*#__PURE__*/function () {
|
|
|
75
75
|
this._bulk_users = new _subscribers_bulk["default"](this);
|
|
76
76
|
this._user = new _subscriber["default"](this);
|
|
77
77
|
this.brands = new _brands["default"](this);
|
|
78
|
-
this.
|
|
78
|
+
this.subscriber_lists = new _subscriber_list.SubscriberListsApi(this);
|
|
79
79
|
|
|
80
80
|
this._validate();
|
|
81
81
|
}
|
|
@@ -31,6 +31,25 @@
|
|
|
31
31
|
"minLength": 1,
|
|
32
32
|
"description": "SubscriberList id"
|
|
33
33
|
},
|
|
34
|
+
"channels": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"enum": [
|
|
39
|
+
"androidpush",
|
|
40
|
+
"iospush",
|
|
41
|
+
"webpush",
|
|
42
|
+
"email",
|
|
43
|
+
"sms",
|
|
44
|
+
"whatsapp",
|
|
45
|
+
"slack",
|
|
46
|
+
"inbox",
|
|
47
|
+
"messenger"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"minItems": 0,
|
|
51
|
+
"description": "channels on which notification to be broadcast. e.g ['androidpush', 'iospush']"
|
|
52
|
+
},
|
|
34
53
|
"template": {
|
|
35
54
|
"$ref": "#/definitions/non_empty_string",
|
|
36
55
|
"description": "slug of Template"
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.SubscriberListsApi = exports.SubscriberListBroadcast = void 0;
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
@@ -31,10 +31,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
31
31
|
|
|
32
32
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
33
|
|
|
34
|
-
var
|
|
35
|
-
function
|
|
34
|
+
var SubscriberListBroadcast = /*#__PURE__*/function () {
|
|
35
|
+
function SubscriberListBroadcast(body) {
|
|
36
36
|
var kwargs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
37
|
-
(0, _classCallCheck2["default"])(this,
|
|
37
|
+
(0, _classCallCheck2["default"])(this, SubscriberListBroadcast);
|
|
38
38
|
|
|
39
39
|
if (!(body instanceof Object)) {
|
|
40
40
|
throw new _utils.SuprsendError("broadcast body must be a json/dictionary");
|
|
@@ -45,7 +45,7 @@ var SubscribersListBroadcast = /*#__PURE__*/function () {
|
|
|
45
45
|
this.brand_id = kwargs === null || kwargs === void 0 ? void 0 : kwargs.brand_id;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
(0, _createClass2["default"])(
|
|
48
|
+
(0, _createClass2["default"])(SubscriberListBroadcast, [{
|
|
49
49
|
key: "get_final_json",
|
|
50
50
|
value: function get_final_json() {
|
|
51
51
|
this.body["$insert_id"] = (0, _utils.uuid)();
|
|
@@ -69,14 +69,14 @@ var SubscribersListBroadcast = /*#__PURE__*/function () {
|
|
|
69
69
|
return [this.body, apparent_size];
|
|
70
70
|
}
|
|
71
71
|
}]);
|
|
72
|
-
return
|
|
72
|
+
return SubscriberListBroadcast;
|
|
73
73
|
}();
|
|
74
74
|
|
|
75
|
-
exports.
|
|
75
|
+
exports.SubscriberListBroadcast = SubscriberListBroadcast;
|
|
76
76
|
|
|
77
|
-
var
|
|
78
|
-
function
|
|
79
|
-
(0, _classCallCheck2["default"])(this,
|
|
77
|
+
var SubscriberListsApi = /*#__PURE__*/function () {
|
|
78
|
+
function SubscriberListsApi(config) {
|
|
79
|
+
(0, _classCallCheck2["default"])(this, SubscriberListsApi);
|
|
80
80
|
this.config = config;
|
|
81
81
|
this.subscriber_list_url = "".concat(this.config.base_url, "v1/subscriber_list/");
|
|
82
82
|
this.broadcast_url = "".concat(this.config.base_url).concat(this.config.workspace_key, "/broadcast/");
|
|
@@ -86,7 +86,7 @@ var SubscribersListApi = /*#__PURE__*/function () {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
(0, _createClass2["default"])(
|
|
89
|
+
(0, _createClass2["default"])(SubscriberListsApi, [{
|
|
90
90
|
key: "__common_headers",
|
|
91
91
|
value: function __common_headers() {
|
|
92
92
|
return {
|
|
@@ -428,57 +428,90 @@ var SubscribersListApi = /*#__PURE__*/function () {
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
return remove;
|
|
431
|
-
}()
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
431
|
+
}()
|
|
432
|
+
}, {
|
|
433
|
+
key: "broadcast",
|
|
434
|
+
value: function () {
|
|
435
|
+
var _broadcast = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(broadcast_instance) {
|
|
436
|
+
var _broadcast_instance$g, _broadcast_instance$g2, broadcast_body, body_size, headers, content_text, signature, response, ok_response;
|
|
437
|
+
|
|
438
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
439
|
+
while (1) {
|
|
440
|
+
switch (_context6.prev = _context6.next) {
|
|
441
|
+
case 0:
|
|
442
|
+
if (broadcast_instance instanceof SubscriberListBroadcast) {
|
|
443
|
+
_context6.next = 2;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
throw new _utils.SuprsendError("argument must be an instance of suprsend.SubscriberListBroadcast");
|
|
448
|
+
|
|
449
|
+
case 2:
|
|
450
|
+
_broadcast_instance$g = broadcast_instance.get_final_json(this.config), _broadcast_instance$g2 = (0, _slicedToArray2["default"])(_broadcast_instance$g, 2), broadcast_body = _broadcast_instance$g2[0], body_size = _broadcast_instance$g2[1];
|
|
451
|
+
headers = _objectSpread(_objectSpread({}, this.__headers), this.__dynamic_headers());
|
|
452
|
+
content_text = JSON.stringify(broadcast_body);
|
|
453
|
+
signature = (0, _signature["default"])(this.broadcast_url, "POST", content_text, headers, this.config.workspace_secret);
|
|
454
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
455
|
+
_context6.prev = 7;
|
|
456
|
+
_context6.next = 10;
|
|
457
|
+
return _axios["default"].post(this.broadcast_url, content_text, {
|
|
458
|
+
headers: headers
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
case 10:
|
|
462
|
+
response = _context6.sent;
|
|
463
|
+
ok_response = Math.floor(response.status / 100) == 2;
|
|
464
|
+
|
|
465
|
+
if (!ok_response) {
|
|
466
|
+
_context6.next = 16;
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return _context6.abrupt("return", {
|
|
471
|
+
success: true,
|
|
472
|
+
status: "success",
|
|
473
|
+
status_code: response.status,
|
|
474
|
+
message: response.statusText
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
case 16:
|
|
478
|
+
return _context6.abrupt("return", {
|
|
479
|
+
success: false,
|
|
480
|
+
status: "fail",
|
|
481
|
+
status_code: response.status,
|
|
482
|
+
message: response.statusText
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
case 17:
|
|
486
|
+
_context6.next = 22;
|
|
487
|
+
break;
|
|
488
|
+
|
|
489
|
+
case 19:
|
|
490
|
+
_context6.prev = 19;
|
|
491
|
+
_context6.t0 = _context6["catch"](7);
|
|
492
|
+
return _context6.abrupt("return", {
|
|
493
|
+
success: false,
|
|
494
|
+
status: "fail",
|
|
495
|
+
status_code: _context6.t0.status || 500,
|
|
496
|
+
message: _context6.t0.message
|
|
497
|
+
});
|
|
479
498
|
|
|
499
|
+
case 22:
|
|
500
|
+
case "end":
|
|
501
|
+
return _context6.stop();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}, _callee6, this, [[7, 19]]);
|
|
505
|
+
}));
|
|
506
|
+
|
|
507
|
+
function broadcast(_x6) {
|
|
508
|
+
return _broadcast.apply(this, arguments);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return broadcast;
|
|
512
|
+
}()
|
|
480
513
|
}]);
|
|
481
|
-
return
|
|
514
|
+
return SubscriberListsApi;
|
|
482
515
|
}();
|
|
483
516
|
|
|
484
|
-
exports.
|
|
517
|
+
exports.SubscriberListsApi = SubscriberListsApi;
|
package/dist/subscribers_bulk.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suprsend/node-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Suprsend Node SDK to trigger workflow from backend",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
+
"types": "types/index.d.ts",
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"@babel/runtime": "^7.16.3",
|
|
27
28
|
"axios": "^0.27.2",
|
package/src/index.js
CHANGED
|
@@ -6,10 +6,7 @@ import Event, { EventCollector } from "./event";
|
|
|
6
6
|
import { BulkEventsFactory } from "./events_bulk";
|
|
7
7
|
import SubscriberFactory from "./subscriber";
|
|
8
8
|
import BulkSubscribersFactory from "./subscribers_bulk";
|
|
9
|
-
import {
|
|
10
|
-
SubscribersListApi,
|
|
11
|
-
SubscribersListBroadcast,
|
|
12
|
-
} from "./subscribers_list";
|
|
9
|
+
import { SubscriberListsApi, SubscriberListBroadcast } from "./subscriber_list";
|
|
13
10
|
import BrandsApi from "./brands";
|
|
14
11
|
import { DEFAULT_UAT_URL, DEFAULT_URL } from "./constants";
|
|
15
12
|
|
|
@@ -36,7 +33,7 @@ class Suprsend {
|
|
|
36
33
|
this._user = new SubscriberFactory(this);
|
|
37
34
|
|
|
38
35
|
this.brands = new BrandsApi(this);
|
|
39
|
-
this.
|
|
36
|
+
this.subscriber_lists = new SubscriberListsApi(this);
|
|
40
37
|
|
|
41
38
|
this._validate();
|
|
42
39
|
}
|
|
@@ -129,4 +126,4 @@ class Suprsend {
|
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
128
|
|
|
132
|
-
export { Suprsend, Event, Workflow,
|
|
129
|
+
export { Suprsend, Event, Workflow, SubscriberListBroadcast };
|
|
@@ -31,6 +31,25 @@
|
|
|
31
31
|
"minLength": 1,
|
|
32
32
|
"description": "SubscriberList id"
|
|
33
33
|
},
|
|
34
|
+
"channels": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"enum": [
|
|
39
|
+
"androidpush",
|
|
40
|
+
"iospush",
|
|
41
|
+
"webpush",
|
|
42
|
+
"email",
|
|
43
|
+
"sms",
|
|
44
|
+
"whatsapp",
|
|
45
|
+
"slack",
|
|
46
|
+
"inbox",
|
|
47
|
+
"messenger"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"minItems": 0,
|
|
51
|
+
"description": "channels on which notification to be broadcast. e.g ['androidpush', 'iospush']"
|
|
52
|
+
},
|
|
34
53
|
"template": {
|
|
35
54
|
"$ref": "#/definitions/non_empty_string",
|
|
36
55
|
"description": "slug of Template"
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES_READABLE,
|
|
14
14
|
} from "./constants";
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class SubscriberListBroadcast {
|
|
17
17
|
constructor(body, kwargs = {}) {
|
|
18
18
|
if (!(body instanceof Object)) {
|
|
19
19
|
throw new SuprsendError("broadcast body must be a json/dictionary");
|
|
@@ -43,7 +43,7 @@ class SubscribersListBroadcast {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
class
|
|
46
|
+
class SubscriberListsApi {
|
|
47
47
|
constructor(config) {
|
|
48
48
|
this.config = config;
|
|
49
49
|
this.subscriber_list_url = `${this.config.base_url}v1/subscriber_list/`;
|
|
@@ -241,56 +241,56 @@ class SubscribersListApi {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
244
|
+
async broadcast(broadcast_instance) {
|
|
245
|
+
if (!(broadcast_instance instanceof SubscriberListBroadcast)) {
|
|
246
|
+
throw new SuprsendError(
|
|
247
|
+
"argument must be an instance of suprsend.SubscriberListBroadcast"
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
const [broadcast_body, body_size] = broadcast_instance.get_final_json(
|
|
251
|
+
this.config
|
|
252
|
+
);
|
|
253
|
+
const headers = { ...this.__headers, ...this.__dynamic_headers() };
|
|
254
|
+
const content_text = JSON.stringify(broadcast_body);
|
|
255
|
+
|
|
256
|
+
const signature = get_request_signature(
|
|
257
|
+
this.broadcast_url,
|
|
258
|
+
"POST",
|
|
259
|
+
content_text,
|
|
260
|
+
headers,
|
|
261
|
+
this.config.workspace_secret
|
|
262
|
+
);
|
|
263
|
+
headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
|
|
264
|
+
|
|
265
|
+
try {
|
|
266
|
+
const response = await axios.post(this.broadcast_url, content_text, {
|
|
267
|
+
headers,
|
|
268
|
+
});
|
|
269
|
+
const ok_response = Math.floor(response.status / 100) == 2;
|
|
270
|
+
if (ok_response) {
|
|
271
|
+
return {
|
|
272
|
+
success: true,
|
|
273
|
+
status: "success",
|
|
274
|
+
status_code: response.status,
|
|
275
|
+
message: response.statusText,
|
|
276
|
+
};
|
|
277
|
+
} else {
|
|
278
|
+
return {
|
|
279
|
+
success: false,
|
|
280
|
+
status: "fail",
|
|
281
|
+
status_code: response.status,
|
|
282
|
+
message: response.statusText,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
} catch (err) {
|
|
286
|
+
return {
|
|
287
|
+
success: false,
|
|
288
|
+
status: "fail",
|
|
289
|
+
status_code: err.status || 500,
|
|
290
|
+
message: err.message,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
export {
|
|
296
|
+
export { SubscriberListsApi, SubscriberListBroadcast };
|
package/src/subscribers_bulk.js
CHANGED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
declare namespace suprsend {
|
|
2
|
+
interface Dictionary {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface SResponse {
|
|
7
|
+
success: boolean;
|
|
8
|
+
status: string;
|
|
9
|
+
status_code: number;
|
|
10
|
+
message: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface SBulkResponse {
|
|
14
|
+
status: string;
|
|
15
|
+
failed_records: Dictionary[];
|
|
16
|
+
total: number;
|
|
17
|
+
success: number;
|
|
18
|
+
failure: number;
|
|
19
|
+
warnings: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Workflow {
|
|
23
|
+
new (
|
|
24
|
+
body: Dictionary,
|
|
25
|
+
kwargs?: { idempotency_key?: string; brand_id?: string }
|
|
26
|
+
): Workflow;
|
|
27
|
+
|
|
28
|
+
add_attachment(
|
|
29
|
+
file_path: string,
|
|
30
|
+
kwargs?: { file_name?: string; ignore_if_error?: boolean }
|
|
31
|
+
): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface BulkWorkflows {
|
|
35
|
+
append(...workflows: Workflow[]): void;
|
|
36
|
+
|
|
37
|
+
trigger(): Promise<SBulkResponse>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface BulkWorkflowsFactory {
|
|
41
|
+
new_instance(): BulkWorkflows;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Events
|
|
45
|
+
interface Event {
|
|
46
|
+
new (
|
|
47
|
+
distinct_id: any,
|
|
48
|
+
event_name: string,
|
|
49
|
+
properties?: Dictionary,
|
|
50
|
+
kwargs?: { idempotency_key?: string; brand_id?: string }
|
|
51
|
+
): Event;
|
|
52
|
+
|
|
53
|
+
add_attachment(
|
|
54
|
+
file_path: string,
|
|
55
|
+
kwargs?: { file_name?: string; ignore_if_error?: boolean }
|
|
56
|
+
): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface BulkEvents {
|
|
60
|
+
append(...events: Event[]): void;
|
|
61
|
+
|
|
62
|
+
trigger(): Promise<SBulkResponse>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface BulkEventsFactory {
|
|
66
|
+
new_instance(): BulkEvents;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// subscribers
|
|
70
|
+
interface Subscriber {
|
|
71
|
+
save(): Promise<SResponse>;
|
|
72
|
+
|
|
73
|
+
append(key: string | Dictionary, value?: any): void;
|
|
74
|
+
remove(key: string | Dictionary, value?: any): void;
|
|
75
|
+
unset(keys: string | string[]): void;
|
|
76
|
+
|
|
77
|
+
set_preferred_language(lang_code: string): void;
|
|
78
|
+
|
|
79
|
+
add_email(email: string): void;
|
|
80
|
+
remove_email(email: string): void;
|
|
81
|
+
|
|
82
|
+
add_sms(mobile_no: string): void;
|
|
83
|
+
remove_sms(mobile_no: string): void;
|
|
84
|
+
|
|
85
|
+
add_whatsapp(mobile_no: string): void;
|
|
86
|
+
remove_whatsapp(mobile_no: string): void;
|
|
87
|
+
|
|
88
|
+
add_androidpush(push_token: string, provider?: string): void;
|
|
89
|
+
remove_androidpush(push_token: string, provider?: string): void;
|
|
90
|
+
|
|
91
|
+
add_iospush(push_token: string, provider?: string): void;
|
|
92
|
+
remove_iospush(push_token: string, provider?: string): void;
|
|
93
|
+
|
|
94
|
+
add_webpush(push_token: Dictionary, provider?: string): void;
|
|
95
|
+
remove_webpush(push_token: Dictionary, provider?: string): void;
|
|
96
|
+
|
|
97
|
+
add_slack_email(email: string): void;
|
|
98
|
+
remove_slack_email(email: string): void;
|
|
99
|
+
|
|
100
|
+
add_slack_userid(user_id: any): void;
|
|
101
|
+
remove_slack_userid(user_id: any): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface SubscriberFactory {
|
|
105
|
+
new_user(distinct_id: any): Subscriber;
|
|
106
|
+
|
|
107
|
+
get_instance(distinct_id: any): Subscriber;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface BulkSubscribersFactory {
|
|
111
|
+
new_instance(): BulkSubscribers;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface BulkSubscribers {
|
|
115
|
+
append(...subscribers: Subscriber[]): void;
|
|
116
|
+
|
|
117
|
+
trigger(): Promise<SBulkResponse>;
|
|
118
|
+
|
|
119
|
+
save(): Promise<SBulkResponse>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// brands
|
|
123
|
+
interface BrandsApi {
|
|
124
|
+
list(options?: { limit?: number; offset?: number }): Promise<Dictionary>;
|
|
125
|
+
|
|
126
|
+
get(brand_id: any): Promise<Dictionary>;
|
|
127
|
+
|
|
128
|
+
upsert(brand_id: any, brand_payload?: Dictionary): Promise<Dictionary>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// lists
|
|
132
|
+
interface SubscriberListBroadcast {
|
|
133
|
+
new (
|
|
134
|
+
body: Dictionary,
|
|
135
|
+
kwargs?: { idempotency_key?: string; brand_id?: string }
|
|
136
|
+
): SubscriberListBroadcast;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface SubscriberListsApi {
|
|
140
|
+
create(payload: Dictionary): Promise<Dictionary>;
|
|
141
|
+
|
|
142
|
+
get_all(options?: { limit?: number; offset?: number }): Promise<Dictionary>;
|
|
143
|
+
|
|
144
|
+
get(list_id: string): Promise<Dictionary>;
|
|
145
|
+
|
|
146
|
+
add(list_id: string, distinct_ids: string[]): Promise<Dictionary>;
|
|
147
|
+
|
|
148
|
+
remove(list_id: string, distinct_ids: string[]): Promise<Dictionary>;
|
|
149
|
+
|
|
150
|
+
broadcast(broadcast_instance: SubscriberListBroadcast): Promise<SResponse>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface Suprsend {
|
|
154
|
+
new (
|
|
155
|
+
workspace_env: string,
|
|
156
|
+
workspace_secret: string,
|
|
157
|
+
config: { is_staging: boolean }
|
|
158
|
+
): Suprsend;
|
|
159
|
+
|
|
160
|
+
get bulk_workflows(): BulkWorkflowsFactory;
|
|
161
|
+
|
|
162
|
+
get bulk_events(): BulkEventsFactory;
|
|
163
|
+
|
|
164
|
+
get user(): SubscriberFactory;
|
|
165
|
+
|
|
166
|
+
get bulk_users(): BulkSubscribersFactory;
|
|
167
|
+
|
|
168
|
+
brands: BrandsApi;
|
|
169
|
+
|
|
170
|
+
subscriber_lists: SubscriberListsApi;
|
|
171
|
+
|
|
172
|
+
add_attachment(
|
|
173
|
+
body: Dictionary,
|
|
174
|
+
file_path: string,
|
|
175
|
+
kwargs?: { file_name?: string; ignore_if_error?: boolean }
|
|
176
|
+
): Dictionary;
|
|
177
|
+
|
|
178
|
+
trigger_workflow(body: Workflow | Dictionary): Promise<SResponse>;
|
|
179
|
+
|
|
180
|
+
track(
|
|
181
|
+
distinct_id: any,
|
|
182
|
+
event_name: string,
|
|
183
|
+
properties?: Dictionary,
|
|
184
|
+
kwargs?: { idempotency_key?: string; brand_id?: string }
|
|
185
|
+
): Promise<SResponse>;
|
|
186
|
+
|
|
187
|
+
track_event(event: Event): Promise<SResponse>;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export const Suprsend: suprsend.Suprsend;
|
|
192
|
+
export const Event: suprsend.Event;
|
|
193
|
+
export const Workflow: suprsend.Workflow;
|
|
194
|
+
export const SubscriberListBroadcast: suprsend.SubscriberListBroadcast;
|