Panagiotis Triantafyllou

couponsets and merchants implementation

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="21" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/warply_android_sdk" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -26,6 +26,7 @@ import ly.warp.sdk.io.adapters.BannerAdapter;
import ly.warp.sdk.io.adapters.OfferAdapter;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.BannerItem;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.DummyDataProvider;
import ly.warp.sdk.io.models.OfferCategory;
import ly.warp.sdk.io.models.OfferItem;
......@@ -100,6 +101,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
initViews();
mPbLoading.setVisibility(View.VISIBLE);
WarplyManager.getCampaigns(mCampaignsCallback);
WarplyManager.getCouponsets(mCouponsetsCallback);
// Setup all category sections
// setupTopOffersSection();
......@@ -431,7 +433,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
});
mBannerAdapter.setOnBannerContentClickListener(article -> {
//TODO: click article
String s = "";
});
// Set the number of pages to preload for adjacent items
......@@ -519,4 +520,16 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
mViewPager.setVisibility(View.GONE);
}
};
private CallbackReceiver<ArrayList<Couponset>> mCouponsetsCallback = new CallbackReceiver<ArrayList<Couponset>>() {
@Override
public void onSuccess(ArrayList<Couponset> result) {
mPbLoading.setVisibility(View.GONE);
}
@Override
public void onFailure(int errorCode) {
mPbLoading.setVisibility(View.GONE);
}
};
}
......
......@@ -80,6 +80,12 @@ public class Couponset implements Parcelable, Serializable {
private static final String FINAL_PRICE = "final_price";
private static final String DISCOUNT_TYPE = "discount_type";
private static final String EXTRA_FIELDS = "extra_fields";
private static final String IS_NEW = "is_new";
private static final String PROMOTED = "promoted";
private static final String PERSONALIZED = "personalized";
private static final String LOCKED = "locked";
private static final String UNLOCK_ACTION = "unlock_action";
private static final String UNLOCK_MESSAGE = "unlock_message";
/* Member variables of the Campaign object */
......@@ -115,6 +121,12 @@ public class Couponset implements Parcelable, Serializable {
private Date endDate = new Date();
private String couponsetType = "";
private JSONObject extraFields = new JSONObject();
private boolean isNew = false;
private boolean promoted = false;
private boolean personalized = false;
private boolean locked = false;
private String unlockAction = "";
private String unlockMessage = "";
public Couponset() {
this.uuid = "";
......@@ -146,6 +158,12 @@ public class Couponset implements Parcelable, Serializable {
this.discount_type = "";
this.final_price = 0.0d;
this.extraFields = new JSONObject();
this.isNew = false;
this.promoted = false;
this.personalized = false;
this.locked = false;
this.unlockAction = "";
this.unlockMessage = "";
}
public Couponset(boolean isUniversal) {
......@@ -168,6 +186,12 @@ public class Couponset implements Parcelable, Serializable {
this.innerText = "";
this.final_price = 0.0d;
this.extraFields = new JSONObject();
this.isNew = false;
this.promoted = false;
this.personalized = false;
this.locked = false;
this.unlockAction = "";
this.unlockMessage = "";
}
/**
......@@ -204,6 +228,12 @@ public class Couponset implements Parcelable, Serializable {
this.active = json.optBoolean(ACTIVE);
this.visible = json.optBoolean(VISIBLE);
this.buyable = json.optBoolean(BUYABLE);
this.isNew = json.optBoolean(IS_NEW);
this.promoted = json.optBoolean(PROMOTED);
this.personalized = json.optBoolean(PERSONALIZED);
this.locked = json.optBoolean(LOCKED);
this.unlockAction = json.optString(UNLOCK_ACTION);
this.unlockMessage = json.optString(UNLOCK_MESSAGE);
this.user_generated = json.optBoolean(USER_GENERATED);
this.limits = json.optJSONObject(LIMITS);
this.points = json.optInt(POINTS);
......@@ -247,6 +277,12 @@ public class Couponset implements Parcelable, Serializable {
} catch (JSONException e) {
e.printStackTrace();
}
this.isNew = json.optBoolean(IS_NEW);
this.promoted = json.optBoolean(PROMOTED);
this.personalized = json.optBoolean(PERSONALIZED);
this.locked = json.optBoolean(LOCKED);
this.unlockAction = json.optString(UNLOCK_ACTION);
this.unlockMessage = json.optString(UNLOCK_MESSAGE);
this.active = json.optBoolean(ACTIVE);
this.buyable = json.optBoolean(BUYABLE);
this.name = json.optString(NAME);
......@@ -322,6 +358,12 @@ public class Couponset implements Parcelable, Serializable {
this.innerText = source.readString();
this.discount_type = source.readString();
this.final_price = source.readDouble();
this.isNew = source.readByte() != 0;
this.promoted = source.readByte() != 0;
this.personalized = source.readByte() != 0;
this.locked = source.readByte() != 0;
this.unlockAction = source.readString();
this.unlockMessage = source.readString();
}
@Override
......@@ -352,6 +394,12 @@ public class Couponset implements Parcelable, Serializable {
dest.writeString(this.innerText);
dest.writeString(this.discount_type);
dest.writeDouble(this.final_price);
dest.writeByte((byte) (this.isNew ? 1 : 0));
dest.writeByte((byte) (this.promoted ? 1 : 0));
dest.writeByte((byte) (this.personalized ? 1 : 0));
dest.writeByte((byte) (this.locked ? 1 : 0));
dest.writeString(this.unlockAction);
dest.writeString(this.unlockMessage);
}
/**
......@@ -391,6 +439,12 @@ public class Couponset implements Parcelable, Serializable {
jObj.putOpt(DISCOUNT_TYPE, this.discount_type);
jObj.putOpt(FINAL_PRICE, this.final_price);
jObj.putOpt(EXTRA_FIELDS, this.extraFields);
jObj.putOpt(IS_NEW, this.isNew);
jObj.putOpt(PROMOTED, this.promoted);
jObj.putOpt(PERSONALIZED, this.personalized);
jObj.putOpt(LOCKED, this.locked);
jObj.putOpt(UNLOCK_ACTION, this.unlockAction);
jObj.putOpt(UNLOCK_MESSAGE, this.unlockMessage);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
......@@ -682,6 +736,55 @@ public class Couponset implements Parcelable, Serializable {
return img_preview;
}
public boolean isNew() {
return isNew;
}
public void setNew(boolean aNew) {
isNew = aNew;
}
public boolean isPromoted() {
return promoted;
}
public void setPromoted(boolean promoted) {
this.promoted = promoted;
}
public boolean isPersonalized() {
return personalized;
}
public void setPersonalized(boolean personalized) {
this.personalized = personalized;
}
public boolean isLocked() {
return locked;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
public String getUnlockAction() {
return unlockAction;
}
public void setUnlockAction(String unlockAction) {
this.unlockAction = unlockAction;
}
public String getUnlockMessage() {
return unlockMessage;
}
public void setUnlockMessage(String unlockMessage) {
this.unlockMessage = unlockMessage;
}
@Override
public int describeContents() {
return 0;
......
......@@ -66,7 +66,9 @@ public class NewCampaign implements Parcelable, Serializable {
private static final String SETTINGS = "settings";
private static final String AUDIENCE = "audience";
private static final String IS_NEW = "is_new";
private static final String BANNER_IMAGE = "Banner_img";
private static final String BANNER_IMAGE = "banner_img";
private static final String BANNER_IMAGE_MOBILE = "banner_img_mobile";
private static final String CAMPAIGN_URL = "campaign_url";
private static final String BANNER_TITLE = "Banner_title";
/* Member variables of the Campaign object */
......@@ -92,6 +94,8 @@ public class NewCampaign implements Parcelable, Serializable {
private final String communicationCategory;
private boolean isNew = false;
private String bannerImage = "";
private String bannerImageMobile = "";
private String campaignUrl = "";
private String bannerTitle = "";
private boolean showExpiration = false;
private String couponImg = "";
......@@ -139,6 +143,12 @@ public class NewCampaign implements Parcelable, Serializable {
if (this.extraFields.has(BANNER_IMAGE)) {
this.bannerImage = this.extraFields.optString(BANNER_IMAGE);
}
if (this.extraFields.has(BANNER_IMAGE_MOBILE)) {
this.bannerImageMobile = this.extraFields.optString(BANNER_IMAGE_MOBILE);
}
if (this.extraFields.has(CAMPAIGN_URL)) {
this.campaignUrl = this.extraFields.optString(CAMPAIGN_URL);
}
if (this.extraFields.has(BANNER_TITLE)) {
this.bannerTitle = this.extraFields.optString(BANNER_TITLE);
}
......@@ -183,6 +193,8 @@ public class NewCampaign implements Parcelable, Serializable {
this.category = source.readString();
this.campaignType = source.readString();
this.bannerImage = source.readString();
this.bannerImageMobile = source.readString();
this.campaignUrl = source.readString();
this.bannerTitle = source.readString();
}
......@@ -210,6 +222,8 @@ public class NewCampaign implements Parcelable, Serializable {
dest.writeString(this.campaignType);
dest.writeString(this.communicationUUID);
dest.writeString(this.bannerImage);
dest.writeString(this.bannerImageMobile);
dest.writeString(this.campaignUrl);
dest.writeString(this.bannerTitle);
}
......@@ -420,6 +434,22 @@ public class NewCampaign implements Parcelable, Serializable {
this.filter = filter;
}
public String getBannerImageMobile() {
return bannerImageMobile;
}
public void setBannerImageMobile(String bannerImageMobile) {
this.bannerImageMobile = bannerImageMobile;
}
public String getCampaignUrl() {
return campaignUrl;
}
public void setCampaignUrl(String campaignUrl) {
this.campaignUrl = campaignUrl;
}
@Override
public int describeContents() {
return 0;
......
......@@ -118,6 +118,28 @@ public interface ApiService {
@Header(WarpConstants.HEADER_SIGNATURE) String signature,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
@Headers("Content-Type: application/json")
@POST("/api/mobile/v2/{appUuid}/context/")
Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
@Headers("Content-Type: application/json")
@POST("/api/mobile/v2/{appUuid}/context/")
Call<ResponseBody> getMerchants(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
// ===========================================================
// Getter & Setter
// ===========================================================
......