Panagiotis Triantafyllou

added event when coupons request completed

...@@ -202,6 +202,11 @@ ...@@ -202,6 +202,11 @@
202 android:permission="android.permission.BIND_JOB_SERVICE" /> 202 android:permission="android.permission.BIND_JOB_SERVICE" />
203 203
204 <service 204 <service
205 + android:name="ly.warp.sdk.services.EventRewardsCouponsService"
206 + android:exported="false"
207 + android:permission="android.permission.BIND_JOB_SERVICE" />
208 +
209 + <service
205 android:name="ly.warp.sdk.services.EventUnifiedCouponsService" 210 android:name="ly.warp.sdk.services.EventUnifiedCouponsService"
206 android:exported="false" 211 android:exported="false"
207 android:permission="android.permission.BIND_JOB_SERVICE" /> 212 android:permission="android.permission.BIND_JOB_SERVICE" />
......
...@@ -418,7 +418,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -418,7 +418,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
418 }); 418 });
419 return; 419 return;
420 } 420 }
421 - if (event.getCouponsAdded() != null) { 421 + if (event.getCouponsAdded() != null || event.getRewardsCouponsEventModel() != null) {
422 Handler mUIHandler = new Handler(Looper.getMainLooper()); 422 Handler mUIHandler = new Handler(Looper.getMainLooper());
423 mUIHandler.post(() -> { 423 mUIHandler.post(() -> {
424 if (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() > 0) 424 if (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() > 0)
......
1 +/*
2 + * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 + *
4 + * Redistribution and use in source and binary forms, without modification, are
5 + * permitted provided that the following conditions are met:
6 + *
7 + * 1. Redistributions of source code must retain the above copyright notice,
8 + * this list of conditions and the following disclaimer.
9 + *
10 + * 2. Redistributions in binary form must reproduce the above copyright notice,
11 + * this list of conditions and the following disclaimer in the documentation
12 + * and/or other materials provided with the distribution.
13 + *
14 + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 + */
25 +
26 +package ly.warp.sdk.io.models;
27 +
28 +
29 +/**
30 + * Created by Panagiotis Triantafyllou on 30-April-24.
31 + */
32 +
33 +public class RewardsCouponsEventModel {
34 + private boolean success;
35 +
36 + public RewardsCouponsEventModel() {
37 + this.success = true;
38 + }
39 +
40 + public boolean isSuccess() {
41 + return success;
42 + }
43 +
44 + public void setSuccess(boolean success) {
45 + this.success = success;
46 + }
47 +}
1 +package ly.warp.sdk.services;
2 +
3 +import android.content.Context;
4 +
5 +import androidx.annotation.NonNull;
6 +import androidx.work.Worker;
7 +import androidx.work.WorkerParameters;
8 +
9 +import org.greenrobot.eventbus.EventBus;
10 +
11 +import ly.warp.sdk.io.models.RewardsCouponsEventModel;
12 +import ly.warp.sdk.utils.managers.WarplyEventBusManager;
13 +
14 +/**
15 + * Created by Panagiotis Triantafyllou on 05/Sept/2022.
16 + */
17 +public class EventRewardsCouponsService extends Worker {
18 +
19 + public EventRewardsCouponsService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
20 + super(context, workerParams);
21 + }
22 +
23 + @NonNull
24 + @Override
25 + public Result doWork() {
26 + RewardsCouponsEventModel couponsAdded = new RewardsCouponsEventModel();
27 + EventBus.getDefault().post(new WarplyEventBusManager(couponsAdded));
28 +
29 + return Result.success();
30 + }
31 +}
...@@ -17,6 +17,7 @@ import ly.warp.sdk.io.models.OpenMyRewardsEventModel; ...@@ -17,6 +17,7 @@ import ly.warp.sdk.io.models.OpenMyRewardsEventModel;
17 import ly.warp.sdk.io.models.QuestionnaireEventModel; 17 import ly.warp.sdk.io.models.QuestionnaireEventModel;
18 import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel; 18 import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel;
19 import ly.warp.sdk.io.models.RefreshVouchersEventModel; 19 import ly.warp.sdk.io.models.RefreshVouchersEventModel;
20 +import ly.warp.sdk.io.models.RewardsCouponsEventModel;
20 import ly.warp.sdk.io.models.UnifiedCouponsEventModel; 21 import ly.warp.sdk.io.models.UnifiedCouponsEventModel;
21 import ly.warp.sdk.io.models.VouchersActivityEventModel; 22 import ly.warp.sdk.io.models.VouchersActivityEventModel;
22 import ly.warp.sdk.io.models.VouchersFetchedEventModel; 23 import ly.warp.sdk.io.models.VouchersFetchedEventModel;
...@@ -48,6 +49,7 @@ public class WarplyEventBusManager { ...@@ -48,6 +49,7 @@ public class WarplyEventBusManager {
48 private LoyaltyGiftsForYouOfferClickEvent giftsYou; 49 private LoyaltyGiftsForYouOfferClickEvent giftsYou;
49 private QuestionnaireEventModel questionnaire; 50 private QuestionnaireEventModel questionnaire;
50 private OpenMyRewardsEventModel openRewards; 51 private OpenMyRewardsEventModel openRewards;
52 + private RewardsCouponsEventModel rewardsCoupons;
51 private VouchersActivityEventModel vouchersActivity; 53 private VouchersActivityEventModel vouchersActivity;
52 private VouchersFetchedEventModel vouchersFetched; 54 private VouchersFetchedEventModel vouchersFetched;
53 private CouponEventModel coupon; 55 private CouponEventModel coupon;
...@@ -89,6 +91,10 @@ public class WarplyEventBusManager { ...@@ -89,6 +91,10 @@ public class WarplyEventBusManager {
89 this.openRewards = openRewards; 91 this.openRewards = openRewards;
90 } 92 }
91 93
94 + public WarplyEventBusManager(RewardsCouponsEventModel rewardsCoupons) {
95 + this.rewardsCoupons = rewardsCoupons;
96 + }
97 +
92 public WarplyEventBusManager(RefreshVouchersEventModel vouchersRefreshed) { 98 public WarplyEventBusManager(RefreshVouchersEventModel vouchersRefreshed) {
93 this.vouchersRefreshed = vouchersRefreshed; 99 this.vouchersRefreshed = vouchersRefreshed;
94 } 100 }
...@@ -338,4 +344,8 @@ public class WarplyEventBusManager { ...@@ -338,4 +344,8 @@ public class WarplyEventBusManager {
338 public OpenMyRewardsEventModel getOpenMyRewardsEventModel() { 344 public OpenMyRewardsEventModel getOpenMyRewardsEventModel() {
339 return openRewards; 345 return openRewards;
340 } 346 }
347 +
348 + public RewardsCouponsEventModel getRewardsCouponsEventModel() {
349 + return rewardsCoupons;
350 + }
341 } 351 }
......
...@@ -155,6 +155,8 @@ import ly.warp.sdk.io.request.WarplyVerifyTicketRequest; ...@@ -155,6 +155,8 @@ import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
155 import ly.warp.sdk.io.volley.ApiClient; 155 import ly.warp.sdk.io.volley.ApiClient;
156 import ly.warp.sdk.io.volley.ApiService; 156 import ly.warp.sdk.io.volley.ApiService;
157 import ly.warp.sdk.services.EventCampaignService; 157 import ly.warp.sdk.services.EventCampaignService;
158 +import ly.warp.sdk.services.EventCouponsService;
159 +import ly.warp.sdk.services.EventRewardsCouponsService;
158 import ly.warp.sdk.services.EventUnifiedCouponsService; 160 import ly.warp.sdk.services.EventUnifiedCouponsService;
159 import ly.warp.sdk.utils.WarpJSONParser; 161 import ly.warp.sdk.utils.WarpJSONParser;
160 import ly.warp.sdk.utils.WarpUtils; 162 import ly.warp.sdk.utils.WarpUtils;
...@@ -4709,6 +4711,8 @@ public class WarplyManager { ...@@ -4709,6 +4711,8 @@ public class WarplyManager {
4709 4711
4710 WarplyManagerHelper.setCouponList(mCouponsList); 4712 WarplyManagerHelper.setCouponList(mCouponsList);
4711 WarplyManagerHelper.setCouponRedeemedList(mCouponRedeemedList); 4713 WarplyManagerHelper.setCouponRedeemedList(mCouponRedeemedList);
4714 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventRewardsCouponsService.class).build();
4715 + WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
4712 4716
4713 Collections.sort(mActiveCouponList, (coupon1, coupon2) -> coupon1.getExpirationDate().compareTo(coupon2.getExpirationDate())); 4717 Collections.sort(mActiveCouponList, (coupon1, coupon2) -> coupon1.getExpirationDate().compareTo(coupon2.getExpirationDate()));
4714 4718
......