Panagiotis Triantafyllou

new coupons part2

......@@ -50,8 +50,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
mBottomNavigationView = findViewById(R.id.bt_tabs);
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
// WarplyManager.getCampaigns(mCampaignsCallback);
// WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
WarplyManager.getCampaigns(mCampaignsCallback);
WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
}
@Override
......
......@@ -96,6 +96,7 @@ public class Coupon implements Parcelable, Serializable {
private String short_description = "";
private String terms = "";
private Couponset couponsetDetails = new Couponset(true);
private Merchant merchantDetails = new Merchant(true);
public Coupon() {
this.barcode = "";
......@@ -133,6 +134,7 @@ public class Coupon implements Parcelable, Serializable {
this.merchantUuid = "";
this.redeemDate = new Date();
this.couponsetDetails = new Couponset(isUniversal);
this.merchantDetails = new Merchant(isUniversal);
}
/**
......@@ -218,6 +220,10 @@ public class Coupon implements Parcelable, Serializable {
if (tempCouponsetDetails != null) {
this.couponsetDetails = new Couponset(tempCouponsetDetails, isUniversal);
}
JSONObject tempMerchantDetails = json.optJSONObject("merchant_details");
if (tempMerchantDetails != null) {
this.merchantDetails = new Merchant(tempMerchantDetails, isUniversal);
}
// this.category = json.optString(CATEGORY);
// this.created = json.optString(CREATED);
......@@ -522,6 +528,22 @@ public class Coupon implements Parcelable, Serializable {
this.terms = terms;
}
public Couponset getCouponsetDetails() {
return couponsetDetails;
}
public void setCouponsetDetails(Couponset couponsetDetails) {
this.couponsetDetails = couponsetDetails;
}
public Merchant getMerchantDetails() {
return merchantDetails;
}
public void setMerchantDetails(Merchant merchantDetails) {
this.merchantDetails = merchantDetails;
}
@Override
public int describeContents() {
return 0;
......
......@@ -180,6 +180,19 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
coordinates = new LatLng(this.latitude, this.longitude);
}
public Merchant(boolean isUniversal) {
this.address = "";
this.city = "";
this.body = "";
this.logo = "";
this.country = "";
this.name = "";
this.postal_code = "";
this.region = "";
this.telephone = "";
this.merchant_metadata = new JSONObject();
}
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
......@@ -242,6 +255,53 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
}
}
public Merchant(JSONObject json, boolean isUniversal) {
if (json != null) {
this.address = json.isNull(ADDRESS) ? "" : json.optString(ADDRESS);
this.body = json.optString(BODY);
this.city = json.optString(CITY);
this.logo = json.optString(LOGO);
this.country = json.optString(COUNTRY);
this.name = json.isNull(NAME) ? "" : json.optString(NAME);
this.postal_code = json.optString(POSTAL_CODE);
this.region = json.optString(REGION);
this.telephone = json.isNull(TELEPHONE) ? "" : json.optString(TELEPHONE);
this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA);
// this.id = json.optString(ID);
// this.store_id = json.optString(STORE_ID);
// this.website = json.optString(WEBSITE);
// this.email = json.optString(EMAIL);
// this.category = json.optString(CATEGORY);
// this.description = json.optString(DESCRIPTION);
// this.short_description = json.optString(SHORT_DESCRIPTION);
// this.latitude = json.isNull(LAT) ? 0.0 : json.optDouble(LAT);
// this.longitude = json.isNull(LON) ? 0.0 : json.optDouble(LON);
// this.image = json.optString(IMAGE);
// this.extra_fields = json.optJSONObject(EXTRA_FIELDS);
// this.active = json.optBoolean(ACTIVE);
// this.vat = json.optString(VAT);
// this.uuid = json.optString(UUID);
// this.category_uuid = json.optString(CATEGORY_UUID);
// this.created = json.optString(CREATED);
// this.parent = json.optString(PARENT);
// this.img = json.optJSONArray(IMG);
// this.img_preview = json.optString(IMG_PREVIEW);
// this.admin_name = json.optString(ADMIN_NAME);
// this.sorting = json.optInt(SORTING);
// this.owner_name = json.optString(OWNER_NAME);
// this.preview = json.optString(PREVIEW);
// this.promoted = json.optBoolean(PROMOTED);
// this.distance = json.optInt(DISTANCE);
// this.default_shown = json.optBoolean(DEFAULT_SHOWN);
// this.hidden = json.optBoolean(HIDDEN);
// this.working_hours = json.optJSONObject(WORKING_HOURS);
// this.tags = json.optJSONArray(TAGS);
// this.product = json.optJSONObject(PRODUCT);
// coordinates = new LatLng(this.latitude, this.longitude);
}
}
public Merchant(Parcel source) {
this.address = source.readString();
this.id = source.readString();
......