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.
@@ -15,10 +15,12 @@ import android.os.Looper;
15
15
  import com.fasterxml.jackson.databind.ObjectMapper;
16
16
  import com.google.firebase.messaging.RemoteMessage;
17
17
  import com.huawei.hms.push.HmsMessageService;
18
+ import com.useinsider.insider.CloseButtonPosition;
18
19
  import com.useinsider.insider.ContentOptimizerDataType;
19
20
  import com.useinsider.insider.Insider;
20
21
  import com.useinsider.insider.InsiderCallback;
21
22
  import com.useinsider.insider.InsiderCallbackType;
23
+ import com.useinsider.insider.InsiderEvent;
22
24
  import com.useinsider.insider.InsiderIdentifiers;
23
25
  import com.useinsider.insider.InsiderProduct;
24
26
  import com.useinsider.insider.InsiderUser;
@@ -187,19 +189,20 @@ public class InsiderPlugin extends CordovaPlugin {
187
189
  } else if (action.equals("removeInapp")) {
188
190
  Insider.Instance.removeInapp(this.cordova.getActivity());
189
191
  } else if (action.equals(InsiderHybridMethods.ITEM_PURCHASED)) {
190
- if (args.get(0) == null || args.getString(1) == null || args.getString(2) == null)
192
+ if (args.get(0) == null || args.getString(1) == null || args.getString(2) == null || args.get(3) == null)
191
193
  return false;
192
194
  cordova.getThreadPool().execute(new Runnable() {
193
195
  @Override
194
196
  public void run() {
195
- Map<String, Object> mustMap = null;
196
- Map<String, Object> optMap = null;
197
+ Map<String, Object> requiredFields = null;
198
+ Map<String, Object> optionalFields = null;
199
+ JSONArray customParameters = null;
197
200
  try {
198
- mustMap = CDVUtils.convertJSONToMap(args.getString(1));
199
- optMap = CDVUtils.convertJSONToMap(args.getString(2));
201
+ requiredFields = CDVUtils.convertJSONToMap(args.getString(1));
202
+ optionalFields = CDVUtils.convertJSONToMap(args.getString(2));
203
+ customParameters = args.getJSONArray(3);
200
204
 
201
- isProductValid(mustMap);
202
- InsiderProduct product = createProduct(mustMap, optMap);
205
+ InsiderProduct product = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
203
206
 
204
207
  Insider.Instance.itemPurchased(String.valueOf(args.get(0)), product);
205
208
  callbackSuccess(callbackContext, "SUCCESS");
@@ -209,18 +212,23 @@ public class InsiderPlugin extends CordovaPlugin {
209
212
  }
210
213
  });
211
214
  } else if (action.equals(InsiderHybridMethods.ITEM_ADDED_TO_CART)) {
212
- if (args.get(0) == null || args.getString(1) == null)
215
+ if (args.get(0) == null || args.getString(1) == null || args.get(2) == null)
213
216
  return false;
214
217
 
215
- Map<String, Object> mustMap = CDVUtils.convertJSONToMap(args.getString(0));
216
- Map<String, Object> optMap = CDVUtils.convertJSONToMap(args.getString(1));
218
+ Map<String, Object> requiredFields = CDVUtils.convertJSONToMap(args.getString(0));
219
+ Map<String, Object> optionalFields = CDVUtils.convertJSONToMap(args.getString(1));
220
+ JSONArray customParameters = args.getJSONArray(2);
217
221
 
218
222
  cordova.getThreadPool().execute(new Runnable() {
219
223
  @Override
220
224
  public void run() {
221
- InsiderProduct product = createProduct(mustMap, optMap);
222
- Insider.Instance.itemAddedToCart(product);
223
- callbackSuccess(callbackContext, "SUCCESS");
225
+ try {
226
+ InsiderProduct product = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
227
+ Insider.Instance.itemAddedToCart(product);
228
+ callbackSuccess(callbackContext, "SUCCESS");
229
+ } catch (Exception e) {
230
+ callbackFailure(callbackContext, e.toString());
231
+ }
224
232
  }
225
233
  });
226
234
  } else if (action.equals(InsiderHybridMethods.ITEM_REMOVED_FROM_CART)) {
@@ -287,20 +295,21 @@ public class InsiderPlugin extends CordovaPlugin {
287
295
  }
288
296
  });
289
297
  } else if (action.equals(InsiderHybridMethods.GET_SMART_RECOMMENDATION_WITH_PRODUCT)) {
290
- if (args.get(0) == null || args.get(1) == null || args.get(2) == null || args.get(3) == null)
298
+ if (args.get(0) == null || args.get(1) == null || args.get(2) == null || args.get(3) == null || args.get(4) == null)
291
299
  return false;
292
300
 
293
301
  cordova.getThreadPool().execute(new Runnable() {
294
302
  @Override
295
303
  public void run() {
296
304
  try {
297
- Map<String, Object> mustMap = CDVUtils.convertJSONToMap(args.getString(0));
298
- Map<String, Object> optMap = CDVUtils.convertJSONToMap(args.getString(1));
305
+ Map<String, Object> requiredFields = CDVUtils.convertJSONToMap(args.getString(0));
306
+ Map<String, Object> optionalFields = CDVUtils.convertJSONToMap(args.getString(1));
307
+ JSONArray customParameters = args.getJSONArray(2);
299
308
 
300
- InsiderProduct product = createProduct(mustMap, optMap);
309
+ InsiderProduct product = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
301
310
  Insider.Instance.getSmartRecommendationWithProduct(product,
302
- args.getInt(2),
303
- args.getString(3),
311
+ args.getInt(3),
312
+ args.getString(4),
304
313
  new RecommendationEngine.SmartRecommendation() {
305
314
  @Override
306
315
  public void loadRecommendationData(JSONObject jsonObject) {
@@ -340,17 +349,18 @@ public class InsiderPlugin extends CordovaPlugin {
340
349
  }
341
350
  });
342
351
  } else if (action.equals(InsiderHybridMethods.CLICK_SMART_RECOMMENDATION_PRODUCT)) {
343
- if (args.get(0) == null || args.get(1) == null || args.get(2) == null)
352
+ if (args.get(0) == null || args.get(1) == null || args.get(2) == null || args.get(3) == null)
344
353
  return false;
345
354
 
346
355
  cordova.getThreadPool().execute(new Runnable() {
347
356
  @Override
348
357
  public void run() {
349
358
  try {
350
- Map<String, Object> mustMap = CDVUtils.convertJSONToMap(args.getString(0));
351
- Map<String, Object> optMap = CDVUtils.convertJSONToMap(args.getString(1));
352
- InsiderProduct recommendationLogProduct = createProduct(mustMap, optMap);
353
- Insider.Instance.clickSmartRecommendationProduct(args.getInt(2),recommendationLogProduct);
359
+ Map<String, Object> requiredFields = CDVUtils.convertJSONToMap(args.getString(0));
360
+ Map<String, Object> optionalFields = CDVUtils.convertJSONToMap(args.getString(1));
361
+ JSONArray customParameters = args.getJSONArray(2);
362
+ InsiderProduct recommendationLogProduct = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
363
+ Insider.Instance.clickSmartRecommendationProduct(args.getInt(3),recommendationLogProduct);
354
364
  callbackSuccess(callbackContext, "{SUCCESS}");
355
365
  } catch (JSONException e) {
356
366
  callbackFailure(callbackContext, "ERROR:" + e.toString());
@@ -366,9 +376,13 @@ public class InsiderPlugin extends CordovaPlugin {
366
376
  @Override
367
377
  public void run() {
368
378
  try {
369
- Map<String, Object> parameters = CDVUtils.convertJSONToMap(args.getString(1));
370
- InsiderHybrid.tagEvent(args.getString(0), parameters);
371
-
379
+ String eventName = args.getString(0);
380
+ JSONArray parametersArray = args.getJSONArray(1);
381
+
382
+ InsiderEvent event = CDVUtils.parseEvent(eventName, parametersArray);
383
+ if (event != null) {
384
+ event.build();
385
+ }
372
386
  callbackSuccess(callbackContext, "{SUCCESS}");
373
387
  } catch (JSONException e) {
374
388
  Insider.Instance.putException(e);
@@ -400,18 +414,23 @@ public class InsiderPlugin extends CordovaPlugin {
400
414
  }
401
415
  });
402
416
  } else if (action.equals(InsiderHybridMethods.VISIT_PRODUCT_DETAIL_PAGE)) {
403
- if (args.get(0) == null || args.get(1) == null)
417
+ if (args.get(0) == null || args.get(1) == null || args.get(2) == null)
404
418
  return false;
405
419
 
406
- Map<String, Object> mustMap = CDVUtils.convertJSONToMap(args.getString(0));
407
- Map<String, Object> optMap = CDVUtils.convertJSONToMap(args.getString(1));
420
+ Map<String, Object> requiredFields = CDVUtils.convertJSONToMap(args.getString(0));
421
+ Map<String, Object> optionalFields = CDVUtils.convertJSONToMap(args.getString(1));
422
+ JSONArray customParameters = args.getJSONArray(2);
408
423
 
409
424
  cordova.getThreadPool().execute(new Runnable() {
410
425
  @Override
411
426
  public void run() {
412
- InsiderProduct recommendationProduct = createProduct(mustMap, optMap);
413
- Insider.Instance.visitProductDetailPage(recommendationProduct);
414
- callbackSuccess(callbackContext, "SUCCESS");
427
+ try {
428
+ InsiderProduct recommendationProduct = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
429
+ Insider.Instance.visitProductDetailPage(recommendationProduct);
430
+ callbackSuccess(callbackContext, "SUCCESS");
431
+ } catch (Exception e) {
432
+ callbackFailure(callbackContext, e.toString());
433
+ }
415
434
  }
416
435
  });
417
436
  } else if (action.equals(InsiderHybridMethods.VISIT_CART_PAGE)) {
@@ -425,15 +444,24 @@ public class InsiderPlugin extends CordovaPlugin {
425
444
  cordova.getThreadPool().execute(new Runnable() {
426
445
  @Override
427
446
  public void run() {
428
- for (int i = 0; i < products.size(); i++) {
429
- HashMap mustMap = (HashMap)(((LinkedHashMap)products.get(i)).get("productMustMap"));
430
- HashMap optMap = (HashMap)(((LinkedHashMap)products.get(i)).get("productOptMap"));
431
- InsiderProduct product = createProduct(mustMap, optMap);
432
- ips[i] = product;
433
- }
447
+ try {
448
+ for (int i = 0; i < products.size(); i++) {
449
+ HashMap requiredFields = (HashMap)(((LinkedHashMap)products.get(i)).get("requiredFields"));
450
+ HashMap optionalFields = (HashMap)(((LinkedHashMap)products.get(i)).get("optionalFields"));
451
+ JSONArray customParameters = null;
452
+ Object customParamsObj = ((LinkedHashMap)products.get(i)).get("customParameters");
453
+ if (customParamsObj != null) {
454
+ customParameters = new JSONArray(customParamsObj.toString());
455
+ }
456
+ InsiderProduct product = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
457
+ ips[i] = product;
458
+ }
434
459
 
435
- Insider.Instance.visitCartPage(ips);
436
- callbackSuccess(callbackContext, "SUCCESS");
460
+ Insider.Instance.visitCartPage(ips);
461
+ callbackSuccess(callbackContext, "SUCCESS");
462
+ } catch (Exception e) {
463
+ callbackFailure(callbackContext, e.toString());
464
+ }
437
465
  }
438
466
  });
439
467
  } else if (action.equals(InsiderHybridMethods.SET_GENDER)) {
@@ -445,7 +473,11 @@ public class InsiderPlugin extends CordovaPlugin {
445
473
  if (args.get(0) == null)
446
474
  return false;
447
475
 
448
- InsiderHybrid.setBirthday(args.getString(0));
476
+ // value is epoch milliseconds as string
477
+ String epochString = args.getString(0);
478
+ long birthdayEpoch = Long.parseLong(epochString);
479
+ Date birthdayDate = new Date(birthdayEpoch);
480
+ Insider.Instance.getCurrentUser().setBirthday(birthdayDate);
449
481
  } else if (action.equals(InsiderHybridMethods.SET_NAME)) {
450
482
  if (args.get(0) == null)
451
483
  return false;
@@ -529,7 +561,12 @@ public class InsiderPlugin extends CordovaPlugin {
529
561
  } else if (action.equals(InsiderHybridMethods.SET_CUSTOM_ATTRIBUTE_WITH_DATE)) {
530
562
  if (args.get(0) == null || args.get(1) == null)
531
563
  return false;
532
- InsiderHybrid.setCustomAttributeWithDate(args.getString(0), args.getString(1));
564
+ // value is epoch milliseconds as string
565
+ String epochString = args.getString(1);
566
+ long dateEpoch = Long.parseLong(epochString);
567
+ Date dateValue = new Date(dateEpoch);
568
+
569
+ Insider.Instance.getCurrentUser().setCustomAttributeWithDate(args.getString(0), dateValue);
533
570
  } else if (action.equals(InsiderHybridMethods.SET_CUSTOM_ATTRIBUTE_WITH_ARRAY)) {
534
571
  if (args.get(0) == null || args.get(1) == null)
535
572
  return false;
@@ -701,6 +738,18 @@ public class InsiderPlugin extends CordovaPlugin {
701
738
  return true;
702
739
  } else if (action.equals("signUpConfirmation")) {
703
740
  Insider.Instance.signUpConfirmation();
741
+ } else if (action.equals(Constants.SET_INTERNAL_BROWSER_CLOSE_BUTTON_POSITION)) {
742
+ if (args.get(0) == null)
743
+ return false;
744
+
745
+ try {
746
+ String position = args.getString(0);
747
+ CloseButtonPosition enumPosition = CloseButtonPosition.valueOf(position);
748
+ Insider.Instance.setInternalBrowserCloseButtonPosition(enumPosition);
749
+ } catch (Exception e) {
750
+ Insider.Instance.putException(e);
751
+ }
752
+ return true;
704
753
  } else if (action.equals("setPushToken")) {
705
754
  Insider.Instance.setPushToken(args.getString(0));
706
755
  } else if (action.equals("setEmail")) {
@@ -754,18 +803,23 @@ public class InsiderPlugin extends CordovaPlugin {
754
803
  }
755
804
  });
756
805
  } else if (action.equals("itemAddedToWishlist")) {
757
- if (args.get(0) == null || args.getString(1) == null)
806
+ if (args.get(0) == null || args.getString(1) == null || args.get(2) == null)
758
807
  return false;
759
808
 
760
- Map<String, Object> mustMap = CDVUtils.convertJSONToMap(args.getString(0));
761
- Map<String, Object> optMap = CDVUtils.convertJSONToMap(args.getString(1));
809
+ Map<String, Object> requiredFields = CDVUtils.convertJSONToMap(args.getString(0));
810
+ Map<String, Object> optionalFields = CDVUtils.convertJSONToMap(args.getString(1));
811
+ JSONArray customParameters = args.getJSONArray(2);
762
812
 
763
813
  cordova.getThreadPool().execute(new Runnable() {
764
814
  @Override
765
815
  public void run() {
766
- InsiderProduct product = createProduct(mustMap, optMap);
767
- Insider.Instance.itemAddedToWishlist(product);
768
- callbackSuccess(callbackContext, "SUCCESS");
816
+ try {
817
+ InsiderProduct product = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
818
+ Insider.Instance.itemAddedToWishlist(product);
819
+ callbackSuccess(callbackContext, "SUCCESS");
820
+ } catch (Exception e) {
821
+ callbackFailure(callbackContext, e.toString());
822
+ }
769
823
  }
770
824
  });
771
825
  } else if (action.equals("itemRemovedFromWishlist")) {
@@ -802,15 +856,24 @@ public class InsiderPlugin extends CordovaPlugin {
802
856
  cordova.getThreadPool().execute(new Runnable() {
803
857
  @Override
804
858
  public void run() {
805
- for (int i = 0; i < products.size(); i++) {
806
- HashMap mustMap = (HashMap)(((LinkedHashMap)products.get(i)).get("productMustMap"));
807
- HashMap optMap = (HashMap)(((LinkedHashMap)products.get(i)).get("productOptMap"));
808
- InsiderProduct product = createProduct(mustMap, optMap);
809
- ips[i] = product;
810
- }
859
+ try {
860
+ for (int i = 0; i < products.size(); i++) {
861
+ HashMap requiredFields = (HashMap)(((LinkedHashMap)products.get(i)).get("requiredFields"));
862
+ HashMap optionalFields = (HashMap)(((LinkedHashMap)products.get(i)).get("optionalFields"));
863
+ JSONArray customParameters = null;
864
+ Object customParamsObj = ((LinkedHashMap)products.get(i)).get("customParameters");
865
+ if (customParamsObj != null) {
866
+ customParameters = new JSONArray(customParamsObj.toString());
867
+ }
868
+ InsiderProduct product = CDVUtils.parseProduct(requiredFields, optionalFields, customParameters);
869
+ ips[i] = product;
870
+ }
811
871
 
812
- Insider.Instance.visitWishlistPage(ips);
813
- callbackSuccess(callbackContext, "SUCCESS");
872
+ Insider.Instance.visitWishlistPage(ips);
873
+ callbackSuccess(callbackContext, "SUCCESS");
874
+ } catch (Exception e) {
875
+ callbackFailure(callbackContext, e.toString());
876
+ }
814
877
  }
815
878
  });
816
879
  } else {
@@ -894,195 +957,44 @@ public class InsiderPlugin extends CordovaPlugin {
894
957
  }
895
958
  }
896
959
 
897
- private static boolean isProductValid(Map<String, Object> productMustMap) {
898
- return productMustMap.containsKey(Constants.PRODUCT_ID)
899
- && productMustMap.containsKey(Constants.NAME)
900
- && productMustMap.containsKey(Constants.TAXONOMY)
901
- && productMustMap.containsKey(Constants.IMAGE_URL)
902
- && productMustMap.containsKey(Constants.UNIT_PRICE)
903
- && productMustMap.containsKey(Constants.CURRENCY);
904
- }
905
960
 
906
- public static InsiderProduct createProduct(Map<String, Object> productMustMap, Map<String, Object> productOptMap) {
961
+ private InsiderIdentifiers[] convertJSONArrayToInsiderIdentifiersArray(JSONArray identifiersArray) {
907
962
  try {
908
- if (!isProductValid(productMustMap)) return null;
909
-
910
- String[] taxonomy;
911
-
912
- Object taxObject = productMustMap.get(Constants.TAXONOMY);
913
-
914
- if (taxObject.getClass().isArray()) {
915
- taxonomy = (String[]) taxObject;
916
- } else {
917
- taxonomy = ((ArrayList<String>) taxObject).toArray(new String[0]);
918
- }
919
-
920
- double price=0;
921
- if(productMustMap.get(Constants.UNIT_PRICE) instanceof Integer ){
922
- price = Integer.valueOf((Integer) productMustMap.get(Constants.UNIT_PRICE)).doubleValue();
963
+ if (identifiersArray == null || identifiersArray.length() == 0) {
964
+ return null;
923
965
  }
924
- else{
925
- price = (double) productMustMap.get(Constants.UNIT_PRICE);
926
- }
927
-
928
- InsiderProduct product = Insider.Instance.createNewProduct(
929
- (String) productMustMap.get(Constants.PRODUCT_ID),
930
- (String) productMustMap.get(Constants.NAME),
931
- taxonomy,
932
- (String) productMustMap.get(Constants.IMAGE_URL),
933
- price,
934
- (String) productMustMap.get(Constants.CURRENCY)
935
- );
936
-
937
- if (productOptMap == null || productOptMap.size() == 0) return product;
938
-
939
- Map<String, Object> validatedMap = InsiderHybridUtils.validateMap(productOptMap);
940
-
941
- for (Map.Entry<String, Object> entry : validatedMap.entrySet()) {
942
- Object value = entry.getValue();
943
- switch (entry.getKey()) {
944
- case Constants.SALE_PRICE:
945
- product.setSalePrice((double) value);
946
- break;
947
- case Constants.STOCK:
948
- product.setStock(((int) value));
949
- break;
950
- case Constants.COLOR:
951
- product.setColor((String) value);
952
- break;
953
- case Constants.SIZE:
954
- product.setSize((String) value);
955
- break;
956
- case Constants.QUANTITY:
957
- product.setQuantity(((int) value));
958
- break;
959
- case Constants.SHIPPING_COST:
960
- product.setShippingCost((double) value);
961
- break;
962
- case Constants.VOUCHER_NAME:
963
- product.setVoucherName((String) value);
964
- break;
965
- case Constants.VOUCHER_DISCOUNT:
966
- product.setVoucherDiscount((double) value);
967
- break;
968
- case Constants.PROMOTION_NAME:
969
- product.setPromotionName((String) value);
970
- break;
971
- case Constants.PROMOTION_DISCOUNT:
972
- product.setPromotionDiscount((double) value);
973
- break;
974
- case Constants.GROUP_CODE:
975
- product.setGroupCode((String) value);
976
- break;
977
- case Constants.BRAND:
978
- product.setBrand((String) value);
979
- break;
980
- case Constants.SKU:
981
- product.setSku((String) value);
982
- break;
983
- case Constants.PRODUCT_GENDER:
984
- product.setGender((String) value);
985
- break;
986
- case Constants.MULTIPACK:
987
- product.setMultipack((String) value);
988
- break;
989
- case Constants.PRODUCT_TYPE:
990
- product.setProductType((String) value);
991
- break;
992
- case Constants.GTIN:
993
- product.setGtin((String) value);
994
- break;
995
- case Constants.DESCRIPTION:
996
- product.setDescription((String) value);
997
- break;
998
- case Constants.TAGS:
999
- String[] tags;
1000
-
1001
- if (value.getClass().isArray()) {
1002
- tags = (String[]) value;
1003
- } else {
1004
- tags = ((ArrayList<String>) value).toArray(new String[0]);
1005
- }
1006
-
1007
- product.setTags(tags);
1008
- break;
1009
- case Constants.IS_IN_STOCK:
1010
- product.setInStock((boolean) value);
1011
- break;
1012
- default:
1013
- setProductCustomAttribute(product, entry.getKey(), value);
1014
- break;
966
+
967
+ InsiderIdentifiers[] identifiers = new InsiderIdentifiers[identifiersArray.length()];
968
+
969
+ for (int i = 0; i < identifiersArray.length(); i++) {
970
+ JSONObject identifierMap = identifiersArray.getJSONObject(i);
971
+ InsiderIdentifiers insiderIdentifiers = new InsiderIdentifiers();
972
+
973
+ Map<String, Object> identifierData = CDVUtils.convertJSONToMap(identifierMap.toString());
974
+ for (String key : identifierData.keySet()) {
975
+ switch (key) {
976
+ case InsiderHybridMethods.ADD_EMAIL:
977
+ insiderIdentifiers.addEmail(String.valueOf(identifierData.get(key)));
978
+ break;
979
+ case InsiderHybridMethods.ADD_PHONE_NUMBER:
980
+ insiderIdentifiers.addPhoneNumber(String.valueOf(identifierData.get(key)));
981
+ break;
982
+ case InsiderHybridMethods.ADD_USER_ID:
983
+ insiderIdentifiers.addUserID(String.valueOf(identifierData.get(key)));
984
+ break;
985
+ default:
986
+ insiderIdentifiers.addCustomIdentifier(key, String.valueOf(identifierData.get(key)));
987
+ break;
988
+ }
1015
989
  }
990
+ identifiers[i] = insiderIdentifiers;
1016
991
  }
1017
- return product;
992
+
993
+ return identifiers;
1018
994
  } catch (Exception e) {
1019
995
  Insider.Instance.putException(e);
1020
996
  }
1021
- return null;
1022
- }
1023
997
 
1024
- private static void setProductCustomAttribute(InsiderProduct product, String key, Object value) {
1025
- try {
1026
- if (key == null || key.length() == 0 || value == null) return;
1027
- switch (value.getClass().getSimpleName()) {
1028
- case "String":
1029
- product.setCustomAttributeWithString(key, (String) value);
1030
- break;
1031
- case "Double":
1032
- product.setCustomAttributeWithDouble(key, (double) value);
1033
- break;
1034
- case "Integer":
1035
- product.setCustomAttributeWithInt(key, (int) value);
1036
- break;
1037
- case "Boolean":
1038
- product.setCustomAttributeWithBoolean(key, (boolean) value);
1039
- break;
1040
- case "Date":
1041
- product.setCustomAttributeWithDate(key, (Date) value);
1042
- break;
1043
- case "String[]":
1044
- product.setCustomAttributeWithStringArray(key, (String[]) value);
1045
- break;
1046
- case "Number[]":
1047
- product.setCustomAttributeWithNumericArray(key, (Number[]) value);
1048
- break;
1049
- default:
1050
- break;
1051
- }
1052
- } catch (Exception e) {
1053
- Insider.Instance.putException(e);
1054
- }
1055
- }
1056
-
1057
- private InsiderIdentifiers[] convertJSONArrayToInsiderIdentifiersArray(JSONArray identifiersArray) throws JSONException {
1058
- if (identifiersArray == null || identifiersArray.length() == 0) {
1059
- return null;
1060
- }
1061
-
1062
- InsiderIdentifiers[] identifiers = new InsiderIdentifiers[identifiersArray.length()];
1063
- for (int i = 0; i < identifiersArray.length(); i++) {
1064
- JSONObject identifierMap = identifiersArray.getJSONObject(i);
1065
- InsiderIdentifiers insiderIdentifiers = new InsiderIdentifiers();
1066
-
1067
- Map<String, Object> identifierData = CDVUtils.convertJSONToMap(identifierMap.toString());
1068
- for (String key : identifierData.keySet()) {
1069
- switch (key) {
1070
- case InsiderHybridMethods.ADD_EMAIL:
1071
- insiderIdentifiers.addEmail(String.valueOf(identifierData.get(key)));
1072
- break;
1073
- case InsiderHybridMethods.ADD_PHONE_NUMBER:
1074
- insiderIdentifiers.addPhoneNumber(String.valueOf(identifierData.get(key)));
1075
- break;
1076
- case InsiderHybridMethods.ADD_USER_ID:
1077
- insiderIdentifiers.addUserID(String.valueOf(identifierData.get(key)));
1078
- break;
1079
- default:
1080
- insiderIdentifiers.addCustomIdentifier(key, String.valueOf(identifierData.get(key)));
1081
- break;
1082
- }
1083
- }
1084
- identifiers[i] = insiderIdentifiers;
1085
- }
1086
- return identifiers;
998
+ return null;
1087
999
  }
1088
1000
  }
@@ -16,7 +16,7 @@ android {
16
16
  }
17
17
 
18
18
  dependencies {
19
- implementation 'com.useinsider:insider:15.2.1'
19
+ implementation 'com.useinsider:insider:15.2.2'
20
20
  implementation 'com.useinsider:insiderhybrid:1.3.4'
21
21
 
22
22
  implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4'
@@ -0,0 +1,14 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <InsiderMobile/Insider.h>
3
+ #import <InsiderHybrid/InsiderHybrid.h>
4
+
5
+ @interface CDVUtils : NSObject
6
+
7
+ + (InsiderEvent *)parseEventFromEventName:(NSString *)eventName andParameters:(NSArray *)parameters;
8
+
9
+ + (InsiderProduct *)parseProductFromRequiredFields:(NSDictionary *)requiredFields
10
+ andOptionalFields:(NSDictionary *)optionalFields
11
+ andCustomParameters:(NSArray *)customParameters;
12
+
13
+ @end
14
+