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.
@@ -1,742 +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 _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); } }
5
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- 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); }
10
- var InsiderProduct = require("./Product");
11
- var InsiderEvent = require("./Event");
12
- var InsiderUser = require("./User");
13
- var InsiderIdentifier = require('./Identifier');
14
- var InsiderCallbackType = require('./CallbackType');
15
- var InsiderGender = require('./Gender');
16
- var InsiderContentOptimizerDataType = require('./ContentOptimizerDataType');
17
- var Utils = require("./Utils");
18
- var InsiderConstants = require("./Constants");
19
- var InsiderPlugin = /*#__PURE__*/_createClass(function InsiderPlugin() {
20
- var _this = this;
21
- _classCallCheck(this, InsiderPlugin);
22
- _defineProperty(this, "insiderUser", {});
23
- _defineProperty(this, "gender", InsiderGender);
24
- _defineProperty(this, "callbackType", InsiderCallbackType);
25
- _defineProperty(this, "contentOptimizerDataType", InsiderContentOptimizerDataType);
26
- _defineProperty(this, "initCordovaBase", function (partnerName, appGroup, customEndpoint, handleNotificationCallback) {
27
- try {
28
- var sdkVersion = InsiderConstants.SDK_VERSION;
29
- document.addEventListener('ins_notification_handle', handleNotificationCallback, false);
30
- if (customEndpoint !== null) Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.INIT_WITH_CUSTOM_ENDPOINT, [partnerName, sdkVersion, appGroup, customEndpoint]);else if (cordova.platformId === "ios") Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.INIT_WITH_LAUNCH_OPTIONS, [partnerName, sdkVersion, appGroup]);else Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.INIT, [partnerName, sdkVersion]);
31
- } catch (error) {
32
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
33
- }
34
- });
35
- _defineProperty(this, "init", function (partnerName, appGroup, handleNotificationCallback) {
36
- if (Utils.checkParameters([{
37
- type: 'string',
38
- value: partnerName
39
- }, {
40
- type: 'string',
41
- value: appGroup
42
- }, {
43
- type: 'function',
44
- value: handleNotificationCallback
45
- }])) {
46
- Utils.showParameterWarningLog(_this.constructor.name + '-init');
47
- return;
48
- }
49
- try {
50
- _this.initCordovaBase(partnerName, appGroup, null, handleNotificationCallback);
51
- } catch (error) {
52
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
53
- }
54
- });
55
- _defineProperty(this, "initWithCustomEndpoint", function (partnerName, appGroup, endpoint, handleNotificationCallback) {
56
- if (Utils.checkParameters([{
57
- type: 'string',
58
- value: partnerName
59
- }, {
60
- type: 'string',
61
- value: appGroup
62
- }, {
63
- type: 'string',
64
- value: endpoint
65
- }, {
66
- type: 'function',
67
- value: handleNotificationCallback
68
- }])) {
69
- Utils.showParameterWarningLog(_this.constructor.name + '-init');
70
- return;
71
- }
72
- try {
73
- _this.initCordovaBase(partnerName, appGroup, endpoint, handleNotificationCallback);
74
- } catch (error) {
75
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
76
- }
77
- });
78
- _defineProperty(this, "reinitWithPartnerName", function (partnerName) {
79
- if (Utils.checkParameters([{
80
- type: 'string',
81
- value: partnerName
82
- }])) {
83
- Utils.showParameterWarningLog(_this.constructor.name + '-reinit');
84
- return;
85
- }
86
- try {
87
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.REINIT_WITH_PARTNER_NAME, [partnerName]);
88
- } catch (error) {
89
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
90
- }
91
- });
92
- _defineProperty(this, "getCurrentUser", function () {
93
- try {
94
- return _this.insiderUser;
95
- } catch (error) {
96
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
97
- }
98
- });
99
- _defineProperty(this, "tagEvent", function (eventName) {
100
- if (Utils.checkParameters([{
101
- type: 'string',
102
- value: eventName
103
- }])) {
104
- Utils.showParameterWarningLog(_this.constructor.name + '-tagEvent');
105
- return;
106
- }
107
- try {
108
- return new InsiderEvent(eventName);
109
- } catch (error) {
110
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
111
- }
112
- });
113
- _defineProperty(this, "createNewProduct", function (productID, name, taxonomy, imageURL, price, currency) {
114
- if (Utils.checkParameters([{
115
- type: 'string',
116
- value: productID
117
- }, {
118
- type: 'string',
119
- value: name
120
- }, {
121
- type: 'object',
122
- value: taxonomy
123
- }, {
124
- type: 'string',
125
- value: imageURL
126
- }, {
127
- type: 'number',
128
- value: price
129
- }, {
130
- type: 'string',
131
- value: currency
132
- }])) {
133
- Utils.showParameterWarningLog(_this.constructor.name + '-createNewProduct');
134
- return new InsiderProduct('', '', [], '', 0, '');
135
- }
136
- return new InsiderProduct(productID, name, taxonomy, imageURL, price, currency);
137
- });
138
- _defineProperty(this, "itemPurchased", function (uniqueSaleID, product) {
139
- if (Utils.checkParameters([{
140
- type: 'string',
141
- value: uniqueSaleID
142
- }, {
143
- type: 'object',
144
- value: product
145
- }])) {
146
- Utils.showParameterWarningLog(_this.constructor.name + '-itemPurchased');
147
- return;
148
- }
149
- try {
150
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_PURCHASED, [uniqueSaleID, product.productMustMap, product.productOptMap]);
151
- } catch (error) {
152
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
153
- }
154
- });
155
- _defineProperty(this, "itemAddedToCart", function (product) {
156
- if (Utils.checkParameters([{
157
- type: 'object',
158
- value: product
159
- }])) {
160
- Utils.showParameterWarningLog(_this.constructor.name + '-itemAddedToCart');
161
- return;
162
- }
163
- try {
164
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_ADDED_TO_CART, [product.productMustMap, product.productOptMap]);
165
- } catch (error) {
166
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
167
- }
168
- });
169
- _defineProperty(this, "itemRemovedFromCart", function (productID) {
170
- if (Utils.checkParameters([{
171
- type: 'string',
172
- value: productID
173
- }])) {
174
- Utils.showParameterWarningLog(_this.constructor.name + '-itemRemovedFromCart');
175
- return;
176
- }
177
- try {
178
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_REMOVED_FROM_CART, [productID]);
179
- } catch (error) {
180
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
181
- }
182
- });
183
- _defineProperty(this, "cartCleared", function () {
184
- try {
185
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.CART_CLEARED, []);
186
- } catch (error) {
187
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
188
- }
189
- });
190
- _defineProperty(this, "getMessageCenterData", function (limit, startDate, endDate) {
191
- if (Utils.checkParameters([{
192
- type: 'number',
193
- value: limit
194
- }, {
195
- type: 'object',
196
- value: startDate
197
- }, {
198
- type: 'object',
199
- value: endDate
200
- }]) || startDate.getTime() === endDate.getTime() || startDate.getTime() > endDate.getTime()) {
201
- Utils.showParameterWarningLog(_this.constructor.name + '-getMessageCenterData');
202
- return;
203
- }
204
- try {
205
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_MESSAGE_CENTER_DATA, [limit, startDate.getTime(), endDate.getTime()]);
206
- } catch (error) {
207
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
208
- }
209
- });
210
- _defineProperty(this, "getSmartRecommendation", function (recommendationID, locale, currency) {
211
- if (Utils.checkParameters([{
212
- type: 'number',
213
- value: recommendationID
214
- }, {
215
- type: 'string',
216
- value: locale
217
- }, {
218
- type: 'string',
219
- value: currency
220
- }])) {
221
- Utils.showParameterWarningLog(_this.constructor.name + '-getSmartRecommendation');
222
- return;
223
- }
224
- try {
225
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_SMART_RECOMMENDATION, [recommendationID, locale, currency]);
226
- } catch (error) {
227
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
228
- }
229
- });
230
- _defineProperty(this, "getSmartRecommendationWithProduct", function (product, recommendationID, locale) {
231
- if (Utils.checkParameters([{
232
- type: 'number',
233
- value: recommendationID
234
- }, {
235
- type: 'string',
236
- value: locale
237
- }, {
238
- type: 'object',
239
- value: product
240
- }])) {
241
- Utils.showParameterWarningLog(_this.constructor.name + '-getSmartRecommendationWithProduct');
242
- return;
243
- }
244
- try {
245
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_SMART_RECOMMENDATION_WITH_PRODUCT, [product.productMustMap, product.productOptMap, recommendationID, locale]);
246
- } catch (error) {
247
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
248
- }
249
- });
250
- _defineProperty(this, "getSmartRecommendationWithProductIDs", function (productIDs, recommendationID, locale, currency) {
251
- if (Utils.checkParameters([{
252
- type: 'number',
253
- value: recommendationID
254
- }, {
255
- type: 'string',
256
- value: locale
257
- }, {
258
- type: 'string',
259
- value: currency
260
- }, {
261
- type: 'object',
262
- value: productIDs
263
- }])) {
264
- Utils.showParameterWarningLog(_this.constructor.name + '-getSmartRecommendationWithProductIDs');
265
- return;
266
- }
267
- productIDs = productIDs.filter(function (value) {
268
- return value != null && typeof value == "string" && value.trim();
269
- });
270
- try {
271
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_SMART_RECOMMENDATION_WITH_PRODUCT_IDS, [productIDs, recommendationID, locale, currency]);
272
- } catch (error) {
273
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
274
- }
275
- });
276
- _defineProperty(this, "clickSmartRecommendationProduct", function (product, recommendationID) {
277
- if (Utils.checkParameters([{
278
- type: 'number',
279
- value: recommendationID
280
- }, {
281
- type: 'object',
282
- value: product
283
- }])) {
284
- Utils.showParameterWarningLog(_this.constructor.name + '-clickSmartRecommendationProduct');
285
- return;
286
- }
287
- try {
288
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.CLICK_SMART_RECOMMENDATION_PRODUCT, [product.productMustMap, product.productOptMap, recommendationID]);
289
- } catch (error) {
290
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
291
- }
292
- });
293
- _defineProperty(this, "getContentStringWithName", function (variableName, defaultValue, contentOptimizerDataType) {
294
- if (Utils.checkParameters([{
295
- type: 'string',
296
- value: variableName
297
- }, {
298
- type: 'string',
299
- value: defaultValue
300
- }, {
301
- type: 'number',
302
- value: contentOptimizerDataType
303
- }])) {
304
- Utils.showParameterWarningLog(_this.constructor.name + '-getContentStringWithName');
305
- return;
306
- }
307
- try {
308
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_STRING_WITH_NAME, [variableName, defaultValue, contentOptimizerDataType]);
309
- } catch (error) {
310
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
311
- }
312
- });
313
- _defineProperty(this, "getContentBoolWithName", function (variableName, defaultValue, contentOptimizerDataType) {
314
- if (Utils.checkParameters([{
315
- type: 'string',
316
- value: variableName
317
- }, {
318
- type: 'boolean',
319
- value: defaultValue
320
- }, {
321
- type: 'number',
322
- value: contentOptimizerDataType
323
- }])) {
324
- Utils.showParameterWarningLog(_this.constructor.name + '-getContentBoolWithName');
325
- return;
326
- }
327
- try {
328
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_BOOL_WITH_NAME, [variableName, defaultValue, contentOptimizerDataType]);
329
- } catch (error) {
330
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
331
- }
332
- });
333
- _defineProperty(this, "getContentIntWithName", function (variableName, defaultValue, contentOptimizerDataType) {
334
- if (Utils.checkParameters([{
335
- type: 'string',
336
- value: variableName
337
- }, {
338
- type: 'number',
339
- value: defaultValue
340
- }, {
341
- type: 'number',
342
- value: contentOptimizerDataType
343
- }])) {
344
- Utils.showParameterWarningLog(_this.constructor.name + '-getContentIntWithName');
345
- return;
346
- }
347
- try {
348
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_INT_WITH_NAME, [variableName, defaultValue, contentOptimizerDataType]);
349
- } catch (error) {
350
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
351
- }
352
- });
353
- _defineProperty(this, "getContentStringWithoutCache", function (variableName, defaultValue, contentOptimizerDataType) {
354
- if (Utils.checkParameters([{
355
- type: 'string',
356
- value: variableName
357
- }, {
358
- type: 'string',
359
- value: defaultValue
360
- }, {
361
- type: 'number',
362
- value: contentOptimizerDataType
363
- }])) {
364
- Utils.showParameterWarningLog(_this.constructor.name + '-getContentStringWithoutCache');
365
- return;
366
- }
367
- try {
368
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_STRING_WITHOUT_CACHE, [variableName, defaultValue, contentOptimizerDataType]);
369
- } catch (error) {
370
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
371
- }
372
- });
373
- _defineProperty(this, "getContentBoolWithoutCache", function (variableName, defaultValue, contentOptimizerDataType) {
374
- if (Utils.checkParameters([{
375
- type: 'string',
376
- value: variableName
377
- }, {
378
- type: 'boolean',
379
- value: defaultValue
380
- }, {
381
- type: 'number',
382
- value: contentOptimizerDataType
383
- }])) {
384
- Utils.showParameterWarningLog(_this.constructor.name + '-getContentBoolWithoutCache');
385
- return;
386
- }
387
- try {
388
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_BOOL_WITHOUT_CACHE, [variableName, defaultValue, contentOptimizerDataType]);
389
- } catch (error) {
390
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
391
- }
392
- });
393
- _defineProperty(this, "getContentIntWithoutCache", function (variableName, defaultValue, contentOptimizerDataType) {
394
- if (Utils.checkParameters([{
395
- type: 'string',
396
- value: variableName
397
- }, {
398
- type: 'number',
399
- value: defaultValue
400
- }, {
401
- type: 'number',
402
- value: contentOptimizerDataType
403
- }])) {
404
- Utils.showParameterWarningLog(_this.constructor.name + '-getContentIntWithoutCache');
405
- return;
406
- }
407
- try {
408
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_CONTENT_INT_WITHOUT_CACHE, [variableName, defaultValue, contentOptimizerDataType]);
409
- } catch (error) {
410
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
411
- }
412
- });
413
- _defineProperty(this, "visitHomePage", function () {
414
- try {
415
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_HOME_PAGE, []);
416
- } catch (error) {
417
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
418
- }
419
- });
420
- _defineProperty(this, "visitListingPage", function (taxonomy) {
421
- if (Utils.checkParameters([{
422
- type: 'object',
423
- value: taxonomy
424
- }])) {
425
- Utils.showParameterWarningLog(_this.constructor.name + '-visitListingPage');
426
- return;
427
- }
428
- try {
429
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_LISTING_PAGE, [taxonomy]);
430
- } catch (error) {
431
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
432
- }
433
- });
434
- _defineProperty(this, "visitProductDetailPage", function (product) {
435
- if (Utils.checkParameters([{
436
- type: 'object',
437
- value: product
438
- }])) {
439
- Utils.showParameterWarningLog(_this.constructor.name + '-visitProductDetailPage');
440
- return;
441
- }
442
- try {
443
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_PRODUCT_DETAIL_PAGE, [product.productMustMap, product.productOptMap]);
444
- } catch (error) {
445
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
446
- }
447
- });
448
- _defineProperty(this, "visitCartPage", function (products) {
449
- if (Utils.checkParameters([{
450
- type: 'object',
451
- value: products
452
- }])) {
453
- Utils.showParameterWarningLog(_this.constructor.name + '-visitCartPage');
454
- return;
455
- }
456
- try {
457
- var productMap = {};
458
- var mappedProducts = new Array(products.length);
459
- products.forEach(function (product, i) {
460
- productMap['productMustMap'] = product.productMustMap;
461
- productMap['productOptMap'] = product.productOptMap;
462
- mappedProducts[i] = productMap;
463
- });
464
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_CART_PAGE, [mappedProducts]);
465
- } catch (error) {
466
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
467
- }
468
- });
469
- _defineProperty(this, "startTrackingGeofence", function () {
470
- try {
471
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.START_TRACKING_GEOFENCE, []);
472
- } catch (error) {
473
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
474
- }
475
- });
476
- _defineProperty(this, "setGDPRConsent", function (gdprConsent) {
477
- if (Utils.checkParameters([{
478
- type: 'boolean',
479
- value: gdprConsent
480
- }])) {
481
- Utils.showParameterWarningLog(_this.constructor.name + '-setGDPRConsent');
482
- return;
483
- }
484
- try {
485
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_GDPR_CONSENT, [gdprConsent.toString().toLowerCase()]);
486
- } catch (error) {
487
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
488
- }
489
- });
490
- _defineProperty(this, "setMobileAppAccess", function (mobileAppAccess) {
491
- if (Utils.checkParameters([{
492
- type: 'boolean',
493
- value: mobileAppAccess
494
- }])) {
495
- Utils.showParameterWarningLog(_this.constructor.name + '-setMobileAppAccess');
496
- return;
497
- }
498
- try {
499
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_MOBILE_APP_ACCESS, [mobileAppAccess.toString().toLowerCase()]);
500
- } catch (error) {
501
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
502
- }
503
- });
504
- _defineProperty(this, "enableIDFACollection", function (idfaCollection) {
505
- if (Utils.checkParameters([{
506
- type: 'boolean',
507
- value: idfaCollection
508
- }])) {
509
- Utils.showParameterWarningLog(_this.constructor.name + '-enableIDFACollection');
510
- return;
511
- }
512
- try {
513
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_IDFA_COLLECTION, [idfaCollection.toString().toLowerCase()]);
514
- } catch (error) {
515
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
516
- }
517
- });
518
- _defineProperty(this, "removeInapp", function () {
519
- try {
520
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.REMOVE_IN_APP, []);
521
- } catch (error) {
522
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
523
- }
524
- });
525
- _defineProperty(this, "registerWithQuietPermission", function (permission) {
526
- if (Utils.checkParameters([{
527
- type: 'boolean',
528
- value: permission
529
- }])) {
530
- Utils.showParameterWarningLog(_this.constructor.name + '-registerWithQuietPermission');
531
- return;
532
- }
533
- try {
534
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.REGISTER_WITH_QUIET_PERMISSION, [permission.toString().toLowerCase()]);
535
- } catch (error) {
536
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
537
- }
538
- });
539
- _defineProperty(this, "setPushToken", function (token) {
540
- if (Utils.checkParameters([{
541
- type: 'string',
542
- value: token
543
- }])) {
544
- Utils.showParameterWarningLog(_this.constructor.name + '-setPushToken');
545
- return;
546
- }
547
- try {
548
- if (cordova.platformId !== InsiderConstants.ANDROID) return;
549
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_HYBRID_PUSH_TOKEN, [token]);
550
- } catch (error) {
551
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
552
- }
553
- });
554
- _defineProperty(this, "enableLocationCollection", function (locationCollection) {
555
- if (Utils.checkParameters([{
556
- type: 'boolean',
557
- value: locationCollection
558
- }])) {
559
- Utils.showParameterWarningLog(_this.constructor.name + '-enableLocationCollection');
560
- return;
561
- }
562
- try {
563
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_LOCATION_COLLECTION, [locationCollection]);
564
- } catch (error) {
565
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
566
- }
567
- });
568
- _defineProperty(this, "enableIpCollection", function (ipCollection) {
569
- if (Utils.checkParameters([{
570
- type: 'boolean',
571
- value: ipCollection
572
- }])) {
573
- Utils.showParameterWarningLog(_this.constructor.name + '-enableIpCollection');
574
- return;
575
- }
576
- try {
577
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_IP_COLLECTION, [ipCollection]);
578
- } catch (error) {
579
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
580
- }
581
- });
582
- _defineProperty(this, "enableCarrierCollection", function (carrierCollection) {
583
- if (Utils.checkParameters([{
584
- type: 'boolean',
585
- value: carrierCollection
586
- }])) {
587
- Utils.showParameterWarningLog(_this.constructor.name + '-enableCarrierCollection');
588
- return;
589
- }
590
- try {
591
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_CARRIER_COLLECTION, [carrierCollection]);
592
- } catch (error) {
593
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
594
- }
595
- });
596
- _defineProperty(this, "signUpConfirmation", function () {
597
- try {
598
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SIGN_UP_CONFIRMATION, []);
599
- } catch (error) {
600
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
601
- }
602
- });
603
- _defineProperty(this, "identifier", function () {
604
- try {
605
- return new InsiderIdentifier();
606
- } catch (error) {
607
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
608
- }
609
- });
610
- _defineProperty(this, "setActiveForegroundPushView", function () {
611
- try {
612
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_ACTIVE_FOREGROUND_PUSH_VIEW, []);
613
- } catch (error) {
614
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
615
- }
616
- });
617
- _defineProperty(this, "setForegroundPushCallback", function (callback) {
618
- if (Utils.checkParameters([{
619
- type: 'function',
620
- value: callback
621
- }])) {
622
- Utils.showParameterWarningLog(_this.constructor.name + '-setForegroundPushCallback');
623
- return;
624
- }
625
- try {
626
- if (cordova.platformId === "ios") {
627
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_FOREGROUND_PUSH_CALLBACK, []);
628
- document.addEventListener('ins_foreground_push_callback', function (data) {
629
- data && callback(data);
630
- }, false);
631
- }
632
- } catch (error) {
633
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
634
- }
635
- });
636
- _defineProperty(this, "handleNotification", function (userInfo) {
637
- if (Utils.checkParameters([{
638
- type: 'object',
639
- value: userInfo
640
- }])) {
641
- Utils.showParameterWarningLog(_this.constructor.name + '-setForegroundPushCallback');
642
- return;
643
- }
644
- try {
645
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.HANDLE_NOTIFICATION, [userInfo]);
646
- } catch (error) {
647
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
648
- }
649
- });
650
- _defineProperty(this, "getInsiderID", function () {
651
- try {
652
- return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_INSIDER_ID, []);
653
- } catch (error) {
654
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
655
- return null;
656
- }
657
- });
658
- _defineProperty(this, "registerInsiderIDListener", function (insiderIDCallback) {
659
- try {
660
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.REGISTER_INSIDER_ID_LISTENER, []);
661
- document.addEventListener('ins_insider_id_listener', function (event) {
662
- if (event.insiderID) {
663
- insiderIDCallback(event.insiderID);
664
- }
665
- }, false);
666
- } catch (error) {
667
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
668
- }
669
- });
670
- _defineProperty(this, "disableInAppMessages", function () {
671
- try {
672
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.DISABLE_IN_APP_MESSAGES, []);
673
- } catch (error) {
674
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
675
- }
676
- });
677
- _defineProperty(this, "enableInAppMessages", function () {
678
- try {
679
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_IN_APP_MESSAGES, []);
680
- } catch (error) {
681
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
682
- }
683
- });
684
- _defineProperty(this, "itemAddedToWishlist", function (product) {
685
- if (Utils.checkParameters([{
686
- type: 'object',
687
- value: product
688
- }])) {
689
- Utils.showParameterWarningLog(_this.constructor.name + '-itemAddedToWishlist');
690
- return;
691
- }
692
- try {
693
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_ADDED_TO_WISHLIST, [product.productMustMap, product.productOptMap]);
694
- } catch (error) {
695
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
696
- }
697
- });
698
- _defineProperty(this, "itemRemovedFromWishlist", function (productID) {
699
- if (Utils.checkParameters([{
700
- type: 'string',
701
- value: productID
702
- }])) {
703
- Utils.showParameterWarningLog(_this.constructor.name + '-itemRemovedFromWishlist');
704
- return;
705
- }
706
- try {
707
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_REMOVED_FROM_WISHLIST, [productID]);
708
- } catch (error) {
709
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
710
- }
711
- });
712
- _defineProperty(this, "wishlistCleared", function () {
713
- try {
714
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.WISHLIST_CLEARED, []);
715
- } catch (error) {
716
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
717
- }
718
- });
719
- _defineProperty(this, "visitWishlistPage", function (products) {
720
- if (Utils.checkParameters([{
721
- type: 'object',
722
- value: products
723
- }])) {
724
- Utils.showParameterWarningLog(_this.constructor.name + '-visitWishlistPage');
725
- return;
726
- }
727
- try {
728
- var productMap = {};
729
- var mappedProducts = new Array(products.length);
730
- products.forEach(function (product, i) {
731
- productMap['productMustMap'] = product.productMustMap;
732
- productMap['productOptMap'] = product.productOptMap;
733
- mappedProducts[i] = productMap;
734
- });
735
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_WISHLIST_PAGE, [mappedProducts]);
736
- } catch (error) {
737
- Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
738
- }
739
- });
740
- this.insiderUser = new InsiderUser();
741
- });
742
- module.exports = new InsiderPlugin();