Panagiotis Triantafyllou

added event when coupons request completed

......@@ -202,6 +202,11 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.EventRewardsCouponsService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.EventUnifiedCouponsService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
......
......@@ -418,7 +418,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
});
return;
}
if (event.getCouponsAdded() != null) {
if (event.getCouponsAdded() != null || event.getRewardsCouponsEventModel() != null) {
Handler mUIHandler = new Handler(Looper.getMainLooper());
mUIHandler.post(() -> {
if (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() > 0)
......
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.models;
/**
* Created by Panagiotis Triantafyllou on 30-April-24.
*/
public class RewardsCouponsEventModel {
private boolean success;
public RewardsCouponsEventModel() {
this.success = true;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}
package ly.warp.sdk.services;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import org.greenrobot.eventbus.EventBus;
import ly.warp.sdk.io.models.RewardsCouponsEventModel;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
/**
* Created by Panagiotis Triantafyllou on 05/Sept/2022.
*/
public class EventRewardsCouponsService extends Worker {
public EventRewardsCouponsService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
RewardsCouponsEventModel couponsAdded = new RewardsCouponsEventModel();
EventBus.getDefault().post(new WarplyEventBusManager(couponsAdded));
return Result.success();
}
}
......@@ -17,6 +17,7 @@ import ly.warp.sdk.io.models.OpenMyRewardsEventModel;
import ly.warp.sdk.io.models.QuestionnaireEventModel;
import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel;
import ly.warp.sdk.io.models.RefreshVouchersEventModel;
import ly.warp.sdk.io.models.RewardsCouponsEventModel;
import ly.warp.sdk.io.models.UnifiedCouponsEventModel;
import ly.warp.sdk.io.models.VouchersActivityEventModel;
import ly.warp.sdk.io.models.VouchersFetchedEventModel;
......@@ -48,6 +49,7 @@ public class WarplyEventBusManager {
private LoyaltyGiftsForYouOfferClickEvent giftsYou;
private QuestionnaireEventModel questionnaire;
private OpenMyRewardsEventModel openRewards;
private RewardsCouponsEventModel rewardsCoupons;
private VouchersActivityEventModel vouchersActivity;
private VouchersFetchedEventModel vouchersFetched;
private CouponEventModel coupon;
......@@ -89,6 +91,10 @@ public class WarplyEventBusManager {
this.openRewards = openRewards;
}
public WarplyEventBusManager(RewardsCouponsEventModel rewardsCoupons) {
this.rewardsCoupons = rewardsCoupons;
}
public WarplyEventBusManager(RefreshVouchersEventModel vouchersRefreshed) {
this.vouchersRefreshed = vouchersRefreshed;
}
......@@ -338,4 +344,8 @@ public class WarplyEventBusManager {
public OpenMyRewardsEventModel getOpenMyRewardsEventModel() {
return openRewards;
}
public RewardsCouponsEventModel getRewardsCouponsEventModel() {
return rewardsCoupons;
}
}
......
......@@ -155,6 +155,8 @@ import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
import ly.warp.sdk.io.volley.ApiClient;
import ly.warp.sdk.io.volley.ApiService;
import ly.warp.sdk.services.EventCampaignService;
import ly.warp.sdk.services.EventCouponsService;
import ly.warp.sdk.services.EventRewardsCouponsService;
import ly.warp.sdk.services.EventUnifiedCouponsService;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarpUtils;
......@@ -4709,6 +4711,8 @@ public class WarplyManager {
WarplyManagerHelper.setCouponList(mCouponsList);
WarplyManagerHelper.setCouponRedeemedList(mCouponRedeemedList);
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventRewardsCouponsService.class).build();
WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
Collections.sort(mActiveCouponList, (coupon1, coupon2) -> coupon1.getExpirationDate().compareTo(coupon2.getExpirationDate()));
......