@suprsend/node-sdk 0.1.1 → 1.1.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/attachment.js +59 -0
- package/dist/bulk_response.js +60 -0
- package/dist/constants.js +46 -0
- package/dist/event.js +159 -84
- package/dist/events_bulk.js +424 -0
- package/dist/index.js +95 -39
- package/dist/request_json/event.json +5 -0
- package/dist/request_json/workflow.json +116 -9
- package/dist/{identity.js → subscriber.js} +193 -48
- package/dist/{identity_helper.js → subscriber_helper.js} +191 -59
- package/dist/subscribers_bulk.js +447 -0
- package/dist/utils.js +210 -1
- package/dist/workflow.js +130 -59
- package/dist/workflows_bulk.js +424 -0
- package/package.json +2 -1
- package/src/attachment.js +44 -0
- package/src/bulk_response.js +35 -0
- package/src/constants.js +32 -0
- package/src/event.js +124 -75
- package/src/events_bulk.js +236 -0
- package/src/index.js +69 -34
- package/src/request_json/event.json +5 -0
- package/src/request_json/workflow.json +116 -9
- package/src/{identity.js → subscriber.js} +118 -34
- package/src/{identity_helper.js → subscriber_helper.js} +196 -53
- package/src/subscribers_bulk.js +237 -0
- package/src/utils.js +136 -0
- package/src/workflow.js +100 -45
- package/src/workflows_bulk.js +236 -0
- package/dist/config.js +0 -13
- package/src/config.js +0 -6
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
"$comment": "Json schema for workflow request",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
+
"$idempotency_key": {
|
|
10
|
+
"type": ["string", "null"],
|
|
11
|
+
"maxLength": 64,
|
|
12
|
+
"description": "unique id provided by client for request"
|
|
13
|
+
},
|
|
9
14
|
"name": {
|
|
10
15
|
"$ref": "#/definitions/non_empty_string",
|
|
11
16
|
"description": "name of workflow"
|
|
@@ -71,6 +76,58 @@
|
|
|
71
76
|
"pattern": "value in email format required. e.g. user@example.com"
|
|
72
77
|
}
|
|
73
78
|
},
|
|
79
|
+
"slack_setting": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"properties": {
|
|
82
|
+
"user_id": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"pattern": "^[uUwW][a-zA-Z0-9]+$",
|
|
85
|
+
"description": "slack member id of user",
|
|
86
|
+
"message": {
|
|
87
|
+
"required": "",
|
|
88
|
+
"pattern": "Slack Member id format: [U|W]XXXXXXXXX"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"email": { "$ref": "#/definitions/email_pattern" }
|
|
92
|
+
},
|
|
93
|
+
"additionalProperties": false
|
|
94
|
+
},
|
|
95
|
+
"androidpush_settings": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"properties": {
|
|
98
|
+
"token": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"minLength": 1,
|
|
101
|
+
"description": "androidpush token"
|
|
102
|
+
},
|
|
103
|
+
"provider": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"enum": ["fcm", "xiaomi", "oppo"],
|
|
106
|
+
"description": "androidpush token provider(fcm/xiaomi)"
|
|
107
|
+
},
|
|
108
|
+
"device_id": { "type": ["string", "null"] }
|
|
109
|
+
},
|
|
110
|
+
"required": ["token", "provider"],
|
|
111
|
+
"additionalProperties": false
|
|
112
|
+
},
|
|
113
|
+
"iospush_settings": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"properties": {
|
|
116
|
+
"token": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"minLength": 1,
|
|
119
|
+
"description": "iospush token"
|
|
120
|
+
},
|
|
121
|
+
"provider": {
|
|
122
|
+
"type": "string",
|
|
123
|
+
"enum": ["apns"],
|
|
124
|
+
"description": "iospush token provider(apns)"
|
|
125
|
+
},
|
|
126
|
+
"device_id": { "type": ["string", "null"] }
|
|
127
|
+
},
|
|
128
|
+
"required": ["token", "provider"],
|
|
129
|
+
"additionalProperties": false
|
|
130
|
+
},
|
|
74
131
|
"user_setting": {
|
|
75
132
|
"type": "object",
|
|
76
133
|
"properties": {
|
|
@@ -79,12 +136,31 @@
|
|
|
79
136
|
"minLength": 1,
|
|
80
137
|
"description": "distinct_id: Id which uniquely identify a user in your app"
|
|
81
138
|
},
|
|
139
|
+
"$channels": {
|
|
140
|
+
"type": "array",
|
|
141
|
+
"items": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"enum": [
|
|
144
|
+
"androidpush",
|
|
145
|
+
"iospush",
|
|
146
|
+
"webpush",
|
|
147
|
+
"email",
|
|
148
|
+
"sms",
|
|
149
|
+
"whatsapp",
|
|
150
|
+
"slack",
|
|
151
|
+
"inbox",
|
|
152
|
+
"messenger"
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
"minItems": 0,
|
|
156
|
+
"description": "user preferred channels. notification will be tried only on specified channels e.g ['email', 'sms']"
|
|
157
|
+
},
|
|
82
158
|
"$email": {
|
|
83
159
|
"oneOf": [
|
|
84
160
|
{ "$ref": "#/definitions/email_pattern" },
|
|
85
161
|
{
|
|
86
162
|
"type": "array",
|
|
87
|
-
"uniqueItems":
|
|
163
|
+
"uniqueItems": false,
|
|
88
164
|
"maxItems": 10,
|
|
89
165
|
"minItems": 1,
|
|
90
166
|
"items": { "$ref": "#/definitions/email_pattern" }
|
|
@@ -96,7 +172,7 @@
|
|
|
96
172
|
{ "$ref": "#/definitions/mobile_number_pattern" },
|
|
97
173
|
{
|
|
98
174
|
"type": "array",
|
|
99
|
-
"uniqueItems":
|
|
175
|
+
"uniqueItems": false,
|
|
100
176
|
"maxItems": 10,
|
|
101
177
|
"minItems": 1,
|
|
102
178
|
"items": { "$ref": "#/definitions/mobile_number_pattern" }
|
|
@@ -105,10 +181,18 @@
|
|
|
105
181
|
},
|
|
106
182
|
"$androidpush": {
|
|
107
183
|
"oneOf": [
|
|
184
|
+
{ "$ref": "#/definitions/androidpush_settings" },
|
|
185
|
+
{
|
|
186
|
+
"type": "array",
|
|
187
|
+
"uniqueItems": false,
|
|
188
|
+
"maxItems": 10,
|
|
189
|
+
"minItems": 1,
|
|
190
|
+
"items": { "$ref": "#/definitions/androidpush_settings" }
|
|
191
|
+
},
|
|
108
192
|
{ "$ref": "#/definitions/non_empty_string" },
|
|
109
193
|
{
|
|
110
194
|
"type": "array",
|
|
111
|
-
"uniqueItems":
|
|
195
|
+
"uniqueItems": false,
|
|
112
196
|
"maxItems": 10,
|
|
113
197
|
"minItems": 1,
|
|
114
198
|
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
@@ -117,10 +201,18 @@
|
|
|
117
201
|
},
|
|
118
202
|
"$iospush": {
|
|
119
203
|
"oneOf": [
|
|
204
|
+
{ "$ref": "#/definitions/iospush_settings" },
|
|
205
|
+
{
|
|
206
|
+
"type": "array",
|
|
207
|
+
"uniqueItems": false,
|
|
208
|
+
"maxItems": 10,
|
|
209
|
+
"minItems": 1,
|
|
210
|
+
"items": { "$ref": "#/definitions/iospush_settings" }
|
|
211
|
+
},
|
|
120
212
|
{ "$ref": "#/definitions/non_empty_string" },
|
|
121
213
|
{
|
|
122
214
|
"type": "array",
|
|
123
|
-
"uniqueItems":
|
|
215
|
+
"uniqueItems": false,
|
|
124
216
|
"maxItems": 10,
|
|
125
217
|
"minItems": 1,
|
|
126
218
|
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
@@ -132,7 +224,7 @@
|
|
|
132
224
|
{ "$ref": "#/definitions/mobile_number_pattern" },
|
|
133
225
|
{
|
|
134
226
|
"type": "array",
|
|
135
|
-
"uniqueItems":
|
|
227
|
+
"uniqueItems": false,
|
|
136
228
|
"maxItems": 10,
|
|
137
229
|
"minItems": 1,
|
|
138
230
|
"items": { "$ref": "#/definitions/mobile_number_pattern" }
|
|
@@ -144,19 +236,31 @@
|
|
|
144
236
|
{ "type": "object", "minProperties": 1 },
|
|
145
237
|
{
|
|
146
238
|
"type": "array",
|
|
147
|
-
"uniqueItems":
|
|
239
|
+
"uniqueItems": false,
|
|
148
240
|
"maxItems": 10,
|
|
149
241
|
"minItems": 1,
|
|
150
242
|
"items": { "type": "object", "minProperties": 1 }
|
|
151
243
|
}
|
|
152
244
|
]
|
|
153
245
|
},
|
|
246
|
+
"$slack": {
|
|
247
|
+
"oneOf": [
|
|
248
|
+
{ "$ref": "#/definitions/slack_setting" },
|
|
249
|
+
{
|
|
250
|
+
"type": "array",
|
|
251
|
+
"uniqueItems": false,
|
|
252
|
+
"maxItems": 10,
|
|
253
|
+
"minItems": 1,
|
|
254
|
+
"items": { "$ref": "#/definitions/slack_setting" }
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
},
|
|
154
258
|
"$inbox": {
|
|
155
259
|
"oneOf": [
|
|
156
260
|
{ "$ref": "#/definitions/non_empty_string" },
|
|
157
261
|
{
|
|
158
262
|
"type": "array",
|
|
159
|
-
"uniqueItems":
|
|
263
|
+
"uniqueItems": false,
|
|
160
264
|
"maxItems": 10,
|
|
161
265
|
"minItems": 1,
|
|
162
266
|
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
@@ -168,7 +272,7 @@
|
|
|
168
272
|
{ "$ref": "#/definitions/non_empty_string" },
|
|
169
273
|
{
|
|
170
274
|
"type": "array",
|
|
171
|
-
"uniqueItems":
|
|
275
|
+
"uniqueItems": false,
|
|
172
276
|
"maxItems": 10,
|
|
173
277
|
"minItems": 1,
|
|
174
278
|
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
@@ -207,7 +311,10 @@
|
|
|
207
311
|
"webpush",
|
|
208
312
|
"email",
|
|
209
313
|
"sms",
|
|
210
|
-
"whatsapp"
|
|
314
|
+
"whatsapp",
|
|
315
|
+
"slack",
|
|
316
|
+
"inbox",
|
|
317
|
+
"messenger"
|
|
211
318
|
]
|
|
212
319
|
},
|
|
213
320
|
"minItems": 0,
|
|
@@ -5,16 +5,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] = void 0;
|
|
8
|
+
exports["default"] = exports.Subscriber = void 0;
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
|
|
14
14
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
15
|
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
17
|
|
|
18
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
|
+
|
|
18
20
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
21
|
|
|
20
22
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -25,7 +27,9 @@ var _signature = _interopRequireDefault(require("./signature"));
|
|
|
25
27
|
|
|
26
28
|
var _axios = _interopRequireDefault(require("axios"));
|
|
27
29
|
|
|
28
|
-
var
|
|
30
|
+
var _subscriber_helper = _interopRequireDefault(require("./subscriber_helper"));
|
|
31
|
+
|
|
32
|
+
var _constants = require("./constants");
|
|
29
33
|
|
|
30
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
35
|
|
|
@@ -37,15 +41,20 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
37
41
|
|
|
38
42
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
39
43
|
|
|
40
|
-
var
|
|
41
|
-
function
|
|
42
|
-
(0, _classCallCheck2["default"])(this,
|
|
44
|
+
var SubscriberFactory = /*#__PURE__*/function () {
|
|
45
|
+
function SubscriberFactory(config) {
|
|
46
|
+
(0, _classCallCheck2["default"])(this, SubscriberFactory);
|
|
43
47
|
this.config = config;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
(0, _createClass2["default"])(
|
|
50
|
+
(0, _createClass2["default"])(SubscriberFactory, [{
|
|
47
51
|
key: "new_user",
|
|
48
52
|
value: function new_user(distinct_id) {
|
|
53
|
+
return this.get_instance(distinct_id);
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "get_instance",
|
|
57
|
+
value: function get_instance(distinct_id) {
|
|
49
58
|
if (!(0, _utils.is_string)(distinct_id)) {
|
|
50
59
|
throw new _utils.SuprsendError("distinct_id must be a string. an Id which uniquely identify a user in your app");
|
|
51
60
|
}
|
|
@@ -56,17 +65,17 @@ var UserIdentityFactory = /*#__PURE__*/function () {
|
|
|
56
65
|
throw new _utils.SuprsendError("distinct_id must be passed");
|
|
57
66
|
}
|
|
58
67
|
|
|
59
|
-
return new
|
|
68
|
+
return new Subscriber(this.config, distinct_id);
|
|
60
69
|
}
|
|
61
70
|
}]);
|
|
62
|
-
return
|
|
71
|
+
return SubscriberFactory;
|
|
63
72
|
}();
|
|
64
73
|
|
|
65
|
-
exports["default"] =
|
|
74
|
+
exports["default"] = SubscriberFactory;
|
|
66
75
|
|
|
67
|
-
var
|
|
68
|
-
function
|
|
69
|
-
(0, _classCallCheck2["default"])(this,
|
|
76
|
+
var Subscriber = /*#__PURE__*/function () {
|
|
77
|
+
function Subscriber(config, distinct_id) {
|
|
78
|
+
(0, _classCallCheck2["default"])(this, Subscriber);
|
|
70
79
|
this.config = config;
|
|
71
80
|
this.distinct_id = distinct_id;
|
|
72
81
|
this.__url = this.__get_url();
|
|
@@ -75,11 +84,12 @@ var UserIdentity = /*#__PURE__*/function () {
|
|
|
75
84
|
this.__info = [];
|
|
76
85
|
this._append_count = 0;
|
|
77
86
|
this._remove_count = 0;
|
|
87
|
+
this._unset_count = 0;
|
|
78
88
|
this._events = [];
|
|
79
|
-
this._helper = new
|
|
89
|
+
this._helper = new _subscriber_helper["default"](distinct_id, config.workspace_key);
|
|
80
90
|
}
|
|
81
91
|
|
|
82
|
-
(0, _createClass2["default"])(
|
|
92
|
+
(0, _createClass2["default"])(Subscriber, [{
|
|
83
93
|
key: "__get_url",
|
|
84
94
|
value: function __get_url() {
|
|
85
95
|
var url_template = "event/";
|
|
@@ -111,9 +121,9 @@ var UserIdentity = /*#__PURE__*/function () {
|
|
|
111
121
|
};
|
|
112
122
|
}
|
|
113
123
|
}, {
|
|
114
|
-
key: "
|
|
115
|
-
value: function
|
|
116
|
-
var all_events = this._events;
|
|
124
|
+
key: "events",
|
|
125
|
+
value: function events() {
|
|
126
|
+
var all_events = (0, _toConsumableArray2["default"])(this._events);
|
|
117
127
|
|
|
118
128
|
var _iterator = _createForOfIteratorHelper(all_events),
|
|
119
129
|
_step;
|
|
@@ -129,86 +139,143 @@ var UserIdentity = /*#__PURE__*/function () {
|
|
|
129
139
|
_iterator.f();
|
|
130
140
|
}
|
|
131
141
|
|
|
132
|
-
if (this._append_count > 0) {
|
|
142
|
+
if (all_events.length === 0 || this._append_count > 0) {
|
|
133
143
|
var user_identify_event = {
|
|
134
144
|
$insert_id: (0, _utils.uuid)(),
|
|
135
145
|
$time: (0, _utils.epoch_milliseconds)(),
|
|
136
|
-
env: this.config.
|
|
146
|
+
env: this.config.workspace_key,
|
|
137
147
|
event: "$identify",
|
|
138
148
|
properties: _objectSpread({
|
|
139
|
-
$anon_id: this.distinct_id,
|
|
140
149
|
$identified_id: this.distinct_id
|
|
141
|
-
}, this.
|
|
150
|
+
}, this.__supr_props)
|
|
142
151
|
};
|
|
143
|
-
all_events.
|
|
152
|
+
all_events = [user_identify_event].concat((0, _toConsumableArray2["default"])(all_events));
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
return all_events;
|
|
147
156
|
}
|
|
148
157
|
}, {
|
|
149
|
-
key: "
|
|
150
|
-
value: function
|
|
158
|
+
key: "validate_event_size",
|
|
159
|
+
value: function validate_event_size(event_dict) {
|
|
160
|
+
var apparent_size = (0, _utils.get_apparent_identity_event_size)(event_dict);
|
|
161
|
+
|
|
162
|
+
if (apparent_size > _constants.IDENTITY_SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES) {
|
|
163
|
+
throw new _utils.SuprsendError("User Event size too big - ".concat(apparent_size, " Bytes, must not cross ").concat(_constants.IDENTITY_SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES_READABLE));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return [event_dict, apparent_size];
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "validate_body",
|
|
170
|
+
value: function validate_body() {
|
|
171
|
+
var is_part_of_bulk = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
172
|
+
var warnings_list = [];
|
|
173
|
+
|
|
151
174
|
if (!(0, _utils.is_empty)(this.__info)) {
|
|
152
|
-
|
|
175
|
+
var msg = "[distinct_id: ".concat(this.distinct_id, "]").concat(this.__info.join("\n"));
|
|
176
|
+
warnings_list.push(msg);
|
|
177
|
+
console.log("WARNING: ".concat(msg));
|
|
153
178
|
}
|
|
154
179
|
|
|
155
180
|
if (!(0, _utils.is_empty)(this.__errors)) {
|
|
156
|
-
|
|
157
|
-
|
|
181
|
+
var _msg = "[distinct_id: ".concat(this.distinct_id, "] ").concat(this.__errors.join("\n"));
|
|
182
|
+
|
|
183
|
+
warnings_list.push(_msg);
|
|
184
|
+
var err_msg = "ERROR: ".concat(_msg);
|
|
158
185
|
|
|
159
|
-
|
|
160
|
-
|
|
186
|
+
if (is_part_of_bulk) {
|
|
187
|
+
console.log(err_msg);
|
|
188
|
+
} else {
|
|
189
|
+
throw new _utils.SuprsendError(err_msg);
|
|
190
|
+
}
|
|
161
191
|
}
|
|
192
|
+
|
|
193
|
+
return warnings_list;
|
|
162
194
|
}
|
|
163
195
|
}, {
|
|
164
196
|
key: "save",
|
|
165
197
|
value: function () {
|
|
166
198
|
var _save = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
167
|
-
var headers, events, content_text, signature, response;
|
|
199
|
+
var is_part_of_bulk, headers, events, _iterator2, _step2, ev, _this$validate_event_, _this$validate_event_2, validated_ev, size, content_text, signature, response, ok_response;
|
|
200
|
+
|
|
168
201
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
169
202
|
while (1) {
|
|
170
203
|
switch (_context.prev = _context.next) {
|
|
171
204
|
case 0:
|
|
172
|
-
|
|
173
|
-
|
|
205
|
+
is_part_of_bulk = false;
|
|
206
|
+
this.validate_body(is_part_of_bulk);
|
|
174
207
|
headers = this.__get_headers();
|
|
175
|
-
events = this.
|
|
208
|
+
events = this.events();
|
|
209
|
+
_iterator2 = _createForOfIteratorHelper(events);
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
213
|
+
ev = _step2.value;
|
|
214
|
+
_this$validate_event_ = this.validate_event_size(ev), _this$validate_event_2 = (0, _slicedToArray2["default"])(_this$validate_event_, 2), validated_ev = _this$validate_event_2[0], size = _this$validate_event_2[1];
|
|
215
|
+
}
|
|
216
|
+
} catch (err) {
|
|
217
|
+
_iterator2.e(err);
|
|
218
|
+
} finally {
|
|
219
|
+
_iterator2.f();
|
|
220
|
+
}
|
|
221
|
+
|
|
176
222
|
content_text = JSON.stringify(events);
|
|
177
223
|
|
|
178
224
|
if (this.config.auth_enabled) {
|
|
179
|
-
signature = (0, _signature["default"])(this.__url, "POST", content_text, headers, this.config.
|
|
180
|
-
headers["Authorization"] = "".concat(this.config.
|
|
225
|
+
signature = (0, _signature["default"])(this.__url, "POST", content_text, headers, this.config.workspace_secret);
|
|
226
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
181
227
|
}
|
|
182
228
|
|
|
183
|
-
_context.prev =
|
|
184
|
-
_context.next =
|
|
229
|
+
_context.prev = 8;
|
|
230
|
+
_context.next = 11;
|
|
185
231
|
return _axios["default"].post(this.__url, content_text, {
|
|
186
232
|
headers: headers
|
|
187
233
|
});
|
|
188
234
|
|
|
189
|
-
case
|
|
235
|
+
case 11:
|
|
190
236
|
response = _context.sent;
|
|
237
|
+
ok_response = Math.floor(response.status / 100) == 2;
|
|
238
|
+
|
|
239
|
+
if (!ok_response) {
|
|
240
|
+
_context.next = 17;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
|
|
191
244
|
return _context.abrupt("return", {
|
|
192
|
-
status_code: response.status,
|
|
193
245
|
success: true,
|
|
246
|
+
status: "success",
|
|
247
|
+
status_code: response.status,
|
|
248
|
+
message: response.statusText
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
case 17:
|
|
252
|
+
return _context.abrupt("return", {
|
|
253
|
+
success: false,
|
|
254
|
+
status: "fail",
|
|
255
|
+
status_code: response.status,
|
|
194
256
|
message: response.statusText
|
|
195
257
|
});
|
|
196
258
|
|
|
197
|
-
case
|
|
198
|
-
_context.
|
|
199
|
-
|
|
259
|
+
case 18:
|
|
260
|
+
_context.next = 23;
|
|
261
|
+
break;
|
|
262
|
+
|
|
263
|
+
case 20:
|
|
264
|
+
_context.prev = 20;
|
|
265
|
+
_context.t0 = _context["catch"](8);
|
|
200
266
|
return _context.abrupt("return", {
|
|
201
|
-
status_code: 400,
|
|
202
267
|
success: false,
|
|
268
|
+
status: "fail",
|
|
269
|
+
status_code: _context.t0.status || 500,
|
|
203
270
|
message: _context.t0.message
|
|
204
271
|
});
|
|
205
272
|
|
|
206
|
-
case
|
|
273
|
+
case 23:
|
|
207
274
|
case "end":
|
|
208
275
|
return _context.stop();
|
|
209
276
|
}
|
|
210
277
|
}
|
|
211
|
-
}, _callee, this, [[
|
|
278
|
+
}, _callee, this, [[8, 20]]);
|
|
212
279
|
}));
|
|
213
280
|
|
|
214
281
|
function save() {
|
|
@@ -297,6 +364,40 @@ var UserIdentity = /*#__PURE__*/function () {
|
|
|
297
364
|
}
|
|
298
365
|
}
|
|
299
366
|
}, {
|
|
367
|
+
key: "unset",
|
|
368
|
+
value: function unset(key) {
|
|
369
|
+
var caller = "unset";
|
|
370
|
+
|
|
371
|
+
if (!(0, _utils.is_string)(key) && !Array.isArray(key)) {
|
|
372
|
+
this.__errors.push("[".concat(caller, "] key must be either string or array"));
|
|
373
|
+
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if ((0, _utils.is_string)(key)) {
|
|
378
|
+
this._helper._unset_k(key, caller);
|
|
379
|
+
|
|
380
|
+
this._collect_event();
|
|
381
|
+
} else {
|
|
382
|
+
var _iterator3 = _createForOfIteratorHelper(key),
|
|
383
|
+
_step3;
|
|
384
|
+
|
|
385
|
+
try {
|
|
386
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
387
|
+
var item = _step3.value;
|
|
388
|
+
|
|
389
|
+
this._helper._unset_k(item, caller);
|
|
390
|
+
}
|
|
391
|
+
} catch (err) {
|
|
392
|
+
_iterator3.e(err);
|
|
393
|
+
} finally {
|
|
394
|
+
_iterator3.f();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
this._collect_event();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}, {
|
|
300
401
|
key: "add_email",
|
|
301
402
|
value: function add_email(email) {
|
|
302
403
|
var caller = "add_email";
|
|
@@ -408,10 +509,54 @@ var UserIdentity = /*#__PURE__*/function () {
|
|
|
408
509
|
|
|
409
510
|
this._helper._remove_webpush(push_token, provider, caller);
|
|
410
511
|
|
|
512
|
+
this._collect_event();
|
|
513
|
+
}
|
|
514
|
+
}, {
|
|
515
|
+
key: "add_slack_email",
|
|
516
|
+
value: function add_slack_email(value) {
|
|
517
|
+
var caller = "add_slack_email";
|
|
518
|
+
|
|
519
|
+
this._helper._add_slack({
|
|
520
|
+
email: value
|
|
521
|
+
}, caller);
|
|
522
|
+
|
|
523
|
+
this._collect_event();
|
|
524
|
+
}
|
|
525
|
+
}, {
|
|
526
|
+
key: "remove_slack_email",
|
|
527
|
+
value: function remove_slack_email(value) {
|
|
528
|
+
var caller = "remove_slack_email";
|
|
529
|
+
|
|
530
|
+
this._helper._remove_slack({
|
|
531
|
+
email: value
|
|
532
|
+
}, caller);
|
|
533
|
+
|
|
534
|
+
this._collect_event();
|
|
535
|
+
}
|
|
536
|
+
}, {
|
|
537
|
+
key: "add_slack_userid",
|
|
538
|
+
value: function add_slack_userid(value) {
|
|
539
|
+
var caller = "add_slack_userid";
|
|
540
|
+
|
|
541
|
+
this._helper._add_slack({
|
|
542
|
+
user_id: value
|
|
543
|
+
}, caller);
|
|
544
|
+
|
|
545
|
+
this._collect_event();
|
|
546
|
+
}
|
|
547
|
+
}, {
|
|
548
|
+
key: "remove_slack_userid",
|
|
549
|
+
value: function remove_slack_userid(value) {
|
|
550
|
+
var caller = "remove_slack_userid";
|
|
551
|
+
|
|
552
|
+
this._helper._remove_slack({
|
|
553
|
+
user_id: value
|
|
554
|
+
}, caller);
|
|
555
|
+
|
|
411
556
|
this._collect_event();
|
|
412
557
|
}
|
|
413
558
|
}]);
|
|
414
|
-
return
|
|
559
|
+
return Subscriber;
|
|
415
560
|
}();
|
|
416
561
|
|
|
417
|
-
|
|
562
|
+
exports.Subscriber = Subscriber;
|