Panagiotis Triantafyllou

coupon availability per campaign

......@@ -54,6 +54,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
......@@ -67,6 +68,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import ly.warp.sdk.Warply;
import ly.warp.sdk.activities.CouponsetInfoActivity;
import ly.warp.sdk.activities.GiftsForYouActivity;
import ly.warp.sdk.activities.WarpViewActivity;
import ly.warp.sdk.db.WarplyDBHelper;
import ly.warp.sdk.io.callbacks.AddressHook;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
......@@ -96,6 +100,7 @@ import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.CouponsetsList;
import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.io.models.MerchantCategoriesList;
import ly.warp.sdk.io.models.MerchantList;
......@@ -1576,11 +1581,22 @@ public class WarplyManager {
if (newCampaignList != null && newCampaignList.size() > 0) {
Collections.sort(newCampaignList, (obj1, obj2) -> Integer.compare(obj1.getSorting(), obj2.getSorting()));
WarplyManagerHelper.setCampaignList(newCampaignList);
campaignLoyaltyList.clear();
ArrayList<Campaign> campaignCarouselList = new ArrayList<>();
campaignCarouselList.clear();
for (Campaign camp : newCampaignList) {
if (resultCampaignsAvailability != null && resultCampaignsAvailability.length() > 0) {
JSONObject campaignSettings = WarpJSONParser.getJSONFromString(camp.getCampaignTypeSettings());
if (campaignSettings != null) {
if (campaignSettings.has("couponset")) {
String cpnUuid = campaignSettings.optString("couponset");
if (resultCampaignsAvailability.has(cpnUuid)) {
camp.setCouponAvailability(resultCampaignsAvailability.optInt(cpnUuid));
}
}
}
}
JSONObject campMetadata = WarpJSONParser.getJSONFromString(camp.getExtraFields());
if (campMetadata != null) {
if (campMetadata.has("carousel")) {
......@@ -1599,6 +1615,7 @@ public class WarplyManager {
campaignLoyaltyList.add(camp);
}
}
WarplyManagerHelper.setCampaignList(newCampaignList);
WarplyManagerHelper.setCarouselList(campaignCarouselList);
Set<Campaign> set = new LinkedHashSet<>(campaignLoyaltyList);
......@@ -1790,6 +1807,9 @@ public class WarplyManager {
if (extraFieldsResp.has("Banner_img")) {
camp.setBannerImage(extraFieldsResp.optString("Banner_img", ""));
}
if (extraFieldsResp.has("category_id")) {
camp.setCategoryId(extraFieldsResp.optString("category_id", ""));
}
}
} else {
camp.setBannerImage("");
......@@ -1929,6 +1949,9 @@ public class WarplyManager {
if (extraFieldsResp.has("Banner_img")) {
camp.setBannerImage(extraFieldsResp.optString("Banner_img", ""));
}
if (extraFieldsResp.has("category_id")) {
camp.setCategoryId(extraFieldsResp.optString("category_id", ""));
}
}
} else {
camp.setBannerImage("");
......@@ -2014,10 +2037,9 @@ public class WarplyManager {
Map<String, Object> jsonParams = new ArrayMap<>();
jsonParams.put("action", "availability");
Map<String, Object> jsonParamsFilters = new ArrayMap<>();
jsonParams.put("uuids", null);
jsonParams.put("availability_enabled", true);
jsonParamsFilters.put("uuids", null);
jsonParamsFilters.put("availability_enabled", true);
jsonParams.put("filters", jsonParamsFilters);
jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext()));
jsonParamsCampaignsAvailability.put("coupon", jsonParams);
RequestBody campaignsAvailabilityRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCampaignsAvailability)).toString());
......