Panagiotis Triantafyllou

cosmote pass requests

...@@ -97,6 +97,7 @@ public class Coupon implements Parcelable, Serializable { ...@@ -97,6 +97,7 @@ public class Coupon implements Parcelable, Serializable {
97 private String terms = ""; 97 private String terms = "";
98 private Couponset couponsetDetails = new Couponset(true); 98 private Couponset couponsetDetails = new Couponset(true);
99 private Merchant merchantDetails = new Merchant(true); 99 private Merchant merchantDetails = new Merchant(true);
100 + private RedeemMerchantDetails redeemDetails = new RedeemMerchantDetails();
100 101
101 public Coupon() { 102 public Coupon() {
102 this.barcode = ""; 103 this.barcode = "";
...@@ -121,6 +122,7 @@ public class Coupon implements Parcelable, Serializable { ...@@ -121,6 +122,7 @@ public class Coupon implements Parcelable, Serializable {
121 this.final_price = 0.0d; 122 this.final_price = 0.0d;
122 this.short_description = ""; 123 this.short_description = "";
123 this.terms = ""; 124 this.terms = "";
125 + this.redeemDetails = new RedeemMerchantDetails();
124 } 126 }
125 127
126 public Coupon(boolean isUniversal) { 128 public Coupon(boolean isUniversal) {
...@@ -135,6 +137,7 @@ public class Coupon implements Parcelable, Serializable { ...@@ -135,6 +137,7 @@ public class Coupon implements Parcelable, Serializable {
135 this.redeemDate = new Date(); 137 this.redeemDate = new Date();
136 this.couponsetDetails = new Couponset(isUniversal); 138 this.couponsetDetails = new Couponset(isUniversal);
137 this.merchantDetails = new Merchant(isUniversal); 139 this.merchantDetails = new Merchant(isUniversal);
140 + this.redeemDetails = new RedeemMerchantDetails();
138 } 141 }
139 142
140 /** 143 /**
...@@ -189,6 +192,10 @@ public class Coupon implements Parcelable, Serializable { ...@@ -189,6 +192,10 @@ public class Coupon implements Parcelable, Serializable {
189 this.final_price = json.optDouble(FINAL_PRICE); 192 this.final_price = json.optDouble(FINAL_PRICE);
190 this.short_description = json.optString(SHORT_DESCRIPTION); 193 this.short_description = json.optString(SHORT_DESCRIPTION);
191 this.terms = json.optString(TERMS); 194 this.terms = json.optString(TERMS);
195 + JSONObject tempRedeemDetails = json.optJSONObject("redeemed_merchant_details");
196 + if (tempRedeemDetails != null) {
197 + this.redeemDetails = new RedeemMerchantDetails(tempRedeemDetails);
198 + }
192 } 199 }
193 } 200 }
194 201
...@@ -224,6 +231,10 @@ public class Coupon implements Parcelable, Serializable { ...@@ -224,6 +231,10 @@ public class Coupon implements Parcelable, Serializable {
224 if (tempMerchantDetails != null) { 231 if (tempMerchantDetails != null) {
225 this.merchantDetails = new Merchant(tempMerchantDetails, isUniversal); 232 this.merchantDetails = new Merchant(tempMerchantDetails, isUniversal);
226 } 233 }
234 + JSONObject tempRedeemDetails = json.optJSONObject("redeemed_merchant_details");
235 + if (tempRedeemDetails != null) {
236 + this.redeemDetails = new RedeemMerchantDetails(tempRedeemDetails);
237 + }
227 238
228 // this.category = json.optString(CATEGORY); 239 // this.category = json.optString(CATEGORY);
229 // this.created = json.optString(CREATED); 240 // this.created = json.optString(CREATED);
...@@ -240,6 +251,75 @@ public class Coupon implements Parcelable, Serializable { ...@@ -240,6 +251,75 @@ public class Coupon implements Parcelable, Serializable {
240 } 251 }
241 } 252 }
242 253
254 + public class RedeemMerchantDetails {
255 + private static final String IMG_PREVIEW = "img_preview";
256 + private static final String NAME = "name";
257 + private static final String UUID = "uuid";
258 + private static final String REDEEMED_DATE = "redeemed_date";
259 +
260 +
261 + private String imgPreview = "";
262 + private String name = "";
263 + private String uuid = "";
264 + private String redeemedDate = "";
265 +
266 + public RedeemMerchantDetails() {
267 + this.imgPreview = "";
268 + this.name = "";
269 + this.uuid = "";
270 + this.redeemedDate = "";
271 + }
272 +
273 + public RedeemMerchantDetails(JSONObject json) {
274 + if (json != null) {
275 + if (json.optJSONObject(IMG_PREVIEW) != null) {
276 + this.imgPreview = json.optString(IMG_PREVIEW);
277 + }
278 + if (json.optJSONObject(NAME) != null) {
279 + this.name = json.optString(NAME);
280 + }
281 + if (json.optJSONObject(UUID) != null) {
282 + this.uuid = json.optString(UUID);
283 + }
284 + if (json.optJSONObject(REDEEMED_DATE) != null) {
285 + this.redeemedDate = json.optString(REDEEMED_DATE);
286 + }
287 + }
288 + }
289 +
290 + public String getImgPreview() {
291 + return imgPreview;
292 + }
293 +
294 + public void setImgPreview(String imgPreview) {
295 + this.imgPreview = imgPreview;
296 + }
297 +
298 + public String getName() {
299 + return name;
300 + }
301 +
302 + public void setName(String name) {
303 + this.name = name;
304 + }
305 +
306 + public String getUuid() {
307 + return uuid;
308 + }
309 +
310 + public void setUuid(String uuid) {
311 + this.uuid = uuid;
312 + }
313 +
314 + public String getRedeemedDate() {
315 + return redeemedDate;
316 + }
317 +
318 + public void setRedeemedDate(String redeemedDate) {
319 + this.redeemedDate = redeemedDate;
320 + }
321 + }
322 +
243 public Coupon(Parcel source) { 323 public Coupon(Parcel source) {
244 this.barcode = source.readString(); 324 this.barcode = source.readString();
245 this.category = source.readString(); 325 this.category = source.readString();
...@@ -544,6 +624,14 @@ public class Coupon implements Parcelable, Serializable { ...@@ -544,6 +624,14 @@ public class Coupon implements Parcelable, Serializable {
544 this.merchantDetails = merchantDetails; 624 this.merchantDetails = merchantDetails;
545 } 625 }
546 626
627 + public RedeemMerchantDetails getRedeemDetails() {
628 + return redeemDetails;
629 + }
630 +
631 + public void setRedeemDetails(RedeemMerchantDetails redeemDetails) {
632 + this.redeemDetails = redeemDetails;
633 + }
634 +
547 @Override 635 @Override
548 public int describeContents() { 636 public int describeContents() {
549 return 0; 637 return 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 +import org.json.JSONArray;
29 +import org.json.JSONException;
30 +import org.json.JSONObject;
31 +
32 +import java.util.ArrayList;
33 +
34 +import ly.warp.sdk.utils.WarpUtils;
35 +import ly.warp.sdk.utils.constants.WarpConstants;
36 +
37 +/**
38 + * Created by Panagiotis Triantafyllou on 20-Jan-25.
39 + */
40 +
41 +public class MarketPassDetailsModel {
42 + private static final String BARCODE = "barcode";
43 + private static final String SUPERMARKETS = "supermarkets";
44 + private static final String TOTAL_DISCOUNT = "total_available_discount";
45 +
46 + private ArrayList<Supermarkets> supermarkets = new ArrayList<Supermarkets>();
47 + private String barcode = "";
48 + private double totalDiscount = 0.0d;
49 +
50 + public MarketPassDetailsModel() {
51 + this.supermarkets = new ArrayList<Supermarkets>();
52 + this.barcode = "";
53 + this.totalDiscount = 0.0d;
54 + }
55 +
56 + /**
57 + * Basic constructor used to create an object from a String, representing a
58 + * JSON Object
59 + *
60 + * @param json The String, representing the JSON Object
61 + * @throws JSONException Thrown if the String cannot be converted to JSON
62 + */
63 + public MarketPassDetailsModel(String json) throws JSONException {
64 + this(new JSONObject(json));
65 + }
66 +
67 + /**
68 + * Constructor used to create an Object from a given JSON Object
69 + *
70 + * @param json JSON Object used to create the Campaign
71 + */
72 + public MarketPassDetailsModel(JSONObject json) {
73 + if (json != null) {
74 + if (json.optJSONArray(SUPERMARKETS) != null) {
75 + JSONArray tempSupermarkets = json.optJSONArray(SUPERMARKETS);
76 + if (tempSupermarkets != null && tempSupermarkets.length() > 0) {
77 + for (int i = 0, lim = tempSupermarkets.length(); i < lim; ++i) {
78 + this.supermarkets.add(new Supermarkets(tempSupermarkets.optJSONObject(i)));
79 + }
80 + }
81 + }
82 + this.barcode = json.optString(BARCODE);
83 + this.totalDiscount = json.optDouble(TOTAL_DISCOUNT);
84 + }
85 + }
86 +
87 + /**
88 + * Converts the Campaign into a JSON Object
89 + *
90 + * @return The JSON Object created from this campaign
91 + */
92 + public JSONObject toJSONObject() {
93 + JSONObject jObj = new JSONObject();
94 + try {
95 + jObj.putOpt(BARCODE, this.barcode);
96 + jObj.putOpt(TOTAL_DISCOUNT, this.totalDiscount);
97 + jObj.putOpt(SUPERMARKETS, this.supermarkets);
98 + } catch (JSONException e) {
99 + if (WarpConstants.DEBUG) {
100 + e.printStackTrace();
101 + }
102 + }
103 + return jObj;
104 + }
105 +
106 + /**
107 + * String representation of the Campaign, as a JSON object
108 + *
109 + * @return A String representation of JSON object
110 + */
111 + public String toString() {
112 + if (toJSONObject() != null)
113 + return toJSONObject().toString();
114 + return null;
115 + }
116 +
117 + /**
118 + * String representation of the Campaign, as a human readable JSON object
119 + *
120 + * @return A human readable String representation of JSON object
121 + */
122 + public String toHumanReadableString() {
123 + String humanReadableString = null;
124 + try {
125 + humanReadableString = toJSONObject().toString(2);
126 + } catch (JSONException e) {
127 + WarpUtils.warn("Failed converting Campaign JSON object to String",
128 + e);
129 + }
130 + return humanReadableString;
131 + }
132 +
133 + public class Supermarkets {
134 + private static final String LOGO = "logo";
135 + private static final String NAME = "name";
136 + private static final String UUID = "uuid";
137 +
138 +
139 + private String logo = "";
140 + private String name = "";
141 + private String uuid = "";
142 +
143 + public Supermarkets() {
144 + this.logo = "";
145 + this.name = "";
146 + this.uuid = "";
147 + }
148 +
149 + public Supermarkets(JSONObject json) {
150 + if (json != null) {
151 + if (json.optJSONObject(LOGO) != null) {
152 + this.logo = json.optString(LOGO);
153 + }
154 + if (json.optJSONObject(NAME) != null) {
155 + this.name = json.optString(NAME);
156 + }
157 + if (json.optJSONObject(UUID) != null) {
158 + this.uuid = json.optString(UUID);
159 + }
160 + }
161 + }
162 +
163 + public String getLogo() {
164 + return logo;
165 + }
166 +
167 + public void setLogo(String logo) {
168 + this.logo = logo;
169 + }
170 +
171 + public String getName() {
172 + return name;
173 + }
174 +
175 + public void setName(String name) {
176 + this.name = name;
177 + }
178 +
179 + public String getUuid() {
180 + return uuid;
181 + }
182 +
183 + public void setUuid(String uuid) {
184 + this.uuid = uuid;
185 + }
186 + }
187 +
188 + // ================================================================================
189 + // Getters
190 + // ================================================================================
191 +
192 +
193 + public ArrayList<Supermarkets> getSupermarkets() {
194 + return supermarkets;
195 + }
196 +
197 + public void setSupermarkets(ArrayList<Supermarkets> supermarkets) {
198 + this.supermarkets = supermarkets;
199 + }
200 +
201 + public String getBarcode() {
202 + return barcode;
203 + }
204 +
205 + public void setBarcode(String barcode) {
206 + this.barcode = barcode;
207 + }
208 +
209 + public double getTotalDiscount() {
210 + return totalDiscount;
211 + }
212 +
213 + public void setTotalDiscount(double totalDiscount) {
214 + this.totalDiscount = totalDiscount;
215 + }
216 +}
...@@ -174,6 +174,18 @@ public interface ApiService { ...@@ -174,6 +174,18 @@ public interface ApiService {
174 174
175 @Headers("Content-Type: application/json") 175 @Headers("Content-Type: application/json")
176 @POST("/oauth/{appUuid}/context") 176 @POST("/oauth/{appUuid}/context")
177 + Call<ResponseBody> getMarketPassDetails(@Path("appUuid") String appUuid,
178 + @Body RequestBody request,
179 + @Header(WarpConstants.HEADER_DATE) String timeStamp,
180 + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
181 + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
182 + @Header(WarpConstants.HEADER_CHANNEL) String channel,
183 + @Header(WarpConstants.HEADER_WEB_ID) String webId,
184 + @Header(WarpConstants.HEADER_SIGNATURE) String signature,
185 + @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
186 +
187 + @Headers("Content-Type: application/json")
188 + @POST("/oauth/{appUuid}/context")
177 Call<ResponseBody> sendTelematicsData(@Path("appUuid") String appUuid, 189 Call<ResponseBody> sendTelematicsData(@Path("appUuid") String appUuid,
178 @Body RequestBody request, 190 @Body RequestBody request,
179 @Header(WarpConstants.HEADER_DATE) String timeStamp, 191 @Header(WarpConstants.HEADER_DATE) String timeStamp,
......