Panagiotis Triantafyllou

couponsets and merchants implementation

1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="AndroidProjectSystem">
4 + <option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="CompilerConfiguration">
4 + <bytecodeTargetLevel target="21" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="deploymentTargetSelector">
4 + <selectionStates>
5 + <SelectionState runConfigName="app">
6 + <option name="selectionMode" value="DROPDOWN" />
7 + </SelectionState>
8 + </selectionStates>
9 + </component>
10 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="GradleMigrationSettings" migrationVersion="1" />
4 + <component name="GradleSettings">
5 + <option name="linkedExternalProjectsSettings">
6 + <GradleProjectSettings>
7 + <option name="testRunner" value="CHOOSE_PER_TEST" />
8 + <option name="externalProjectPath" value="$PROJECT_DIR$" />
9 + <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
10 + <option name="modules">
11 + <set>
12 + <option value="$PROJECT_DIR$" />
13 + <option value="$PROJECT_DIR$/app" />
14 + <option value="$PROJECT_DIR$/warply_android_sdk" />
15 + </set>
16 + </option>
17 + </GradleProjectSettings>
18 + </option>
19 + </component>
20 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="ProjectMigrations">
4 + <option name="MigrateToGradleLocalJavaHome">
5 + <set>
6 + <option value="$PROJECT_DIR$" />
7 + </set>
8 + </option>
9 + </component>
10 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<project version="4">
2 + <component name="ExternalStorageConfigurationManager" enabled="true" />
3 + <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK" />
4 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="RunConfigurationProducerService">
4 + <option name="ignoredProducers">
5 + <set>
6 + <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
7 + <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
8 + <option value="com.intellij.execution.junit.PatternConfigurationProducer" />
9 + <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
10 + <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
11 + <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
12 + <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
13 + <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
14 + </set>
15 + </option>
16 + </component>
17 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="VcsDirectoryMappings">
4 + <mapping directory="" vcs="Git" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
...@@ -26,6 +26,7 @@ import ly.warp.sdk.io.adapters.BannerAdapter; ...@@ -26,6 +26,7 @@ import ly.warp.sdk.io.adapters.BannerAdapter;
26 import ly.warp.sdk.io.adapters.OfferAdapter; 26 import ly.warp.sdk.io.adapters.OfferAdapter;
27 import ly.warp.sdk.io.callbacks.CallbackReceiver; 27 import ly.warp.sdk.io.callbacks.CallbackReceiver;
28 import ly.warp.sdk.io.models.BannerItem; 28 import ly.warp.sdk.io.models.BannerItem;
29 +import ly.warp.sdk.io.models.Couponset;
29 import ly.warp.sdk.io.models.DummyDataProvider; 30 import ly.warp.sdk.io.models.DummyDataProvider;
30 import ly.warp.sdk.io.models.OfferCategory; 31 import ly.warp.sdk.io.models.OfferCategory;
31 import ly.warp.sdk.io.models.OfferItem; 32 import ly.warp.sdk.io.models.OfferItem;
...@@ -100,6 +101,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe ...@@ -100,6 +101,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
100 initViews(); 101 initViews();
101 mPbLoading.setVisibility(View.VISIBLE); 102 mPbLoading.setVisibility(View.VISIBLE);
102 WarplyManager.getCampaigns(mCampaignsCallback); 103 WarplyManager.getCampaigns(mCampaignsCallback);
104 + WarplyManager.getCouponsets(mCouponsetsCallback);
103 105
104 // Setup all category sections 106 // Setup all category sections
105 // setupTopOffersSection(); 107 // setupTopOffersSection();
...@@ -431,7 +433,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe ...@@ -431,7 +433,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
431 }); 433 });
432 mBannerAdapter.setOnBannerContentClickListener(article -> { 434 mBannerAdapter.setOnBannerContentClickListener(article -> {
433 //TODO: click article 435 //TODO: click article
434 - String s = "";
435 }); 436 });
436 437
437 // Set the number of pages to preload for adjacent items 438 // Set the number of pages to preload for adjacent items
...@@ -519,4 +520,16 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe ...@@ -519,4 +520,16 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
519 mViewPager.setVisibility(View.GONE); 520 mViewPager.setVisibility(View.GONE);
520 } 521 }
521 }; 522 };
523 +
524 + private CallbackReceiver<ArrayList<Couponset>> mCouponsetsCallback = new CallbackReceiver<ArrayList<Couponset>>() {
525 + @Override
526 + public void onSuccess(ArrayList<Couponset> result) {
527 + mPbLoading.setVisibility(View.GONE);
528 + }
529 +
530 + @Override
531 + public void onFailure(int errorCode) {
532 + mPbLoading.setVisibility(View.GONE);
533 + }
534 + };
522 } 535 }
......
...@@ -80,6 +80,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -80,6 +80,12 @@ public class Couponset implements Parcelable, Serializable {
80 private static final String FINAL_PRICE = "final_price"; 80 private static final String FINAL_PRICE = "final_price";
81 private static final String DISCOUNT_TYPE = "discount_type"; 81 private static final String DISCOUNT_TYPE = "discount_type";
82 private static final String EXTRA_FIELDS = "extra_fields"; 82 private static final String EXTRA_FIELDS = "extra_fields";
83 + private static final String IS_NEW = "is_new";
84 + private static final String PROMOTED = "promoted";
85 + private static final String PERSONALIZED = "personalized";
86 + private static final String LOCKED = "locked";
87 + private static final String UNLOCK_ACTION = "unlock_action";
88 + private static final String UNLOCK_MESSAGE = "unlock_message";
83 89
84 90
85 /* Member variables of the Campaign object */ 91 /* Member variables of the Campaign object */
...@@ -115,6 +121,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -115,6 +121,12 @@ public class Couponset implements Parcelable, Serializable {
115 private Date endDate = new Date(); 121 private Date endDate = new Date();
116 private String couponsetType = ""; 122 private String couponsetType = "";
117 private JSONObject extraFields = new JSONObject(); 123 private JSONObject extraFields = new JSONObject();
124 + private boolean isNew = false;
125 + private boolean promoted = false;
126 + private boolean personalized = false;
127 + private boolean locked = false;
128 + private String unlockAction = "";
129 + private String unlockMessage = "";
118 130
119 public Couponset() { 131 public Couponset() {
120 this.uuid = ""; 132 this.uuid = "";
...@@ -146,6 +158,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -146,6 +158,12 @@ public class Couponset implements Parcelable, Serializable {
146 this.discount_type = ""; 158 this.discount_type = "";
147 this.final_price = 0.0d; 159 this.final_price = 0.0d;
148 this.extraFields = new JSONObject(); 160 this.extraFields = new JSONObject();
161 + this.isNew = false;
162 + this.promoted = false;
163 + this.personalized = false;
164 + this.locked = false;
165 + this.unlockAction = "";
166 + this.unlockMessage = "";
149 } 167 }
150 168
151 public Couponset(boolean isUniversal) { 169 public Couponset(boolean isUniversal) {
...@@ -168,6 +186,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -168,6 +186,12 @@ public class Couponset implements Parcelable, Serializable {
168 this.innerText = ""; 186 this.innerText = "";
169 this.final_price = 0.0d; 187 this.final_price = 0.0d;
170 this.extraFields = new JSONObject(); 188 this.extraFields = new JSONObject();
189 + this.isNew = false;
190 + this.promoted = false;
191 + this.personalized = false;
192 + this.locked = false;
193 + this.unlockAction = "";
194 + this.unlockMessage = "";
171 } 195 }
172 196
173 /** 197 /**
...@@ -204,6 +228,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -204,6 +228,12 @@ public class Couponset implements Parcelable, Serializable {
204 this.active = json.optBoolean(ACTIVE); 228 this.active = json.optBoolean(ACTIVE);
205 this.visible = json.optBoolean(VISIBLE); 229 this.visible = json.optBoolean(VISIBLE);
206 this.buyable = json.optBoolean(BUYABLE); 230 this.buyable = json.optBoolean(BUYABLE);
231 + this.isNew = json.optBoolean(IS_NEW);
232 + this.promoted = json.optBoolean(PROMOTED);
233 + this.personalized = json.optBoolean(PERSONALIZED);
234 + this.locked = json.optBoolean(LOCKED);
235 + this.unlockAction = json.optString(UNLOCK_ACTION);
236 + this.unlockMessage = json.optString(UNLOCK_MESSAGE);
207 this.user_generated = json.optBoolean(USER_GENERATED); 237 this.user_generated = json.optBoolean(USER_GENERATED);
208 this.limits = json.optJSONObject(LIMITS); 238 this.limits = json.optJSONObject(LIMITS);
209 this.points = json.optInt(POINTS); 239 this.points = json.optInt(POINTS);
...@@ -247,6 +277,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -247,6 +277,12 @@ public class Couponset implements Parcelable, Serializable {
247 } catch (JSONException e) { 277 } catch (JSONException e) {
248 e.printStackTrace(); 278 e.printStackTrace();
249 } 279 }
280 + this.isNew = json.optBoolean(IS_NEW);
281 + this.promoted = json.optBoolean(PROMOTED);
282 + this.personalized = json.optBoolean(PERSONALIZED);
283 + this.locked = json.optBoolean(LOCKED);
284 + this.unlockAction = json.optString(UNLOCK_ACTION);
285 + this.unlockMessage = json.optString(UNLOCK_MESSAGE);
250 this.active = json.optBoolean(ACTIVE); 286 this.active = json.optBoolean(ACTIVE);
251 this.buyable = json.optBoolean(BUYABLE); 287 this.buyable = json.optBoolean(BUYABLE);
252 this.name = json.optString(NAME); 288 this.name = json.optString(NAME);
...@@ -322,6 +358,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -322,6 +358,12 @@ public class Couponset implements Parcelable, Serializable {
322 this.innerText = source.readString(); 358 this.innerText = source.readString();
323 this.discount_type = source.readString(); 359 this.discount_type = source.readString();
324 this.final_price = source.readDouble(); 360 this.final_price = source.readDouble();
361 + this.isNew = source.readByte() != 0;
362 + this.promoted = source.readByte() != 0;
363 + this.personalized = source.readByte() != 0;
364 + this.locked = source.readByte() != 0;
365 + this.unlockAction = source.readString();
366 + this.unlockMessage = source.readString();
325 } 367 }
326 368
327 @Override 369 @Override
...@@ -352,6 +394,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -352,6 +394,12 @@ public class Couponset implements Parcelable, Serializable {
352 dest.writeString(this.innerText); 394 dest.writeString(this.innerText);
353 dest.writeString(this.discount_type); 395 dest.writeString(this.discount_type);
354 dest.writeDouble(this.final_price); 396 dest.writeDouble(this.final_price);
397 + dest.writeByte((byte) (this.isNew ? 1 : 0));
398 + dest.writeByte((byte) (this.promoted ? 1 : 0));
399 + dest.writeByte((byte) (this.personalized ? 1 : 0));
400 + dest.writeByte((byte) (this.locked ? 1 : 0));
401 + dest.writeString(this.unlockAction);
402 + dest.writeString(this.unlockMessage);
355 } 403 }
356 404
357 /** 405 /**
...@@ -391,6 +439,12 @@ public class Couponset implements Parcelable, Serializable { ...@@ -391,6 +439,12 @@ public class Couponset implements Parcelable, Serializable {
391 jObj.putOpt(DISCOUNT_TYPE, this.discount_type); 439 jObj.putOpt(DISCOUNT_TYPE, this.discount_type);
392 jObj.putOpt(FINAL_PRICE, this.final_price); 440 jObj.putOpt(FINAL_PRICE, this.final_price);
393 jObj.putOpt(EXTRA_FIELDS, this.extraFields); 441 jObj.putOpt(EXTRA_FIELDS, this.extraFields);
442 + jObj.putOpt(IS_NEW, this.isNew);
443 + jObj.putOpt(PROMOTED, this.promoted);
444 + jObj.putOpt(PERSONALIZED, this.personalized);
445 + jObj.putOpt(LOCKED, this.locked);
446 + jObj.putOpt(UNLOCK_ACTION, this.unlockAction);
447 + jObj.putOpt(UNLOCK_MESSAGE, this.unlockMessage);
394 } catch (JSONException e) { 448 } catch (JSONException e) {
395 if (WarpConstants.DEBUG) { 449 if (WarpConstants.DEBUG) {
396 e.printStackTrace(); 450 e.printStackTrace();
...@@ -682,6 +736,55 @@ public class Couponset implements Parcelable, Serializable { ...@@ -682,6 +736,55 @@ public class Couponset implements Parcelable, Serializable {
682 return img_preview; 736 return img_preview;
683 } 737 }
684 738
739 +
740 + public boolean isNew() {
741 + return isNew;
742 + }
743 +
744 + public void setNew(boolean aNew) {
745 + isNew = aNew;
746 + }
747 +
748 + public boolean isPromoted() {
749 + return promoted;
750 + }
751 +
752 + public void setPromoted(boolean promoted) {
753 + this.promoted = promoted;
754 + }
755 +
756 + public boolean isPersonalized() {
757 + return personalized;
758 + }
759 +
760 + public void setPersonalized(boolean personalized) {
761 + this.personalized = personalized;
762 + }
763 +
764 + public boolean isLocked() {
765 + return locked;
766 + }
767 +
768 + public void setLocked(boolean locked) {
769 + this.locked = locked;
770 + }
771 +
772 + public String getUnlockAction() {
773 + return unlockAction;
774 + }
775 +
776 + public void setUnlockAction(String unlockAction) {
777 + this.unlockAction = unlockAction;
778 + }
779 +
780 + public String getUnlockMessage() {
781 + return unlockMessage;
782 + }
783 +
784 + public void setUnlockMessage(String unlockMessage) {
785 + this.unlockMessage = unlockMessage;
786 + }
787 +
685 @Override 788 @Override
686 public int describeContents() { 789 public int describeContents() {
687 return 0; 790 return 0;
......
...@@ -66,7 +66,9 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -66,7 +66,9 @@ public class NewCampaign implements Parcelable, Serializable {
66 private static final String SETTINGS = "settings"; 66 private static final String SETTINGS = "settings";
67 private static final String AUDIENCE = "audience"; 67 private static final String AUDIENCE = "audience";
68 private static final String IS_NEW = "is_new"; 68 private static final String IS_NEW = "is_new";
69 - private static final String BANNER_IMAGE = "Banner_img"; 69 + private static final String BANNER_IMAGE = "banner_img";
70 + private static final String BANNER_IMAGE_MOBILE = "banner_img_mobile";
71 + private static final String CAMPAIGN_URL = "campaign_url";
70 private static final String BANNER_TITLE = "Banner_title"; 72 private static final String BANNER_TITLE = "Banner_title";
71 73
72 /* Member variables of the Campaign object */ 74 /* Member variables of the Campaign object */
...@@ -92,6 +94,8 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -92,6 +94,8 @@ public class NewCampaign implements Parcelable, Serializable {
92 private final String communicationCategory; 94 private final String communicationCategory;
93 private boolean isNew = false; 95 private boolean isNew = false;
94 private String bannerImage = ""; 96 private String bannerImage = "";
97 + private String bannerImageMobile = "";
98 + private String campaignUrl = "";
95 private String bannerTitle = ""; 99 private String bannerTitle = "";
96 private boolean showExpiration = false; 100 private boolean showExpiration = false;
97 private String couponImg = ""; 101 private String couponImg = "";
...@@ -139,6 +143,12 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -139,6 +143,12 @@ public class NewCampaign implements Parcelable, Serializable {
139 if (this.extraFields.has(BANNER_IMAGE)) { 143 if (this.extraFields.has(BANNER_IMAGE)) {
140 this.bannerImage = this.extraFields.optString(BANNER_IMAGE); 144 this.bannerImage = this.extraFields.optString(BANNER_IMAGE);
141 } 145 }
146 + if (this.extraFields.has(BANNER_IMAGE_MOBILE)) {
147 + this.bannerImageMobile = this.extraFields.optString(BANNER_IMAGE_MOBILE);
148 + }
149 + if (this.extraFields.has(CAMPAIGN_URL)) {
150 + this.campaignUrl = this.extraFields.optString(CAMPAIGN_URL);
151 + }
142 if (this.extraFields.has(BANNER_TITLE)) { 152 if (this.extraFields.has(BANNER_TITLE)) {
143 this.bannerTitle = this.extraFields.optString(BANNER_TITLE); 153 this.bannerTitle = this.extraFields.optString(BANNER_TITLE);
144 } 154 }
...@@ -183,6 +193,8 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -183,6 +193,8 @@ public class NewCampaign implements Parcelable, Serializable {
183 this.category = source.readString(); 193 this.category = source.readString();
184 this.campaignType = source.readString(); 194 this.campaignType = source.readString();
185 this.bannerImage = source.readString(); 195 this.bannerImage = source.readString();
196 + this.bannerImageMobile = source.readString();
197 + this.campaignUrl = source.readString();
186 this.bannerTitle = source.readString(); 198 this.bannerTitle = source.readString();
187 } 199 }
188 200
...@@ -210,6 +222,8 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -210,6 +222,8 @@ public class NewCampaign implements Parcelable, Serializable {
210 dest.writeString(this.campaignType); 222 dest.writeString(this.campaignType);
211 dest.writeString(this.communicationUUID); 223 dest.writeString(this.communicationUUID);
212 dest.writeString(this.bannerImage); 224 dest.writeString(this.bannerImage);
225 + dest.writeString(this.bannerImageMobile);
226 + dest.writeString(this.campaignUrl);
213 dest.writeString(this.bannerTitle); 227 dest.writeString(this.bannerTitle);
214 } 228 }
215 229
...@@ -420,6 +434,22 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -420,6 +434,22 @@ public class NewCampaign implements Parcelable, Serializable {
420 this.filter = filter; 434 this.filter = filter;
421 } 435 }
422 436
437 + public String getBannerImageMobile() {
438 + return bannerImageMobile;
439 + }
440 +
441 + public void setBannerImageMobile(String bannerImageMobile) {
442 + this.bannerImageMobile = bannerImageMobile;
443 + }
444 +
445 + public String getCampaignUrl() {
446 + return campaignUrl;
447 + }
448 +
449 + public void setCampaignUrl(String campaignUrl) {
450 + this.campaignUrl = campaignUrl;
451 + }
452 +
423 @Override 453 @Override
424 public int describeContents() { 454 public int describeContents() {
425 return 0; 455 return 0;
......
...@@ -118,6 +118,28 @@ public interface ApiService { ...@@ -118,6 +118,28 @@ public interface ApiService {
118 @Header(WarpConstants.HEADER_SIGNATURE) String signature, 118 @Header(WarpConstants.HEADER_SIGNATURE) String signature,
119 @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer); 119 @Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
120 120
121 + @Headers("Content-Type: application/json")
122 + @POST("/api/mobile/v2/{appUuid}/context/")
123 + Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid,
124 + @Body RequestBody request,
125 + @Header(WarpConstants.HEADER_DATE) String timeStamp,
126 + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
127 + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
128 + @Header(WarpConstants.HEADER_CHANNEL) String channel,
129 + @Header(WarpConstants.HEADER_WEB_ID) String webId,
130 + @Header(WarpConstants.HEADER_SIGNATURE) String signature);
131 +
132 + @Headers("Content-Type: application/json")
133 + @POST("/api/mobile/v2/{appUuid}/context/")
134 + Call<ResponseBody> getMerchants(@Path("appUuid") String appUuid,
135 + @Body RequestBody request,
136 + @Header(WarpConstants.HEADER_DATE) String timeStamp,
137 + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
138 + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
139 + @Header(WarpConstants.HEADER_CHANNEL) String channel,
140 + @Header(WarpConstants.HEADER_WEB_ID) String webId,
141 + @Header(WarpConstants.HEADER_SIGNATURE) String signature);
142 +
121 // =========================================================== 143 // ===========================================================
122 // Getter & Setter 144 // Getter & Setter
123 // =========================================================== 145 // ===========================================================
......