@suprsend/node-sdk 1.12.0 → 1.13.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/constants.js +2 -8
- package/dist/event.js +2 -2
- package/dist/events_bulk.js +2 -2
- package/dist/index.js +21 -0
- package/dist/object_edit.js +6 -12
- package/dist/object_edit_internal_helper.js +40 -301
- package/dist/objects_api.js +193 -242
- package/dist/request_json/workflow.json +7 -29
- package/dist/request_json/workflow_trigger.json +7 -29
- package/dist/subscriber.js +10 -27
- package/dist/subscriber_helper.js +33 -291
- package/dist/subscriber_list.js +2 -2
- package/dist/user_edit.js +412 -0
- package/dist/user_edit_internal_helper.js +363 -0
- package/dist/users_api.js +400 -98
- package/dist/users_edit_bulk.js +312 -0
- package/dist/workflow.js +2 -2
- package/dist/workflow_request.js +2 -2
- package/dist/workflow_trigger_bulk.js +2 -2
- package/dist/workflows_bulk.js +2 -2
- package/package.json +1 -1
- package/src/constants.js +0 -4
- package/src/event.js +4 -5
- package/src/events_bulk.js +3 -5
- package/src/index.js +6 -0
- package/src/object_edit.js +6 -6
- package/src/object_edit_internal_helper.js +37 -295
- package/src/objects_api.js +97 -93
- package/src/request_json/workflow.json +7 -29
- package/src/request_json/workflow_trigger.json +7 -29
- package/src/subscriber.js +8 -20
- package/src/subscriber_helper.js +34 -284
- package/src/subscriber_list.js +4 -4
- package/src/user_edit.js +360 -0
- package/src/user_edit_internal_helper.js +297 -0
- package/src/users_api.js +207 -27
- package/src/users_edit_bulk.js +211 -0
- package/src/workflow.js +4 -5
- package/src/workflow_request.js +4 -4
- package/src/workflow_trigger_bulk.js +2 -4
- package/src/workflows_bulk.js +3 -5
- package/types/index.d.ts +113 -8
- package/dist/language_codes.js +0 -197
- package/src/language_codes.js +0 -188
package/src/objects_api.js
CHANGED
|
@@ -7,52 +7,50 @@ export default class ObjectsApi {
|
|
|
7
7
|
constructor(config) {
|
|
8
8
|
this.config = config;
|
|
9
9
|
this.list_url = `${this.config.base_url}v1/object/`;
|
|
10
|
+
this.bulk_url = `${this.config.base_url}v1/bulk/object/`;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
__get_headers() {
|
|
13
14
|
return {
|
|
14
15
|
"Content-Type": "application/json; charset=utf-8",
|
|
15
16
|
"User-Agent": this.config.user_agent,
|
|
16
|
-
Date: new Date().toISOString(),
|
|
17
|
+
Date: new Date().toISOString(),
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
if (!is_string(object_type)) {
|
|
22
|
-
throw new InputValueError("object_type must be a string");
|
|
23
|
-
}
|
|
24
|
-
object_type = object_type.trim();
|
|
25
|
-
if (!object_type) {
|
|
21
|
+
_validate_object_type(object_type) {
|
|
22
|
+
if (!object_type || !is_string(object_type) || !object_type.trim()) {
|
|
26
23
|
throw new InputValueError("missing object_type");
|
|
27
24
|
}
|
|
28
|
-
return object_type;
|
|
25
|
+
return object_type.trim();
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
if (!is_string(object_id)) {
|
|
33
|
-
throw new InputValueError("object_id must be a string");
|
|
34
|
-
}
|
|
35
|
-
object_id = object_id.trim();
|
|
36
|
-
if (!object_id) {
|
|
28
|
+
_validate_object_id(object_id) {
|
|
29
|
+
if (!object_id || !is_string(object_id) || !object_id.trim()) {
|
|
37
30
|
throw new InputValueError("missing object_id");
|
|
38
31
|
}
|
|
39
|
-
return object_id;
|
|
32
|
+
return object_id.trim();
|
|
40
33
|
}
|
|
41
34
|
|
|
42
|
-
async list(object_type, options
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
async list(object_type, options) {
|
|
36
|
+
object_type = this._validate_object_type(object_type);
|
|
37
|
+
const object_type_encoded = encodeURIComponent(object_type);
|
|
38
|
+
const encoded_options = options
|
|
39
|
+
? new URLSearchParams(options).toString()
|
|
40
|
+
: "";
|
|
41
|
+
|
|
42
|
+
const url = `${this.list_url}${object_type_encoded}/${
|
|
43
|
+
encoded_options ? `?${encoded_options}` : ""
|
|
44
|
+
}`;
|
|
45
|
+
const headers = this.__get_headers();
|
|
46
|
+
const sig = get_request_signature(
|
|
49
47
|
url,
|
|
50
48
|
"GET",
|
|
51
49
|
"",
|
|
52
50
|
headers,
|
|
53
51
|
this.config.workspace_secret
|
|
54
52
|
);
|
|
55
|
-
headers["Authorization"] = `${this.config.workspace_key}:${
|
|
53
|
+
headers["Authorization"] = `${this.config.workspace_key}:${sig}`;
|
|
56
54
|
|
|
57
55
|
try {
|
|
58
56
|
const response = await axios.get(url, { headers });
|
|
@@ -63,18 +61,18 @@ export default class ObjectsApi {
|
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
detail_url(object_type, object_id) {
|
|
66
|
-
|
|
67
|
-
const
|
|
64
|
+
object_type = this._validate_object_type(object_type);
|
|
65
|
+
const object_type_encoded = encodeURIComponent(object_type);
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
const
|
|
67
|
+
object_id = this._validate_object_id(object_id);
|
|
68
|
+
const object_id_encoded = encodeURIComponent(object_id);
|
|
71
69
|
|
|
72
|
-
return `${this.list_url}${
|
|
70
|
+
return `${this.list_url}${object_type_encoded}/${object_id_encoded}/`;
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
async get(object_type, object_id) {
|
|
76
74
|
const url = this.detail_url(object_type, object_id);
|
|
77
|
-
const headers = this.
|
|
75
|
+
const headers = this.__get_headers();
|
|
78
76
|
const signature = get_request_signature(
|
|
79
77
|
url,
|
|
80
78
|
"GET",
|
|
@@ -92,10 +90,11 @@ export default class ObjectsApi {
|
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
async upsert(object_type, object_id,
|
|
93
|
+
async upsert(object_type, object_id, payload = {}) {
|
|
96
94
|
const url = this.detail_url(object_type, object_id);
|
|
97
|
-
|
|
98
|
-
const
|
|
95
|
+
payload = payload || {};
|
|
96
|
+
const headers = this.__get_headers();
|
|
97
|
+
const content_text = JSON.stringify(payload || {});
|
|
99
98
|
const signature = get_request_signature(
|
|
100
99
|
url,
|
|
101
100
|
"POST",
|
|
@@ -113,24 +112,22 @@ export default class ObjectsApi {
|
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
async edit(
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
edit_instance.get_object_id()
|
|
125
|
-
);
|
|
126
|
-
payload = edit_instance.get_payload();
|
|
115
|
+
async edit(edit_ins_or_object_type, object_id, edit_payload) {
|
|
116
|
+
let payload, url;
|
|
117
|
+
|
|
118
|
+
if (edit_ins_or_object_type instanceof ObjectEdit) {
|
|
119
|
+
const edit_ins = edit_ins_or_object_type;
|
|
120
|
+
edit_ins.validate_body();
|
|
121
|
+
payload = edit_ins.get_payload();
|
|
122
|
+
url = this.detail_url(edit_ins.object_type, edit_ins.object_id);
|
|
127
123
|
} else {
|
|
124
|
+
const object_type = edit_ins_or_object_type;
|
|
125
|
+
payload = edit_payload || {};
|
|
128
126
|
url = this.detail_url(object_type, object_id);
|
|
129
|
-
payload = edit_payload;
|
|
130
127
|
}
|
|
131
128
|
|
|
132
129
|
const content_text = JSON.stringify(payload || {});
|
|
133
|
-
const headers = this.
|
|
130
|
+
const headers = this.__get_headers();
|
|
134
131
|
const signature = get_request_signature(
|
|
135
132
|
url,
|
|
136
133
|
"PATCH",
|
|
@@ -150,7 +147,7 @@ export default class ObjectsApi {
|
|
|
150
147
|
|
|
151
148
|
async delete(object_type, object_id) {
|
|
152
149
|
const url = this.detail_url(object_type, object_id);
|
|
153
|
-
const headers = this.
|
|
150
|
+
const headers = this.__get_headers();
|
|
154
151
|
const signature = get_request_signature(
|
|
155
152
|
url,
|
|
156
153
|
"DELETE",
|
|
@@ -172,17 +169,12 @@ export default class ObjectsApi {
|
|
|
172
169
|
}
|
|
173
170
|
}
|
|
174
171
|
|
|
175
|
-
async bulk_ops_url(object_type) {
|
|
176
|
-
const validatedType = this.validate_object_type(object_type);
|
|
177
|
-
const encodedType = encodeURIComponent(validatedType);
|
|
178
|
-
|
|
179
|
-
return `${this.config.base_url}v1/bulk/object/${encodedType}/`;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
172
|
async bulk_delete(object_type, payload) {
|
|
183
|
-
|
|
184
|
-
const
|
|
173
|
+
object_type = this._validate_object_type(object_type);
|
|
174
|
+
const object_type_encoded = encodeURIComponent(object_type);
|
|
175
|
+
const url = `${this.bulk_url}${object_type_encoded}/`;
|
|
185
176
|
payload = payload || {};
|
|
177
|
+
const headers = this.__get_headers();
|
|
186
178
|
const content_text = JSON.stringify(payload);
|
|
187
179
|
const signature = get_request_signature(
|
|
188
180
|
url,
|
|
@@ -196,7 +188,7 @@ export default class ObjectsApi {
|
|
|
196
188
|
try {
|
|
197
189
|
const response = await axios.delete(url, {
|
|
198
190
|
headers: headers,
|
|
199
|
-
data:
|
|
191
|
+
data: content_text,
|
|
200
192
|
});
|
|
201
193
|
if (response.status >= 200 && response.status < 300) {
|
|
202
194
|
return { success: true, status_code: response.status };
|
|
@@ -208,13 +200,17 @@ export default class ObjectsApi {
|
|
|
208
200
|
}
|
|
209
201
|
}
|
|
210
202
|
|
|
211
|
-
async get_subscriptions(object_type, object_id, options
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
203
|
+
async get_subscriptions(object_type, object_id, options) {
|
|
204
|
+
const encoded_options = options
|
|
205
|
+
? new URLSearchParams(options).toString()
|
|
206
|
+
: "";
|
|
207
|
+
const _detail_url = this.detail_url(object_type, object_id);
|
|
208
|
+
const url = `${_detail_url}subscription/${
|
|
209
|
+
encoded_options ? `?${encoded_options}` : ""
|
|
210
|
+
}`;
|
|
211
|
+
const headers = this.__get_headers();
|
|
216
212
|
const signature = get_request_signature(
|
|
217
|
-
|
|
213
|
+
url,
|
|
218
214
|
"GET",
|
|
219
215
|
"",
|
|
220
216
|
headers,
|
|
@@ -223,21 +219,22 @@ export default class ObjectsApi {
|
|
|
223
219
|
headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
|
|
224
220
|
|
|
225
221
|
try {
|
|
226
|
-
const response = await axios.get(
|
|
222
|
+
const response = await axios.get(url, { headers });
|
|
227
223
|
return response.data;
|
|
228
224
|
} catch (err) {
|
|
229
225
|
throw new SuprsendApiError(err);
|
|
230
226
|
}
|
|
231
227
|
}
|
|
232
228
|
|
|
233
|
-
async create_subscriptions(object_type, object_id,
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const
|
|
229
|
+
async create_subscriptions(object_type, object_id, payload) {
|
|
230
|
+
const _detail_url = this.detail_url(object_type, object_id);
|
|
231
|
+
const url = `${_detail_url}subscription/`;
|
|
232
|
+
payload = payload || {};
|
|
233
|
+
const content_text = JSON.stringify(payload);
|
|
234
|
+
const headers = this.__get_headers();
|
|
235
|
+
|
|
239
236
|
const signature = get_request_signature(
|
|
240
|
-
|
|
237
|
+
url,
|
|
241
238
|
"POST",
|
|
242
239
|
content_text,
|
|
243
240
|
headers,
|
|
@@ -246,23 +243,21 @@ export default class ObjectsApi {
|
|
|
246
243
|
headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
|
|
247
244
|
|
|
248
245
|
try {
|
|
249
|
-
const response = await axios.post(
|
|
250
|
-
headers,
|
|
251
|
-
});
|
|
246
|
+
const response = await axios.post(url, content_text, { headers });
|
|
252
247
|
return response.data;
|
|
253
248
|
} catch (err) {
|
|
254
249
|
throw new SuprsendApiError(err);
|
|
255
250
|
}
|
|
256
251
|
}
|
|
257
252
|
|
|
258
|
-
async delete_subscriptions(object_type, object_id,
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const
|
|
253
|
+
async delete_subscriptions(object_type, object_id, payload) {
|
|
254
|
+
const _detail_url = this.detail_url(object_type, object_id);
|
|
255
|
+
const url = `${_detail_url}subscription/`;
|
|
256
|
+
payload = payload || {};
|
|
257
|
+
const content_text = JSON.stringify(payload);
|
|
258
|
+
const headers = this.__get_headers();
|
|
264
259
|
const signature = get_request_signature(
|
|
265
|
-
|
|
260
|
+
url,
|
|
266
261
|
"DELETE",
|
|
267
262
|
content_text,
|
|
268
263
|
headers,
|
|
@@ -271,9 +266,9 @@ export default class ObjectsApi {
|
|
|
271
266
|
headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
|
|
272
267
|
|
|
273
268
|
try {
|
|
274
|
-
const response = await axios.delete(
|
|
269
|
+
const response = await axios.delete(url, {
|
|
275
270
|
headers: headers,
|
|
276
|
-
data:
|
|
271
|
+
data: content_text,
|
|
277
272
|
});
|
|
278
273
|
if (response.status >= 200 && response.status < 300) {
|
|
279
274
|
return { success: true, status_code: response.status };
|
|
@@ -285,13 +280,17 @@ export default class ObjectsApi {
|
|
|
285
280
|
}
|
|
286
281
|
}
|
|
287
282
|
|
|
288
|
-
async get_objects_subscribed_to(object_type, object_id, options =
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const
|
|
283
|
+
async get_objects_subscribed_to(object_type, object_id, options = null) {
|
|
284
|
+
const encoded_options = options
|
|
285
|
+
? new URLSearchParams(options).toString()
|
|
286
|
+
: "";
|
|
287
|
+
const _detail_url = this.detail_url(object_type, object_id);
|
|
288
|
+
const url = `${_detail_url}subscribed_to/object/${
|
|
289
|
+
encoded_options ? `?${encoded_options}` : ""
|
|
290
|
+
}`;
|
|
291
|
+
const headers = this.__get_headers();
|
|
293
292
|
const signature = get_request_signature(
|
|
294
|
-
|
|
293
|
+
url,
|
|
295
294
|
"GET",
|
|
296
295
|
"",
|
|
297
296
|
headers,
|
|
@@ -300,7 +299,7 @@ export default class ObjectsApi {
|
|
|
300
299
|
headers["Authorization"] = `${this.config.workspace_key}:${signature}`;
|
|
301
300
|
|
|
302
301
|
try {
|
|
303
|
-
const response = await axios.get(
|
|
302
|
+
const response = await axios.get(url, { headers });
|
|
304
303
|
return response.data;
|
|
305
304
|
} catch (err) {
|
|
306
305
|
throw new SuprsendApiError(err);
|
|
@@ -308,9 +307,14 @@ export default class ObjectsApi {
|
|
|
308
307
|
}
|
|
309
308
|
|
|
310
309
|
get_instance(object_type, object_id) {
|
|
311
|
-
|
|
312
|
-
|
|
310
|
+
object_type = this._validate_object_type(object_type);
|
|
311
|
+
object_id = this._validate_object_id(object_id);
|
|
312
|
+
return new ObjectEdit(this.config, object_type, object_id);
|
|
313
|
+
}
|
|
313
314
|
|
|
314
|
-
|
|
315
|
+
get_edit_instance(object_type, object_id) {
|
|
316
|
+
object_type = this._validate_object_type(object_type);
|
|
317
|
+
object_id = this._validate_object_id(object_id);
|
|
318
|
+
return new ObjectEdit(this.config, object_type, object_id);
|
|
315
319
|
}
|
|
316
320
|
}
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"type": "array",
|
|
52
52
|
"items": { "$ref": "#/definitions/user_setting" },
|
|
53
53
|
"minItems": 1,
|
|
54
|
-
"maxItems": 100,
|
|
55
54
|
"description": "user object to run workflow for. At least 1 user is required"
|
|
56
55
|
},
|
|
57
56
|
"data": {
|
|
@@ -65,27 +64,6 @@
|
|
|
65
64
|
"type": "string",
|
|
66
65
|
"minLength": 2
|
|
67
66
|
},
|
|
68
|
-
"mobile_number_pattern": {
|
|
69
|
-
"type": "string",
|
|
70
|
-
"minLength": 8,
|
|
71
|
-
"pattern": "^\\+[0-9\\s]+",
|
|
72
|
-
"message": {
|
|
73
|
-
"required": "Either a mobile-number or an array of mobile-numbers. e.g [\"+41446681800\"]",
|
|
74
|
-
"pattern": "number must start with + and must contain country code. e.g. +41446681800"
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
"email_pattern": {
|
|
78
|
-
"type": "string",
|
|
79
|
-
"format": "email",
|
|
80
|
-
"pattern": "^\\S+@\\S+\\.\\S+$",
|
|
81
|
-
"description": "email of an user",
|
|
82
|
-
"minLength": 6,
|
|
83
|
-
"maxLength": 127,
|
|
84
|
-
"message": {
|
|
85
|
-
"required": "",
|
|
86
|
-
"pattern": "value in email format required. e.g. user@example.com"
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
67
|
"slack_setting": {
|
|
90
68
|
"type": "object",
|
|
91
69
|
"properties": {
|
|
@@ -113,7 +91,7 @@
|
|
|
113
91
|
}
|
|
114
92
|
},
|
|
115
93
|
"email": {
|
|
116
|
-
"$ref": "#/definitions/
|
|
94
|
+
"$ref": "#/definitions/non_empty_string"
|
|
117
95
|
},
|
|
118
96
|
"incoming_webhook": {
|
|
119
97
|
"type": "object",
|
|
@@ -240,25 +218,25 @@
|
|
|
240
218
|
},
|
|
241
219
|
"$email": {
|
|
242
220
|
"oneOf": [
|
|
243
|
-
{ "$ref": "#/definitions/
|
|
221
|
+
{ "$ref": "#/definitions/non_empty_string" },
|
|
244
222
|
{
|
|
245
223
|
"type": "array",
|
|
246
224
|
"uniqueItems": false,
|
|
247
225
|
"maxItems": 10,
|
|
248
226
|
"minItems": 1,
|
|
249
|
-
"items": { "$ref": "#/definitions/
|
|
227
|
+
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
250
228
|
}
|
|
251
229
|
]
|
|
252
230
|
},
|
|
253
231
|
"$sms": {
|
|
254
232
|
"oneOf": [
|
|
255
|
-
{ "$ref": "#/definitions/
|
|
233
|
+
{ "$ref": "#/definitions/non_empty_string" },
|
|
256
234
|
{
|
|
257
235
|
"type": "array",
|
|
258
236
|
"uniqueItems": false,
|
|
259
237
|
"maxItems": 10,
|
|
260
238
|
"minItems": 1,
|
|
261
|
-
"items": { "$ref": "#/definitions/
|
|
239
|
+
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
262
240
|
}
|
|
263
241
|
]
|
|
264
242
|
},
|
|
@@ -304,13 +282,13 @@
|
|
|
304
282
|
},
|
|
305
283
|
"$whatsapp": {
|
|
306
284
|
"oneOf": [
|
|
307
|
-
{ "$ref": "#/definitions/
|
|
285
|
+
{ "$ref": "#/definitions/non_empty_string" },
|
|
308
286
|
{
|
|
309
287
|
"type": "array",
|
|
310
288
|
"uniqueItems": false,
|
|
311
289
|
"maxItems": 10,
|
|
312
290
|
"minItems": 1,
|
|
313
|
-
"items": { "$ref": "#/definitions/
|
|
291
|
+
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
314
292
|
}
|
|
315
293
|
]
|
|
316
294
|
},
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
38
|
"minItems": 1,
|
|
39
|
-
"maxItems": 100,
|
|
40
39
|
"description": "list of recipient id/object to run workflow for. At least 1 user is required"
|
|
41
40
|
},
|
|
42
41
|
"data": {
|
|
@@ -60,27 +59,6 @@
|
|
|
60
59
|
"type": "string",
|
|
61
60
|
"minLength": 1
|
|
62
61
|
},
|
|
63
|
-
"mobile_number_pattern": {
|
|
64
|
-
"type": "string",
|
|
65
|
-
"minLength": 8,
|
|
66
|
-
"pattern": "^\\+[0-9\\s]+",
|
|
67
|
-
"message": {
|
|
68
|
-
"required": "Either a mobile-number or an array of mobile-numbers. e.g [\"+41446681800\"]",
|
|
69
|
-
"pattern": "number must start with + and must contain country code. e.g. +41446681800"
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"email_pattern": {
|
|
73
|
-
"type": "string",
|
|
74
|
-
"format": "email",
|
|
75
|
-
"pattern": "^\\S+@\\S+\\.\\S+$",
|
|
76
|
-
"description": "email of an user",
|
|
77
|
-
"minLength": 6,
|
|
78
|
-
"maxLength": 127,
|
|
79
|
-
"message": {
|
|
80
|
-
"required": "",
|
|
81
|
-
"pattern": "value in email format required. e.g. user@example.com"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
62
|
"slack_setting": {
|
|
85
63
|
"type": "object",
|
|
86
64
|
"properties": {
|
|
@@ -108,7 +86,7 @@
|
|
|
108
86
|
}
|
|
109
87
|
},
|
|
110
88
|
"email": {
|
|
111
|
-
"$ref": "#/definitions/
|
|
89
|
+
"$ref": "#/definitions/non_empty_string"
|
|
112
90
|
},
|
|
113
91
|
"incoming_webhook": {
|
|
114
92
|
"type": "object",
|
|
@@ -235,25 +213,25 @@
|
|
|
235
213
|
},
|
|
236
214
|
"$email": {
|
|
237
215
|
"oneOf": [
|
|
238
|
-
{ "$ref": "#/definitions/
|
|
216
|
+
{ "$ref": "#/definitions/non_empty_string" },
|
|
239
217
|
{
|
|
240
218
|
"type": "array",
|
|
241
219
|
"uniqueItems": false,
|
|
242
220
|
"maxItems": 10,
|
|
243
221
|
"minItems": 1,
|
|
244
|
-
"items": { "$ref": "#/definitions/
|
|
222
|
+
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
245
223
|
}
|
|
246
224
|
]
|
|
247
225
|
},
|
|
248
226
|
"$sms": {
|
|
249
227
|
"oneOf": [
|
|
250
|
-
{ "$ref": "#/definitions/
|
|
228
|
+
{ "$ref": "#/definitions/non_empty_string" },
|
|
251
229
|
{
|
|
252
230
|
"type": "array",
|
|
253
231
|
"uniqueItems": false,
|
|
254
232
|
"maxItems": 10,
|
|
255
233
|
"minItems": 1,
|
|
256
|
-
"items": { "$ref": "#/definitions/
|
|
234
|
+
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
257
235
|
}
|
|
258
236
|
]
|
|
259
237
|
},
|
|
@@ -283,13 +261,13 @@
|
|
|
283
261
|
},
|
|
284
262
|
"$whatsapp": {
|
|
285
263
|
"oneOf": [
|
|
286
|
-
{ "$ref": "#/definitions/
|
|
264
|
+
{ "$ref": "#/definitions/non_empty_string" },
|
|
287
265
|
{
|
|
288
266
|
"type": "array",
|
|
289
267
|
"uniqueItems": false,
|
|
290
268
|
"maxItems": 10,
|
|
291
269
|
"minItems": 1,
|
|
292
|
-
"items": { "$ref": "#/definitions/
|
|
270
|
+
"items": { "$ref": "#/definitions/non_empty_string" }
|
|
293
271
|
}
|
|
294
272
|
]
|
|
295
273
|
},
|
package/src/subscriber.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
is_object,
|
|
3
|
-
SuprsendError,
|
|
4
3
|
epoch_milliseconds,
|
|
5
4
|
uuid,
|
|
6
5
|
is_empty,
|
|
@@ -44,8 +43,7 @@ export class Subscriber {
|
|
|
44
43
|
constructor(config, distinct_id) {
|
|
45
44
|
this.config = config;
|
|
46
45
|
this.distinct_id = distinct_id;
|
|
47
|
-
this.__url = this.
|
|
48
|
-
this.__super_props = this.__super_properties();
|
|
46
|
+
this.__url = `${this.config.base_url}event/`;
|
|
49
47
|
|
|
50
48
|
this.__errors = [];
|
|
51
49
|
this.__info = [];
|
|
@@ -54,10 +52,6 @@ export class Subscriber {
|
|
|
54
52
|
this.__warnings_list = [];
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
__get_url() {
|
|
58
|
-
return `${this.config.base_url}event/`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
55
|
__get_headers() {
|
|
62
56
|
return {
|
|
63
57
|
"Content-Type": "application/json; charset=utf-8",
|
|
@@ -66,12 +60,6 @@ export class Subscriber {
|
|
|
66
60
|
};
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
__super_properties() {
|
|
70
|
-
return {
|
|
71
|
-
$ss_sdk_version: this.config.user_agent,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
63
|
get_events() {
|
|
76
64
|
return {
|
|
77
65
|
$schema: "2",
|
|
@@ -80,7 +68,7 @@ export class Subscriber {
|
|
|
80
68
|
env: this.config.workspace_key,
|
|
81
69
|
distinct_id: this.distinct_id,
|
|
82
70
|
$user_operations: this.user_operations,
|
|
83
|
-
properties: this.
|
|
71
|
+
properties: { $ss_sdk_version: this.config.user_agent },
|
|
84
72
|
};
|
|
85
73
|
}
|
|
86
74
|
|
|
@@ -370,37 +358,37 @@ export class Subscriber {
|
|
|
370
358
|
this._collect_event();
|
|
371
359
|
}
|
|
372
360
|
|
|
373
|
-
add_androidpush(push_token, provider
|
|
361
|
+
add_androidpush(push_token, provider) {
|
|
374
362
|
const caller = "add_androidpush";
|
|
375
363
|
this._helper._add_androidpush(push_token, provider, caller);
|
|
376
364
|
this._collect_event();
|
|
377
365
|
}
|
|
378
366
|
|
|
379
|
-
remove_androidpush(push_token, provider
|
|
367
|
+
remove_androidpush(push_token, provider) {
|
|
380
368
|
const caller = "remove_androidpush";
|
|
381
369
|
this._helper._remove_androidpush(push_token, provider, caller);
|
|
382
370
|
this._collect_event();
|
|
383
371
|
}
|
|
384
372
|
|
|
385
|
-
add_iospush(push_token, provider
|
|
373
|
+
add_iospush(push_token, provider) {
|
|
386
374
|
const caller = "add_iospush";
|
|
387
375
|
this._helper._add_iospush(push_token, provider, caller);
|
|
388
376
|
this._collect_event();
|
|
389
377
|
}
|
|
390
378
|
|
|
391
|
-
remove_iospush(push_token, provider
|
|
379
|
+
remove_iospush(push_token, provider) {
|
|
392
380
|
const caller = "remove_iospush";
|
|
393
381
|
this._helper._remove_iospush(push_token, provider, caller);
|
|
394
382
|
this._collect_event();
|
|
395
383
|
}
|
|
396
384
|
|
|
397
|
-
add_webpush(push_token, provider
|
|
385
|
+
add_webpush(push_token, provider) {
|
|
398
386
|
const caller = "add_webpush";
|
|
399
387
|
this._helper._add_webpush(push_token, provider, caller);
|
|
400
388
|
this._collect_event();
|
|
401
389
|
}
|
|
402
390
|
|
|
403
|
-
remove_webpush(push_token, provider
|
|
391
|
+
remove_webpush(push_token, provider) {
|
|
404
392
|
const caller = "remove_webpush";
|
|
405
393
|
this._helper._remove_webpush(push_token, provider, caller);
|
|
406
394
|
this._collect_event();
|