Panagiotis Triantafyllou

new version 4.5.4.3

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.2'
PUBLISH_VERSION = '4.5.4.3'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -1487,6 +1487,8 @@ public enum Warply {
if (path.equals("register") || path.equals("change_password") || path.equals("password_reset")
|| path.equals("generate"))
url = buildWarplyAuthRequestUrl(path, true);
else if (path.equals("campaigns"))
url = buildWarplyRequestUrl(null);
else
url = buildWarplyAuthRequestUrl(path, false);
requestToServerInternal(Method.POST, url, data, listener, tag, hasAuthHeaders);
......
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.callbacks;
import org.json.JSONObject;
import ly.warp.sdk.io.models.NewCampaignList;
/**
* Created by Panagiotis Triantafyllou on 12-May-22.
*/
public class NewCampaignsHook implements CallbackReceiver<JSONObject> {
private final CallbackReceiver<NewCampaignList> mListener;
private final String mRequestSignature;
public NewCampaignsHook(CallbackReceiver<NewCampaignList> listener, String requestSignature) {
this.mListener = listener;
this.mRequestSignature = requestSignature;
}
@Override
public void onSuccess(JSONObject result) {
if (mListener != null) {
int status = result.optInt("status", 2);
if (status == 1) {
mListener.onSuccess(new NewCampaignList(result, mRequestSignature));
} else
mListener.onFailure(status);
}
}
@Override
public void onFailure(int errorCode) {
if (mListener != null)
mListener.onFailure(errorCode);
}
}
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.models;
import android.os.Parcel;
import android.os.Parcelable;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
* Created by Panagiotis Triantafyllou on 12-May-22.
*/
public class NewCampaign implements Parcelable, Serializable {
private static final long serialVersionUID = -4754964462459705285L;
/* Constants used to export the campaign in JSON formal and vice versa */
private static final String SUBTITLE = "subtitle";
private static final String TITLE = "title";
private static final String COMMUNICATION_UUID = "communication_uuid";
private static final String MESSAGE = "message";
private static final String DESCRIPTION = "description";
private static final String INDEX_URL = "index_url";
private static final String LOGO_URL = "logo_url";
private static final String START_DATE = "start_date";
private static final String END_DATE = "end_date";
private static final String SORTING = "sorting";
private static final String CATEGORY = "category";
private static final String COMMUNICATION_NAME = "communication_name";
private static final String COMMUNICATION_CATEGORY = "communication_category";
private static final String EXTRA_FIELDS = "extra_fields";
private static final String WORKFLOW_SETTINGS = "workflow_settings";
private static final String DISPLAY_TYPE = "display_type";
private static final String DELIVERY_METHOD = "delivery_method";
private static final String CAMPAIGN_TYPE = "campaign_type";
private static final String SETTINGS = "settings";
private static final String AUDIENCE = "audience";
private static final String IS_NEW = "is_new";
/* Member variables of the Campaign object */
private final String campaignType;
private final String settings;
private final String audience;
private final String deliveryMethod;
private final String displayType;
private final String extraFields;
private final String workflowSettings;
private final String category;
private final int sorting;
private final String indexUrl;
private final String message;
private final String description;
private final String subtitle;
private final String title;
private final String communicationUUID;
private final String logoUrl;
private final String startDate;
private final String endDate;
private final String communicationName;
private final String communicationCategory;
private boolean isNew = false;
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
*
* @param json The String, representing the JSON Object
* @throws JSONException Thrown if the String cannot be converted to JSON
*/
public NewCampaign(String json) throws JSONException {
this(new JSONObject(json));
}
/**
* Constructor used to create an Object from a given JSON Object
*
* @param json JSON Object used to create the Campaign
*/
public NewCampaign(JSONObject json) {
this.indexUrl = json.optString(INDEX_URL);
this.logoUrl = json.optString(LOGO_URL);
this.communicationUUID = json.optString(COMMUNICATION_UUID);
this.subtitle = json.optString(SUBTITLE);
this.message = json.optString(MESSAGE);
this.category = json.optString(CATEGORY);
this.title = json.optString(TITLE);
this.sorting = json.optInt(SORTING);
this.extraFields = json.optString(EXTRA_FIELDS);
this.campaignType = json.optString(CAMPAIGN_TYPE);
this.deliveryMethod = json.optString(DELIVERY_METHOD);
this.displayType = json.optString(DISPLAY_TYPE);
this.settings = json.optString(SETTINGS);
this.audience = json.optString(AUDIENCE);
this.workflowSettings = json.optString(WORKFLOW_SETTINGS);
this.description = json.optString(DESCRIPTION);
this.startDate = json.optString(START_DATE);
this.endDate = json.optString(END_DATE);
this.communicationName = json.optString(COMMUNICATION_NAME);
this.communicationCategory = json.optString(COMMUNICATION_CATEGORY);
this.isNew = json.optBoolean(IS_NEW);
}
public NewCampaign(Parcel source) {
this.indexUrl = source.readString();
this.message = source.readString();
this.communicationUUID = source.readString();
this.subtitle = source.readString();
this.title = source.readString();
this.sorting = source.readInt();
this.isNew = source.readByte() != 0;
this.logoUrl = source.readString();
this.extraFields = source.readString();
this.deliveryMethod = source.readString();
this.displayType = source.readString();
this.settings = source.readString();
this.audience = source.readString();
this.workflowSettings = source.readString();
this.description = source.readString();
this.startDate = source.readString();
this.endDate = source.readString();
this.communicationName = source.readString();
this.communicationCategory = source.readString();
this.category = source.readString();
this.campaignType = source.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.indexUrl);
dest.writeString(this.message);
dest.writeString(this.subtitle);
dest.writeString(this.title);
dest.writeInt(this.sorting);
dest.writeInt(this.isNew ? 1 : 0);
dest.writeString(this.logoUrl);
dest.writeString(extraFields);
dest.writeString(deliveryMethod);
dest.writeString(displayType);
dest.writeString(this.settings);
dest.writeString(this.audience);
dest.writeString(this.workflowSettings);
dest.writeString(this.description);
dest.writeString(this.startDate);
dest.writeString(this.endDate);
dest.writeString(this.communicationName);
dest.writeString(this.communicationCategory);
dest.writeString(this.category);
dest.writeString(this.campaignType);
dest.writeString(this.communicationUUID);
}
/**
* Converts the Campaign into a JSON Object
*
* @return The JSON Object created from this campaign
*/
public JSONObject toJSONObject() {
JSONObject jObj = new JSONObject();
try {
jObj.putOpt(INDEX_URL, this.indexUrl);
jObj.putOpt(LOGO_URL, this.logoUrl);
jObj.putOpt(MESSAGE, this.message);
jObj.putOpt(COMMUNICATION_UUID, this.communicationUUID);
jObj.putOpt(SUBTITLE, this.subtitle);
jObj.putOpt(TITLE, this.title);
jObj.putOpt(SORTING, this.sorting);
jObj.putOpt(IS_NEW, this.isNew);
jObj.putOpt(EXTRA_FIELDS, this.extraFields);
jObj.putOpt(DELIVERY_METHOD, this.deliveryMethod);
jObj.putOpt(DISPLAY_TYPE, this.displayType);
jObj.putOpt(SETTINGS, this.settings);
jObj.putOpt(AUDIENCE, this.audience);
jObj.putOpt(WORKFLOW_SETTINGS, this.workflowSettings);
jObj.putOpt(DESCRIPTION, this.description);
jObj.putOpt(START_DATE, this.startDate);
jObj.putOpt(END_DATE, this.endDate);
jObj.putOpt(COMMUNICATION_NAME, this.communicationName);
jObj.putOpt(COMMUNICATION_CATEGORY, this.communicationCategory);
jObj.putOpt(CATEGORY, this.category);
jObj.putOpt(CAMPAIGN_TYPE, this.campaignType);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
}
}
return jObj;
}
/**
* String representation of the Campaign, as a JSON object
*
* @return A String representation of JSON object
*/
public String toString() {
if (toJSONObject() != null)
return toJSONObject().toString();
return null;
}
/**
* String representation of the Campaign, as a human readable JSON object
*
* @return A human readable String representation of JSON object
*/
public String toHumanReadableString() {
String humanReadableString = null;
try {
humanReadableString = toJSONObject().toString(2);
} catch (JSONException e) {
WarpUtils.warn("Failed converting Campaign JSON object to String",
e);
}
return humanReadableString;
}
// ================================================================================
// Getters
// ================================================================================
/**
* @return The message of the campaign
*/
public String getMessage() {
return message;
}
/**
* @return The subtitle of the campaign
*/
public String getSubtitle() {
return subtitle;
}
/**
* @return The title of the campaign
*/
public String getTitle() {
return title;
}
/**
* @return An int that is used for sorting. This should be used as the
* default sorting value
*/
public int getSorting() {
return sorting;
}
/**
* Method used to get if the campaign is a new one
*
* @return <code>true</code> if the campaign is new; <code>false</code>
* otherwise
*/
public boolean getIsNew() {
return isNew;
}
public String getLogoUrl() {
return logoUrl;
}
public String getIndexUrl() {
return indexUrl;
}
public String getExtraFields() {
return extraFields;
}
public String getDeliveryMethod() {
return deliveryMethod;
}
public String getDisplayType() {
return displayType;
}
public String getCampaignType() {
return campaignType;
}
public String getSettings() {
return settings;
}
public String getAudience() {
return audience;
}
public String getWorkflowSettings() {
return workflowSettings;
}
public String getCategory() {
return category;
}
public String getDescription() {
return description;
}
public String getCommunicationUUID() {
return communicationUUID;
}
public String getStartDate() {
return startDate;
}
public String getEndDate() {
return endDate;
}
public String getCommunicationName() {
return communicationName;
}
public String getCommunicationCategory() {
return communicationCategory;
}
public boolean isNew() {
return isNew;
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<NewCampaign> CREATOR = new Creator<NewCampaign>() {
public NewCampaign createFromParcel(Parcel source) {
return new NewCampaign(source);
}
public NewCampaign[] newArray(int size) {
return new NewCampaign[size];
}
};
}
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.models;
import androidx.annotation.NonNull;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
/**
* Created by Panagiotis Triantafyllou on 12-May-22.
*/
public class NewCampaignList extends ArrayList<NewCampaign> {
/**
* Generated for serialized class
*/
private static final long serialVersionUID = -188843583823948267L;
private static final String JSON_KEY_MAPP = "MAPP_CAMPAIGNING";
private static final String JSON_KEY_MAPP_VALUE = "campaigns";
private static final String JSON_KEY_CONTEXT = "context";
private String mRequestSignature = "";
private NewCampaignList(String requestSignature) {
this.mRequestSignature = requestSignature;
}
public NewCampaignList() {
super();
}
/**
* Constructor used to create the CampaignList from a JSON Object.
*
* @param campaignListJSONObject The JSON Object, used to create the CampaignList
*/
public NewCampaignList(JSONObject campaignListJSONObject, String requestSignature) {
this(requestSignature);
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;
}
}
......@@ -13,6 +13,8 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
......@@ -40,7 +42,7 @@ public class WarplyContentRequest {
private long mCacheUpdateInterval = 0;
private String mContentCategory = "";
private ArrayList<String> mTags = new ArrayList<>();
private String mLanguage = "";
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
......
package ly.warp.sdk.io.request;
import android.util.Base64;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
* Created by Panagiotis Triantafyllou on 12-May-22.
*/
public class WarplyGetCampaignsRequest {
// ===========================================================
// Constants
// ===========================================================
private final String KEY_ACTION = "action";
private final String KEY_ACTION_VALUE = "retrieve";
private final String KEY_LANGUAGE = "language";
private final String KEY_FILTERS = "filters";
// ===========================================================
// Fields
// ===========================================================
private JSONObject mFilters = new JSONObject();
private long mCacheUpdateInterval = 0;
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of WarplyGetCampaignsRequest, initializes an empty filters HashMap
*/
public WarplyGetCampaignsRequest() {
mFilters = new JSONObject();
}
public WarplyGetCampaignsRequest(WarplyGetCampaignsRequest copy) {
if (copy != null) {
this.mFilters = copy.mFilters;
this.mCacheUpdateInterval = copy.mCacheUpdateInterval;
}
}
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public boolean equals(Object object) {
if (object instanceof WarplyGetCampaignsRequest) {
WarplyGetCampaignsRequest other = (WarplyGetCampaignsRequest) object;
return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters)));
}
return false;
}
@Override
public int hashCode() {
return mFilters.hashCode();
}
// ===========================================================
// Methods
// ===========================================================
// ===========================================================
// Getter & Setter
// ===========================================================
public WarplyGetCampaignsRequest setLanguage(String language) {
mLanguage = language;
return this;
}
public WarplyGetCampaignsRequest setFilters(JSONObject filters) {
mFilters = filters;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
* @return mCacheUpdateInterval
*/
public long getCacheUpdateInterval() {
return mCacheUpdateInterval;
}
/**
* Call this to set how often the cached data will be updated.
*
* @param updateInterval The time that data will be cached
* @return WarplyGetCampaignsRequest
*/
public WarplyGetCampaignsRequest setCacheUpdateInterval(long updateInterval) {
this.mCacheUpdateInterval = updateInterval;
if (mCacheUpdateInterval < 0) {
mCacheUpdateInterval = 0;
}
return this;
}
/**
* Call this to check if the Application uses Cache
*
* @return <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
*/
public boolean isUseCache() {
return mCacheUpdateInterval > 0;
}
/**
* Call this to check whether the cached data need to be updated
*
* @param useCache <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
* @return WarplyGetCampaignsRequest
*/
public WarplyGetCampaignsRequest setUseCache(boolean useCache) {
if (useCache) {
mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval
: WarpConstants.INBOX_UPDATE_INTERVAL;
} else {
mCacheUpdateInterval = 0;
}
return this;
}
/**
* Call this to build the campaigns Json object
*
* @return bodyJsonObject
*/
public JSONObject toJson() {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
if (mFilters != null && mFilters.length() > 0)
bodyJsonObject.putOpt(KEY_FILTERS, mFilters);
else
bodyJsonObject.putOpt(KEY_FILTERS, new JSONObject());
} catch (JSONException e) {
if (WarpConstants.DEBUG)
e.printStackTrace();
}
return bodyJsonObject;
}
public String getSignature() {
String signature = mFilters != null && mFilters.length() > 0 ? String.valueOf(mFilters.hashCode()) : "default_get_campaigns_request";
try {
byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8"));
signature = Base64.encodeToString(hash, Base64.NO_WRAP);
} catch (NullPointerException | NoSuchAlgorithmException
| UnsupportedEncodingException e) {
e.printStackTrace();
}
return signature;
}
}
......@@ -12,6 +12,8 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
......@@ -40,7 +42,7 @@ public class WarplyGetCouponsetsRequest {
private boolean mActive = true;
private boolean mVisible = true;
private ArrayList<String> mUuids = new ArrayList<>();
private String mLanguage = "";
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
......
......@@ -10,6 +10,8 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
......@@ -32,7 +34,7 @@ public class WarplyMerchantCategoriesRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mLanguage = "";
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
......
......@@ -13,6 +13,8 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
......@@ -51,7 +53,7 @@ public class WarplyMerchantsRequest {
private String mUuid = "";
private int mDistance = 0;
private ArrayList<Double> mCenter = new ArrayList<>();
private String mLanguage = "";
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
......
......@@ -39,7 +39,7 @@ public class WarplyProductsRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mProductsCategory = "";
private String mLanguage = "";
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
......
......@@ -10,6 +10,8 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
......@@ -33,7 +35,7 @@ public class WarplyTagsCategoriesRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mLanguage = "";
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
......
......@@ -10,6 +10,8 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
......@@ -33,7 +35,7 @@ public class WarplyTagsRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mLanguage = "";
private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
// ===========================================================
// Constructor
......
......@@ -30,7 +30,7 @@ public class WarpConstants {
/**
* The version of the SDK installed in the device
*/
public static final String SDK_VERSION = "4.5.4.2";
public static final String SDK_VERSION = "4.5.4.3";
/**
* The URL of the server where it should ping
......@@ -126,6 +126,7 @@ public class WarpConstants {
public static final String MICROAPP_CONTACT = "contact";
public static final String MICROAPP_CARDS = "cards";
public static final String MICROAPP_COUPONS = "coupon";
public static final String MICROAPP_NEW_CAMPAIGNS = "campaigns";
public static final String MICROAPP_TRANSACTIONS = "transactions";
public static final String MICROAPP_CONTENT = "content";
public static final String MICROAPP_APPLICATION_DATA = "application_data";
......
......@@ -39,6 +39,7 @@ import ly.warp.sdk.io.callbacks.CouponsHook;
import ly.warp.sdk.io.callbacks.CouponsetsHook;
import ly.warp.sdk.io.callbacks.MerchantCategoriesHook;
import ly.warp.sdk.io.callbacks.MerchantsHook;
import ly.warp.sdk.io.callbacks.NewCampaignsHook;
import ly.warp.sdk.io.callbacks.PointsHook;
import ly.warp.sdk.io.callbacks.ProductsHook;
import ly.warp.sdk.io.callbacks.TagsCategoriesHook;
......@@ -53,6 +54,7 @@ import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.CouponsetsList;
import ly.warp.sdk.io.models.MerchantCategoriesList;
import ly.warp.sdk.io.models.MerchantList;
import ly.warp.sdk.io.models.NewCampaignList;
import ly.warp.sdk.io.models.PointsList;
import ly.warp.sdk.io.models.ProductList;
import ly.warp.sdk.io.models.TagsCategoriesList;
......@@ -71,6 +73,7 @@ import ly.warp.sdk.io.request.WarplyEditAddressRequest;
import ly.warp.sdk.io.request.WarplyEditConsumerRequest;
import ly.warp.sdk.io.request.WarplyForgotPasswordRequest;
import ly.warp.sdk.io.request.WarplyGetAddressRequest;
import ly.warp.sdk.io.request.WarplyGetCampaignsRequest;
import ly.warp.sdk.io.request.WarplyGetCardsRequest;
import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest;
import ly.warp.sdk.io.request.WarplyLoginRequest;
......@@ -1267,4 +1270,43 @@ public class WarplyManager {
}
});
}
public static void getCampaigns(WarplyGetCampaignsRequest request, boolean auth, final CallbackReceiver<NewCampaignList> receiver) {
WarpUtils.log("************* WARPLY Get Campaigns Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active");
WarpUtils.log("**************************************************");
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_NEW_CAMPAIGNS, auth, "campaigns", request.toJson(), new NewCampaignsHook(new CallbackReceiver<NewCampaignList>() {
@Override
public void onSuccess(NewCampaignList result) {
receiver.onSuccess(result);
}
@Override
public void onFailure(int errorCode) {
if (auth) {
if (errorCode == 401) {
refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
getCampaigns(request, auth, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
} else
receiver.onFailure(errorCode);
}
},
request.getSignature()));
}
}
......