Panagiotis Triantafyllou

new coupons request part1

...@@ -50,8 +50,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation ...@@ -50,8 +50,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
50 mBottomNavigationView = findViewById(R.id.bt_tabs); 50 mBottomNavigationView = findViewById(R.id.bt_tabs);
51 51
52 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); 52 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
53 - WarplyManager.getCampaigns(mCampaignsCallback); 53 +// WarplyManager.getCampaigns(mCampaignsCallback);
54 - WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); 54 +// WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
55 } 55 }
56 56
57 @Override 57 @Override
......
...@@ -95,6 +95,7 @@ public class Coupon implements Parcelable, Serializable { ...@@ -95,6 +95,7 @@ public class Coupon implements Parcelable, Serializable {
95 private double final_price = 0.0d; 95 private double final_price = 0.0d;
96 private String short_description = ""; 96 private String short_description = "";
97 private String terms = ""; 97 private String terms = "";
98 + private Couponset couponsetDetails = new Couponset(true);
98 99
99 public Coupon() { 100 public Coupon() {
100 this.barcode = ""; 101 this.barcode = "";
...@@ -121,6 +122,19 @@ public class Coupon implements Parcelable, Serializable { ...@@ -121,6 +122,19 @@ public class Coupon implements Parcelable, Serializable {
121 this.terms = ""; 122 this.terms = "";
122 } 123 }
123 124
125 + public Coupon(boolean isUniversal) {
126 + this.barcode = "";
127 + this.coupon = "";
128 + this.discount = "";
129 + this.expiration = "";
130 + this.status = 0;
131 + this.changesDates = new JSONObject();
132 + this.couponsetUuid = "";
133 + this.merchantUuid = "";
134 + this.redeemDate = new Date();
135 + this.couponsetDetails = new Couponset(isUniversal);
136 + }
137 +
124 /** 138 /**
125 * Basic constructor used to create an object from a String, representing a 139 * Basic constructor used to create an object from a String, representing a
126 * JSON Object 140 * JSON Object
...@@ -176,6 +190,50 @@ public class Coupon implements Parcelable, Serializable { ...@@ -176,6 +190,50 @@ public class Coupon implements Parcelable, Serializable {
176 } 190 }
177 } 191 }
178 192
193 + public Coupon(JSONObject json, boolean isUniversal) {
194 + if (json != null) {
195 + this.barcode = json.optString(BARCODE);
196 + this.changesDates = json.optJSONObject(CHANGES_DATES);
197 + if (this.changesDates != null) {
198 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
199 + Date newDate = new Date();
200 + String tempRedeemDate = this.changesDates.optString("redeemed");
201 + try {
202 + newDate = simpleDateFormat.parse(tempRedeemDate);
203 + this.redeemDate = newDate;
204 + } catch (ParseException e) {
205 + e.printStackTrace();
206 + }
207 + }
208 + this.coupon = json.optString(COUPON);
209 + this.couponsetUuid = json.optString(COUPONSET_UUID);
210 + this.discount = json.optString(DISCOUNT);
211 + if (this.discount.contains(",")) {
212 + this.discount = this.discount.replace(",", ".");
213 + }
214 + this.expiration = json.optString(EXPIRATION);
215 + this.merchantUuid = json.optString(MERCHANT_UUID);
216 + this.status = json.optInt(STATUS);
217 + JSONObject tempCouponsetDetails = json.optJSONObject("couponset_details");
218 + if (tempCouponsetDetails != null) {
219 + this.couponsetDetails = new Couponset(tempCouponsetDetails, isUniversal);
220 + }
221 +
222 +// this.category = json.optString(CATEGORY);
223 +// this.created = json.optString(CREATED);
224 +// this.description = json.optString(DESCRIPTION);
225 +// this.image = json.optString(IMAGE);
226 +// this.name = json.optString(NAME);
227 +// this.transactionDate = json.optString(TRANSACTION_DATE);
228 +// this.transactionUuid = json.optString(TRANSACTION_UUID);
229 +// this.innerText = json.optString(INNER_TEXT);
230 +// this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE);
231 +// this.final_price = json.optDouble(FINAL_PRICE);
232 +// this.short_description = json.optString(SHORT_DESCRIPTION);
233 +// this.terms = json.optString(TERMS);
234 + }
235 + }
236 +
179 public Coupon(Parcel source) { 237 public Coupon(Parcel source) {
180 this.barcode = source.readString(); 238 this.barcode = source.readString();
181 this.category = source.readString(); 239 this.category = source.readString();
......
...@@ -33,6 +33,9 @@ import org.json.JSONException; ...@@ -33,6 +33,9 @@ import org.json.JSONException;
33 import org.json.JSONObject; 33 import org.json.JSONObject;
34 34
35 import java.io.Serializable; 35 import java.io.Serializable;
36 +import java.text.ParseException;
37 +import java.text.SimpleDateFormat;
38 +import java.util.Date;
36 39
37 import ly.warp.sdk.utils.WarpUtils; 40 import ly.warp.sdk.utils.WarpUtils;
38 import ly.warp.sdk.utils.constants.WarpConstants; 41 import ly.warp.sdk.utils.constants.WarpConstants;
...@@ -108,6 +111,7 @@ public class Couponset implements Parcelable, Serializable { ...@@ -108,6 +111,7 @@ public class Couponset implements Parcelable, Serializable {
108 private String innerText = ""; 111 private String innerText = "";
109 private String discount_type = ""; 112 private String discount_type = "";
110 private double final_price = 0.0d; 113 private double final_price = 0.0d;
114 + private Date endDate = new Date();
111 115
112 public Couponset() { 116 public Couponset() {
113 this.uuid = ""; 117 this.uuid = "";
...@@ -140,6 +144,23 @@ public class Couponset implements Parcelable, Serializable { ...@@ -140,6 +144,23 @@ public class Couponset implements Parcelable, Serializable {
140 this.final_price = 0.0d; 144 this.final_price = 0.0d;
141 } 145 }
142 146
147 + public Couponset(boolean isUniversal) {
148 + this.admin_name = "";
149 + this.active = false;
150 + this.buyable = false;
151 + this.category = "";
152 + this.created = "";
153 + this.discount = "";
154 + this.discount_type = "";
155 + this.name = "";
156 + this.img = new JSONArray();
157 + this.short_description = "";
158 + this.terms = "";
159 + this.updated = "";
160 + this.uuid = "";
161 +// this.endDate = new Date();
162 + }
163 +
143 /** 164 /**
144 * Basic constructor used to create an object from a String, representing a 165 * Basic constructor used to create an object from a String, representing a
145 * JSON Object 166 * JSON Object
...@@ -196,6 +217,56 @@ public class Couponset implements Parcelable, Serializable { ...@@ -196,6 +217,56 @@ public class Couponset implements Parcelable, Serializable {
196 } 217 }
197 } 218 }
198 219
220 + public Couponset(JSONObject json, boolean isUniversal) {
221 + if (json != null) {
222 + this.uuid = json.optString(UUID);
223 + this.admin_name = json.optString(ADMIN_NAME);
224 + this.created = json.optString(CREATED);
225 + this.updated = json.optString(UPDATED);
226 + this.img = json.optJSONArray(IMG);
227 + this.active = json.optBoolean(ACTIVE);
228 + this.buyable = json.optBoolean(BUYABLE);
229 + this.name = json.optString(NAME);
230 + this.short_description = json.optString(SHORT_DESCRIPTION);
231 + this.discount = json.optString(DISCOUNT);
232 + this.category = json.optString(CATEGORY);
233 + this.terms = json.optString(TERMS);
234 + this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE);
235 +// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
236 +// Date newDate = new Date();
237 +// String tempRedeemDate = json.optString("end_date");
238 +// try {
239 +// newDate = simpleDateFormat.parse(tempRedeemDate);
240 +// this.endDate = newDate;
241 +// } catch (ParseException e) {
242 +// e.printStackTrace();
243 +// }
244 +
245 +// this.app_uuid = json.optString(APP_UUID);
246 +// this.img_preview = json.optString(IMG_PREVIEW);
247 +// this.sorting = json.optInt(SORTING);
248 +// this.visible = json.optBoolean(VISIBLE);
249 +// this.user_generated = json.optBoolean(USER_GENERATED);
250 +// this.limits = json.optJSONObject(LIMITS);
251 +// this.points = json.optInt(POINTS);
252 +// this.points_cause = json.optString(POINTS_CAUSE);
253 +// JSONObject exp = null;
254 +// try {
255 +// exp = new JSONObject(json.optString(EXPIRATION));
256 +// this.expiration = exp.optString(VALUE);
257 +// } catch (JSONException e) {
258 +// e.printStackTrace();
259 +// this.expiration = "";
260 +// }
261 +// this.third_party_service = json.optBoolean(THIRD_PARTY_SERVICE);
262 +// this.description = json.optString(DESCRIPTION);
263 +// this.availability = json.optInt(AVAILABILITY);
264 +// this.merchantUuid = json.optString(MERCHANT_UUID);
265 +// this.innerText = json.optString(INNER_TEXT);
266 +// this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE);
267 + }
268 + }
269 +
199 public Couponset(Parcel source) { 270 public Couponset(Parcel source) {
200 this.uuid = source.readString(); 271 this.uuid = source.readString();
201 this.admin_name = source.readString(); 272 this.admin_name = source.readString();
......