Showing
6 changed files
with
449 additions
and
54 deletions
... | @@ -36,9 +36,10 @@ public class SplashActivity extends BaseActivity { | ... | @@ -36,9 +36,10 @@ public class SplashActivity extends BaseActivity { |
36 | @Override | 36 | @Override |
37 | public void onWarplyReady() { | 37 | public void onWarplyReady() { |
38 | if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) { | 38 | if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) { |
39 | - WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest() | 39 | + //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons |
40 | - .setGuid("7000023717"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282 | 40 | + //prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282 |
41 | - mLoginReceiver); | 41 | + WarplyManager.getCosmoteUser("7000000833", mLoginReceiver); |
42 | +// WarplyManager.verifyTicket("", "7000000833", mLoginReceiver); | ||
42 | } else { | 43 | } else { |
43 | startNextActivity(); | 44 | startNextActivity(); |
44 | } | 45 | } | ... | ... |
... | @@ -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.5.4r18' | 5 | + PUBLISH_VERSION = '4.5.5.4r19' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ||
... | @@ -112,6 +112,9 @@ dependencies { | ... | @@ -112,6 +112,9 @@ dependencies { |
112 | 112 | ||
113 | //------------------------------ Lifecycle -----------------------------// | 113 | //------------------------------ Lifecycle -----------------------------// |
114 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" | 114 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" |
115 | + | ||
116 | + //------------------------------ Retrofit Logs -----------------------------// | ||
117 | +// implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' | ||
115 | } | 118 | } |
116 | 119 | ||
117 | // In every export please update the version number | 120 | // In every export please update the version number | ... | ... |
... | @@ -18,6 +18,8 @@ import androidx.recyclerview.widget.LinearLayoutManager; | ... | @@ -18,6 +18,8 @@ import androidx.recyclerview.widget.LinearLayoutManager; |
18 | import androidx.recyclerview.widget.RecyclerView; | 18 | import androidx.recyclerview.widget.RecyclerView; |
19 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; | 19 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
20 | 20 | ||
21 | +import org.json.JSONObject; | ||
22 | + | ||
21 | import java.util.ArrayList; | 23 | import java.util.ArrayList; |
22 | 24 | ||
23 | import ly.warp.sdk.R; | 25 | import ly.warp.sdk.R; |
... | @@ -120,6 +122,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip | ... | @@ -120,6 +122,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip |
120 | if (view.getId() == R.id.rl_driving_history) { | 122 | if (view.getId() == R.id.rl_driving_history) { |
121 | Intent intent = new Intent(getContext(), TelematicsHistoryActivity.class); | 123 | Intent intent = new Intent(getContext(), TelematicsHistoryActivity.class); |
122 | startActivity(intent); | 124 | startActivity(intent); |
125 | + return; | ||
126 | + } | ||
127 | + if (view.getId() == R.id.iv_settings) { | ||
128 | + WarplyManager.logout(mLogoutReceiver); | ||
123 | } | 129 | } |
124 | } | 130 | } |
125 | 131 | ||
... | @@ -152,4 +158,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip | ... | @@ -152,4 +158,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip |
152 | Toast.makeText(getActivity(), "Coupons Error", Toast.LENGTH_SHORT).show(); | 158 | Toast.makeText(getActivity(), "Coupons Error", Toast.LENGTH_SHORT).show(); |
153 | } | 159 | } |
154 | }; | 160 | }; |
161 | + | ||
162 | + private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() { | ||
163 | + @Override | ||
164 | + public void onSuccess(JSONObject result) { | ||
165 | + Toast.makeText(getActivity(), "LOGOUT SUCCESS", Toast.LENGTH_SHORT).show(); | ||
166 | + } | ||
167 | + | ||
168 | + @Override | ||
169 | + public void onFailure(int errorCode) { | ||
170 | + Toast.makeText(getActivity(), "LOGOUT ERROR", Toast.LENGTH_SHORT).show(); | ||
171 | + } | ||
172 | + }; | ||
155 | } | 173 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -47,7 +47,12 @@ public class ApiClient { | ... | @@ -47,7 +47,12 @@ public class ApiClient { |
47 | } | 47 | } |
48 | 48 | ||
49 | private static OkHttpClient getClient() { | 49 | private static OkHttpClient getClient() { |
50 | + /* Logs Enabled */ | ||
51 | +// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); | ||
52 | +// interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); | ||
53 | + | ||
50 | return new OkHttpClient.Builder() | 54 | return new OkHttpClient.Builder() |
55 | +// .addInterceptor(interceptor) // Logs Enabled | ||
51 | .connectTimeout(30, TimeUnit.SECONDS) | 56 | .connectTimeout(30, TimeUnit.SECONDS) |
52 | .writeTimeout(30, TimeUnit.SECONDS) | 57 | .writeTimeout(30, TimeUnit.SECONDS) |
53 | .readTimeout(30, TimeUnit.SECONDS) | 58 | .readTimeout(30, TimeUnit.SECONDS) | ... | ... |
... | @@ -44,6 +44,39 @@ public interface ApiService { | ... | @@ -44,6 +44,39 @@ public interface ApiService { |
44 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); | 44 | @Header(WarpConstants.HEADER_SIGNATURE) String signature); |
45 | 45 | ||
46 | @Headers("Content-Type: application/json") | 46 | @Headers("Content-Type: application/json") |
47 | + @POST("/partners/oauth/{appUuid}/token") | ||
48 | + Call<ResponseBody> cosmoteUser(@Path("appUuid") String appUuid, | ||
49 | + @Body RequestBody request, | ||
50 | + @Header(WarpConstants.HEADER_DATE) String timeStamp, | ||
51 | + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | ||
52 | + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | ||
53 | + @Header(WarpConstants.HEADER_CHANNEL) String channel, | ||
54 | + @Header(WarpConstants.HEADER_WEB_ID) String webId, | ||
55 | + @Header(WarpConstants.HEADER_SIGNATURE) String signature, | ||
56 | + @Header(WarpConstants.HEADER_AUTHORIZATION) String basic); | ||
57 | + | ||
58 | + @Headers("Content-Type: application/json") | ||
59 | + @POST("/partners/cosmote/verify") | ||
60 | + Call<ResponseBody> verifyUser(@Body RequestBody request, | ||
61 | + @Header(WarpConstants.HEADER_DATE) String timeStamp, | ||
62 | + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | ||
63 | + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | ||
64 | + @Header(WarpConstants.HEADER_CHANNEL) String channel, | ||
65 | + @Header(WarpConstants.HEADER_WEB_ID) String webId, | ||
66 | + @Header(WarpConstants.HEADER_SIGNATURE) String signature); | ||
67 | + | ||
68 | + @Headers("Content-Type: application/json") | ||
69 | + @POST("/oauth/{appUuid}/logout") | ||
70 | + Call<ResponseBody> logoutUser(@Path("appUuid") String appUuid, | ||
71 | + @Body RequestBody request, | ||
72 | + @Header(WarpConstants.HEADER_DATE) String timeStamp, | ||
73 | + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId, | ||
74 | + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId, | ||
75 | + @Header(WarpConstants.HEADER_CHANNEL) String channel, | ||
76 | + @Header(WarpConstants.HEADER_WEB_ID) String webId, | ||
77 | + @Header(WarpConstants.HEADER_SIGNATURE) String signature); | ||
78 | + | ||
79 | + @Headers("Content-Type: application/json") | ||
47 | @POST("/oauth/{appUuid}/context") | 80 | @POST("/oauth/{appUuid}/context") |
48 | Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid, | 81 | Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid, |
49 | @Body RequestBody request, | 82 | @Body RequestBody request, | ... | ... |
... | @@ -596,28 +596,71 @@ public class WarplyManager { | ... | @@ -596,28 +596,71 @@ public class WarplyManager { |
596 | WarpUtils.log("[WARP Trace] WARPLY Logout is active"); | 596 | WarpUtils.log("[WARP Trace] WARPLY Logout is active"); |
597 | WarpUtils.log("**************************************************"); | 597 | WarpUtils.log("**************************************************"); |
598 | 598 | ||
599 | - WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false); | 599 | + ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); |
600 | - WarpUtils.setUserTag(Warply.getWarplyContext(), ""); | ||
601 | - WarplyManagerHelper.clearCCMSLoyaltyCampaigns(); | ||
602 | 600 | ||
603 | - WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteAuth(); | 601 | + String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); |
604 | - WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteClient(); | 602 | + String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); |
603 | + String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | ||
605 | 604 | ||
606 | - JSONObject newResult = new JSONObject(); | 605 | + Map<String, Object> jsonParams = new ArrayMap<>(); |
607 | - try { | 606 | + jsonParams.put("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); |
608 | - newResult.putOpt("status", 1); | 607 | + jsonParams.put("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); |
609 | - newResult.putOpt("message", "Success"); | 608 | + |
610 | - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 609 | + RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); |
611 | - dynatraceEvent.setEventName("custom_success_logout_loyalty"); | 610 | + |
612 | - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 611 | + Call<ResponseBody> logoutCall = service.logoutUser( |
613 | - receiver.onSuccess(newResult); | 612 | + WarplyProperty.getAppUuid(Warply.getWarplyContext()), |
614 | - } catch (JSONException e) { | 613 | + loginRequest, |
615 | - e.printStackTrace(); | 614 | + timeStamp, |
616 | - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 615 | + "android:" + Warply.getWarplyContext().getPackageName(), |
617 | - dynatraceEvent.setEventName("custom_error_logout_loyalty"); | 616 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), |
618 | - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 617 | + "mobile", |
619 | - receiver.onFailure(2); | 618 | + webId, |
620 | - } | 619 | + WarpUtils.produceSignature(apiKey + timeStamp) |
620 | + ); | ||
621 | + | ||
622 | + logoutCall.enqueue(new Callback<ResponseBody>() { | ||
623 | + @Override | ||
624 | + public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { | ||
625 | + if (response.code() == 200 && response.body() != null) { | ||
626 | + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false); | ||
627 | + WarpUtils.setUserTag(Warply.getWarplyContext(), ""); | ||
628 | + WarplyManagerHelper.clearCCMSLoyaltyCampaigns(); | ||
629 | + | ||
630 | + WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteAuth(); | ||
631 | + WarplyDBHelper.getInstance(Warply.getWarplyContext()).deleteClient(); | ||
632 | + | ||
633 | + JSONObject newResult = new JSONObject(); | ||
634 | + try { | ||
635 | + newResult.putOpt("status", 1); | ||
636 | + newResult.putOpt("message", "Success"); | ||
637 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
638 | + dynatraceEvent.setEventName("custom_success_logout_loyalty"); | ||
639 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
640 | + receiver.onSuccess(newResult); | ||
641 | + } catch (JSONException e) { | ||
642 | + e.printStackTrace(); | ||
643 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
644 | + dynatraceEvent.setEventName("custom_error_logout_loyalty"); | ||
645 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
646 | + receiver.onFailure(2); | ||
647 | + } | ||
648 | + } else { | ||
649 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
650 | + dynatraceEvent.setEventName("custom_error_logout_loyalty"); | ||
651 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
652 | + receiver.onFailure(response.code()); | ||
653 | + } | ||
654 | + } | ||
655 | + | ||
656 | + @Override | ||
657 | + public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) { | ||
658 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
659 | + dynatraceEvent.setEventName("custom_error_logout_loyalty"); | ||
660 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
661 | + receiver.onFailure(2); | ||
662 | + } | ||
663 | + }); | ||
621 | } | 664 | } |
622 | 665 | ||
623 | public static void changePassword(WarplyChangePasswordRequest request, final CallbackReceiver<JSONObject> receiver) { | 666 | public static void changePassword(WarplyChangePasswordRequest request, final CallbackReceiver<JSONObject> receiver) { |
... | @@ -856,6 +899,284 @@ public class WarplyManager { | ... | @@ -856,6 +899,284 @@ public class WarplyManager { |
856 | }); | 899 | }); |
857 | } | 900 | } |
858 | 901 | ||
902 | + public static void getCosmoteUser(String guid, final CallbackReceiver<JSONObject> receiver) { | ||
903 | + WarpUtils.log("************* WARPLY Cosmote User Request ********************"); | ||
904 | + WarpUtils.log("[WARP Trace] WARPLY Cosmote User Request is active"); | ||
905 | + WarpUtils.log("**************************************************"); | ||
906 | + | ||
907 | + ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | ||
908 | + | ||
909 | + String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | ||
910 | + String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); | ||
911 | + String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | ||
912 | + | ||
913 | + Map<String, Object> jsonParams = new ArrayMap<>(); | ||
914 | + jsonParams.put("user_identifier", guid); | ||
915 | + | ||
916 | + RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); | ||
917 | + | ||
918 | + Call<ResponseBody> loginCall = service.cosmoteUser( | ||
919 | + WarplyProperty.getAppUuid(Warply.getWarplyContext()), | ||
920 | + loginRequest, | ||
921 | + timeStamp, | ||
922 | + "android:" + Warply.getWarplyContext().getPackageName(), | ||
923 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | ||
924 | + "mobile", | ||
925 | + webId, | ||
926 | + WarpUtils.produceSignature(apiKey + timeStamp), | ||
927 | + "Basic MVBQNFhCQzhFYTJBaUdCNkJWZGFGUERlTTNLQ3kzMjU6YzViMzAyZDY5N2FiNGY3NzhiNThhMTg0YzBkZWRmNGU=" | ||
928 | + ); | ||
929 | + | ||
930 | + loginCall.enqueue(new Callback<ResponseBody>() { | ||
931 | + @Override | ||
932 | + public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { | ||
933 | + if (response.code() == 200 && response.body() != null) { | ||
934 | + JSONObject jobjLoginResponse = null; | ||
935 | + try { | ||
936 | + jobjLoginResponse = new JSONObject(response.body().string()); | ||
937 | + } catch (Exception e) { | ||
938 | + e.printStackTrace(); | ||
939 | + } | ||
940 | + | ||
941 | + if (jobjLoginResponse != null && jobjLoginResponse.has("status") && jobjLoginResponse.optString("status", "2").equals("1")) { | ||
942 | + JSONObject tokens = jobjLoginResponse.optJSONObject("result"); | ||
943 | + if (tokens != null) { | ||
944 | + WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveClientAccess( | ||
945 | + tokens.optString("client_id", ""), | ||
946 | + tokens.optString("client_secret", "") | ||
947 | + ); | ||
948 | + | ||
949 | + WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveAuthAccess( | ||
950 | + tokens.optString("access_token", ""), | ||
951 | + tokens.optString("refresh_token", "") | ||
952 | + ); | ||
953 | + | ||
954 | + JSONObject newResult = new JSONObject(); | ||
955 | + try { | ||
956 | + newResult.putOpt("status", 1); | ||
957 | + newResult.putOpt("message", "Success"); | ||
958 | + receiver.onSuccess(newResult); | ||
959 | + } catch (JSONException e) { | ||
960 | + e.printStackTrace(); | ||
961 | + receiver.onFailure(2); | ||
962 | + } | ||
963 | + | ||
964 | + getConsumer(new WarplyConsumerRequest(), new CallbackReceiver<Consumer>() { | ||
965 | + @Override | ||
966 | + public void onSuccess(Consumer result) { | ||
967 | + WarplyManagerHelper.setConsumerInternal(result); | ||
968 | + | ||
969 | + if (result != null) { | ||
970 | + JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata()); | ||
971 | + if (profMetadata != null && profMetadata.has("nonTelco")) { | ||
972 | + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco")); | ||
973 | + } else { | ||
974 | + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false); | ||
975 | + } | ||
976 | + } | ||
977 | + | ||
978 | + if (result != null) { | ||
979 | + JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata()); | ||
980 | + if (profMetadata != null) { | ||
981 | + if (profMetadata.has("badge")) { | ||
982 | + WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge")); | ||
983 | + } | ||
984 | + | ||
985 | + if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) { | ||
986 | + if (!isMyServiceRunning(WarplyHealthService.class)) { | ||
987 | + Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); | ||
988 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
989 | + AlarmManager mgr = (AlarmManager) Warply.getWarplyContext().getSystemService(Context.ALARM_SERVICE); | ||
990 | + PendingIntent pi = PendingIntent.getService(Warply.getWarplyContext(), 2002, stepsServiceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE); | ||
991 | + mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pi); | ||
992 | + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
993 | + Warply.getWarplyContext().startForegroundService(stepsServiceIntent); | ||
994 | + } else { | ||
995 | + Warply.getWarplyContext().startService(stepsServiceIntent); | ||
996 | + } | ||
997 | + | ||
998 | + WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | ||
999 | + pacingVisible.setVisible(true); | ||
1000 | + EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | ||
1001 | + } | ||
1002 | + } | ||
1003 | + } | ||
1004 | + } | ||
1005 | + } | ||
1006 | + | ||
1007 | + @Override | ||
1008 | + public void onFailure(int errorCode) { | ||
1009 | + | ||
1010 | + } | ||
1011 | + }); | ||
1012 | + } else | ||
1013 | + receiver.onFailure(2); | ||
1014 | + } else { | ||
1015 | + receiver.onFailure(2); | ||
1016 | + } | ||
1017 | + } else { | ||
1018 | + receiver.onFailure(response.code()); | ||
1019 | + } | ||
1020 | + } | ||
1021 | + | ||
1022 | + @Override | ||
1023 | + public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) { | ||
1024 | + receiver.onFailure(2); | ||
1025 | + } | ||
1026 | + }); | ||
1027 | + } | ||
1028 | + | ||
1029 | + public static void verifyTicket(String ticket, String guid, final CallbackReceiver<JSONObject> receiver) { | ||
1030 | + WarpUtils.log("************* WARPLY Verify Ticket Request ********************"); | ||
1031 | + WarpUtils.log("[WARP Trace] WARPLY Verify Ticket Request is active"); | ||
1032 | + WarpUtils.log("**************************************************"); | ||
1033 | + | ||
1034 | + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false); | ||
1035 | + WarpUtils.setUserTag(Warply.getWarplyContext(), ""); | ||
1036 | + WarplyManagerHelper.clearCCMSLoyaltyCampaigns(); | ||
1037 | + | ||
1038 | + ApiService service = ApiClient.getRetrofitInstance().create(ApiService.class); | ||
1039 | + | ||
1040 | + String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | ||
1041 | + String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); | ||
1042 | + String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | ||
1043 | + | ||
1044 | + Map<String, Object> jsonParams = new ArrayMap<>(); | ||
1045 | + jsonParams.put("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext())); | ||
1046 | + jsonParams.put("guid", guid); | ||
1047 | + jsonParams.put("ticket", ticket); | ||
1048 | + | ||
1049 | + RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); | ||
1050 | + | ||
1051 | + Call<ResponseBody> loginCall = service.verifyUser( | ||
1052 | + loginRequest, | ||
1053 | + timeStamp, | ||
1054 | + "android:" + Warply.getWarplyContext().getPackageName(), | ||
1055 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | ||
1056 | + "mobile", | ||
1057 | + webId, | ||
1058 | + WarpUtils.produceSignature(apiKey + timeStamp) | ||
1059 | + ); | ||
1060 | + | ||
1061 | + loginCall.enqueue(new Callback<ResponseBody>() { | ||
1062 | + @Override | ||
1063 | + public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { | ||
1064 | + if (response.code() == 200 && response.body() != null) { | ||
1065 | + JSONObject jobjLoginResponse = null; | ||
1066 | + try { | ||
1067 | + jobjLoginResponse = new JSONObject(response.body().string()); | ||
1068 | + } catch (Exception e) { | ||
1069 | + e.printStackTrace(); | ||
1070 | + } | ||
1071 | + | ||
1072 | + if (jobjLoginResponse != null && jobjLoginResponse.has("status") && jobjLoginResponse.optString("status", "2").equals("1")) { | ||
1073 | + JSONObject tokens = jobjLoginResponse.optJSONObject("result"); | ||
1074 | + if (tokens != null) { | ||
1075 | + WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveClientAccess( | ||
1076 | + tokens.optString("client_id", ""), | ||
1077 | + tokens.optString("client_secret", "") | ||
1078 | + ); | ||
1079 | + | ||
1080 | + WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveAuthAccess( | ||
1081 | + tokens.optString("access_token", ""), | ||
1082 | + tokens.optString("refresh_token", "") | ||
1083 | + ); | ||
1084 | + | ||
1085 | + JSONObject newResult = new JSONObject(); | ||
1086 | + try { | ||
1087 | + newResult.putOpt("status", 1); | ||
1088 | + newResult.putOpt("message", "Success"); | ||
1089 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
1090 | + dynatraceEvent.setEventName("custom_success_login_loyalty"); | ||
1091 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
1092 | + receiver.onSuccess(newResult); | ||
1093 | + } catch (JSONException e) { | ||
1094 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
1095 | + dynatraceEvent.setEventName("custom_error_login_loyalty"); | ||
1096 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
1097 | + | ||
1098 | + e.printStackTrace(); | ||
1099 | + receiver.onFailure(2); | ||
1100 | + } | ||
1101 | + | ||
1102 | + getConsumer(new WarplyConsumerRequest(), new CallbackReceiver<Consumer>() { | ||
1103 | + @Override | ||
1104 | + public void onSuccess(Consumer result) { | ||
1105 | + WarplyManagerHelper.setConsumerInternal(result); | ||
1106 | + | ||
1107 | + if (result != null) { | ||
1108 | + JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata()); | ||
1109 | + if (profMetadata != null && profMetadata.has("nonTelco")) { | ||
1110 | + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco")); | ||
1111 | + } else { | ||
1112 | + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false); | ||
1113 | + } | ||
1114 | + } | ||
1115 | + | ||
1116 | + if (result != null) { | ||
1117 | + JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata()); | ||
1118 | + if (profMetadata != null) { | ||
1119 | + if (profMetadata.has("badge")) { | ||
1120 | + WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge")); | ||
1121 | + } | ||
1122 | + | ||
1123 | + if (profMetadata.has("steps_enabled") && profMetadata.optBoolean("steps_enabled")) { | ||
1124 | + if (!isMyServiceRunning(WarplyHealthService.class)) { | ||
1125 | + Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); | ||
1126 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
1127 | + AlarmManager mgr = (AlarmManager) Warply.getWarplyContext().getSystemService(Context.ALARM_SERVICE); | ||
1128 | + PendingIntent pi = PendingIntent.getService(Warply.getWarplyContext(), 2002, stepsServiceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); | ||
1129 | + mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pi); | ||
1130 | + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
1131 | + Warply.getWarplyContext().startForegroundService(stepsServiceIntent); | ||
1132 | + } else { | ||
1133 | + Warply.getWarplyContext().startService(stepsServiceIntent); | ||
1134 | + } | ||
1135 | + | ||
1136 | + WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | ||
1137 | + pacingVisible.setVisible(true); | ||
1138 | + EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | ||
1139 | + } | ||
1140 | + } | ||
1141 | + } | ||
1142 | + } | ||
1143 | + } | ||
1144 | + | ||
1145 | + @Override | ||
1146 | + public void onFailure(int errorCode) { | ||
1147 | + | ||
1148 | + } | ||
1149 | + }); | ||
1150 | + } else { | ||
1151 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
1152 | + dynatraceEvent.setEventName("custom_error_login_loyalty"); | ||
1153 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
1154 | + receiver.onFailure(2); | ||
1155 | + } | ||
1156 | + } else { | ||
1157 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
1158 | + dynatraceEvent.setEventName("custom_error_login_loyalty"); | ||
1159 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
1160 | + receiver.onFailure(2); | ||
1161 | + } | ||
1162 | + } else { | ||
1163 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
1164 | + dynatraceEvent.setEventName("custom_error_login_loyalty"); | ||
1165 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
1166 | + receiver.onFailure(response.code()); | ||
1167 | + } | ||
1168 | + } | ||
1169 | + | ||
1170 | + @Override | ||
1171 | + public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) { | ||
1172 | + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | ||
1173 | + dynatraceEvent.setEventName("custom_error_login_loyalty"); | ||
1174 | + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | ||
1175 | + receiver.onFailure(2); | ||
1176 | + } | ||
1177 | + }); | ||
1178 | + } | ||
1179 | + | ||
859 | public static void verifyTicket(WarplyVerifyTicketRequest request, final CallbackReceiver<JSONObject> receiver) { | 1180 | public static void verifyTicket(WarplyVerifyTicketRequest request, final CallbackReceiver<JSONObject> receiver) { |
860 | WarpUtils.log("************* WARPLY Verify Ticket Request ********************"); | 1181 | WarpUtils.log("************* WARPLY Verify Ticket Request ********************"); |
861 | WarpUtils.log("[WARP Trace] WARPLY Verify Ticket Request is active"); | 1182 | WarpUtils.log("[WARP Trace] WARPLY Verify Ticket Request is active"); |
... | @@ -1573,7 +1894,8 @@ public class WarplyManager { | ... | @@ -1573,7 +1894,8 @@ public class WarplyManager { |
1573 | //TODO: check to see if we need merchants global else delete request | 1894 | //TODO: check to see if we need merchants global else delete request |
1574 | ListenableFuture<MerchantList> futureMerchants = getMerchantsRetro(service); | 1895 | ListenableFuture<MerchantList> futureMerchants = getMerchantsRetro(service); |
1575 | ListenableFuture<CouponsetsList> futureCouponsets = getCouponsetsRetro(service); | 1896 | ListenableFuture<CouponsetsList> futureCouponsets = getCouponsetsRetro(service); |
1576 | - ListenableFuture<CouponList> futureCoupons = getCouponsUniversalRetro(service, 0); | 1897 | + SettableFuture<CouponList> futureUniversal = SettableFuture.create(); |
1898 | + ListenableFuture<CouponList> futureCoupons = getCouponsUniversalRetro(service, 0, futureUniversal); | ||
1577 | 1899 | ||
1578 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureMerchants, futureCouponsets, futureCoupons); | 1900 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureMerchants, futureCouponsets, futureCoupons); |
1579 | ListenableFuture<CouponList> mergedResultFuture = Futures.transformAsync( | 1901 | ListenableFuture<CouponList> mergedResultFuture = Futures.transformAsync( |
... | @@ -1609,7 +1931,8 @@ public class WarplyManager { | ... | @@ -1609,7 +1931,8 @@ public class WarplyManager { |
1609 | ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(3)); | 1931 | ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(3)); |
1610 | 1932 | ||
1611 | ListenableFuture<ArrayList<Campaign>> futureCampaigns = getCampaignsRetro(service); | 1933 | ListenableFuture<ArrayList<Campaign>> futureCampaigns = getCampaignsRetro(service); |
1612 | - ListenableFuture<ArrayList<Campaign>> futurePersonalizedCampaigns = getCampaignsPersonalizedRetro(service, 0); | 1934 | + SettableFuture<ArrayList<Campaign>> futurePersonalized = SettableFuture.create(); |
1935 | + ListenableFuture<ArrayList<Campaign>> futurePersonalizedCampaigns = getCampaignsPersonalizedRetro(service, 0, futurePersonalized); | ||
1613 | ListenableFuture<JSONObject> futureCampaignAvailability = getCampaignAvailability(service); | 1936 | ListenableFuture<JSONObject> futureCampaignAvailability = getCampaignAvailability(service); |
1614 | 1937 | ||
1615 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCampaigns, futurePersonalizedCampaigns, futureCampaignAvailability); | 1938 | ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCampaigns, futurePersonalizedCampaigns, futureCampaignAvailability); |
... | @@ -1830,7 +2153,8 @@ public class WarplyManager { | ... | @@ -1830,7 +2153,8 @@ public class WarplyManager { |
1830 | dynatraceEvent.setEventName("custom_error_campaigns_loyalty"); | 2153 | dynatraceEvent.setEventName("custom_error_campaigns_loyalty"); |
1831 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 2154 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
1832 | // receiver.onFailure(response.code()); | 2155 | // receiver.onFailure(response.code()); |
1833 | - future.set(new ArrayList<Campaign>()); | 2156 | +// future.set(new ArrayList<Campaign>()); |
2157 | + future.setException(new Throwable()); | ||
1834 | } | 2158 | } |
1835 | } | 2159 | } |
1836 | 2160 | ||
... | @@ -1840,16 +2164,15 @@ public class WarplyManager { | ... | @@ -1840,16 +2164,15 @@ public class WarplyManager { |
1840 | dynatraceEvent.setEventName("custom_error_campaigns_loyalty"); | 2164 | dynatraceEvent.setEventName("custom_error_campaigns_loyalty"); |
1841 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 2165 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
1842 | // receiver.onFailure(2); | 2166 | // receiver.onFailure(2); |
1843 | - future.set(new ArrayList<Campaign>()); | 2167 | +// future.set(new ArrayList<Campaign>()); |
2168 | + future.setException(new Throwable()); | ||
1844 | } | 2169 | } |
1845 | }); | 2170 | }); |
1846 | 2171 | ||
1847 | return future; | 2172 | return future; |
1848 | } | 2173 | } |
1849 | 2174 | ||
1850 | - private static /*void*/ ListenableFuture<ArrayList<Campaign>> getCampaignsPersonalizedRetro(ApiService service, int tries/*, final CallbackReceiver<ArrayList<Campaign>> receiver*/) { | 2175 | + private static /*void*/ ListenableFuture<ArrayList<Campaign>> getCampaignsPersonalizedRetro(ApiService service, int tries/*, final CallbackReceiver<ArrayList<Campaign>> receiver*/, SettableFuture<ArrayList<Campaign>> future) { |
1851 | - SettableFuture<ArrayList<Campaign>> future = SettableFuture.create(); | ||
1852 | - | ||
1853 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | 2176 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); |
1854 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); | 2177 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); |
1855 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | 2178 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); |
... | @@ -1980,13 +2303,14 @@ public class WarplyManager { | ... | @@ -1980,13 +2303,14 @@ public class WarplyManager { |
1980 | public void onSuccess(JSONObject result) { | 2303 | public void onSuccess(JSONObject result) { |
1981 | int status = result.optInt("status", 2); | 2304 | int status = result.optInt("status", 2); |
1982 | if (status == 1) | 2305 | if (status == 1) |
1983 | - getCampaignsPersonalizedRetro(service, tries/*, receiver*/); | 2306 | + getCampaignsPersonalizedRetro(service, tries/*, receiver*/, future); |
1984 | else { | 2307 | else { |
1985 | // receiver.onFailure(status); | 2308 | // receiver.onFailure(status); |
1986 | if (tries < MAX_RETRIES) { | 2309 | if (tries < MAX_RETRIES) { |
1987 | - getCampaignsPersonalizedRetro(service, (tries + 1)); | 2310 | + getCampaignsPersonalizedRetro(service, (tries + 1), future); |
1988 | } else { | 2311 | } else { |
1989 | - future.set(new ArrayList<Campaign>()); | 2312 | +// future.set(new ArrayList<Campaign>()); |
2313 | + future.setException(new Throwable()); | ||
1990 | } | 2314 | } |
1991 | } | 2315 | } |
1992 | } | 2316 | } |
... | @@ -1995,9 +2319,10 @@ public class WarplyManager { | ... | @@ -1995,9 +2319,10 @@ public class WarplyManager { |
1995 | public void onFailure(int errorCode) { | 2319 | public void onFailure(int errorCode) { |
1996 | // receiver.onFailure(errorCode); | 2320 | // receiver.onFailure(errorCode); |
1997 | if (tries < MAX_RETRIES) { | 2321 | if (tries < MAX_RETRIES) { |
1998 | - getCampaignsPersonalizedRetro(service, (tries + 1)); | 2322 | + getCampaignsPersonalizedRetro(service, (tries + 1), future); |
1999 | } else { | 2323 | } else { |
2000 | - future.set(new ArrayList<Campaign>()); | 2324 | +// future.set(new ArrayList<Campaign>()); |
2325 | + future.setException(new Throwable()); | ||
2001 | } | 2326 | } |
2002 | } | 2327 | } |
2003 | }); | 2328 | }); |
... | @@ -2006,7 +2331,8 @@ public class WarplyManager { | ... | @@ -2006,7 +2331,8 @@ public class WarplyManager { |
2006 | dynatraceEvent.setEventName("custom_error_campaigns_personalized_loyalty"); | 2331 | dynatraceEvent.setEventName("custom_error_campaigns_personalized_loyalty"); |
2007 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 2332 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
2008 | // receiver.onFailure(response.code()); | 2333 | // receiver.onFailure(response.code()); |
2009 | - future.set(new ArrayList<Campaign>()); | 2334 | +// future.set(new ArrayList<Campaign>()); |
2335 | + future.setException(new Throwable()); | ||
2010 | } | 2336 | } |
2011 | } | 2337 | } |
2012 | 2338 | ||
... | @@ -2016,7 +2342,8 @@ public class WarplyManager { | ... | @@ -2016,7 +2342,8 @@ public class WarplyManager { |
2016 | dynatraceEvent.setEventName("custom_error_campaigns_personalized_loyalty"); | 2342 | dynatraceEvent.setEventName("custom_error_campaigns_personalized_loyalty"); |
2017 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 2343 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
2018 | // receiver.onFailure(2); | 2344 | // receiver.onFailure(2); |
2019 | - future.set(new ArrayList<Campaign>()); | 2345 | +// future.set(new ArrayList<Campaign>()); |
2346 | + future.setException(new Throwable()); | ||
2020 | } | 2347 | } |
2021 | }); | 2348 | }); |
2022 | 2349 | ||
... | @@ -2093,7 +2420,8 @@ public class WarplyManager { | ... | @@ -2093,7 +2420,8 @@ public class WarplyManager { |
2093 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 2420 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
2094 | dynatraceEvent.setEventName("custom_error_available_coupons"); | 2421 | dynatraceEvent.setEventName("custom_error_available_coupons"); |
2095 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 2422 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
2096 | - future.set(new JSONObject()); | 2423 | +// future.set(new JSONObject()); |
2424 | + future.setException(new Throwable()); | ||
2097 | } | 2425 | } |
2098 | } | 2426 | } |
2099 | 2427 | ||
... | @@ -2102,7 +2430,8 @@ public class WarplyManager { | ... | @@ -2102,7 +2430,8 @@ public class WarplyManager { |
2102 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 2430 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
2103 | dynatraceEvent.setEventName("custom_error_available_coupons"); | 2431 | dynatraceEvent.setEventName("custom_error_available_coupons"); |
2104 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 2432 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
2105 | - future.set(new JSONObject()); | 2433 | +// future.set(new JSONObject()); |
2434 | + future.setException(new Throwable()); | ||
2106 | } | 2435 | } |
2107 | }); | 2436 | }); |
2108 | 2437 | ||
... | @@ -3630,7 +3959,8 @@ public class WarplyManager { | ... | @@ -3630,7 +3959,8 @@ public class WarplyManager { |
3630 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 3959 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
3631 | dynatraceEvent.setEventName("custom_error_couponsets_loyalty"); | 3960 | dynatraceEvent.setEventName("custom_error_couponsets_loyalty"); |
3632 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 3961 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
3633 | - future.set(new CouponsetsList()); | 3962 | +// future.set(new CouponsetsList()); |
3963 | + future.setException(new Throwable()); | ||
3634 | } | 3964 | } |
3635 | } | 3965 | } |
3636 | 3966 | ||
... | @@ -3639,7 +3969,8 @@ public class WarplyManager { | ... | @@ -3639,7 +3969,8 @@ public class WarplyManager { |
3639 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 3969 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
3640 | dynatraceEvent.setEventName("custom_error_couponsets_loyalty"); | 3970 | dynatraceEvent.setEventName("custom_error_couponsets_loyalty"); |
3641 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 3971 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
3642 | - future.set(new CouponsetsList()); | 3972 | +// future.set(new CouponsetsList()); |
3973 | + future.setException(new Throwable()); | ||
3643 | } | 3974 | } |
3644 | }); | 3975 | }); |
3645 | 3976 | ||
... | @@ -4149,7 +4480,8 @@ public class WarplyManager { | ... | @@ -4149,7 +4480,8 @@ public class WarplyManager { |
4149 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 4480 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
4150 | dynatraceEvent.setEventName("custom_error_shops_loyalty"); | 4481 | dynatraceEvent.setEventName("custom_error_shops_loyalty"); |
4151 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 4482 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
4152 | - future.set(new MerchantList()); | 4483 | +// future.set(new MerchantList()); |
4484 | + future.setException(new Throwable()); | ||
4153 | } | 4485 | } |
4154 | } | 4486 | } |
4155 | 4487 | ||
... | @@ -4158,7 +4490,8 @@ public class WarplyManager { | ... | @@ -4158,7 +4490,8 @@ public class WarplyManager { |
4158 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 4490 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
4159 | dynatraceEvent.setEventName("custom_error_shops_loyalty"); | 4491 | dynatraceEvent.setEventName("custom_error_shops_loyalty"); |
4160 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 4492 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
4161 | - future.set(new MerchantList()); | 4493 | +// future.set(new MerchantList()); |
4494 | + future.setException(new Throwable()); | ||
4162 | } | 4495 | } |
4163 | }); | 4496 | }); |
4164 | 4497 | ||
... | @@ -4310,9 +4643,7 @@ public class WarplyManager { | ... | @@ -4310,9 +4643,7 @@ public class WarplyManager { |
4310 | }); | 4643 | }); |
4311 | } | 4644 | } |
4312 | 4645 | ||
4313 | - private static ListenableFuture<CouponList> getCouponsUniversalRetro(ApiService service, int tries) { | 4646 | + private static ListenableFuture<CouponList> getCouponsUniversalRetro(ApiService service, int tries, SettableFuture<CouponList> future) { |
4314 | - SettableFuture<CouponList> future = SettableFuture.create(); | ||
4315 | - | ||
4316 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); | 4647 | String timeStamp = DateFormat.format("yyyy-MM-dd hh:mm:ss", System.currentTimeMillis()).toString(); |
4317 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); | 4648 | String apiKey = WarpUtils.getApiKey(Warply.getWarplyContext()); |
4318 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); | 4649 | String webId = WarpUtils.getWebId(Warply.getWarplyContext()); |
... | @@ -4422,13 +4753,14 @@ public class WarplyManager { | ... | @@ -4422,13 +4753,14 @@ public class WarplyManager { |
4422 | public void onSuccess(JSONObject result) { | 4753 | public void onSuccess(JSONObject result) { |
4423 | int status = result.optInt("status", 2); | 4754 | int status = result.optInt("status", 2); |
4424 | if (status == 1) | 4755 | if (status == 1) |
4425 | - getCouponsUniversalRetro(service, tries/*, receiver*/); | 4756 | + getCouponsUniversalRetro(service, tries/*, receiver*/, future); |
4426 | else { | 4757 | else { |
4427 | // receiver.onFailure(status); | 4758 | // receiver.onFailure(status); |
4428 | if (tries < MAX_RETRIES) { | 4759 | if (tries < MAX_RETRIES) { |
4429 | - getCouponsUniversalRetro(service, (tries + 1)); | 4760 | + getCouponsUniversalRetro(service, (tries + 1), future); |
4430 | } else { | 4761 | } else { |
4431 | - future.set(new CouponList()); | 4762 | +// future.set(new CouponList()); |
4763 | + future.setException(new Throwable()); | ||
4432 | } | 4764 | } |
4433 | } | 4765 | } |
4434 | } | 4766 | } |
... | @@ -4437,9 +4769,10 @@ public class WarplyManager { | ... | @@ -4437,9 +4769,10 @@ public class WarplyManager { |
4437 | public void onFailure(int errorCode) { | 4769 | public void onFailure(int errorCode) { |
4438 | // receiver.onFailure(errorCode); | 4770 | // receiver.onFailure(errorCode); |
4439 | if (tries < MAX_RETRIES) { | 4771 | if (tries < MAX_RETRIES) { |
4440 | - getCouponsUniversalRetro(service, (tries + 1)); | 4772 | + getCouponsUniversalRetro(service, (tries + 1), future); |
4441 | } else { | 4773 | } else { |
4442 | - future.set(new CouponList()); | 4774 | +// future.set(new CouponList()); |
4775 | + future.setException(new Throwable()); | ||
4443 | } | 4776 | } |
4444 | } | 4777 | } |
4445 | }); | 4778 | }); |
... | @@ -4447,7 +4780,8 @@ public class WarplyManager { | ... | @@ -4447,7 +4780,8 @@ public class WarplyManager { |
4447 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 4780 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
4448 | dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); | 4781 | dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); |
4449 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 4782 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
4450 | - future.set(new CouponList()); | 4783 | +// future.set(new CouponList()); |
4784 | + future.setException(new Throwable()); | ||
4451 | } | 4785 | } |
4452 | } | 4786 | } |
4453 | 4787 | ||
... | @@ -4456,7 +4790,8 @@ public class WarplyManager { | ... | @@ -4456,7 +4790,8 @@ public class WarplyManager { |
4456 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 4790 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
4457 | dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); | 4791 | dynatraceEvent.setEventName("custom_error_user_coupons_loyalty"); |
4458 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 4792 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
4459 | - future.set(new CouponList()); | 4793 | +// future.set(new CouponList()); |
4794 | + future.setException(new Throwable()); | ||
4460 | } | 4795 | } |
4461 | }); | 4796 | }); |
4462 | 4797 | ... | ... |
-
Please register or login to post a comment