Panagiotis Triantafyllou

version 4.5.1

......@@ -33,8 +33,8 @@ PushIcon=ic_notify
# If the device packages need to be send to the engage server
SendPackages=false
# The language for some requests in case of multi language support
Language=el
# The app language
#Language=el
# The merchant id for some requests
MerchantId=20113
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.0'
PUBLISH_VERSION = '4.5.1'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
/*
* 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.JSONArray;
import org.json.JSONObject;
import ly.warp.sdk.io.models.CouponsetsList;
/**
* Created by Panagiotis Triantafyllou on 04-Feb-22.
*/
public class CouponsetsHook implements CallbackReceiver<JSONObject> {
private final String JSON_KEY_MAPP = "MAPP_COUPON";
private final String JSON_KEY_CONTEXT = "context";
private final CallbackReceiver<CouponsetsList> mListener;
private final String mRequestSignature;
public CouponsetsHook(CallbackReceiver<CouponsetsList> 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) {
JSONObject couponsetsJSONObject = result.optJSONObject(JSON_KEY_CONTEXT);
if (couponsetsJSONObject != null) {
JSONArray jArrayResult = couponsetsJSONObject.optJSONArray(JSON_KEY_MAPP);
if (jArrayResult == null) {
mListener.onFailure(2);
return;
}
mListener.onSuccess(new CouponsetsList(couponsetsJSONObject, mRequestSignature));
}
} else
mListener.onFailure(status);
}
}
@Override
public void onFailure(int errorCode) {
if (mListener != null)
mListener.onFailure(errorCode);
}
}
......@@ -58,6 +58,8 @@ public class Coupon implements Parcelable, Serializable {
private static final String STATUS = "status";
private static final String TRANSACTION_DATE = "transaction_date";
private static final String TRANSACTION_UUID = "transaction_uuid";
private static final String CHANGES_DATES = "changes_dates";
private static final String COUPONSET_UUID = "couponset_uuid";
/* Member variables of the Campaign object */
......@@ -73,6 +75,8 @@ public class Coupon implements Parcelable, Serializable {
private int status = 0;
private String transactionDate = "";
private String transactionUuid = "";
private JSONObject changesDates = new JSONObject();
private String couponsetUuid = "";
/**
* Basic constructor used to create an object from a String, representing a
......@@ -104,6 +108,8 @@ public class Coupon implements Parcelable, Serializable {
this.status = json.optInt(STATUS);
this.transactionDate = json.optString(TRANSACTION_DATE);
this.transactionUuid = json.optString(TRANSACTION_UUID);
this.changesDates = json.optJSONObject(CHANGES_DATES);
this.couponsetUuid = json.optString(COUPONSET_UUID);
}
}
......@@ -120,6 +126,7 @@ public class Coupon implements Parcelable, Serializable {
this.status = source.readInt();
this.transactionDate = source.readString();
this.transactionUuid = source.readString();
this.couponsetUuid = source.readString();
}
@Override
......@@ -136,6 +143,7 @@ public class Coupon implements Parcelable, Serializable {
dest.writeInt(this.status);
dest.writeString(this.transactionDate);
dest.writeString(this.transactionUuid);
dest.writeString(this.couponsetUuid);
}
/**
......@@ -158,6 +166,8 @@ public class Coupon implements Parcelable, Serializable {
jObj.putOpt(STATUS, this.status);
jObj.putOpt(TRANSACTION_DATE, this.transactionDate);
jObj.putOpt(TRANSACTION_UUID, this.transactionUuid);
jObj.putOpt(CHANGES_DATES, this.changesDates);
jObj.putOpt(COUPONSET_UUID, this.couponsetUuid);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
......@@ -245,6 +255,14 @@ public class Coupon implements Parcelable, Serializable {
return transactionUuid;
}
public JSONObject getChangesDates() {
return changesDates;
}
public String getCouponsetUuid() {
return couponsetUuid;
}
@Override
public int describeContents() {
return 0;
......
/*
* 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.JSONArray;
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 04-Feb-22.
*/
public class Couponset 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 UUID = "uuid";
private static final String ADMIN_NAME = "admin_name";
private static final String CREATED = "created";
private static final String UPDATED = "updated";
private static final String APP_UUID = "app_uuid";
private static final String IMG = "img";
private static final String IMG_PREVIEW = "img_preview";
private static final String SORTING = "sorting";
private static final String ACTIVE = "active";
private static final String VISIBLE = "visible";
private static final String BUYABLE = "buyable";
private static final String USER_GENERATED = "user_generated";
private static final String LIMITS = "limits";
private static final String POINTS = "points";
private static final String POINTS_CAUSE = "points_cause";
private static final String EXPIRATION = "expiration";
private static final String THIRD_PARTY_SERVICE = "third_party_service";
private static final String NAME = "name";
private static final String DESCRIPTION = "description";
private static final String SHORT_DESCRIPTION = "short_description";
private static final String DISCOUNT = "discount";
private static final String CATEGORY = "category";
private static final String TERMS = "terms";
private static final String AVAILABILITY = "availability";
/* Member variables of the Campaign object */
private String uuid = "";
private String admin_name = "";
private String created = "";
private String updated = "";
private String app_uuid = "";
private JSONArray img = new JSONArray();
private String img_preview = "";
private int sorting = 0;
private boolean active = false;
private boolean visible = false;
private boolean buyable = false;
private boolean user_generated = false;
private JSONObject limits = new JSONObject();
private int points = 0;
private String points_cause = "";
private String expiration = "";
private boolean third_party_service = false;
private String name = "";
private String description = "";
private String short_description = "";
private String discount = "";
private String category = "";
private String terms = "";
private int availability = 0;
/**
* 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 Couponset(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 Address
*/
public Couponset(JSONObject json) {
if (json != null) {
this.uuid = json.optString(UUID);
this.admin_name = json.optString(ADMIN_NAME);
this.created = json.optString(CREATED);
this.updated = json.optString(UPDATED);
this.app_uuid = json.optString(APP_UUID);
this.img = json.optJSONArray(IMG);
this.img_preview = json.optString(IMG_PREVIEW);
this.sorting = json.optInt(SORTING);
this.active = json.optBoolean(ACTIVE);
this.visible = json.optBoolean(VISIBLE);
this.buyable = json.optBoolean(BUYABLE);
this.user_generated = json.optBoolean(USER_GENERATED);
this.limits = json.optJSONObject(LIMITS);
this.points = json.optInt(POINTS);
this.points_cause = json.optString(POINTS_CAUSE);
this.expiration = json.optString(EXPIRATION);
this.third_party_service = json.optBoolean(THIRD_PARTY_SERVICE);
this.name = json.optString(NAME);
this.description = json.optString(DESCRIPTION);
this.short_description = json.optString(SHORT_DESCRIPTION);
this.discount = json.optString(DISCOUNT);
this.category = json.optString(CATEGORY);
this.terms = json.optString(TERMS);
this.availability = json.optInt(AVAILABILITY);
}
}
public Couponset(Parcel source) {
this.uuid = source.readString();
this.admin_name = source.readString();
this.created = source.readString();
this.updated = source.readString();
this.app_uuid = source.readString();
this.img_preview = source.readString();
this.sorting = source.readInt();
this.active = source.readByte() != 0;
this.visible = source.readByte() != 0;
this.buyable = source.readByte() != 0;
this.user_generated = source.readByte() != 0;
this.points = source.readInt();
this.points_cause = source.readString();
this.expiration = source.readString();
this.third_party_service = source.readByte() != 0;
this.name = source.readString();
this.description = source.readString();
this.short_description = source.readString();
this.discount = source.readString();
this.category = source.readString();
this.terms = source.readString();
this.availability = source.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.uuid);
dest.writeString(this.admin_name);
dest.writeString(this.created);
dest.writeString(this.updated);
dest.writeString(this.app_uuid);
dest.writeString(this.img_preview);
dest.writeInt(this.sorting);
dest.writeByte((byte) (this.active ? 1 : 0));
dest.writeByte((byte) (this.visible ? 1 : 0));
dest.writeByte((byte) (this.buyable ? 1 : 0));
dest.writeByte((byte) (this.user_generated ? 1 : 0));
dest.writeInt(this.points);
dest.writeString(this.points_cause);
dest.writeString(this.expiration);
dest.writeByte((byte) (this.third_party_service ? 1 : 0));
dest.writeString(this.name);
dest.writeString(this.description);
dest.writeString(this.short_description);
dest.writeString(this.discount);
dest.writeString(this.category);
dest.writeString(this.terms);
dest.writeInt(this.availability);
}
/**
* Converts the Couponset into a JSON Object
*
* @return The JSON Object created from this Couponset
*/
public JSONObject toJSONObject() {
JSONObject jObj = new JSONObject();
try {
jObj.putOpt(UUID, this.uuid);
jObj.putOpt(ADMIN_NAME, this.admin_name);
jObj.putOpt(CREATED, this.created);
jObj.putOpt(UPDATED, this.updated);
jObj.putOpt(APP_UUID, this.app_uuid);
jObj.putOpt(IMG, this.img);
jObj.putOpt(IMG_PREVIEW, this.img_preview);
jObj.putOpt(SORTING, this.sorting);
jObj.putOpt(ACTIVE, this.active);
jObj.putOpt(VISIBLE, this.visible);
jObj.putOpt(BUYABLE, this.buyable);
jObj.putOpt(USER_GENERATED, this.user_generated);
jObj.putOpt(LIMITS, this.limits);
jObj.putOpt(POINTS, this.points);
jObj.putOpt(POINTS_CAUSE, this.points_cause);
jObj.putOpt(EXPIRATION, this.expiration);
jObj.putOpt(THIRD_PARTY_SERVICE, this.third_party_service);
jObj.putOpt(NAME, this.name);
jObj.putOpt(DESCRIPTION, this.description);
jObj.putOpt(SHORT_DESCRIPTION, this.short_description);
jObj.putOpt(DISCOUNT, this.discount);
jObj.putOpt(CATEGORY, this.category);
jObj.putOpt(TERMS, this.terms);
jObj.putOpt(AVAILABILITY, this.availability);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
}
}
return jObj;
}
/**
* String representation of the Couponset, 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 Address, 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 Couponset JSON object to String", e);
}
return humanReadableString;
}
// ================================================================================
// Getters
// ================================================================================
public String getUuid() {
return uuid;
}
public String getAdminName() {
return admin_name;
}
public String getCreated() {
return created;
}
public String getUpdated() {
return updated;
}
public String getAppUuid() {
return app_uuid;
}
public JSONArray getImg() {
return img;
}
public String getImgPreview() {
return img_preview;
}
public int getSorting() {
return sorting;
}
public boolean isActive() {
return active;
}
public boolean isVisible() {
return visible;
}
public boolean isBuyable() {
return buyable;
}
public boolean isUserGenerated() {
return user_generated;
}
public JSONObject getLimits() {
return limits;
}
public int getPoints() {
return points;
}
public String getPointsCause() {
return points_cause;
}
public String getExpiration() {
return expiration;
}
public boolean isThirdPartyService() {
return third_party_service;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public String getShortDescription() {
return short_description;
}
public String getDiscount() {
return discount;
}
public String getCategory() {
return category;
}
public String getTerms() {
return terms;
}
public int getAvailability() {
return availability;
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<Couponset> CREATOR = new Creator<Couponset>() {
public Couponset createFromParcel(Parcel source) {
return new Couponset(source);
}
public Couponset[] newArray(int size) {
return new Couponset[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 04-Feb-22.
*/
public class CouponsetsList extends ArrayList<Couponset> {
/**
* Generated for serialized class
*/
private static final long serialVersionUID = -188843583823948267L;
private static final String JSON_KEY_COUPON = "MAPP_COUPON";
private String mRequestSignature = "";
private CouponsetsList(String requestSignature) {
this.mRequestSignature = requestSignature;
}
public CouponsetsList() {
super();
}
/**
* Constructor used to create the CouponsetsList from a JSON Object.
*
* @param addressListJSONObject The JSON Object, used to create the CouponsetsList
*/
public CouponsetsList(JSONObject addressListJSONObject, String requestSignature) {
this(requestSignature);
if (addressListJSONObject == null)
return;
JSONArray jArray = addressListJSONObject.optJSONArray(JSON_KEY_COUPON);
if (jArray != null && jArray.length() > 0) {
for (int i = 0, lim = jArray.length(); i < lim; ++i) {
add(new Couponset(jArray.optJSONObject(i)));
}
}
}
@NonNull
public String getRequestSignature() {
return mRequestSignature;
}
}
......@@ -13,8 +13,6 @@ 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;
/**
......@@ -42,6 +40,7 @@ public class WarplyContentRequest {
private long mCacheUpdateInterval = 0;
private String mContentCategory = "";
private ArrayList<String> mTags = new ArrayList<>();
private String mLanguage = "";
// ===========================================================
// Constructor
......@@ -97,6 +96,11 @@ public class WarplyContentRequest {
return this;
}
public WarplyContentRequest setLanguage(String lan) {
mLanguage = lan;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -159,7 +163,7 @@ public class WarplyContentRequest {
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_ACTIVE, true);
bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
bodyJsonObject.putOpt(KEY_CATEGORY, TextUtils.isEmpty(mContentCategory) ? JSONObject.NULL : mContentCategory);
JSONArray jsArray = new JSONArray(mTags);
bodyJsonObject.putOpt(KEY_TAGS, jsArray.length() == 0 ? JSONObject.NULL : jsArray);
......
package ly.warp.sdk.io.request;
import android.util.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
* Created by Panagiotis Triantafyllou on 04-Feb-22.
*/
public class WarplyGetCouponsetsRequest {
// ===========================================================
// Constants
// ===========================================================
private final String KEY_ACTION = "action";
private final String KEY_ACTION_VALUE = "retrieve_multilingual";
private final String KEY_ACTIVE = "active";
private final String KEY_VISIBLE = "visible";
private final String KEY_LANGUAGE = "language";
private final String KEY_UUIDS = "uuids";
// ===========================================================
// Fields
// ===========================================================
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private boolean mActive = true;
private boolean mVisible = true;
private ArrayList<String> mUuids = new ArrayList<>();
private String mLanguage = "";
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of WarplyGetCouponsetsRequest, initializes an empty filters HashMap
*/
public WarplyGetCouponsetsRequest() {
mFilters = new HashMap<>();
}
public WarplyGetCouponsetsRequest(WarplyGetCouponsetsRequest 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 WarplyGetCouponsetsRequest) {
WarplyGetCouponsetsRequest other = (WarplyGetCouponsetsRequest) 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 WarplyGetCouponsetsRequest setActive(boolean active) {
mActive = active;
return this;
}
public WarplyGetCouponsetsRequest setVisible(boolean visible) {
mVisible = visible;
return this;
}
public WarplyGetCouponsetsRequest setUuids(ArrayList<String> uuids) {
mUuids = uuids;
return this;
}
public WarplyGetCouponsetsRequest setLanguage(String language) {
mLanguage = language;
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 WarplyGetCouponsetsRequest
*/
public WarplyGetCouponsetsRequest 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 WarplyGetCouponsetsRequest
*/
public WarplyGetCouponsetsRequest setUseCache(boolean useCache) {
if (useCache) {
mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval
: WarpConstants.INBOX_UPDATE_INTERVAL;
} else {
mCacheUpdateInterval = 0;
}
return this;
}
/**
* Call this to build the couponsets Json object
*
* @return bodyJsonObject
*/
public JSONObject toJson() {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_ACTIVE, mActive);
bodyJsonObject.putOpt(KEY_VISIBLE, mVisible);
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
if (mUuids != null && mUuids.size() > 0)
bodyJsonObject.putOpt(KEY_UUIDS, new JSONArray(mUuids));
} catch (JSONException e) {
if (WarpConstants.DEBUG)
e.printStackTrace();
}
return bodyJsonObject;
}
public String getSignature() {
String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_get_couponsets_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;
}
}
......@@ -10,8 +10,6 @@ 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;
/**
......@@ -34,6 +32,7 @@ public class WarplyMerchantCategoriesRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mLanguage = "";
// ===========================================================
// Constructor
......@@ -79,6 +78,11 @@ public class WarplyMerchantCategoriesRequest {
// Getter & Setter
// ===========================================================
public WarplyMerchantCategoriesRequest setLanguage(String lan) {
mLanguage = lan;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -140,7 +144,7 @@ public class WarplyMerchantCategoriesRequest {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
} catch (JSONException e) {
if (WarpConstants.DEBUG)
e.printStackTrace();
......
......@@ -13,8 +13,6 @@ 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;
/**
......@@ -53,6 +51,7 @@ public class WarplyMerchantsRequest {
private String mUuid = "";
private int mDistance = 0;
private ArrayList<Double> mCenter = new ArrayList<>();
private String mLanguage = "";
// ===========================================================
// Constructor
......@@ -133,6 +132,11 @@ public class WarplyMerchantsRequest {
return this;
}
public WarplyMerchantsRequest setLanguage(String lan) {
mLanguage = lan;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -198,7 +202,7 @@ public class WarplyMerchantsRequest {
bodyJsonObject.putOpt(KEY_ACTIVE, true);
bodyJsonObject.putOpt(KEY_CATEGORIES, new JSONArray(mCategories));
bodyJsonObject.putOpt(KEY_DEFAULT_SHOWN, mDefaultShown ? mDefaultShown : JSONObject.NULL);
bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
if (mDistance != 0 && mCenter != null && mCenter.size() > 0) {
JSONObject locObj = new JSONObject();
locObj.putOpt(KEY_CENTER, mCenter);
......
......@@ -3,7 +3,6 @@ package ly.warp.sdk.io.request;
import android.text.TextUtils;
import android.util.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -11,7 +10,6 @@ import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
......@@ -41,6 +39,7 @@ public class WarplyProductsRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mProductsCategory = "";
private String mLanguage = "";
// ===========================================================
// Constructor
......@@ -91,6 +90,11 @@ public class WarplyProductsRequest {
return this;
}
public WarplyProductsRequest setLanguage(String lan) {
mLanguage = lan;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -152,7 +156,7 @@ public class WarplyProductsRequest {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
bodyJsonObject.putOpt(KEY_MERCHANT_ID, WarplyProperty.getMerchantId(Warply.getWarplyContext()));
JSONObject extraJson = new JSONObject();
extraJson.put(KEY_CATEGORY_NAME, TextUtils.isEmpty(mProductsCategory) ? JSONObject.NULL : mProductsCategory);
......
......@@ -10,12 +10,10 @@ 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;
/**
* Created by Panagiotis Triantafyllou on 18-Jan-22.
* Created by Panagiotis Triantafyllou on 04-Feb-22.
*/
public class WarplyRedeemCouponRequest {
......@@ -25,12 +23,8 @@ public class WarplyRedeemCouponRequest {
// ===========================================================
private final String KEY_ACTION = "action";
private final String KEY_ACTION_VALUE = "vcurrency_purchase";
private final String KEY_MERCHANT_ID = "merchant_id";
private final String KEY_PRODUCT_ID = "product_id";
private final String KEY_PRODUCT_UUID = "product_uuid";
private final String KEY_CAUSE = "cause";
private final String KEY_CAUSE_VALUE = "coupon";
private final String KEY_ACTION_VALUE = "retrieve_coupon";
private final String KEY_COUPONSET = "coupon_set";
// ===========================================================
// Fields
......@@ -38,8 +32,7 @@ public class WarplyRedeemCouponRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mId = "";
private String mUuid = "";
private String mCouponsetUuid = "";
// ===========================================================
// Constructor
......@@ -85,13 +78,8 @@ public class WarplyRedeemCouponRequest {
// Getter & Setter
// ===========================================================
public WarplyRedeemCouponRequest setSku(String sku) {
mId = sku;
return this;
}
public WarplyRedeemCouponRequest setUuid(String uuid) {
mUuid = uuid;
public WarplyRedeemCouponRequest setCouponsetUuid(String uuid) {
mCouponsetUuid = uuid;
return this;
}
......@@ -148,7 +136,7 @@ public class WarplyRedeemCouponRequest {
}
/**
* Call this to build the offers Json object
* Call this to build the redeem coupon Json object
*
* @return bodyJsonObject
*/
......@@ -156,10 +144,7 @@ public class WarplyRedeemCouponRequest {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_MERCHANT_ID, WarplyProperty.getMerchantId(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_PRODUCT_ID, mId);
bodyJsonObject.putOpt(KEY_PRODUCT_UUID, mUuid);
bodyJsonObject.putOpt(KEY_CAUSE, KEY_CAUSE_VALUE);
bodyJsonObject.putOpt(KEY_COUPONSET, mCouponsetUuid);
} catch (JSONException e) {
if (WarpConstants.DEBUG)
e.printStackTrace();
......
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 java.util.HashMap;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
* Created by Panagiotis Triantafyllou on 18-Jan-22.
*/
public class WarplyRedeemProductRequest {
// ===========================================================
// Constants
// ===========================================================
private final String KEY_ACTION = "action";
private final String KEY_ACTION_VALUE = "vcurrency_purchase";
private final String KEY_MERCHANT_ID = "merchant_id";
private final String KEY_PRODUCT_ID = "product_id";
private final String KEY_PRODUCT_UUID = "product_uuid";
private final String KEY_CAUSE = "cause";
private final String KEY_CAUSE_VALUE = "coupon";
// ===========================================================
// Fields
// ===========================================================
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mId = "";
private String mUuid = "";
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of WarplyRedeemCouponRequest, initializes an empty filters HashMap
*/
public WarplyRedeemProductRequest() {
mFilters = new HashMap<>();
}
public WarplyRedeemProductRequest(WarplyRedeemProductRequest 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 WarplyRedeemProductRequest) {
WarplyRedeemProductRequest other = (WarplyRedeemProductRequest) 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 WarplyRedeemProductRequest setSku(String sku) {
mId = sku;
return this;
}
public WarplyRedeemProductRequest setUuid(String uuid) {
mUuid = uuid;
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 WarplyRedeemCouponRequest
*/
public WarplyRedeemProductRequest 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 WarplyRedeemCouponRequest
*/
public WarplyRedeemProductRequest setUseCache(boolean useCache) {
if (useCache) {
mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval
: WarpConstants.INBOX_UPDATE_INTERVAL;
} else {
mCacheUpdateInterval = 0;
}
return this;
}
/**
* Call this to build the offers Json object
*
* @return bodyJsonObject
*/
public JSONObject toJson() {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_MERCHANT_ID, WarplyProperty.getMerchantId(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_PRODUCT_ID, mId);
bodyJsonObject.putOpt(KEY_PRODUCT_UUID, mUuid);
bodyJsonObject.putOpt(KEY_CAUSE, KEY_CAUSE_VALUE);
} catch (JSONException e) {
if (WarpConstants.DEBUG)
e.printStackTrace();
}
return bodyJsonObject;
}
public String getSignature() {
String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_redeem_product_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;
}
}
......@@ -10,8 +10,6 @@ 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;
/**
......@@ -35,6 +33,7 @@ public class WarplyTagsCategoriesRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mLanguage = "";
// ===========================================================
// Constructor
......@@ -80,6 +79,11 @@ public class WarplyTagsCategoriesRequest {
// Getter & Setter
// ===========================================================
public WarplyTagsCategoriesRequest setLanguage(String lan) {
mLanguage = lan;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -141,7 +145,7 @@ public class WarplyTagsCategoriesRequest {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
bodyJsonObject.putOpt(KEY_ACTIVE, true);
} catch (JSONException e) {
if (WarpConstants.DEBUG)
......
......@@ -10,8 +10,6 @@ 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;
/**
......@@ -35,6 +33,7 @@ public class WarplyTagsRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mLanguage = "";
// ===========================================================
// Constructor
......@@ -80,6 +79,11 @@ public class WarplyTagsRequest {
// Getter & Setter
// ===========================================================
public WarplyTagsRequest setLanguage(String lan) {
mLanguage = lan;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -141,7 +145,7 @@ public class WarplyTagsRequest {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext()));
bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
bodyJsonObject.putOpt(KEY_ACTIVE, true);
} catch (JSONException e) {
if (WarpConstants.DEBUG)
......
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 java.util.HashMap;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
* Created by Panagiotis Triantafyllou on 04-Feb-22.
*/
public class WarplyValidateCouponRequest {
// ===========================================================
// Constants
// ===========================================================
private final String KEY_ACTION = "action";
private final String KEY_ACTION_VALUE = "validate";
private final String KEY_COUPON = "coupon";
// ===========================================================
// Fields
// ===========================================================
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mCoupon = "";
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of WarplyValidateCouponRequest, initializes an empty filters HashMap
*/
public WarplyValidateCouponRequest() {
mFilters = new HashMap<>();
}
public WarplyValidateCouponRequest(WarplyValidateCouponRequest 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 WarplyValidateCouponRequest) {
WarplyValidateCouponRequest other = (WarplyValidateCouponRequest) 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 WarplyValidateCouponRequest setCoupon(String code) {
mCoupon = code;
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 WarplyValidateCouponRequest
*/
public WarplyValidateCouponRequest 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 WarplyValidateCouponRequest
*/
public WarplyValidateCouponRequest setUseCache(boolean useCache) {
if (useCache) {
mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval
: WarpConstants.INBOX_UPDATE_INTERVAL;
} else {
mCacheUpdateInterval = 0;
}
return this;
}
/**
* Call this to build the validate coupon Json object
*
* @return bodyJsonObject
*/
public JSONObject toJson() {
JSONObject bodyJsonObject = new JSONObject();
try {
bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
bodyJsonObject.putOpt(KEY_COUPON, mCoupon);
} catch (JSONException e) {
if (WarpConstants.DEBUG)
e.printStackTrace();
}
return bodyJsonObject;
}
public String getSignature() {
String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_validate_coupon_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;
}
}
......@@ -30,7 +30,7 @@ public class WarpConstants {
/**
* The version of the SDK installed in the device
*/
public static final String SDK_VERSION = "4.5.0";
public static final String SDK_VERSION = "4.5.1";
/**
* The URL of the server where it should ping
......
......@@ -36,6 +36,7 @@ import ly.warp.sdk.io.callbacks.CardsHook;
import ly.warp.sdk.io.callbacks.ContactHook;
import ly.warp.sdk.io.callbacks.ContentHook;
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.PointsHook;
......@@ -49,6 +50,7 @@ import ly.warp.sdk.io.models.CardList;
import ly.warp.sdk.io.models.Consumer;
import ly.warp.sdk.io.models.ContentList;
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.PointsList;
......@@ -70,12 +72,14 @@ 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.WarplyGetCardsRequest;
import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest;
import ly.warp.sdk.io.request.WarplyLoginRequest;
import ly.warp.sdk.io.request.WarplyMerchantCategoriesRequest;
import ly.warp.sdk.io.request.WarplyMerchantsRequest;
import ly.warp.sdk.io.request.WarplyPointHistoryRequest;
import ly.warp.sdk.io.request.WarplyProductsRequest;
import ly.warp.sdk.io.request.WarplyRedeemCouponRequest;
import ly.warp.sdk.io.request.WarplyRedeemProductRequest;
import ly.warp.sdk.io.request.WarplyRefreshTokenRequest;
import ly.warp.sdk.io.request.WarplyRegisterRequest;
import ly.warp.sdk.io.request.WarplyRequestOTPRequest;
......@@ -86,6 +90,7 @@ import ly.warp.sdk.io.request.WarplyTokenAuthorizeRequest;
import ly.warp.sdk.io.request.WarplyTransactionHistoryRequest;
import ly.warp.sdk.io.request.WarplyUploadConsumerPhotoRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.io.request.WarplyValidateCouponRequest;
import ly.warp.sdk.io.request.WarplyVerifyOTPRequest;
import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
import ly.warp.sdk.utils.WarpUtils;
......@@ -1031,9 +1036,9 @@ public class WarplyManager {
});
}
public static void redeemCoupon(WarplyRedeemCouponRequest request, final CallbackReceiver<JSONObject> receiver) {
WarpUtils.log("************* WARPLY Redeem Coupons Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Redeem Coupons Request is active");
public static void redeemProduct(WarplyRedeemProductRequest request, final CallbackReceiver<JSONObject> receiver) {
WarpUtils.log("************* WARPLY Redeem Product Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Redeem Product Request is active");
WarpUtils.log("**************************************************");
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_TRANSACTIONS, true, "context", request.toJson(), new CallbackReceiver<JSONObject>() {
......@@ -1050,7 +1055,7 @@ public class WarplyManager {
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
redeemCoupon(request, receiver);
redeemProduct(request, receiver);
else
receiver.onFailure(status);
}
......@@ -1173,4 +1178,93 @@ public class WarplyManager {
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_SHOPS, request.toJson(),
new MerchantsHook(receiver, request.getSignature()));
}
public static void getCouponsets(WarplyGetCouponsetsRequest request, final CallbackReceiver<CouponsetsList> receiver) {
WarpUtils.log("************* WARPLY Get Couponsets Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Get Couponsets Request is active");
WarpUtils.log("**************************************************");
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, request.toJson(), new CouponsetsHook(new CallbackReceiver<CouponsetsList>() {
@Override
public void onSuccess(CouponsetsList result) {
receiver.onSuccess(result);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
},
request.getSignature()));
}
public static void redeemCoupon(WarplyRedeemCouponRequest request, final CallbackReceiver<JSONObject> receiver) {
WarpUtils.log("************* WARPLY Redeem Coupon Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Redeem Coupon Request is active");
WarpUtils.log("**************************************************");
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
receiver.onSuccess(result);
}
@Override
public void onFailure(int errorCode) {
if (errorCode == 401) {
refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
redeemCoupon(request, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
}
});
}
public static void validateCoupon(WarplyValidateCouponRequest request, final CallbackReceiver<JSONObject> receiver) {
WarpUtils.log("************* WARPLY Validate Coupon Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Validate Coupon Request is active");
WarpUtils.log("**************************************************");
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
receiver.onSuccess(result);
}
@Override
public void onFailure(int errorCode) {
if (errorCode == 401) {
refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
validateCoupon(request, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
}
});
}
}
......