Panagiotis Triantafyllou

revert session impl, crash fixes

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4.6rc40' 5 + PUBLISH_VERSION = '4.5.4.6rc41'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -119,7 +119,7 @@ public class DiskBasedCache implements Cache { ...@@ -119,7 +119,7 @@ public class DiskBasedCache implements Cache {
119 byte[] data = streamToBytes(cis, (int) Math.abs((int)(file.length() - cis.bytesRead))); 119 byte[] data = streamToBytes(cis, (int) Math.abs((int)(file.length() - cis.bytesRead)));
120 // byte[] data = readAllBytes(cis); 120 // byte[] data = readAllBytes(cis);
121 return entry.toCacheEntry(data); 121 return entry.toCacheEntry(data);
122 - } catch (IOException e) { 122 + } catch (IOException | NegativeArraySizeException e) {
123 VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString()); 123 VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString());
124 remove(key); 124 remove(key);
125 return null; 125 return null;
...@@ -315,11 +315,11 @@ public class DiskBasedCache implements Cache { ...@@ -315,11 +315,11 @@ public class DiskBasedCache implements Cache {
315 /** 315 /**
316 * Reads the contents of an InputStream into a byte[]. 316 * Reads the contents of an InputStream into a byte[].
317 * */ 317 * */
318 - private static byte[] streamToBytes(InputStream in, int length) throws IOException { 318 + private static byte[] streamToBytes(InputStream in, int length) throws IOException, NegativeArraySizeException {
319 byte[] bytes = new byte[1]; 319 byte[] bytes = new byte[1];
320 try { 320 try {
321 bytes = IOUtils.toByteArray(in); 321 bytes = IOUtils.toByteArray(in);
322 - } catch (OutOfMemoryError e) { 322 + } catch (OutOfMemoryError | NegativeArraySizeException e) {
323 e.printStackTrace(); 323 e.printStackTrace();
324 } 324 }
325 int count; 325 int count;
......
...@@ -63,7 +63,7 @@ public class WarplyProperty { ...@@ -63,7 +63,7 @@ public class WarplyProperty {
63 Properties properties = new Properties(); 63 Properties properties = new Properties();
64 properties.load(context.getResources().getAssets().open(PROPERTIES_FILE)); 64 properties.load(context.getResources().getAssets().open(PROPERTIES_FILE));
65 return properties.getProperty(propertyKey); 65 return properties.getProperty(propertyKey);
66 - } catch (IOException e) { 66 + } catch (IOException | NullPointerException e) {
67 WarpUtils.log(e.getMessage()); 67 WarpUtils.log(e.getMessage());
68 return ""; 68 return "";
69 } 69 }
......
...@@ -87,7 +87,6 @@ import ly.warp.sdk.io.models.CouponList; ...@@ -87,7 +87,6 @@ import ly.warp.sdk.io.models.CouponList;
87 import ly.warp.sdk.io.models.Couponset; 87 import ly.warp.sdk.io.models.Couponset;
88 import ly.warp.sdk.io.models.CouponsetsList; 88 import ly.warp.sdk.io.models.CouponsetsList;
89 import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel; 89 import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel;
90 -import ly.warp.sdk.io.models.LoyaltySDKSessionExpiredEventModel;
91 import ly.warp.sdk.io.models.Merchant; 90 import ly.warp.sdk.io.models.Merchant;
92 import ly.warp.sdk.io.models.MerchantCategoriesList; 91 import ly.warp.sdk.io.models.MerchantCategoriesList;
93 import ly.warp.sdk.io.models.MerchantList; 92 import ly.warp.sdk.io.models.MerchantList;
...@@ -544,31 +543,21 @@ public class WarplyManager { ...@@ -544,31 +543,21 @@ public class WarplyManager {
544 @Override 543 @Override
545 public void onFailure(int errorCode) { 544 public void onFailure(int errorCode) {
546 if (errorCode == 401) { 545 if (errorCode == 401) {
547 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 546 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
548 -// @Override 547 + @Override
549 -// public void onSuccess(JSONObject result) { 548 + public void onSuccess(JSONObject result) {
550 -// int status = result.optInt("status", 2); 549 + int status = result.optInt("status", 2);
551 -// if (status == 1) 550 + if (status == 1)
552 -// getConsumer(request, receiver); 551 + getConsumer(request, receiver);
553 -// else 552 + else
554 -// receiver.onFailure(status); 553 + receiver.onFailure(status);
555 -// } 554 + }
556 -//
557 -// @Override
558 -// public void onFailure(int errorCode) {
559 -// receiver.onFailure(errorCode);
560 -// }
561 -// });
562 -
563 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
564 - sessionExpired.setLoyaltySessionExpired(true);
565 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
566 -
567 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
568 - dynatraceEvent.setEventName("custom_error_profile_loyalty");
569 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
570 555
556 + @Override
557 + public void onFailure(int errorCode) {
571 receiver.onFailure(errorCode); 558 receiver.onFailure(errorCode);
559 + }
560 + });
572 } else { 561 } else {
573 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 562 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
574 dynatraceEvent.setEventName("custom_error_profile_loyalty"); 563 dynatraceEvent.setEventName("custom_error_profile_loyalty");
...@@ -592,19 +581,6 @@ public class WarplyManager { ...@@ -592,19 +581,6 @@ public class WarplyManager {
592 WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteAuth(); 581 WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteAuth();
593 WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteClient(); 582 WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteClient();
594 583
595 - try {
596 - WarpUtils.log("=================== TOKEN DELETED =========================");
597 - WarpUtils.log("Auth Table Not Empty: " + String.valueOf(WarplyDBHelper.getInstance(Warply.getWarplyContext()).isTableNotEmpty("auth")));
598 - WarpUtils.log("Bearer: " + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token"));
599 - WarpUtils.log("=================== TOKEN DELETED =========================");
600 - } catch (Exception e) {
601 - e.printStackTrace();
602 - WarpUtils.log("=================== TOKEN DELETED =========================");
603 - WarpUtils.log("Auth Table Not Empty: false");
604 - WarpUtils.log("Bearer: ");
605 - WarpUtils.log("=================== TOKEN DELETED =========================");
606 - }
607 -
608 JSONObject newResult = new JSONObject(); 584 JSONObject newResult = new JSONObject();
609 try { 585 try {
610 newResult.putOpt("status", 1); 586 newResult.putOpt("status", 1);
...@@ -999,30 +975,21 @@ public class WarplyManager { ...@@ -999,30 +975,21 @@ public class WarplyManager {
999 @Override 975 @Override
1000 public void onFailure(int errorCode) { 976 public void onFailure(int errorCode) {
1001 if (errorCode == 401) { 977 if (errorCode == 401) {
1002 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 978 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1003 -// @Override 979 + @Override
1004 -// public void onSuccess(JSONObject result) { 980 + public void onSuccess(JSONObject result) {
1005 -// int status = result.optInt("status", 2); 981 + int status = result.optInt("status", 2);
1006 -// if (status == 1) 982 + if (status == 1)
1007 -// getUserCoupons(request, receiver); 983 + getUserCoupons(request, receiver);
1008 -// else 984 + else
1009 -// receiver.onFailure(status); 985 + receiver.onFailure(status);
1010 -// } 986 + }
1011 -//
1012 -// @Override
1013 -// public void onFailure(int errorCode) {
1014 -// receiver.onFailure(errorCode);
1015 -// }
1016 -// });
1017 -
1018 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1019 - sessionExpired.setLoyaltySessionExpired(true);
1020 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1021 987
1022 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 988 + @Override
1023 - dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); 989 + public void onFailure(int errorCode) {
1024 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1025 receiver.onFailure(errorCode); 990 receiver.onFailure(errorCode);
991 + }
992 + });
1026 } else { 993 } else {
1027 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 994 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1028 dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); 995 dynatraceEvent.setEventName("custom_error_user_coupons_loyalty");
...@@ -1454,30 +1421,21 @@ public class WarplyManager { ...@@ -1454,30 +1421,21 @@ public class WarplyManager {
1454 @Override 1421 @Override
1455 public void onFailure(int errorCode) { 1422 public void onFailure(int errorCode) {
1456 if (errorCode == 401) { 1423 if (errorCode == 401) {
1457 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1424 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1458 -// @Override 1425 + @Override
1459 -// public void onSuccess(JSONObject result) { 1426 + public void onSuccess(JSONObject result) {
1460 -// int status = result.optInt("status", 2); 1427 + int status = result.optInt("status", 2);
1461 -// if (status == 1) 1428 + if (status == 1)
1462 -// redeemCoupon(request, receiver); 1429 + redeemCoupon(request, receiver);
1463 -// else 1430 + else
1464 -// receiver.onFailure(status); 1431 + receiver.onFailure(status);
1465 -// } 1432 + }
1466 -//
1467 -// @Override
1468 -// public void onFailure(int errorCode) {
1469 -// receiver.onFailure(errorCode);
1470 -// }
1471 -// });
1472 -
1473 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1474 - sessionExpired.setLoyaltySessionExpired(true);
1475 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1476 1433
1477 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1434 + @Override
1478 - dynatraceEvent.setEventName("custom_error_retrieve_coupon_loyalty"); 1435 + public void onFailure(int errorCode) {
1479 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1480 receiver.onFailure(errorCode); 1436 receiver.onFailure(errorCode);
1437 + }
1438 + });
1481 } else { 1439 } else {
1482 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1440 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1483 dynatraceEvent.setEventName("custom_error_retrieve_coupon_loyalty"); 1441 dynatraceEvent.setEventName("custom_error_retrieve_coupon_loyalty");
...@@ -1652,30 +1610,21 @@ public class WarplyManager { ...@@ -1652,30 +1610,21 @@ public class WarplyManager {
1652 @Override 1610 @Override
1653 public void onFailure(int errorCode) { 1611 public void onFailure(int errorCode) {
1654 if (errorCode == 401) { 1612 if (errorCode == 401) {
1655 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1613 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1656 -// @Override 1614 + @Override
1657 -// public void onSuccess(JSONObject result) { 1615 + public void onSuccess(JSONObject result) {
1658 -// int status = result.optInt("status", 2); 1616 + int status = result.optInt("status", 2);
1659 -// if (status == 1) 1617 + if (status == 1)
1660 -// getCampaignsPersonalized(request, receiver); 1618 + getCampaignsPersonalized(request, receiver);
1661 -// else 1619 + else
1662 -// receiver.onFailure(status); 1620 + receiver.onFailure(status);
1663 -// } 1621 + }
1664 -//
1665 -// @Override
1666 -// public void onFailure(int errorCode) {
1667 -// receiver.onFailure(errorCode);
1668 -// }
1669 -// });
1670 -
1671 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1672 - sessionExpired.setLoyaltySessionExpired(true);
1673 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1674 1622
1675 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1623 + @Override
1676 - dynatraceEvent.setEventName("custom_error_campaigns_personalized_loyalty"); 1624 + public void onFailure(int errorCode) {
1677 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1678 receiver.onFailure(errorCode); 1625 receiver.onFailure(errorCode);
1626 + }
1627 + });
1679 } else { 1628 } else {
1680 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1629 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1681 dynatraceEvent.setEventName("custom_error_campaigns_personalized_loyalty"); 1630 dynatraceEvent.setEventName("custom_error_campaigns_personalized_loyalty");
...@@ -1712,30 +1661,21 @@ public class WarplyManager { ...@@ -1712,30 +1661,21 @@ public class WarplyManager {
1712 @Override 1661 @Override
1713 public void onFailure(int errorCode) { 1662 public void onFailure(int errorCode) {
1714 if (errorCode == 401) { 1663 if (errorCode == 401) {
1715 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1664 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1716 -// @Override 1665 + @Override
1717 -// public void onSuccess(JSONObject result) { 1666 + public void onSuccess(JSONObject result) {
1718 -// int status = result.optInt("status", 2); 1667 + int status = result.optInt("status", 2);
1719 -// if (status == 1) 1668 + if (status == 1)
1720 -// consumerIntegration(request, receiver); 1669 + consumerIntegration(request, receiver);
1721 -// else 1670 + else
1722 -// receiver.onFailure(status); 1671 + receiver.onFailure(status);
1723 -// } 1672 + }
1724 -//
1725 -// @Override
1726 -// public void onFailure(int errorCode) {
1727 -// receiver.onFailure(errorCode);
1728 -// }
1729 -// });
1730 -
1731 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1732 - sessionExpired.setLoyaltySessionExpired(true);
1733 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1734 1673
1735 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1674 + @Override
1736 - dynatraceEvent.setEventName("custom_error_customer_state_loyalty"); 1675 + public void onFailure(int errorCode) {
1737 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1738 receiver.onFailure(errorCode); 1676 receiver.onFailure(errorCode);
1677 + }
1678 + });
1739 } else { 1679 } else {
1740 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1680 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1741 dynatraceEvent.setEventName("custom_error_customer_state_loyalty"); 1681 dynatraceEvent.setEventName("custom_error_customer_state_loyalty");
...@@ -1771,30 +1711,21 @@ public class WarplyManager { ...@@ -1771,30 +1711,21 @@ public class WarplyManager {
1771 @Override 1711 @Override
1772 public void onFailure(int errorCode) { 1712 public void onFailure(int errorCode) {
1773 if (errorCode == 401) { 1713 if (errorCode == 401) {
1774 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1714 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1775 -// @Override 1715 + @Override
1776 -// public void onSuccess(JSONObject result) { 1716 + public void onSuccess(JSONObject result) {
1777 -// int status = result.optInt("status", 2); 1717 + int status = result.optInt("status", 2);
1778 -// if (status == 1) 1718 + if (status == 1)
1779 -// cosmoteSharing(request, receiver); 1719 + cosmoteSharing(request, receiver);
1780 -// else 1720 + else
1781 -// receiver.onFailure(status); 1721 + receiver.onFailure(status);
1782 -// } 1722 + }
1783 -//
1784 -// @Override
1785 -// public void onFailure(int errorCode) {
1786 -// receiver.onFailure(errorCode);
1787 -// }
1788 -// });
1789 -
1790 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1791 - sessionExpired.setLoyaltySessionExpired(true);
1792 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1793 1723
1794 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1724 + @Override
1795 - dynatraceEvent.setEventName("custom_error_sharing_loyalty"); 1725 + public void onFailure(int errorCode) {
1796 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1797 receiver.onFailure(errorCode); 1726 receiver.onFailure(errorCode);
1727 + }
1728 + });
1798 } else { 1729 } else {
1799 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1730 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1800 dynatraceEvent.setEventName("custom_error_sharing_loyalty"); 1731 dynatraceEvent.setEventName("custom_error_sharing_loyalty");
...@@ -1830,30 +1761,21 @@ public class WarplyManager { ...@@ -1830,30 +1761,21 @@ public class WarplyManager {
1830 @Override 1761 @Override
1831 public void onFailure(int errorCode) { 1762 public void onFailure(int errorCode) {
1832 if (errorCode == 401) { 1763 if (errorCode == 401) {
1833 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1764 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1834 -// @Override 1765 + @Override
1835 -// public void onSuccess(JSONObject result) { 1766 + public void onSuccess(JSONObject result) {
1836 -// int status = result.optInt("status", 2); 1767 + int status = result.optInt("status", 2);
1837 -// if (status == 1) 1768 + if (status == 1)
1838 -// cosmoteRetrieveSharing(request, receiver); 1769 + cosmoteRetrieveSharing(request, receiver);
1839 -// else 1770 + else
1840 -// receiver.onFailure(status); 1771 + receiver.onFailure(status);
1841 -// } 1772 + }
1842 -//
1843 -// @Override
1844 -// public void onFailure(int errorCode) {
1845 -// receiver.onFailure(errorCode);
1846 -// }
1847 -// });
1848 -
1849 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1850 - sessionExpired.setLoyaltySessionExpired(true);
1851 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1852 1773
1853 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1774 + @Override
1854 - dynatraceEvent.setEventName("custom_error_retrieve_sharing_loyalty"); 1775 + public void onFailure(int errorCode) {
1855 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1856 receiver.onFailure(errorCode); 1776 receiver.onFailure(errorCode);
1777 + }
1778 + });
1857 } else { 1779 } else {
1858 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1780 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1859 dynatraceEvent.setEventName("custom_error_retrieve_sharing_loyalty"); 1781 dynatraceEvent.setEventName("custom_error_retrieve_sharing_loyalty");
...@@ -1894,30 +1816,21 @@ public class WarplyManager { ...@@ -1894,30 +1816,21 @@ public class WarplyManager {
1894 @Override 1816 @Override
1895 public void onFailure(int errorCode) { 1817 public void onFailure(int errorCode) {
1896 if (errorCode == 401) { 1818 if (errorCode == 401) {
1897 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1819 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1898 -// @Override 1820 + @Override
1899 -// public void onSuccess(JSONObject result) { 1821 + public void onSuccess(JSONObject result) {
1900 -// int status = result.optInt("status", 2); 1822 + int status = result.optInt("status", 2);
1901 -// if (status == 1) 1823 + if (status == 1)
1902 -// getPacingDetails(request, receiver); 1824 + getPacingDetails(request, receiver);
1903 -// else 1825 + else
1904 -// receiver.onFailure(status); 1826 + receiver.onFailure(status);
1905 -// } 1827 + }
1906 -//
1907 -// @Override
1908 -// public void onFailure(int errorCode) {
1909 -// receiver.onFailure(errorCode);
1910 -// }
1911 -// });
1912 -
1913 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1914 - sessionExpired.setLoyaltySessionExpired(true);
1915 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1916 1828
1917 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1829 + @Override
1918 - dynatraceEvent.setEventName("custom_error_pacing_loyalty"); 1830 + public void onFailure(int errorCode) {
1919 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1920 receiver.onFailure(errorCode); 1831 receiver.onFailure(errorCode);
1832 + }
1833 + });
1921 } else { 1834 } else {
1922 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1835 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1923 dynatraceEvent.setEventName("custom_error_pacing_loyalty"); 1836 dynatraceEvent.setEventName("custom_error_pacing_loyalty");
...@@ -1954,30 +1867,21 @@ public class WarplyManager { ...@@ -1954,30 +1867,21 @@ public class WarplyManager {
1954 @Override 1867 @Override
1955 public void onFailure(int errorCode) { 1868 public void onFailure(int errorCode) {
1956 if (errorCode == 401) { 1869 if (errorCode == 401) {
1957 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1870 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1958 -// @Override 1871 + @Override
1959 -// public void onSuccess(JSONObject result) { 1872 + public void onSuccess(JSONObject result) {
1960 -// int status = result.optInt("status", 2); 1873 + int status = result.optInt("status", 2);
1961 -// if (status == 1) 1874 + if (status == 1)
1962 -// cosmoteCouponSharing(request, receiver); 1875 + cosmoteCouponSharing(request, receiver);
1963 -// else 1876 + else
1964 -// receiver.onFailure(status); 1877 + receiver.onFailure(status);
1965 -// } 1878 + }
1966 -//
1967 -// @Override
1968 -// public void onFailure(int errorCode) {
1969 -// receiver.onFailure(errorCode);
1970 -// }
1971 -// });
1972 -
1973 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
1974 - sessionExpired.setLoyaltySessionExpired(true);
1975 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
1976 1879
1977 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1880 + @Override
1978 - dynatraceEvent.setEventName("custom_error_coupon_sharing_loyalty"); 1881 + public void onFailure(int errorCode) {
1979 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
1980 receiver.onFailure(errorCode); 1882 receiver.onFailure(errorCode);
1883 + }
1884 + });
1981 } else { 1885 } else {
1982 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1886 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
1983 dynatraceEvent.setEventName("custom_error_coupon_sharing_loyalty"); 1887 dynatraceEvent.setEventName("custom_error_coupon_sharing_loyalty");
...@@ -2050,30 +1954,21 @@ public class WarplyManager { ...@@ -2050,30 +1954,21 @@ public class WarplyManager {
2050 @Override 1954 @Override
2051 public void onFailure(int errorCode) { 1955 public void onFailure(int errorCode) {
2052 if (errorCode == 401) { 1956 if (errorCode == 401) {
2053 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1957 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
2054 -// @Override 1958 + @Override
2055 -// public void onSuccess(JSONObject result) { 1959 + public void onSuccess(JSONObject result) {
2056 -// int status = result.optInt("status", 2); 1960 + int status = result.optInt("status", 2);
2057 -// if (status == 1) 1961 + if (status == 1)
2058 -// getUserCoupons(request, receiver); 1962 + getUserCoupons(request, receiver);
2059 -// else 1963 + else
2060 -// receiver.onFailure(status); 1964 + receiver.onFailure(status);
2061 -// } 1965 + }
2062 -//
2063 -// @Override
2064 -// public void onFailure(int errorCode) {
2065 -// receiver.onFailure(errorCode);
2066 -// }
2067 -// });
2068 -
2069 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
2070 - sessionExpired.setLoyaltySessionExpired(true);
2071 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
2072 1966
2073 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 1967 + @Override
2074 - dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); 1968 + public void onFailure(int errorCode) {
2075 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
2076 receiver.onFailure(errorCode); 1969 receiver.onFailure(errorCode);
1970 + }
1971 + });
2077 } else 1972 } else
2078 receiver.onFailure(errorCode); 1973 receiver.onFailure(errorCode);
2079 } 1974 }
...@@ -2246,15 +2141,6 @@ public class WarplyManager { ...@@ -2246,15 +2141,6 @@ public class WarplyManager {
2246 EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); 2141 EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
2247 receiver.onFailure(2); 2142 receiver.onFailure(2);
2248 } 2143 }
2249 - } else if (responseCoupons.code() == 401) {
2250 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
2251 - sessionExpired.setLoyaltySessionExpired(true);
2252 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
2253 -
2254 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
2255 - dynatraceEvent.setEventName("custom_error_user_coupons_loyalty");
2256 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
2257 - receiver.onFailure(responseCoupons.code());
2258 } else { 2144 } else {
2259 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2145 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
2260 dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); 2146 dynatraceEvent.setEventName("custom_error_user_coupons_loyalty");
...@@ -2437,23 +2323,21 @@ public class WarplyManager { ...@@ -2437,23 +2323,21 @@ public class WarplyManager {
2437 @Override 2323 @Override
2438 public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { 2324 public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
2439 if (response.code() == 401) { 2325 if (response.code() == 401) {
2440 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 2326 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
2441 -// @Override 2327 + @Override
2442 -// public void onSuccess(JSONObject result) { 2328 + public void onSuccess(JSONObject result) {
2443 -// int status = result.optInt("status", 2); 2329 + int status = result.optInt("status", 2);
2444 -// if (status == 1) 2330 + if (status == 1)
2445 -// getUserCouponsRetro(service, callback); 2331 + getUserCouponsRetro(service, callback);
2446 -// else 2332 + else
2447 -// callback.onFailure(call, new Throwable()); 2333 + callback.onFailure(call, new Throwable());
2448 -// } 2334 + }
2449 -//
2450 -// @Override
2451 -// public void onFailure(int errorCode) {
2452 -// callback.onFailure(call, new Throwable());
2453 -// }
2454 -// });
2455 2335
2456 - callback.onResponse(call, response); 2336 + @Override
2337 + public void onFailure(int errorCode) {
2338 + callback.onFailure(call, new Throwable());
2339 + }
2340 + });
2457 } else { 2341 } else {
2458 callback.onResponse(call, response); 2342 callback.onResponse(call, response);
2459 } 2343 }
...@@ -2584,30 +2468,21 @@ public class WarplyManager { ...@@ -2584,30 +2468,21 @@ public class WarplyManager {
2584 @Override 2468 @Override
2585 public void onFailure(int errorCode) { 2469 public void onFailure(int errorCode) {
2586 if (errorCode == 401) { 2470 if (errorCode == 401) {
2587 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 2471 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
2588 -// @Override 2472 + @Override
2589 -// public void onSuccess(JSONObject result) { 2473 + public void onSuccess(JSONObject result) {
2590 -// int status = result.optInt("status", 2); 2474 + int status = result.optInt("status", 2);
2591 -// if (status == 1) 2475 + if (status == 1)
2592 -// submitOrder(request, receiver); 2476 + submitOrder(request, receiver);
2593 -// else 2477 + else
2594 -// receiver.onFailure(status); 2478 + receiver.onFailure(status);
2595 -// } 2479 + }
2596 -//
2597 -// @Override
2598 -// public void onFailure(int errorCode) {
2599 -// receiver.onFailure(errorCode);
2600 -// }
2601 -// });
2602 -
2603 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
2604 - sessionExpired.setLoyaltySessionExpired(true);
2605 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
2606 2480
2607 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2481 + @Override
2608 - dynatraceEvent.setEventName("custom_error_submit_order_loyalty"); 2482 + public void onFailure(int errorCode) {
2609 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
2610 receiver.onFailure(errorCode); 2483 receiver.onFailure(errorCode);
2484 + }
2485 + });
2611 } else { 2486 } else {
2612 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2487 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
2613 dynatraceEvent.setEventName("custom_error_submit_order_loyalty"); 2488 dynatraceEvent.setEventName("custom_error_submit_order_loyalty");
...@@ -2635,30 +2510,21 @@ public class WarplyManager { ...@@ -2635,30 +2510,21 @@ public class WarplyManager {
2635 @Override 2510 @Override
2636 public void onFailure(int errorCode) { 2511 public void onFailure(int errorCode) {
2637 if (errorCode == 401) { 2512 if (errorCode == 401) {
2638 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 2513 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
2639 -// @Override 2514 + @Override
2640 -// public void onSuccess(JSONObject result) { 2515 + public void onSuccess(JSONObject result) {
2641 -// int status = result.optInt("status", 2); 2516 + int status = result.optInt("status", 2);
2642 -// if (status == 1) 2517 + if (status == 1)
2643 -// getSharingHistory(request, receiver); 2518 + getSharingHistory(request, receiver);
2644 -// else 2519 + else
2645 -// receiver.onFailure(status); 2520 + receiver.onFailure(status);
2646 -// } 2521 + }
2647 -//
2648 -// @Override
2649 -// public void onFailure(int errorCode) {
2650 -// receiver.onFailure(errorCode);
2651 -// }
2652 -// });
2653 -
2654 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
2655 - sessionExpired.setLoyaltySessionExpired(true);
2656 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
2657 2522
2658 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2523 + @Override
2659 - dynatraceEvent.setEventName("custom_error_sharing_history_loyalty"); 2524 + public void onFailure(int errorCode) {
2660 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
2661 receiver.onFailure(errorCode); 2525 receiver.onFailure(errorCode);
2526 + }
2527 + });
2662 } else { 2528 } else {
2663 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2529 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
2664 dynatraceEvent.setEventName("custom_error_sharing_history_loyalty"); 2530 dynatraceEvent.setEventName("custom_error_sharing_history_loyalty");
...@@ -2695,30 +2561,21 @@ public class WarplyManager { ...@@ -2695,30 +2561,21 @@ public class WarplyManager {
2695 @Override 2561 @Override
2696 public void onFailure(int errorCode) { 2562 public void onFailure(int errorCode) {
2697 if (errorCode == 401) { 2563 if (errorCode == 401) {
2698 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 2564 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
2699 -// @Override 2565 + @Override
2700 -// public void onSuccess(JSONObject result) { 2566 + public void onSuccess(JSONObject result) {
2701 -// int status = result.optInt("status", 2); 2567 + int status = result.optInt("status", 2);
2702 -// if (status == 1) 2568 + if (status == 1)
2703 -// postEvent(request, receiver); 2569 + postEvent(request, receiver);
2704 -// else 2570 + else
2705 -// receiver.onFailure(status); 2571 + receiver.onFailure(status);
2706 -// } 2572 + }
2707 -//
2708 -// @Override
2709 -// public void onFailure(int errorCode) {
2710 -// receiver.onFailure(errorCode);
2711 -// }
2712 -// });
2713 -
2714 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
2715 - sessionExpired.setLoyaltySessionExpired(true);
2716 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
2717 2573
2718 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2574 + @Override
2719 - dynatraceEvent.setEventName("custom_error_post_event_loyalty"); 2575 + public void onFailure(int errorCode) {
2720 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
2721 receiver.onFailure(errorCode); 2576 receiver.onFailure(errorCode);
2577 + }
2578 + });
2722 } else { 2579 } else {
2723 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2580 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
2724 dynatraceEvent.setEventName("custom_error_post_event_loyalty"); 2581 dynatraceEvent.setEventName("custom_error_post_event_loyalty");
...@@ -2754,30 +2611,21 @@ public class WarplyManager { ...@@ -2754,30 +2611,21 @@ public class WarplyManager {
2754 @Override 2611 @Override
2755 public void onFailure(int errorCode) { 2612 public void onFailure(int errorCode) {
2756 if (errorCode == 401) { 2613 if (errorCode == 401) {
2757 -// refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 2614 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
2758 -// @Override 2615 + @Override
2759 -// public void onSuccess(JSONObject result) { 2616 + public void onSuccess(JSONObject result) {
2760 -// int status = result.optInt("status", 2); 2617 + int status = result.optInt("status", 2);
2761 -// if (status == 1) 2618 + if (status == 1)
2762 -// setPacingDetails(request, receiver); 2619 + setPacingDetails(request, receiver);
2763 -// else 2620 + else
2764 -// receiver.onFailure(status); 2621 + receiver.onFailure(status);
2765 -// } 2622 + }
2766 -//
2767 -// @Override
2768 -// public void onFailure(int errorCode) {
2769 -// receiver.onFailure(errorCode);
2770 -// }
2771 -// });
2772 -
2773 - LoyaltySDKSessionExpiredEventModel sessionExpired = new LoyaltySDKSessionExpiredEventModel();
2774 - sessionExpired.setLoyaltySessionExpired(true);
2775 - EventBus.getDefault().post(new WarplyEventBusManager(sessionExpired));
2776 2623
2777 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2624 + @Override
2778 - dynatraceEvent.setEventName("custom_error_save_pacing_loyalty"); 2625 + public void onFailure(int errorCode) {
2779 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
2780 receiver.onFailure(errorCode); 2626 receiver.onFailure(errorCode);
2627 + }
2628 + });
2781 } else { 2629 } else {
2782 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 2630 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
2783 dynatraceEvent.setEventName("custom_error_save_pacing_loyalty"); 2631 dynatraceEvent.setEventName("custom_error_save_pacing_loyalty");
......