cordova-plugin-insider 3.0.2 → 3.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/www/User.js DELETED
@@ -1,482 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
5
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
6
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
- var Utils = require("./Utils");
10
- var InsiderConstants = require("./Constants");
11
- var User = /*#__PURE__*/function () {
12
- function User() {
13
- _classCallCheck(this, User);
14
- }
15
- return _createClass(User, [{
16
- key: "setGender",
17
- value: function setGender(gender) {
18
- if (Utils.checkParameters([{
19
- type: 'number',
20
- value: gender
21
- }])) {
22
- Utils.showParameterWarningLog(this.constructor.name + '-setGender');
23
- return this;
24
- }
25
- try {
26
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_GENDER, [gender]);
27
- } catch (error) {
28
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
29
- }
30
- return this;
31
- }
32
- }, {
33
- key: "setBirthday",
34
- value: function setBirthday(birthday) {
35
- if (Utils.checkParameters([{
36
- type: 'string',
37
- value: birthday
38
- }])) {
39
- Utils.showParameterWarningLog(this.constructor.name + '-setBirthday');
40
- return this;
41
- }
42
- try {
43
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_BIRTDAY, [birthday.toISOString()]);
44
- } catch (error) {
45
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
46
- }
47
- return this;
48
- }
49
- }, {
50
- key: "setName",
51
- value: function setName(name) {
52
- if (Utils.checkParameters([{
53
- type: 'string',
54
- value: name
55
- }])) {
56
- Utils.showParameterWarningLog(this.constructor.name + '-setName');
57
- return this;
58
- }
59
- try {
60
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_NAME, [name]);
61
- } catch (error) {
62
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
63
- }
64
- return this;
65
- }
66
- }, {
67
- key: "setSurname",
68
- value: function setSurname(surname) {
69
- if (Utils.checkParameters([{
70
- type: 'string',
71
- value: surname
72
- }])) {
73
- Utils.showParameterWarningLog(this.constructor.name + '-setSurname');
74
- return this;
75
- }
76
- try {
77
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_SURNAME, [surname]);
78
- } catch (error) {
79
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
80
- }
81
- return this;
82
- }
83
- }, {
84
- key: "setAge",
85
- value: function setAge(age) {
86
- if (Utils.checkParameters([{
87
- type: 'string',
88
- value: age
89
- }])) {
90
- Utils.showParameterWarningLog(this.constructor.name + '-setAge');
91
- return this;
92
- }
93
- try {
94
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_AGE, [age]);
95
- } catch (error) {
96
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
97
- }
98
- return this;
99
- }
100
- }, {
101
- key: "setEmail",
102
- value: function setEmail(email) {
103
- if (Utils.checkParameters([{
104
- type: 'string',
105
- value: email
106
- }])) {
107
- Utils.showParameterWarningLog(this.constructor.name + '-setEmail');
108
- return this;
109
- }
110
- try {
111
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_EMAIL, [email]);
112
- } catch (error) {
113
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
114
- }
115
- return this;
116
- }
117
- }, {
118
- key: "setPhoneNumber",
119
- value: function setPhoneNumber(phone) {
120
- if (Utils.checkParameters([{
121
- type: 'string',
122
- value: phone
123
- }])) {
124
- Utils.showParameterWarningLog(this.constructor.name + '-setPhoneNumber');
125
- return this;
126
- }
127
- try {
128
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_PHONE_NUMBER, [phone]);
129
- } catch (error) {
130
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
131
- }
132
- return this;
133
- }
134
- }, {
135
- key: "setLanguage",
136
- value: function setLanguage(language) {
137
- if (Utils.checkParameters([{
138
- type: 'string',
139
- value: language
140
- }])) {
141
- Utils.showParameterWarningLog(this.constructor.name + '-setLanguage');
142
- return this;
143
- }
144
- try {
145
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LANGUAGE, [language]);
146
- } catch (error) {
147
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
148
- }
149
- return this;
150
- }
151
- }, {
152
- key: "setLocale",
153
- value: function setLocale(locale) {
154
- if (Utils.checkParameters([{
155
- type: 'string',
156
- value: locale
157
- }])) {
158
- Utils.showParameterWarningLog(this.constructor.name + '-setLocale');
159
- return this;
160
- }
161
- try {
162
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LOCALE, [locale]);
163
- } catch (error) {
164
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
165
- }
166
- return this;
167
- }
168
- }, {
169
- key: "setFacebookID",
170
- value: function setFacebookID(facebookID) {
171
- if (Utils.checkParameters([{
172
- type: 'string',
173
- value: facebookID
174
- }])) {
175
- Utils.showParameterWarningLog(this.constructor.name + '-setFacebookID');
176
- return this;
177
- }
178
- try {
179
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_FACEBOOK_ID, [facebookID]);
180
- } catch (error) {
181
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
182
- }
183
- return this;
184
- }
185
- }, {
186
- key: "setTwitterID",
187
- value: function setTwitterID(twitterID) {
188
- if (Utils.checkParameters([{
189
- type: 'string',
190
- value: twitterID
191
- }])) {
192
- Utils.showParameterWarningLog(this.constructor.name + '-setTwitterID');
193
- return this;
194
- }
195
- try {
196
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_TWITTER_ID, [twitterID]);
197
- } catch (error) {
198
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
199
- }
200
- return this;
201
- }
202
- }, {
203
- key: "setEmailOptin",
204
- value: function setEmailOptin(emailOptIn) {
205
- if (Utils.checkParameters([{
206
- type: 'boolean',
207
- value: emailOptIn
208
- }])) {
209
- Utils.showParameterWarningLog(this.constructor.name + '-setEmailOptin');
210
- return this;
211
- }
212
- try {
213
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_EMAIL_OPTIN, [emailOptIn]);
214
- } catch (error) {
215
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
216
- }
217
- return this;
218
- }
219
- }, {
220
- key: "setSMSOptin",
221
- value: function setSMSOptin(smsOptIn) {
222
- if (Utils.checkParameters([{
223
- type: 'boolean',
224
- value: smsOptIn
225
- }])) {
226
- Utils.showParameterWarningLog(this.constructor.name + '-setSMSOptin');
227
- return this;
228
- }
229
- try {
230
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_SMS_OPTIN, [smsOptIn]);
231
- } catch (error) {
232
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
233
- }
234
- return this;
235
- }
236
- }, {
237
- key: "setPushOptin",
238
- value: function setPushOptin(pushOptIn) {
239
- if (Utils.checkParameters([{
240
- type: 'boolean',
241
- value: pushOptIn
242
- }])) {
243
- Utils.showParameterWarningLog(this.constructor.name + '-setPushOptin');
244
- return this;
245
- }
246
- try {
247
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_PUSH_OPTIN, [pushOptIn]);
248
- } catch (error) {
249
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
250
- }
251
- return this;
252
- }
253
- }, {
254
- key: "setLocationOptin",
255
- value: function setLocationOptin(locationOptIn) {
256
- if (Utils.checkParameters([{
257
- type: 'boolean',
258
- value: locationOptIn
259
- }])) {
260
- Utils.showParameterWarningLog(this.constructor.name + '-setLocationOptin');
261
- return this;
262
- }
263
- try {
264
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LOCATION_OPTIN, [locationOptIn]);
265
- } catch (error) {
266
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
267
- }
268
- return this;
269
- }
270
- }, {
271
- key: "setWhatsappOptin",
272
- value: function setWhatsappOptin(whatsappOptin) {
273
- if (Utils.checkParameters([{
274
- type: 'boolean',
275
- value: whatsappOptin
276
- }])) {
277
- Utils.showParameterWarningLog(this.constructor.name + '-setWhatsappOptin');
278
- return this;
279
- }
280
- try {
281
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_WHATSAPP_OPTIN, [whatsappOptin]);
282
- } catch (error) {
283
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
284
- }
285
- return this;
286
- }
287
- }, {
288
- key: "login",
289
- value: function login(identifiers, insiderIDResult) {
290
- try {
291
- if (!Utils.checkParameters([{
292
- type: 'function',
293
- value: insiderIDResult
294
- }, {
295
- type: 'object',
296
- value: identifiers
297
- }])) {
298
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGIN, [identifiers, insiderIDResult]).then(function (id) {
299
- return insiderIDResult(id);
300
- });
301
- } else if (!Utils.checkParameters([{
302
- type: 'object',
303
- value: identifiers
304
- }])) {
305
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGIN, [identifiers]);
306
- } else {
307
- Utils.showParameterWarningLog(this.constructor.name + '-login');
308
- }
309
- } catch (error) {
310
- Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
311
- }
312
- }
313
- }, {
314
- key: "logout",
315
- value: function logout() {
316
- try {
317
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGOUT, []);
318
- } catch (error) {
319
- Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
320
- }
321
- }
322
- }, {
323
- key: "logoutResettingInsiderID",
324
- value: function logoutResettingInsiderID(identifiers, insiderIDResult) {
325
- try {
326
- var identifiersArray = identifiers && Array.isArray(identifiers) ? identifiers.map(function (id) {
327
- return id.identifiers;
328
- }) : null;
329
- if (!Utils.checkParameters([{
330
- type: 'function',
331
- value: insiderIDResult
332
- }])) {
333
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGOUT_RESETTING_INSIDER_ID, [identifiersArray, insiderIDResult]).then(function (id) {
334
- return insiderIDResult(id);
335
- });
336
- } else {
337
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGOUT_RESETTING_INSIDER_ID, [identifiersArray]);
338
- }
339
- } catch (error) {
340
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
341
- }
342
- }
343
- }, {
344
- key: "setCustomAttributeWithString",
345
- value: function setCustomAttributeWithString(key, value) {
346
- if (Utils.checkParameters([{
347
- type: 'string',
348
- value: key
349
- }, {
350
- type: 'string',
351
- value: value
352
- }])) {
353
- Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithString');
354
- return this;
355
- }
356
- try {
357
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_STRING, [key, value]);
358
- } catch (error) {
359
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
360
- }
361
- return this;
362
- }
363
- }, {
364
- key: "setCustomAttributeWithInt",
365
- value: function setCustomAttributeWithInt(key, value) {
366
- if (Utils.checkParameters([{
367
- type: 'string',
368
- value: key
369
- }, {
370
- type: 'number',
371
- value: value
372
- }])) {
373
- Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithInt');
374
- return this;
375
- }
376
- try {
377
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_INT, [key, value]);
378
- } catch (error) {
379
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
380
- }
381
- return this;
382
- }
383
- }, {
384
- key: "setCustomAttributeWithDouble",
385
- value: function setCustomAttributeWithDouble(key, value) {
386
- if (Utils.checkParameters([{
387
- type: 'string',
388
- value: key
389
- }, {
390
- type: 'number',
391
- value: value
392
- }])) {
393
- Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithDouble');
394
- return this;
395
- }
396
- try {
397
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_DOUBLE, [key, value]);
398
- } catch (error) {
399
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
400
- }
401
- return this;
402
- }
403
- }, {
404
- key: "setCustomAttributeWithBoolean",
405
- value: function setCustomAttributeWithBoolean(key, value) {
406
- if (Utils.checkParameters([{
407
- type: 'string',
408
- value: key
409
- }, {
410
- type: 'boolean',
411
- value: value
412
- }])) {
413
- Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithBoolean');
414
- return this;
415
- }
416
- try {
417
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_BOOLEAN, [key, value]);
418
- } catch (error) {
419
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
420
- }
421
- return this;
422
- }
423
- }, {
424
- key: "setCustomAttributeWithDate",
425
- value: function setCustomAttributeWithDate(key, value) {
426
- if (Utils.checkParameters([{
427
- type: 'string',
428
- value: key
429
- }, {
430
- type: 'object',
431
- value: value
432
- }])) {
433
- Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithDate');
434
- return this;
435
- }
436
- try {
437
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_DATE, [key, value.toISOString()]);
438
- } catch (error) {
439
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
440
- }
441
- return this;
442
- }
443
- }, {
444
- key: "setCustomAttributeWithArray",
445
- value: function setCustomAttributeWithArray(key, value) {
446
- if (Utils.checkParameters([{
447
- type: 'string',
448
- value: key
449
- }, {
450
- type: 'object',
451
- value: value
452
- }])) {
453
- Utils.showParameterWarningLog(this.constructor.name + '-setCustomAttributeWithArray');
454
- return this;
455
- }
456
- try {
457
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_ARRAY, [key, value]);
458
- } catch (error) {
459
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
460
- }
461
- return this;
462
- }
463
- }, {
464
- key: "unsetCustomAttribute",
465
- value: function unsetCustomAttribute(key) {
466
- if (Utils.checkParameters([{
467
- type: 'string',
468
- value: key
469
- }])) {
470
- Utils.showParameterWarningLog(this.constructor.name + '-unsetCustomAttribute');
471
- return this;
472
- }
473
- try {
474
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.UNSET_CUSTOM_ATTRIBUTE, [key]);
475
- } catch (error) {
476
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
477
- }
478
- return this;
479
- }
480
- }]);
481
- }();
482
- module.exports = User;
package/www/Utils.js DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- module.exports = {
5
- asyncExec: function asyncExec(className, reference) {
6
- var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
7
- return new Promise(function (resolve, reject) {
8
- window.cordova.exec(resolve, reject, className, reference, args);
9
- });
10
- },
11
- generateJSONErrorString: function generateJSONErrorString(error) {
12
- return '[InsiderCordova][JavaScriptError] ' + error;
13
- },
14
- checkParameters: function checkParameters(parameters) {
15
- return parameters.some(function (parameterConfig) {
16
- switch (parameterConfig.type) {
17
- case "numeric_array":
18
- if (!Array.isArray(parameterConfig.value)) {
19
- return true;
20
- }
21
- return !parameterConfig.value.every(function (item) {
22
- return typeof item === "number";
23
- });
24
- case "string_array":
25
- if (!Array.isArray(parameterConfig.value)) {
26
- return true;
27
- }
28
- return !parameterConfig.value.every(function (item) {
29
- return typeof item === "string";
30
- });
31
- default:
32
- return parameterConfig.type !== _typeof(parameterConfig.value);
33
- }
34
- });
35
- },
36
- showParameterWarningLog: function showParameterWarningLog(functionName) {
37
- console.warn("[InsiderCordova] paramaters is not valid, function: " + functionName);
38
- }
39
- };