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