Panagiotis Triantafyllou

fixed coupons

......@@ -24,10 +24,15 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Campaign;
import ly.warp.sdk.io.models.CampaignList;
import ly.warp.sdk.io.models.Consumer;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.CouponsetsList;
import ly.warp.sdk.io.request.WarplyConsumerRequest;
import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest;
import ly.warp.sdk.io.request.WarplyInboxRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.managers.WarplyManager;
import ly.warp.sdk.utils.managers.WarplySessionManager;
......@@ -45,7 +50,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
private Fragment mFragmentToSet = null;
private static Consumer mConsumer;
private static HashMap mUniqueCampaignList = new HashMap<String, CampaignList>();
private static CouponList mCouponList;
private static CouponList mCouponList = new CouponList();
private CouponsetsList mCouponsetsList;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -175,6 +181,22 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
}
// Thread.currentThread().interrupt();
WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest()
.setLanguage(WarplyProperty.getLanguage(BaseFragmentActivity.this)), mCouponsetsReceiver);
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
private CallbackReceiver<CouponsetsList> mCouponsetsReceiver = new CallbackReceiver<CouponsetsList>() {
@Override
public void onSuccess(CouponsetsList result) {
mCouponsetsList = result;
WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
......@@ -184,10 +206,21 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
}
};
private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
mCouponList = result;
for (Coupon coupon : result) {
for (Couponset couponset : mCouponsetsList) {
if (coupon.getCouponsetUuid().equals(couponset.getUuid())) {
coupon.setDescription(couponset.getShortDescription());
coupon.setImage(couponset.getImgPreview());
coupon.setName(couponset.getName());
mCouponList.add(coupon);
}
}
}
Thread.currentThread().interrupt();
new Handler(Looper.getMainLooper()).post(() -> {
initViews();
......
......@@ -263,6 +263,62 @@ public class Coupon implements Parcelable, Serializable {
return couponsetUuid;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public void setCategory(String category) {
this.category = category;
}
public void setCoupon(String coupon) {
this.coupon = coupon;
}
public void setCreated(String created) {
this.created = created;
}
public void setDescription(String description) {
this.description = description;
}
public void setDiscount(String discount) {
this.discount = discount;
}
public void setExpiration(String expiration) {
this.expiration = expiration;
}
public void setImage(String image) {
this.image = image;
}
public void setName(String name) {
this.name = name;
}
public void setStatus(int status) {
this.status = status;
}
public void setTransactionDate(String transactionDate) {
this.transactionDate = transactionDate;
}
public void setTransactionUuid(String transactionUuid) {
this.transactionUuid = transactionUuid;
}
public void setChangesDates(JSONObject changesDates) {
this.changesDates = changesDates;
}
public void setCouponsetUuid(String couponsetUuid) {
this.couponsetUuid = couponsetUuid;
}
@Override
public int describeContents() {
return 0;
......