Panagiotis Triantafyllou

optimize campaigns, new campaign keys

......@@ -3,15 +3,15 @@
# The app uuid the warply sdk need to connect to the engage server
# dev f83dfde1145e4c2da69793abb2f579af
# prod 0086a2088301440792091b9f814c2267
Uuid=0086a2088301440792091b9f814c2267
Uuid=f83dfde1145e4c2da69793abb2f579af
# If we need to see logs in Logcat
Debug=false
Debug=true
# Production or Development environment of the engage server
# Production: https://engage.warp.ly
# Development: https://engage-stage.warp.ly
BaseURL=https://engage.warp.ly
BaseURL=https://engage-stage.warp.ly
# For Verify Ticket request
VerifyURL=/partners/cosmote/verify
......@@ -39,7 +39,7 @@ PushIcon=ic_notify
SendPackages=false
# The app language
Language=el
Language=en
# The merchant id for some requests
MerchantId=20113
......
......@@ -36,7 +36,7 @@ public class SplashActivity extends BaseActivity {
public void onWarplyReady() {
if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest()
.setGuid("6010490808"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282
.setGuid("7000000831"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282
mLoginReceiver);
} else {
startNextActivity();
......
......@@ -65,6 +65,7 @@ dependencies {
api 'com.github.siyamed:android-shape-imageview:0.9.3'
implementation 'org.greenrobot:eventbus:3.3.1'
api 'org.apmem.tools:layouts:1.10'
api 'com.google.guava:guava:30.1-android'
//------------------------------ Firebase -----------------------------//
api platform('com.google.firebase:firebase-bom:29.0.3')
......
......@@ -50,9 +50,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
mBottomNavigationView = findViewById(R.id.bt_tabs);
// WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback);
WarplyManager.getCampaigns(mCampaignsCallback);
WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
}
......@@ -123,7 +122,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
private final CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
@Override
public void onSuccess(ArrayList<Campaign> result) {
Toast.makeText(BaseFragmentActivity.this, "Campaigns Success", Toast.LENGTH_SHORT).show();
Toast.makeText(BaseFragmentActivity.this, "Campaigns Success " + String.valueOf(result.size()), Toast.LENGTH_SHORT).show();
}
@Override
......
......@@ -74,6 +74,8 @@ public class Campaign implements Parcelable, Serializable {
private static final String CAMPAIGN_TYPE_SETTINGS = "campaign_type_settings";
private static final String BANNER_IMAGE = "Banner_img";
private static final String BANNER_TITLE = "Banner_title";
private static final String CATEGORY_ID = "category_id";
private static final String COUPON_AVAILABILITY = "coupon_availability";
/* Member variables of the Campaign object */
......@@ -103,7 +105,8 @@ public class Campaign implements Parcelable, Serializable {
private String campaignTypeSettings;
private String bannerImage;
private String bannerTitle;
private UnifiedCampaignModel unifiedCampaign;
private String categoryId;
private Integer couponAvailability;
/**
* Basic constructor used to create an object from a String, representing a
......@@ -143,7 +146,8 @@ public class Campaign implements Parcelable, Serializable {
this.campaignTypeSettings = "";
this.bannerImage = "";
this.bannerTitle = "";
this.unifiedCampaign = new UnifiedCampaignModel();
this.couponAvailability = null;
this.categoryId = "";
}
/**
......@@ -204,6 +208,8 @@ public class Campaign implements Parcelable, Serializable {
} else {
this.actions = null;
}
this.categoryId = json.optString(CATEGORY_ID);
this.couponAvailability = json.optInt(COUPON_AVAILABILITY);
}
public Campaign(Parcel source) {
......@@ -231,6 +237,8 @@ public class Campaign implements Parcelable, Serializable {
this.actions = source.readArrayList(CampaignAction.class.getClassLoader());
this.busId = source.readString();
this.campaignTypeSettings = source.readString();
this.categoryId = source.readString();
this.couponAvailability = source.readInt();
}
@Override
......@@ -259,6 +267,8 @@ public class Campaign implements Parcelable, Serializable {
dest.writeList(this.actions);
dest.writeString(this.busId);
dest.writeString(this.campaignTypeSettings);
dest.writeInt(this.couponAvailability);
dest.writeString(this.categoryId);
}
/**
......@@ -293,6 +303,8 @@ public class Campaign implements Parcelable, Serializable {
jObj.putOpt(DISPLAY_TYPE, this.displayType);
jObj.put(BUS_ID, this.busId);
jObj.put(CAMPAIGN_TYPE_SETTINGS, this.campaignTypeSettings);
jObj.putOpt(COUPON_AVAILABILITY, this.couponAvailability);
jObj.putOpt(CATEGORY_ID, this.categoryId);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
......@@ -366,6 +378,23 @@ public class Campaign implements Parcelable, Serializable {
// Getters
// ================================================================================
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public Integer getCouponAvailability() {
return couponAvailability;
}
public void setCouponAvailability(Integer couponAvailability) {
this.couponAvailability = couponAvailability;
}
/**
* @return The loyalty action of the Campaign, used if custom actions are
* implemented
......@@ -630,14 +659,6 @@ public class Campaign implements Parcelable, Serializable {
this.bannerTitle = bannerTitle;
}
public UnifiedCampaignModel getUnifiedCampaign() {
return unifiedCampaign;
}
public void setUnifiedCampaign(UnifiedCampaignModel unifiedCampaign) {
this.unifiedCampaign = unifiedCampaign;
}
@Override
public int describeContents() {
return 0;
......
......@@ -79,6 +79,21 @@ public class NewCampaignList extends ArrayList<NewCampaign> {
}
}
public NewCampaignList(JSONObject campaignListJSONObject) {
campaignListJSONObject = campaignListJSONObject.optJSONObject(JSON_KEY_CONTEXT);
if (campaignListJSONObject == null)
return;
JSONObject jsonObject = campaignListJSONObject.optJSONObject(JSON_KEY_MAPP);
if(jsonObject == null)
return;;
JSONArray jArray = jsonObject.optJSONArray(JSON_KEY_MAPP_VALUE);
if (jArray != null) {
for (int i = 0, lim = jArray.length(); i < lim; ++i) {
add(new NewCampaign(jArray.optJSONObject(i)));
}
}
}
@NonNull
public String getRequestSignature() {
return mRequestSignature;
......
......@@ -89,20 +89,31 @@ public interface ApiService {
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
@Headers("Content-Type: application/json")
@POST("/api/mobile/v2/{appUuid}/context/")
Call<ResponseBody> getCampaigns(@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("/oauth/{appUuid}/context")
Call<ResponseBody> sendTelematicsData(@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,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
Call<ResponseBody> getCampaignsPersonalized(@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,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
@Headers("Content-Type: application/json")
@POST("/oauth/{appUuid}/context")
Call<ResponseBody> cancelUnifiedCoupon(@Path("appUuid") String appUuid,
Call<ResponseBody> sendTelematicsData(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
......@@ -114,19 +125,19 @@ public interface ApiService {
@Headers("Content-Type: application/json")
@POST("/oauth/{appUuid}/context")
Call<ResponseBody> getTelematicsHistoy(@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,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
Call<ResponseBody> cancelUnifiedCoupon(@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,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
@Headers("Content-Type: application/json")
@POST("/oauth/{appUuid}/context")
Call<ResponseBody> getTripMetrics(@Path("appUuid") String appUuid,
Call<ResponseBody> getTelematicsHistoy(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
......@@ -138,7 +149,7 @@ public interface ApiService {
@Headers("Content-Type: application/json")
@POST("/oauth/{appUuid}/context")
Call<ResponseBody> rateTrip(@Path("appUuid") String appUuid,
Call<ResponseBody> getTripMetrics(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
......@@ -148,6 +159,18 @@ public interface ApiService {
@Header(WarpConstants.HEADER_SIGNATURE) String signature,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
@Headers("Content-Type: application/json")
@POST("/oauth/{appUuid}/context")
Call<ResponseBody> rateTrip(@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,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
// ===========================================================
// Getter & Setter
// ===========================================================
......