Showing
18 changed files
with
865 additions
and
49 deletions
| ... | @@ -33,8 +33,8 @@ PushIcon=ic_notify | ... | @@ -33,8 +33,8 @@ PushIcon=ic_notify | 
| 33 | # If the device packages need to be send to the engage server | 33 | # If the device packages need to be send to the engage server | 
| 34 | SendPackages=false | 34 | SendPackages=false | 
| 35 | 35 | ||
| 36 | -# The language for some requests in case of multi language support | 36 | +# The app language | 
| 37 | -Language=el | 37 | +#Language=el | 
| 38 | 38 | ||
| 39 | # The merchant id for some requests | 39 | # The merchant id for some requests | 
| 40 | MerchantId=20113 | 40 | MerchantId=20113 | ... | ... | 
| ... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' | ... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' | 
| 2 | 2 | ||
| 3 | ext { | 3 | ext { | 
| 4 | PUBLISH_GROUP_ID = 'ly.warp' | 4 | PUBLISH_GROUP_ID = 'ly.warp' | 
| 5 | - PUBLISH_VERSION = '4.5.0' | 5 | + PUBLISH_VERSION = '4.5.1' | 
| 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 
| 7 | } | 7 | } | 
| 8 | 8 | ... | ... | 
| 1 | +/* | ||
| 2 | + * Copyright 2010-2013 Warply Ltd. All rights reserved. | ||
| 3 | + * | ||
| 4 | + * Redistribution and use in source and binary forms, without modification, are | ||
| 5 | + * permitted provided that the following conditions are met: | ||
| 6 | + * | ||
| 7 | + * 1. Redistributions of source code must retain the above copyright notice, | ||
| 8 | + * this list of conditions and the following disclaimer. | ||
| 9 | + * | ||
| 10 | + * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| 11 | + * this list of conditions and the following disclaimer in the documentation | ||
| 12 | + * and/or other materials provided with the distribution. | ||
| 13 | + * | ||
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR | ||
| 15 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 16 | + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| 17 | + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 18 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 19 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
| 20 | + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 21 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 22 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
| 23 | + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 24 | + */ | ||
| 25 | + | ||
| 26 | +package ly.warp.sdk.io.callbacks; | ||
| 27 | + | ||
| 28 | +import org.json.JSONArray; | ||
| 29 | +import org.json.JSONObject; | ||
| 30 | + | ||
| 31 | +import ly.warp.sdk.io.models.CouponsetsList; | ||
| 32 | + | ||
| 33 | + | ||
| 34 | +/** | ||
| 35 | + * Created by Panagiotis Triantafyllou on 04-Feb-22. | ||
| 36 | + */ | ||
| 37 | + | ||
| 38 | +public class CouponsetsHook implements CallbackReceiver<JSONObject> { | ||
| 39 | + | ||
| 40 | + private final String JSON_KEY_MAPP = "MAPP_COUPON"; | ||
| 41 | + private final String JSON_KEY_CONTEXT = "context"; | ||
| 42 | + private final CallbackReceiver<CouponsetsList> mListener; | ||
| 43 | + private final String mRequestSignature; | ||
| 44 | + | ||
| 45 | + public CouponsetsHook(CallbackReceiver<CouponsetsList> listener, String requestSignature) { | ||
| 46 | + this.mListener = listener; | ||
| 47 | + this.mRequestSignature = requestSignature; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public void onSuccess(JSONObject result) { | ||
| 52 | + if (mListener != null) { | ||
| 53 | + int status = result.optInt("status", 2); | ||
| 54 | + if (status == 1) { | ||
| 55 | + JSONObject couponsetsJSONObject = result.optJSONObject(JSON_KEY_CONTEXT); | ||
| 56 | + if (couponsetsJSONObject != null) { | ||
| 57 | + JSONArray jArrayResult = couponsetsJSONObject.optJSONArray(JSON_KEY_MAPP); | ||
| 58 | + if (jArrayResult == null) { | ||
| 59 | + mListener.onFailure(2); | ||
| 60 | + return; | ||
| 61 | + } | ||
| 62 | + mListener.onSuccess(new CouponsetsList(couponsetsJSONObject, mRequestSignature)); | ||
| 63 | + } | ||
| 64 | + } else | ||
| 65 | + mListener.onFailure(status); | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public void onFailure(int errorCode) { | ||
| 71 | + if (mListener != null) | ||
| 72 | + mListener.onFailure(errorCode); | ||
| 73 | + } | ||
| 74 | +} | 
| ... | @@ -58,6 +58,8 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -58,6 +58,8 @@ public class Coupon implements Parcelable, Serializable { | 
| 58 | private static final String STATUS = "status"; | 58 | private static final String STATUS = "status"; | 
| 59 | private static final String TRANSACTION_DATE = "transaction_date"; | 59 | private static final String TRANSACTION_DATE = "transaction_date"; | 
| 60 | private static final String TRANSACTION_UUID = "transaction_uuid"; | 60 | private static final String TRANSACTION_UUID = "transaction_uuid"; | 
| 61 | + private static final String CHANGES_DATES = "changes_dates"; | ||
| 62 | + private static final String COUPONSET_UUID = "couponset_uuid"; | ||
| 61 | 63 | ||
| 62 | /* Member variables of the Campaign object */ | 64 | /* Member variables of the Campaign object */ | 
| 63 | 65 | ||
| ... | @@ -73,6 +75,8 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -73,6 +75,8 @@ public class Coupon implements Parcelable, Serializable { | 
| 73 | private int status = 0; | 75 | private int status = 0; | 
| 74 | private String transactionDate = ""; | 76 | private String transactionDate = ""; | 
| 75 | private String transactionUuid = ""; | 77 | private String transactionUuid = ""; | 
| 78 | + private JSONObject changesDates = new JSONObject(); | ||
| 79 | + private String couponsetUuid = ""; | ||
| 76 | 80 | ||
| 77 | /** | 81 | /** | 
| 78 | * Basic constructor used to create an object from a String, representing a | 82 | * Basic constructor used to create an object from a String, representing a | 
| ... | @@ -104,6 +108,8 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -104,6 +108,8 @@ public class Coupon implements Parcelable, Serializable { | 
| 104 | this.status = json.optInt(STATUS); | 108 | this.status = json.optInt(STATUS); | 
| 105 | this.transactionDate = json.optString(TRANSACTION_DATE); | 109 | this.transactionDate = json.optString(TRANSACTION_DATE); | 
| 106 | this.transactionUuid = json.optString(TRANSACTION_UUID); | 110 | this.transactionUuid = json.optString(TRANSACTION_UUID); | 
| 111 | + this.changesDates = json.optJSONObject(CHANGES_DATES); | ||
| 112 | + this.couponsetUuid = json.optString(COUPONSET_UUID); | ||
| 107 | } | 113 | } | 
| 108 | } | 114 | } | 
| 109 | 115 | ||
| ... | @@ -120,6 +126,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -120,6 +126,7 @@ public class Coupon implements Parcelable, Serializable { | 
| 120 | this.status = source.readInt(); | 126 | this.status = source.readInt(); | 
| 121 | this.transactionDate = source.readString(); | 127 | this.transactionDate = source.readString(); | 
| 122 | this.transactionUuid = source.readString(); | 128 | this.transactionUuid = source.readString(); | 
| 129 | + this.couponsetUuid = source.readString(); | ||
| 123 | } | 130 | } | 
| 124 | 131 | ||
| 125 | @Override | 132 | @Override | 
| ... | @@ -136,6 +143,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -136,6 +143,7 @@ public class Coupon implements Parcelable, Serializable { | 
| 136 | dest.writeInt(this.status); | 143 | dest.writeInt(this.status); | 
| 137 | dest.writeString(this.transactionDate); | 144 | dest.writeString(this.transactionDate); | 
| 138 | dest.writeString(this.transactionUuid); | 145 | dest.writeString(this.transactionUuid); | 
| 146 | + dest.writeString(this.couponsetUuid); | ||
| 139 | } | 147 | } | 
| 140 | 148 | ||
| 141 | /** | 149 | /** | 
| ... | @@ -158,6 +166,8 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -158,6 +166,8 @@ public class Coupon implements Parcelable, Serializable { | 
| 158 | jObj.putOpt(STATUS, this.status); | 166 | jObj.putOpt(STATUS, this.status); | 
| 159 | jObj.putOpt(TRANSACTION_DATE, this.transactionDate); | 167 | jObj.putOpt(TRANSACTION_DATE, this.transactionDate); | 
| 160 | jObj.putOpt(TRANSACTION_UUID, this.transactionUuid); | 168 | jObj.putOpt(TRANSACTION_UUID, this.transactionUuid); | 
| 169 | + jObj.putOpt(CHANGES_DATES, this.changesDates); | ||
| 170 | + jObj.putOpt(COUPONSET_UUID, this.couponsetUuid); | ||
| 161 | } catch (JSONException e) { | 171 | } catch (JSONException e) { | 
| 162 | if (WarpConstants.DEBUG) { | 172 | if (WarpConstants.DEBUG) { | 
| 163 | e.printStackTrace(); | 173 | e.printStackTrace(); | 
| ... | @@ -245,6 +255,14 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -245,6 +255,14 @@ public class Coupon implements Parcelable, Serializable { | 
| 245 | return transactionUuid; | 255 | return transactionUuid; | 
| 246 | } | 256 | } | 
| 247 | 257 | ||
| 258 | + public JSONObject getChangesDates() { | ||
| 259 | + return changesDates; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + public String getCouponsetUuid() { | ||
| 263 | + return couponsetUuid; | ||
| 264 | + } | ||
| 265 | + | ||
| 248 | @Override | 266 | @Override | 
| 249 | public int describeContents() { | 267 | public int describeContents() { | 
| 250 | return 0; | 268 | return 0; | ... | ... | 
This diff is collapsed. Click to expand it.
| 1 | +/* | ||
| 2 | + * Copyright 2010-2013 Warply Ltd. All rights reserved. | ||
| 3 | + * | ||
| 4 | + * Redistribution and use in source and binary forms, without modification, are | ||
| 5 | + * permitted provided that the following conditions are met: | ||
| 6 | + * | ||
| 7 | + * 1. Redistributions of source code must retain the above copyright notice, | ||
| 8 | + * this list of conditions and the following disclaimer. | ||
| 9 | + * | ||
| 10 | + * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| 11 | + * this list of conditions and the following disclaimer in the documentation | ||
| 12 | + * and/or other materials provided with the distribution. | ||
| 13 | + * | ||
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR | ||
| 15 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 16 | + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| 17 | + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 18 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 19 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
| 20 | + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 21 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 22 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
| 23 | + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 24 | + */ | ||
| 25 | + | ||
| 26 | +package ly.warp.sdk.io.models; | ||
| 27 | + | ||
| 28 | +import androidx.annotation.NonNull; | ||
| 29 | + | ||
| 30 | +import org.json.JSONArray; | ||
| 31 | +import org.json.JSONObject; | ||
| 32 | + | ||
| 33 | +import java.util.ArrayList; | ||
| 34 | + | ||
| 35 | +/** | ||
| 36 | + * Created by Panagiotis Triantafyllou on 04-Feb-22. | ||
| 37 | + */ | ||
| 38 | + | ||
| 39 | +public class CouponsetsList extends ArrayList<Couponset> { | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * Generated for serialized class | ||
| 43 | + */ | ||
| 44 | + private static final long serialVersionUID = -188843583823948267L; | ||
| 45 | + | ||
| 46 | + private static final String JSON_KEY_COUPON = "MAPP_COUPON"; | ||
| 47 | + | ||
| 48 | + private String mRequestSignature = ""; | ||
| 49 | + | ||
| 50 | + private CouponsetsList(String requestSignature) { | ||
| 51 | + this.mRequestSignature = requestSignature; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public CouponsetsList() { | ||
| 55 | + super(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Constructor used to create the CouponsetsList from a JSON Object. | ||
| 60 | + * | ||
| 61 | + * @param addressListJSONObject The JSON Object, used to create the CouponsetsList | ||
| 62 | + */ | ||
| 63 | + public CouponsetsList(JSONObject addressListJSONObject, String requestSignature) { | ||
| 64 | + this(requestSignature); | ||
| 65 | + | ||
| 66 | + if (addressListJSONObject == null) | ||
| 67 | + return; | ||
| 68 | + | ||
| 69 | + JSONArray jArray = addressListJSONObject.optJSONArray(JSON_KEY_COUPON); | ||
| 70 | + if (jArray != null && jArray.length() > 0) { | ||
| 71 | + for (int i = 0, lim = jArray.length(); i < lim; ++i) { | ||
| 72 | + add(new Couponset(jArray.optJSONObject(i))); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @NonNull | ||
| 78 | + public String getRequestSignature() { | ||
| 79 | + return mRequestSignature; | ||
| 80 | + } | ||
| 81 | +} | 
| ... | @@ -13,8 +13,6 @@ import java.security.NoSuchAlgorithmException; | ... | @@ -13,8 +13,6 @@ import java.security.NoSuchAlgorithmException; | 
| 13 | import java.util.ArrayList; | 13 | import java.util.ArrayList; | 
| 14 | import java.util.HashMap; | 14 | import java.util.HashMap; | 
| 15 | 15 | ||
| 16 | -import ly.warp.sdk.Warply; | ||
| 17 | -import ly.warp.sdk.utils.WarplyProperty; | ||
| 18 | import ly.warp.sdk.utils.constants.WarpConstants; | 16 | import ly.warp.sdk.utils.constants.WarpConstants; | 
| 19 | 17 | ||
| 20 | /** | 18 | /** | 
| ... | @@ -42,6 +40,7 @@ public class WarplyContentRequest { | ... | @@ -42,6 +40,7 @@ public class WarplyContentRequest { | 
| 42 | private long mCacheUpdateInterval = 0; | 40 | private long mCacheUpdateInterval = 0; | 
| 43 | private String mContentCategory = ""; | 41 | private String mContentCategory = ""; | 
| 44 | private ArrayList<String> mTags = new ArrayList<>(); | 42 | private ArrayList<String> mTags = new ArrayList<>(); | 
| 43 | + private String mLanguage = ""; | ||
| 45 | 44 | ||
| 46 | // =========================================================== | 45 | // =========================================================== | 
| 47 | // Constructor | 46 | // Constructor | 
| ... | @@ -97,6 +96,11 @@ public class WarplyContentRequest { | ... | @@ -97,6 +96,11 @@ public class WarplyContentRequest { | 
| 97 | return this; | 96 | return this; | 
| 98 | } | 97 | } | 
| 99 | 98 | ||
| 99 | + public WarplyContentRequest setLanguage(String lan) { | ||
| 100 | + mLanguage = lan; | ||
| 101 | + return this; | ||
| 102 | + } | ||
| 103 | + | ||
| 100 | /** | 104 | /** | 
| 101 | * Call this to get how often the cached data will be updated. | 105 | * Call this to get how often the cached data will be updated. | 
| 102 | * | 106 | * | 
| ... | @@ -159,7 +163,7 @@ public class WarplyContentRequest { | ... | @@ -159,7 +163,7 @@ public class WarplyContentRequest { | 
| 159 | try { | 163 | try { | 
| 160 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 164 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 
| 161 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 165 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 
| 162 | - bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext())); | 166 | + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage); | 
| 163 | bodyJsonObject.putOpt(KEY_CATEGORY, TextUtils.isEmpty(mContentCategory) ? JSONObject.NULL : mContentCategory); | 167 | bodyJsonObject.putOpt(KEY_CATEGORY, TextUtils.isEmpty(mContentCategory) ? JSONObject.NULL : mContentCategory); | 
| 164 | JSONArray jsArray = new JSONArray(mTags); | 168 | JSONArray jsArray = new JSONArray(mTags); | 
| 165 | bodyJsonObject.putOpt(KEY_TAGS, jsArray.length() == 0 ? JSONObject.NULL : jsArray); | 169 | bodyJsonObject.putOpt(KEY_TAGS, jsArray.length() == 0 ? JSONObject.NULL : jsArray); | ... | ... | 
| 1 | +package ly.warp.sdk.io.request; | ||
| 2 | + | ||
| 3 | +import android.util.Base64; | ||
| 4 | + | ||
| 5 | +import org.json.JSONArray; | ||
| 6 | +import org.json.JSONException; | ||
| 7 | +import org.json.JSONObject; | ||
| 8 | + | ||
| 9 | +import java.io.UnsupportedEncodingException; | ||
| 10 | +import java.security.MessageDigest; | ||
| 11 | +import java.security.NoSuchAlgorithmException; | ||
| 12 | +import java.util.ArrayList; | ||
| 13 | +import java.util.HashMap; | ||
| 14 | + | ||
| 15 | +import ly.warp.sdk.utils.constants.WarpConstants; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Created by Panagiotis Triantafyllou on 04-Feb-22. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | +public class WarplyGetCouponsetsRequest { | ||
| 22 | + | ||
| 23 | + // =========================================================== | ||
| 24 | + // Constants | ||
| 25 | + // =========================================================== | ||
| 26 | + | ||
| 27 | + private final String KEY_ACTION = "action"; | ||
| 28 | + private final String KEY_ACTION_VALUE = "retrieve_multilingual"; | ||
| 29 | + private final String KEY_ACTIVE = "active"; | ||
| 30 | + private final String KEY_VISIBLE = "visible"; | ||
| 31 | + private final String KEY_LANGUAGE = "language"; | ||
| 32 | + private final String KEY_UUIDS = "uuids"; | ||
| 33 | + | ||
| 34 | + // =========================================================== | ||
| 35 | + // Fields | ||
| 36 | + // =========================================================== | ||
| 37 | + | ||
| 38 | + private HashMap<String, String> mFilters; | ||
| 39 | + private long mCacheUpdateInterval = 0; | ||
| 40 | + private boolean mActive = true; | ||
| 41 | + private boolean mVisible = true; | ||
| 42 | + private ArrayList<String> mUuids = new ArrayList<>(); | ||
| 43 | + private String mLanguage = ""; | ||
| 44 | + | ||
| 45 | + // =========================================================== | ||
| 46 | + // Constructor | ||
| 47 | + // =========================================================== | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Default constructor of WarplyGetCouponsetsRequest, initializes an empty filters HashMap | ||
| 51 | + */ | ||
| 52 | + public WarplyGetCouponsetsRequest() { | ||
| 53 | + mFilters = new HashMap<>(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public WarplyGetCouponsetsRequest(WarplyGetCouponsetsRequest copy) { | ||
| 57 | + if (copy != null) { | ||
| 58 | + this.mFilters = copy.mFilters; | ||
| 59 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + // =========================================================== | ||
| 64 | + // Methods for/from SuperClass/Interfaces | ||
| 65 | + // =========================================================== | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public boolean equals(Object object) { | ||
| 69 | + if (object instanceof WarplyGetCouponsetsRequest) { | ||
| 70 | + WarplyGetCouponsetsRequest other = (WarplyGetCouponsetsRequest) object; | ||
| 71 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
| 72 | + } | ||
| 73 | + return false; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public int hashCode() { | ||
| 78 | + return mFilters.hashCode(); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + // =========================================================== | ||
| 82 | + // Methods | ||
| 83 | + // =========================================================== | ||
| 84 | + | ||
| 85 | + // =========================================================== | ||
| 86 | + // Getter & Setter | ||
| 87 | + // =========================================================== | ||
| 88 | + | ||
| 89 | + public WarplyGetCouponsetsRequest setActive(boolean active) { | ||
| 90 | + mActive = active; | ||
| 91 | + return this; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public WarplyGetCouponsetsRequest setVisible(boolean visible) { | ||
| 95 | + mVisible = visible; | ||
| 96 | + return this; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public WarplyGetCouponsetsRequest setUuids(ArrayList<String> uuids) { | ||
| 100 | + mUuids = uuids; | ||
| 101 | + return this; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public WarplyGetCouponsetsRequest setLanguage(String language) { | ||
| 105 | + mLanguage = language; | ||
| 106 | + return this; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * Call this to get how often the cached data will be updated. | ||
| 111 | + * | ||
| 112 | + * @return mCacheUpdateInterval | ||
| 113 | + */ | ||
| 114 | + public long getCacheUpdateInterval() { | ||
| 115 | + return mCacheUpdateInterval; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * Call this to set how often the cached data will be updated. | ||
| 120 | + * | ||
| 121 | + * @param updateInterval The time that data will be cached | ||
| 122 | + * @return WarplyGetCouponsetsRequest | ||
| 123 | + */ | ||
| 124 | + public WarplyGetCouponsetsRequest setCacheUpdateInterval(long updateInterval) { | ||
| 125 | + | ||
| 126 | + this.mCacheUpdateInterval = updateInterval; | ||
| 127 | + if (mCacheUpdateInterval < 0) { | ||
| 128 | + mCacheUpdateInterval = 0; | ||
| 129 | + } | ||
| 130 | + return this; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * Call this to check if the Application uses Cache | ||
| 135 | + * | ||
| 136 | + * @return <p>true - the Application is using Cache</p> | ||
| 137 | + * <p>false - the Application is not using Cache</p> | ||
| 138 | + */ | ||
| 139 | + public boolean isUseCache() { | ||
| 140 | + return mCacheUpdateInterval > 0; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * Call this to check whether the cached data need to be updated | ||
| 145 | + * | ||
| 146 | + * @param useCache <p>true - the Application is using Cache</p> | ||
| 147 | + * <p>false - the Application is not using Cache</p> | ||
| 148 | + * @return WarplyGetCouponsetsRequest | ||
| 149 | + */ | ||
| 150 | + public WarplyGetCouponsetsRequest setUseCache(boolean useCache) { | ||
| 151 | + | ||
| 152 | + if (useCache) { | ||
| 153 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
| 154 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
| 155 | + } else { | ||
| 156 | + mCacheUpdateInterval = 0; | ||
| 157 | + } | ||
| 158 | + return this; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * Call this to build the couponsets Json object | ||
| 163 | + * | ||
| 164 | + * @return bodyJsonObject | ||
| 165 | + */ | ||
| 166 | + public JSONObject toJson() { | ||
| 167 | + JSONObject bodyJsonObject = new JSONObject(); | ||
| 168 | + try { | ||
| 169 | + bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
| 170 | + bodyJsonObject.putOpt(KEY_ACTIVE, mActive); | ||
| 171 | + bodyJsonObject.putOpt(KEY_VISIBLE, mVisible); | ||
| 172 | + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage); | ||
| 173 | + if (mUuids != null && mUuids.size() > 0) | ||
| 174 | + bodyJsonObject.putOpt(KEY_UUIDS, new JSONArray(mUuids)); | ||
| 175 | + } catch (JSONException e) { | ||
| 176 | + if (WarpConstants.DEBUG) | ||
| 177 | + e.printStackTrace(); | ||
| 178 | + } | ||
| 179 | + return bodyJsonObject; | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + public String getSignature() { | ||
| 183 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_get_couponsets_request"; | ||
| 184 | + try { | ||
| 185 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
| 186 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
| 187 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
| 188 | + | UnsupportedEncodingException e) { | ||
| 189 | + e.printStackTrace(); | ||
| 190 | + } | ||
| 191 | + return signature; | ||
| 192 | + } | ||
| 193 | +} | 
| ... | @@ -10,8 +10,6 @@ import java.security.MessageDigest; | ... | @@ -10,8 +10,6 @@ import java.security.MessageDigest; | 
| 10 | import java.security.NoSuchAlgorithmException; | 10 | import java.security.NoSuchAlgorithmException; | 
| 11 | import java.util.HashMap; | 11 | import java.util.HashMap; | 
| 12 | 12 | ||
| 13 | -import ly.warp.sdk.Warply; | ||
| 14 | -import ly.warp.sdk.utils.WarplyProperty; | ||
| 15 | import ly.warp.sdk.utils.constants.WarpConstants; | 13 | import ly.warp.sdk.utils.constants.WarpConstants; | 
| 16 | 14 | ||
| 17 | /** | 15 | /** | 
| ... | @@ -34,6 +32,7 @@ public class WarplyMerchantCategoriesRequest { | ... | @@ -34,6 +32,7 @@ public class WarplyMerchantCategoriesRequest { | 
| 34 | 32 | ||
| 35 | private HashMap<String, String> mFilters; | 33 | private HashMap<String, String> mFilters; | 
| 36 | private long mCacheUpdateInterval = 0; | 34 | private long mCacheUpdateInterval = 0; | 
| 35 | + private String mLanguage = ""; | ||
| 37 | 36 | ||
| 38 | // =========================================================== | 37 | // =========================================================== | 
| 39 | // Constructor | 38 | // Constructor | 
| ... | @@ -79,6 +78,11 @@ public class WarplyMerchantCategoriesRequest { | ... | @@ -79,6 +78,11 @@ public class WarplyMerchantCategoriesRequest { | 
| 79 | // Getter & Setter | 78 | // Getter & Setter | 
| 80 | // =========================================================== | 79 | // =========================================================== | 
| 81 | 80 | ||
| 81 | + public WarplyMerchantCategoriesRequest setLanguage(String lan) { | ||
| 82 | + mLanguage = lan; | ||
| 83 | + return this; | ||
| 84 | + } | ||
| 85 | + | ||
| 82 | /** | 86 | /** | 
| 83 | * Call this to get how often the cached data will be updated. | 87 | * Call this to get how often the cached data will be updated. | 
| 84 | * | 88 | * | 
| ... | @@ -140,7 +144,7 @@ public class WarplyMerchantCategoriesRequest { | ... | @@ -140,7 +144,7 @@ public class WarplyMerchantCategoriesRequest { | 
| 140 | JSONObject bodyJsonObject = new JSONObject(); | 144 | JSONObject bodyJsonObject = new JSONObject(); | 
| 141 | try { | 145 | try { | 
| 142 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 146 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 
| 143 | - bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext())); | 147 | + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage); | 
| 144 | } catch (JSONException e) { | 148 | } catch (JSONException e) { | 
| 145 | if (WarpConstants.DEBUG) | 149 | if (WarpConstants.DEBUG) | 
| 146 | e.printStackTrace(); | 150 | e.printStackTrace(); | ... | ... | 
| ... | @@ -13,8 +13,6 @@ import java.security.NoSuchAlgorithmException; | ... | @@ -13,8 +13,6 @@ import java.security.NoSuchAlgorithmException; | 
| 13 | import java.util.ArrayList; | 13 | import java.util.ArrayList; | 
| 14 | import java.util.HashMap; | 14 | import java.util.HashMap; | 
| 15 | 15 | ||
| 16 | -import ly.warp.sdk.Warply; | ||
| 17 | -import ly.warp.sdk.utils.WarplyProperty; | ||
| 18 | import ly.warp.sdk.utils.constants.WarpConstants; | 16 | import ly.warp.sdk.utils.constants.WarpConstants; | 
| 19 | 17 | ||
| 20 | /** | 18 | /** | 
| ... | @@ -53,6 +51,7 @@ public class WarplyMerchantsRequest { | ... | @@ -53,6 +51,7 @@ public class WarplyMerchantsRequest { | 
| 53 | private String mUuid = ""; | 51 | private String mUuid = ""; | 
| 54 | private int mDistance = 0; | 52 | private int mDistance = 0; | 
| 55 | private ArrayList<Double> mCenter = new ArrayList<>(); | 53 | private ArrayList<Double> mCenter = new ArrayList<>(); | 
| 54 | + private String mLanguage = ""; | ||
| 56 | 55 | ||
| 57 | // =========================================================== | 56 | // =========================================================== | 
| 58 | // Constructor | 57 | // Constructor | 
| ... | @@ -133,6 +132,11 @@ public class WarplyMerchantsRequest { | ... | @@ -133,6 +132,11 @@ public class WarplyMerchantsRequest { | 
| 133 | return this; | 132 | return this; | 
| 134 | } | 133 | } | 
| 135 | 134 | ||
| 135 | + public WarplyMerchantsRequest setLanguage(String lan) { | ||
| 136 | + mLanguage = lan; | ||
| 137 | + return this; | ||
| 138 | + } | ||
| 139 | + | ||
| 136 | /** | 140 | /** | 
| 137 | * Call this to get how often the cached data will be updated. | 141 | * Call this to get how often the cached data will be updated. | 
| 138 | * | 142 | * | 
| ... | @@ -198,7 +202,7 @@ public class WarplyMerchantsRequest { | ... | @@ -198,7 +202,7 @@ public class WarplyMerchantsRequest { | 
| 198 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 202 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 
| 199 | bodyJsonObject.putOpt(KEY_CATEGORIES, new JSONArray(mCategories)); | 203 | bodyJsonObject.putOpt(KEY_CATEGORIES, new JSONArray(mCategories)); | 
| 200 | bodyJsonObject.putOpt(KEY_DEFAULT_SHOWN, mDefaultShown ? mDefaultShown : JSONObject.NULL); | 204 | bodyJsonObject.putOpt(KEY_DEFAULT_SHOWN, mDefaultShown ? mDefaultShown : JSONObject.NULL); | 
| 201 | - bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext())); | 205 | + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage); | 
| 202 | if (mDistance != 0 && mCenter != null && mCenter.size() > 0) { | 206 | if (mDistance != 0 && mCenter != null && mCenter.size() > 0) { | 
| 203 | JSONObject locObj = new JSONObject(); | 207 | JSONObject locObj = new JSONObject(); | 
| 204 | locObj.putOpt(KEY_CENTER, mCenter); | 208 | locObj.putOpt(KEY_CENTER, mCenter); | ... | ... | 
| ... | @@ -3,7 +3,6 @@ package ly.warp.sdk.io.request; | ... | @@ -3,7 +3,6 @@ package ly.warp.sdk.io.request; | 
| 3 | import android.text.TextUtils; | 3 | import android.text.TextUtils; | 
| 4 | import android.util.Base64; | 4 | import android.util.Base64; | 
| 5 | 5 | ||
| 6 | -import org.json.JSONArray; | ||
| 7 | import org.json.JSONException; | 6 | import org.json.JSONException; | 
| 8 | import org.json.JSONObject; | 7 | import org.json.JSONObject; | 
| 9 | 8 | ||
| ... | @@ -11,7 +10,6 @@ import java.io.UnsupportedEncodingException; | ... | @@ -11,7 +10,6 @@ import java.io.UnsupportedEncodingException; | 
| 11 | import java.security.MessageDigest; | 10 | import java.security.MessageDigest; | 
| 12 | import java.security.NoSuchAlgorithmException; | 11 | import java.security.NoSuchAlgorithmException; | 
| 13 | import java.util.HashMap; | 12 | import java.util.HashMap; | 
| 14 | -import java.util.Map; | ||
| 15 | 13 | ||
| 16 | import ly.warp.sdk.Warply; | 14 | import ly.warp.sdk.Warply; | 
| 17 | import ly.warp.sdk.utils.WarplyProperty; | 15 | import ly.warp.sdk.utils.WarplyProperty; | 
| ... | @@ -41,6 +39,7 @@ public class WarplyProductsRequest { | ... | @@ -41,6 +39,7 @@ public class WarplyProductsRequest { | 
| 41 | private HashMap<String, String> mFilters; | 39 | private HashMap<String, String> mFilters; | 
| 42 | private long mCacheUpdateInterval = 0; | 40 | private long mCacheUpdateInterval = 0; | 
| 43 | private String mProductsCategory = ""; | 41 | private String mProductsCategory = ""; | 
| 42 | + private String mLanguage = ""; | ||
| 44 | 43 | ||
| 45 | // =========================================================== | 44 | // =========================================================== | 
| 46 | // Constructor | 45 | // Constructor | 
| ... | @@ -91,6 +90,11 @@ public class WarplyProductsRequest { | ... | @@ -91,6 +90,11 @@ public class WarplyProductsRequest { | 
| 91 | return this; | 90 | return this; | 
| 92 | } | 91 | } | 
| 93 | 92 | ||
| 93 | + public WarplyProductsRequest setLanguage(String lan) { | ||
| 94 | + mLanguage = lan; | ||
| 95 | + return this; | ||
| 96 | + } | ||
| 97 | + | ||
| 94 | /** | 98 | /** | 
| 95 | * Call this to get how often the cached data will be updated. | 99 | * Call this to get how often the cached data will be updated. | 
| 96 | * | 100 | * | 
| ... | @@ -152,7 +156,7 @@ public class WarplyProductsRequest { | ... | @@ -152,7 +156,7 @@ public class WarplyProductsRequest { | 
| 152 | JSONObject bodyJsonObject = new JSONObject(); | 156 | JSONObject bodyJsonObject = new JSONObject(); | 
| 153 | try { | 157 | try { | 
| 154 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 158 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 
| 155 | - bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext())); | 159 | + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage); | 
| 156 | bodyJsonObject.putOpt(KEY_MERCHANT_ID, WarplyProperty.getMerchantId(Warply.getWarplyContext())); | 160 | bodyJsonObject.putOpt(KEY_MERCHANT_ID, WarplyProperty.getMerchantId(Warply.getWarplyContext())); | 
| 157 | JSONObject extraJson = new JSONObject(); | 161 | JSONObject extraJson = new JSONObject(); | 
| 158 | extraJson.put(KEY_CATEGORY_NAME, TextUtils.isEmpty(mProductsCategory) ? JSONObject.NULL : mProductsCategory); | 162 | extraJson.put(KEY_CATEGORY_NAME, TextUtils.isEmpty(mProductsCategory) ? JSONObject.NULL : mProductsCategory); | ... | ... | 
| ... | @@ -10,12 +10,10 @@ import java.security.MessageDigest; | ... | @@ -10,12 +10,10 @@ import java.security.MessageDigest; | 
| 10 | import java.security.NoSuchAlgorithmException; | 10 | import java.security.NoSuchAlgorithmException; | 
| 11 | import java.util.HashMap; | 11 | import java.util.HashMap; | 
| 12 | 12 | ||
| 13 | -import ly.warp.sdk.Warply; | ||
| 14 | -import ly.warp.sdk.utils.WarplyProperty; | ||
| 15 | import ly.warp.sdk.utils.constants.WarpConstants; | 13 | import ly.warp.sdk.utils.constants.WarpConstants; | 
| 16 | 14 | ||
| 17 | /** | 15 | /** | 
| 18 | - * Created by Panagiotis Triantafyllou on 18-Jan-22. | 16 | + * Created by Panagiotis Triantafyllou on 04-Feb-22. | 
| 19 | */ | 17 | */ | 
| 20 | 18 | ||
| 21 | public class WarplyRedeemCouponRequest { | 19 | public class WarplyRedeemCouponRequest { | 
| ... | @@ -25,12 +23,8 @@ public class WarplyRedeemCouponRequest { | ... | @@ -25,12 +23,8 @@ public class WarplyRedeemCouponRequest { | 
| 25 | // =========================================================== | 23 | // =========================================================== | 
| 26 | 24 | ||
| 27 | private final String KEY_ACTION = "action"; | 25 | private final String KEY_ACTION = "action"; | 
| 28 | - private final String KEY_ACTION_VALUE = "vcurrency_purchase"; | 26 | + private final String KEY_ACTION_VALUE = "retrieve_coupon"; | 
| 29 | - private final String KEY_MERCHANT_ID = "merchant_id"; | 27 | + private final String KEY_COUPONSET = "coupon_set"; | 
| 30 | - private final String KEY_PRODUCT_ID = "product_id"; | ||
| 31 | - private final String KEY_PRODUCT_UUID = "product_uuid"; | ||
| 32 | - private final String KEY_CAUSE = "cause"; | ||
| 33 | - private final String KEY_CAUSE_VALUE = "coupon"; | ||
| 34 | 28 | ||
| 35 | // =========================================================== | 29 | // =========================================================== | 
| 36 | // Fields | 30 | // Fields | 
| ... | @@ -38,8 +32,7 @@ public class WarplyRedeemCouponRequest { | ... | @@ -38,8 +32,7 @@ public class WarplyRedeemCouponRequest { | 
| 38 | 32 | ||
| 39 | private HashMap<String, String> mFilters; | 33 | private HashMap<String, String> mFilters; | 
| 40 | private long mCacheUpdateInterval = 0; | 34 | private long mCacheUpdateInterval = 0; | 
| 41 | - private String mId = ""; | 35 | + private String mCouponsetUuid = ""; | 
| 42 | - private String mUuid = ""; | ||
| 43 | 36 | ||
| 44 | // =========================================================== | 37 | // =========================================================== | 
| 45 | // Constructor | 38 | // Constructor | 
| ... | @@ -85,13 +78,8 @@ public class WarplyRedeemCouponRequest { | ... | @@ -85,13 +78,8 @@ public class WarplyRedeemCouponRequest { | 
| 85 | // Getter & Setter | 78 | // Getter & Setter | 
| 86 | // =========================================================== | 79 | // =========================================================== | 
| 87 | 80 | ||
| 88 | - public WarplyRedeemCouponRequest setSku(String sku) { | 81 | + public WarplyRedeemCouponRequest setCouponsetUuid(String uuid) { | 
| 89 | - mId = sku; | 82 | + mCouponsetUuid = uuid; | 
| 90 | - return this; | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - public WarplyRedeemCouponRequest setUuid(String uuid) { | ||
| 94 | - mUuid = uuid; | ||
| 95 | return this; | 83 | return this; | 
| 96 | } | 84 | } | 
| 97 | 85 | ||
| ... | @@ -148,7 +136,7 @@ public class WarplyRedeemCouponRequest { | ... | @@ -148,7 +136,7 @@ public class WarplyRedeemCouponRequest { | 
| 148 | } | 136 | } | 
| 149 | 137 | ||
| 150 | /** | 138 | /** | 
| 151 | - * Call this to build the offers Json object | 139 | + * Call this to build the redeem coupon Json object | 
| 152 | * | 140 | * | 
| 153 | * @return bodyJsonObject | 141 | * @return bodyJsonObject | 
| 154 | */ | 142 | */ | 
| ... | @@ -156,10 +144,7 @@ public class WarplyRedeemCouponRequest { | ... | @@ -156,10 +144,7 @@ public class WarplyRedeemCouponRequest { | 
| 156 | JSONObject bodyJsonObject = new JSONObject(); | 144 | JSONObject bodyJsonObject = new JSONObject(); | 
| 157 | try { | 145 | try { | 
| 158 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 146 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 
| 159 | - bodyJsonObject.putOpt(KEY_MERCHANT_ID, WarplyProperty.getMerchantId(Warply.getWarplyContext())); | 147 | + bodyJsonObject.putOpt(KEY_COUPONSET, mCouponsetUuid); | 
| 160 | - bodyJsonObject.putOpt(KEY_PRODUCT_ID, mId); | ||
| 161 | - bodyJsonObject.putOpt(KEY_PRODUCT_UUID, mUuid); | ||
| 162 | - bodyJsonObject.putOpt(KEY_CAUSE, KEY_CAUSE_VALUE); | ||
| 163 | } catch (JSONException e) { | 148 | } catch (JSONException e) { | 
| 164 | if (WarpConstants.DEBUG) | 149 | if (WarpConstants.DEBUG) | 
| 165 | e.printStackTrace(); | 150 | e.printStackTrace(); | ... | ... | 
| 1 | +package ly.warp.sdk.io.request; | ||
| 2 | + | ||
| 3 | +import android.util.Base64; | ||
| 4 | + | ||
| 5 | +import org.json.JSONException; | ||
| 6 | +import org.json.JSONObject; | ||
| 7 | + | ||
| 8 | +import java.io.UnsupportedEncodingException; | ||
| 9 | +import java.security.MessageDigest; | ||
| 10 | +import java.security.NoSuchAlgorithmException; | ||
| 11 | +import java.util.HashMap; | ||
| 12 | + | ||
| 13 | +import ly.warp.sdk.Warply; | ||
| 14 | +import ly.warp.sdk.utils.WarplyProperty; | ||
| 15 | +import ly.warp.sdk.utils.constants.WarpConstants; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Created by Panagiotis Triantafyllou on 18-Jan-22. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | +public class WarplyRedeemProductRequest { | ||
| 22 | + | ||
| 23 | + // =========================================================== | ||
| 24 | + // Constants | ||
| 25 | + // =========================================================== | ||
| 26 | + | ||
| 27 | + private final String KEY_ACTION = "action"; | ||
| 28 | + private final String KEY_ACTION_VALUE = "vcurrency_purchase"; | ||
| 29 | + private final String KEY_MERCHANT_ID = "merchant_id"; | ||
| 30 | + private final String KEY_PRODUCT_ID = "product_id"; | ||
| 31 | + private final String KEY_PRODUCT_UUID = "product_uuid"; | ||
| 32 | + private final String KEY_CAUSE = "cause"; | ||
| 33 | + private final String KEY_CAUSE_VALUE = "coupon"; | ||
| 34 | + | ||
| 35 | + // =========================================================== | ||
| 36 | + // Fields | ||
| 37 | + // =========================================================== | ||
| 38 | + | ||
| 39 | + private HashMap<String, String> mFilters; | ||
| 40 | + private long mCacheUpdateInterval = 0; | ||
| 41 | + private String mId = ""; | ||
| 42 | + private String mUuid = ""; | ||
| 43 | + | ||
| 44 | + // =========================================================== | ||
| 45 | + // Constructor | ||
| 46 | + // =========================================================== | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * Default constructor of WarplyRedeemCouponRequest, initializes an empty filters HashMap | ||
| 50 | + */ | ||
| 51 | + public WarplyRedeemProductRequest() { | ||
| 52 | + mFilters = new HashMap<>(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public WarplyRedeemProductRequest(WarplyRedeemProductRequest copy) { | ||
| 56 | + if (copy != null) { | ||
| 57 | + this.mFilters = copy.mFilters; | ||
| 58 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + // =========================================================== | ||
| 63 | + // Methods for/from SuperClass/Interfaces | ||
| 64 | + // =========================================================== | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public boolean equals(Object object) { | ||
| 68 | + if (object instanceof WarplyRedeemProductRequest) { | ||
| 69 | + WarplyRedeemProductRequest other = (WarplyRedeemProductRequest) object; | ||
| 70 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
| 71 | + } | ||
| 72 | + return false; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public int hashCode() { | ||
| 77 | + return mFilters.hashCode(); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + // =========================================================== | ||
| 81 | + // Methods | ||
| 82 | + // =========================================================== | ||
| 83 | + | ||
| 84 | + // =========================================================== | ||
| 85 | + // Getter & Setter | ||
| 86 | + // =========================================================== | ||
| 87 | + | ||
| 88 | + public WarplyRedeemProductRequest setSku(String sku) { | ||
| 89 | + mId = sku; | ||
| 90 | + return this; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public WarplyRedeemProductRequest setUuid(String uuid) { | ||
| 94 | + mUuid = uuid; | ||
| 95 | + return this; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * Call this to get how often the cached data will be updated. | ||
| 100 | + * | ||
| 101 | + * @return mCacheUpdateInterval | ||
| 102 | + */ | ||
| 103 | + public long getCacheUpdateInterval() { | ||
| 104 | + return mCacheUpdateInterval; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * Call this to set how often the cached data will be updated. | ||
| 109 | + * | ||
| 110 | + * @param updateInterval The time that data will be cached | ||
| 111 | + * @return WarplyRedeemCouponRequest | ||
| 112 | + */ | ||
| 113 | + public WarplyRedeemProductRequest setCacheUpdateInterval(long updateInterval) { | ||
| 114 | + | ||
| 115 | + this.mCacheUpdateInterval = updateInterval; | ||
| 116 | + if (mCacheUpdateInterval < 0) { | ||
| 117 | + mCacheUpdateInterval = 0; | ||
| 118 | + } | ||
| 119 | + return this; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + /** | ||
| 123 | + * Call this to check if the Application uses Cache | ||
| 124 | + * | ||
| 125 | + * @return <p>true - the Application is using Cache</p> | ||
| 126 | + * <p>false - the Application is not using Cache</p> | ||
| 127 | + */ | ||
| 128 | + public boolean isUseCache() { | ||
| 129 | + return mCacheUpdateInterval > 0; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * Call this to check whether the cached data need to be updated | ||
| 134 | + * | ||
| 135 | + * @param useCache <p>true - the Application is using Cache</p> | ||
| 136 | + * <p>false - the Application is not using Cache</p> | ||
| 137 | + * @return WarplyRedeemCouponRequest | ||
| 138 | + */ | ||
| 139 | + public WarplyRedeemProductRequest setUseCache(boolean useCache) { | ||
| 140 | + | ||
| 141 | + if (useCache) { | ||
| 142 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
| 143 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
| 144 | + } else { | ||
| 145 | + mCacheUpdateInterval = 0; | ||
| 146 | + } | ||
| 147 | + return this; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + /** | ||
| 151 | + * Call this to build the offers Json object | ||
| 152 | + * | ||
| 153 | + * @return bodyJsonObject | ||
| 154 | + */ | ||
| 155 | + public JSONObject toJson() { | ||
| 156 | + JSONObject bodyJsonObject = new JSONObject(); | ||
| 157 | + try { | ||
| 158 | + bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
| 159 | + bodyJsonObject.putOpt(KEY_MERCHANT_ID, WarplyProperty.getMerchantId(Warply.getWarplyContext())); | ||
| 160 | + bodyJsonObject.putOpt(KEY_PRODUCT_ID, mId); | ||
| 161 | + bodyJsonObject.putOpt(KEY_PRODUCT_UUID, mUuid); | ||
| 162 | + bodyJsonObject.putOpt(KEY_CAUSE, KEY_CAUSE_VALUE); | ||
| 163 | + } catch (JSONException e) { | ||
| 164 | + if (WarpConstants.DEBUG) | ||
| 165 | + e.printStackTrace(); | ||
| 166 | + } | ||
| 167 | + return bodyJsonObject; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + public String getSignature() { | ||
| 171 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_redeem_product_request"; | ||
| 172 | + try { | ||
| 173 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
| 174 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
| 175 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
| 176 | + | UnsupportedEncodingException e) { | ||
| 177 | + e.printStackTrace(); | ||
| 178 | + } | ||
| 179 | + return signature; | ||
| 180 | + } | ||
| 181 | +} | 
| ... | @@ -10,8 +10,6 @@ import java.security.MessageDigest; | ... | @@ -10,8 +10,6 @@ import java.security.MessageDigest; | 
| 10 | import java.security.NoSuchAlgorithmException; | 10 | import java.security.NoSuchAlgorithmException; | 
| 11 | import java.util.HashMap; | 11 | import java.util.HashMap; | 
| 12 | 12 | ||
| 13 | -import ly.warp.sdk.Warply; | ||
| 14 | -import ly.warp.sdk.utils.WarplyProperty; | ||
| 15 | import ly.warp.sdk.utils.constants.WarpConstants; | 13 | import ly.warp.sdk.utils.constants.WarpConstants; | 
| 16 | 14 | ||
| 17 | /** | 15 | /** | 
| ... | @@ -35,6 +33,7 @@ public class WarplyTagsCategoriesRequest { | ... | @@ -35,6 +33,7 @@ public class WarplyTagsCategoriesRequest { | 
| 35 | 33 | ||
| 36 | private HashMap<String, String> mFilters; | 34 | private HashMap<String, String> mFilters; | 
| 37 | private long mCacheUpdateInterval = 0; | 35 | private long mCacheUpdateInterval = 0; | 
| 36 | + private String mLanguage = ""; | ||
| 38 | 37 | ||
| 39 | // =========================================================== | 38 | // =========================================================== | 
| 40 | // Constructor | 39 | // Constructor | 
| ... | @@ -80,6 +79,11 @@ public class WarplyTagsCategoriesRequest { | ... | @@ -80,6 +79,11 @@ public class WarplyTagsCategoriesRequest { | 
| 80 | // Getter & Setter | 79 | // Getter & Setter | 
| 81 | // =========================================================== | 80 | // =========================================================== | 
| 82 | 81 | ||
| 82 | + public WarplyTagsCategoriesRequest setLanguage(String lan) { | ||
| 83 | + mLanguage = lan; | ||
| 84 | + return this; | ||
| 85 | + } | ||
| 86 | + | ||
| 83 | /** | 87 | /** | 
| 84 | * Call this to get how often the cached data will be updated. | 88 | * Call this to get how often the cached data will be updated. | 
| 85 | * | 89 | * | 
| ... | @@ -141,7 +145,7 @@ public class WarplyTagsCategoriesRequest { | ... | @@ -141,7 +145,7 @@ public class WarplyTagsCategoriesRequest { | 
| 141 | JSONObject bodyJsonObject = new JSONObject(); | 145 | JSONObject bodyJsonObject = new JSONObject(); | 
| 142 | try { | 146 | try { | 
| 143 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 147 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 
| 144 | - bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext())); | 148 | + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage); | 
| 145 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 149 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 
| 146 | } catch (JSONException e) { | 150 | } catch (JSONException e) { | 
| 147 | if (WarpConstants.DEBUG) | 151 | if (WarpConstants.DEBUG) | ... | ... | 
| ... | @@ -10,8 +10,6 @@ import java.security.MessageDigest; | ... | @@ -10,8 +10,6 @@ import java.security.MessageDigest; | 
| 10 | import java.security.NoSuchAlgorithmException; | 10 | import java.security.NoSuchAlgorithmException; | 
| 11 | import java.util.HashMap; | 11 | import java.util.HashMap; | 
| 12 | 12 | ||
| 13 | -import ly.warp.sdk.Warply; | ||
| 14 | -import ly.warp.sdk.utils.WarplyProperty; | ||
| 15 | import ly.warp.sdk.utils.constants.WarpConstants; | 13 | import ly.warp.sdk.utils.constants.WarpConstants; | 
| 16 | 14 | ||
| 17 | /** | 15 | /** | 
| ... | @@ -35,6 +33,7 @@ public class WarplyTagsRequest { | ... | @@ -35,6 +33,7 @@ public class WarplyTagsRequest { | 
| 35 | 33 | ||
| 36 | private HashMap<String, String> mFilters; | 34 | private HashMap<String, String> mFilters; | 
| 37 | private long mCacheUpdateInterval = 0; | 35 | private long mCacheUpdateInterval = 0; | 
| 36 | + private String mLanguage = ""; | ||
| 38 | 37 | ||
| 39 | // =========================================================== | 38 | // =========================================================== | 
| 40 | // Constructor | 39 | // Constructor | 
| ... | @@ -80,6 +79,11 @@ public class WarplyTagsRequest { | ... | @@ -80,6 +79,11 @@ public class WarplyTagsRequest { | 
| 80 | // Getter & Setter | 79 | // Getter & Setter | 
| 81 | // =========================================================== | 80 | // =========================================================== | 
| 82 | 81 | ||
| 82 | + public WarplyTagsRequest setLanguage(String lan) { | ||
| 83 | + mLanguage = lan; | ||
| 84 | + return this; | ||
| 85 | + } | ||
| 86 | + | ||
| 83 | /** | 87 | /** | 
| 84 | * Call this to get how often the cached data will be updated. | 88 | * Call this to get how often the cached data will be updated. | 
| 85 | * | 89 | * | 
| ... | @@ -141,7 +145,7 @@ public class WarplyTagsRequest { | ... | @@ -141,7 +145,7 @@ public class WarplyTagsRequest { | 
| 141 | JSONObject bodyJsonObject = new JSONObject(); | 145 | JSONObject bodyJsonObject = new JSONObject(); | 
| 142 | try { | 146 | try { | 
| 143 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 147 | bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 
| 144 | - bodyJsonObject.putOpt(KEY_LANGUAGE, WarplyProperty.getLanguage(Warply.getWarplyContext())); | 148 | + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage); | 
| 145 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 149 | bodyJsonObject.putOpt(KEY_ACTIVE, true); | 
| 146 | } catch (JSONException e) { | 150 | } catch (JSONException e) { | 
| 147 | if (WarpConstants.DEBUG) | 151 | if (WarpConstants.DEBUG) | ... | ... | 
| 1 | +package ly.warp.sdk.io.request; | ||
| 2 | + | ||
| 3 | +import android.util.Base64; | ||
| 4 | + | ||
| 5 | +import org.json.JSONException; | ||
| 6 | +import org.json.JSONObject; | ||
| 7 | + | ||
| 8 | +import java.io.UnsupportedEncodingException; | ||
| 9 | +import java.security.MessageDigest; | ||
| 10 | +import java.security.NoSuchAlgorithmException; | ||
| 11 | +import java.util.HashMap; | ||
| 12 | + | ||
| 13 | +import ly.warp.sdk.utils.constants.WarpConstants; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * Created by Panagiotis Triantafyllou on 04-Feb-22. | ||
| 17 | + */ | ||
| 18 | + | ||
| 19 | +public class WarplyValidateCouponRequest { | ||
| 20 | + | ||
| 21 | + // =========================================================== | ||
| 22 | + // Constants | ||
| 23 | + // =========================================================== | ||
| 24 | + | ||
| 25 | + private final String KEY_ACTION = "action"; | ||
| 26 | + private final String KEY_ACTION_VALUE = "validate"; | ||
| 27 | + private final String KEY_COUPON = "coupon"; | ||
| 28 | + | ||
| 29 | + // =========================================================== | ||
| 30 | + // Fields | ||
| 31 | + // =========================================================== | ||
| 32 | + | ||
| 33 | + private HashMap<String, String> mFilters; | ||
| 34 | + private long mCacheUpdateInterval = 0; | ||
| 35 | + private String mCoupon = ""; | ||
| 36 | + | ||
| 37 | + // =========================================================== | ||
| 38 | + // Constructor | ||
| 39 | + // =========================================================== | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * Default constructor of WarplyValidateCouponRequest, initializes an empty filters HashMap | ||
| 43 | + */ | ||
| 44 | + public WarplyValidateCouponRequest() { | ||
| 45 | + mFilters = new HashMap<>(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public WarplyValidateCouponRequest(WarplyValidateCouponRequest copy) { | ||
| 49 | + if (copy != null) { | ||
| 50 | + this.mFilters = copy.mFilters; | ||
| 51 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + // =========================================================== | ||
| 56 | + // Methods for/from SuperClass/Interfaces | ||
| 57 | + // =========================================================== | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public boolean equals(Object object) { | ||
| 61 | + if (object instanceof WarplyValidateCouponRequest) { | ||
| 62 | + WarplyValidateCouponRequest other = (WarplyValidateCouponRequest) object; | ||
| 63 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
| 64 | + } | ||
| 65 | + return false; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public int hashCode() { | ||
| 70 | + return mFilters.hashCode(); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + // =========================================================== | ||
| 74 | + // Methods | ||
| 75 | + // =========================================================== | ||
| 76 | + | ||
| 77 | + // =========================================================== | ||
| 78 | + // Getter & Setter | ||
| 79 | + // =========================================================== | ||
| 80 | + | ||
| 81 | + public WarplyValidateCouponRequest setCoupon(String code) { | ||
| 82 | + mCoupon = code; | ||
| 83 | + return this; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * Call this to get how often the cached data will be updated. | ||
| 88 | + * | ||
| 89 | + * @return mCacheUpdateInterval | ||
| 90 | + */ | ||
| 91 | + public long getCacheUpdateInterval() { | ||
| 92 | + return mCacheUpdateInterval; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * Call this to set how often the cached data will be updated. | ||
| 97 | + * | ||
| 98 | + * @param updateInterval The time that data will be cached | ||
| 99 | + * @return WarplyValidateCouponRequest | ||
| 100 | + */ | ||
| 101 | + public WarplyValidateCouponRequest setCacheUpdateInterval(long updateInterval) { | ||
| 102 | + | ||
| 103 | + this.mCacheUpdateInterval = updateInterval; | ||
| 104 | + if (mCacheUpdateInterval < 0) { | ||
| 105 | + mCacheUpdateInterval = 0; | ||
| 106 | + } | ||
| 107 | + return this; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * Call this to check if the Application uses Cache | ||
| 112 | + * | ||
| 113 | + * @return <p>true - the Application is using Cache</p> | ||
| 114 | + * <p>false - the Application is not using Cache</p> | ||
| 115 | + */ | ||
| 116 | + public boolean isUseCache() { | ||
| 117 | + return mCacheUpdateInterval > 0; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + /** | ||
| 121 | + * Call this to check whether the cached data need to be updated | ||
| 122 | + * | ||
| 123 | + * @param useCache <p>true - the Application is using Cache</p> | ||
| 124 | + * <p>false - the Application is not using Cache</p> | ||
| 125 | + * @return WarplyValidateCouponRequest | ||
| 126 | + */ | ||
| 127 | + public WarplyValidateCouponRequest setUseCache(boolean useCache) { | ||
| 128 | + | ||
| 129 | + if (useCache) { | ||
| 130 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
| 131 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
| 132 | + } else { | ||
| 133 | + mCacheUpdateInterval = 0; | ||
| 134 | + } | ||
| 135 | + return this; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * Call this to build the validate coupon Json object | ||
| 140 | + * | ||
| 141 | + * @return bodyJsonObject | ||
| 142 | + */ | ||
| 143 | + public JSONObject toJson() { | ||
| 144 | + JSONObject bodyJsonObject = new JSONObject(); | ||
| 145 | + try { | ||
| 146 | + bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
| 147 | + bodyJsonObject.putOpt(KEY_COUPON, mCoupon); | ||
| 148 | + } catch (JSONException e) { | ||
| 149 | + if (WarpConstants.DEBUG) | ||
| 150 | + e.printStackTrace(); | ||
| 151 | + } | ||
| 152 | + return bodyJsonObject; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + public String getSignature() { | ||
| 156 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_validate_coupon_request"; | ||
| 157 | + try { | ||
| 158 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
| 159 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
| 160 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
| 161 | + | UnsupportedEncodingException e) { | ||
| 162 | + e.printStackTrace(); | ||
| 163 | + } | ||
| 164 | + return signature; | ||
| 165 | + } | ||
| 166 | +} | 
| ... | @@ -30,7 +30,7 @@ public class WarpConstants { | ... | @@ -30,7 +30,7 @@ public class WarpConstants { | 
| 30 | /** | 30 | /** | 
| 31 | * The version of the SDK installed in the device | 31 | * The version of the SDK installed in the device | 
| 32 | */ | 32 | */ | 
| 33 | - public static final String SDK_VERSION = "4.5.0"; | 33 | + public static final String SDK_VERSION = "4.5.1"; | 
| 34 | 34 | ||
| 35 | /** | 35 | /** | 
| 36 | * The URL of the server where it should ping | 36 | * The URL of the server where it should ping | ... | ... | 
| ... | @@ -36,6 +36,7 @@ import ly.warp.sdk.io.callbacks.CardsHook; | ... | @@ -36,6 +36,7 @@ import ly.warp.sdk.io.callbacks.CardsHook; | 
| 36 | import ly.warp.sdk.io.callbacks.ContactHook; | 36 | import ly.warp.sdk.io.callbacks.ContactHook; | 
| 37 | import ly.warp.sdk.io.callbacks.ContentHook; | 37 | import ly.warp.sdk.io.callbacks.ContentHook; | 
| 38 | import ly.warp.sdk.io.callbacks.CouponsHook; | 38 | import ly.warp.sdk.io.callbacks.CouponsHook; | 
| 39 | +import ly.warp.sdk.io.callbacks.CouponsetsHook; | ||
| 39 | import ly.warp.sdk.io.callbacks.MerchantCategoriesHook; | 40 | import ly.warp.sdk.io.callbacks.MerchantCategoriesHook; | 
| 40 | import ly.warp.sdk.io.callbacks.MerchantsHook; | 41 | import ly.warp.sdk.io.callbacks.MerchantsHook; | 
| 41 | import ly.warp.sdk.io.callbacks.PointsHook; | 42 | import ly.warp.sdk.io.callbacks.PointsHook; | 
| ... | @@ -49,6 +50,7 @@ import ly.warp.sdk.io.models.CardList; | ... | @@ -49,6 +50,7 @@ import ly.warp.sdk.io.models.CardList; | 
| 49 | import ly.warp.sdk.io.models.Consumer; | 50 | import ly.warp.sdk.io.models.Consumer; | 
| 50 | import ly.warp.sdk.io.models.ContentList; | 51 | import ly.warp.sdk.io.models.ContentList; | 
| 51 | import ly.warp.sdk.io.models.CouponList; | 52 | import ly.warp.sdk.io.models.CouponList; | 
| 53 | +import ly.warp.sdk.io.models.CouponsetsList; | ||
| 52 | import ly.warp.sdk.io.models.MerchantCategoriesList; | 54 | import ly.warp.sdk.io.models.MerchantCategoriesList; | 
| 53 | import ly.warp.sdk.io.models.MerchantList; | 55 | import ly.warp.sdk.io.models.MerchantList; | 
| 54 | import ly.warp.sdk.io.models.PointsList; | 56 | import ly.warp.sdk.io.models.PointsList; | 
| ... | @@ -70,12 +72,14 @@ import ly.warp.sdk.io.request.WarplyEditConsumerRequest; | ... | @@ -70,12 +72,14 @@ import ly.warp.sdk.io.request.WarplyEditConsumerRequest; | 
| 70 | import ly.warp.sdk.io.request.WarplyForgotPasswordRequest; | 72 | import ly.warp.sdk.io.request.WarplyForgotPasswordRequest; | 
| 71 | import ly.warp.sdk.io.request.WarplyGetAddressRequest; | 73 | import ly.warp.sdk.io.request.WarplyGetAddressRequest; | 
| 72 | import ly.warp.sdk.io.request.WarplyGetCardsRequest; | 74 | import ly.warp.sdk.io.request.WarplyGetCardsRequest; | 
| 75 | +import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest; | ||
| 73 | import ly.warp.sdk.io.request.WarplyLoginRequest; | 76 | import ly.warp.sdk.io.request.WarplyLoginRequest; | 
| 74 | import ly.warp.sdk.io.request.WarplyMerchantCategoriesRequest; | 77 | import ly.warp.sdk.io.request.WarplyMerchantCategoriesRequest; | 
| 75 | import ly.warp.sdk.io.request.WarplyMerchantsRequest; | 78 | import ly.warp.sdk.io.request.WarplyMerchantsRequest; | 
| 76 | import ly.warp.sdk.io.request.WarplyPointHistoryRequest; | 79 | import ly.warp.sdk.io.request.WarplyPointHistoryRequest; | 
| 77 | import ly.warp.sdk.io.request.WarplyProductsRequest; | 80 | import ly.warp.sdk.io.request.WarplyProductsRequest; | 
| 78 | import ly.warp.sdk.io.request.WarplyRedeemCouponRequest; | 81 | import ly.warp.sdk.io.request.WarplyRedeemCouponRequest; | 
| 82 | +import ly.warp.sdk.io.request.WarplyRedeemProductRequest; | ||
| 79 | import ly.warp.sdk.io.request.WarplyRefreshTokenRequest; | 83 | import ly.warp.sdk.io.request.WarplyRefreshTokenRequest; | 
| 80 | import ly.warp.sdk.io.request.WarplyRegisterRequest; | 84 | import ly.warp.sdk.io.request.WarplyRegisterRequest; | 
| 81 | import ly.warp.sdk.io.request.WarplyRequestOTPRequest; | 85 | import ly.warp.sdk.io.request.WarplyRequestOTPRequest; | 
| ... | @@ -86,6 +90,7 @@ import ly.warp.sdk.io.request.WarplyTokenAuthorizeRequest; | ... | @@ -86,6 +90,7 @@ import ly.warp.sdk.io.request.WarplyTokenAuthorizeRequest; | 
| 86 | import ly.warp.sdk.io.request.WarplyTransactionHistoryRequest; | 90 | import ly.warp.sdk.io.request.WarplyTransactionHistoryRequest; | 
| 87 | import ly.warp.sdk.io.request.WarplyUploadConsumerPhotoRequest; | 91 | import ly.warp.sdk.io.request.WarplyUploadConsumerPhotoRequest; | 
| 88 | import ly.warp.sdk.io.request.WarplyUserCouponsRequest; | 92 | import ly.warp.sdk.io.request.WarplyUserCouponsRequest; | 
| 93 | +import ly.warp.sdk.io.request.WarplyValidateCouponRequest; | ||
| 89 | import ly.warp.sdk.io.request.WarplyVerifyOTPRequest; | 94 | import ly.warp.sdk.io.request.WarplyVerifyOTPRequest; | 
| 90 | import ly.warp.sdk.io.request.WarplyVerifyTicketRequest; | 95 | import ly.warp.sdk.io.request.WarplyVerifyTicketRequest; | 
| 91 | import ly.warp.sdk.utils.WarpUtils; | 96 | import ly.warp.sdk.utils.WarpUtils; | 
| ... | @@ -1031,9 +1036,9 @@ public class WarplyManager { | ... | @@ -1031,9 +1036,9 @@ public class WarplyManager { | 
| 1031 | }); | 1036 | }); | 
| 1032 | } | 1037 | } | 
| 1033 | 1038 | ||
| 1034 | - public static void redeemCoupon(WarplyRedeemCouponRequest request, final CallbackReceiver<JSONObject> receiver) { | 1039 | + public static void redeemProduct(WarplyRedeemProductRequest request, final CallbackReceiver<JSONObject> receiver) { | 
| 1035 | - WarpUtils.log("************* WARPLY Redeem Coupons Request ********************"); | 1040 | + WarpUtils.log("************* WARPLY Redeem Product Request ********************"); | 
| 1036 | - WarpUtils.log("[WARP Trace] WARPLY Redeem Coupons Request is active"); | 1041 | + WarpUtils.log("[WARP Trace] WARPLY Redeem Product Request is active"); | 
| 1037 | WarpUtils.log("**************************************************"); | 1042 | WarpUtils.log("**************************************************"); | 
| 1038 | 1043 | ||
| 1039 | Warply.postReceiveMicroappData(WarpConstants.MICROAPP_TRANSACTIONS, true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | 1044 | Warply.postReceiveMicroappData(WarpConstants.MICROAPP_TRANSACTIONS, true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | 
| ... | @@ -1050,7 +1055,7 @@ public class WarplyManager { | ... | @@ -1050,7 +1055,7 @@ public class WarplyManager { | 
| 1050 | public void onSuccess(JSONObject result) { | 1055 | public void onSuccess(JSONObject result) { | 
| 1051 | int status = result.optInt("status", 2); | 1056 | int status = result.optInt("status", 2); | 
| 1052 | if (status == 1) | 1057 | if (status == 1) | 
| 1053 | - redeemCoupon(request, receiver); | 1058 | + redeemProduct(request, receiver); | 
| 1054 | else | 1059 | else | 
| 1055 | receiver.onFailure(status); | 1060 | receiver.onFailure(status); | 
| 1056 | } | 1061 | } | 
| ... | @@ -1173,4 +1178,93 @@ public class WarplyManager { | ... | @@ -1173,4 +1178,93 @@ public class WarplyManager { | 
| 1173 | Warply.postReceiveMicroappData(WarpConstants.MICROAPP_SHOPS, request.toJson(), | 1178 | Warply.postReceiveMicroappData(WarpConstants.MICROAPP_SHOPS, request.toJson(), | 
| 1174 | new MerchantsHook(receiver, request.getSignature())); | 1179 | new MerchantsHook(receiver, request.getSignature())); | 
| 1175 | } | 1180 | } | 
| 1181 | + | ||
| 1182 | + public static void getCouponsets(WarplyGetCouponsetsRequest request, final CallbackReceiver<CouponsetsList> receiver) { | ||
| 1183 | + WarpUtils.log("************* WARPLY Get Couponsets Request ********************"); | ||
| 1184 | + WarpUtils.log("[WARP Trace] WARPLY Get Couponsets Request is active"); | ||
| 1185 | + WarpUtils.log("**************************************************"); | ||
| 1186 | + | ||
| 1187 | + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, request.toJson(), new CouponsetsHook(new CallbackReceiver<CouponsetsList>() { | ||
| 1188 | + @Override | ||
| 1189 | + public void onSuccess(CouponsetsList result) { | ||
| 1190 | + receiver.onSuccess(result); | ||
| 1191 | + } | ||
| 1192 | + | ||
| 1193 | + @Override | ||
| 1194 | + public void onFailure(int errorCode) { | ||
| 1195 | + receiver.onFailure(errorCode); | ||
| 1196 | + } | ||
| 1197 | + }, | ||
| 1198 | + request.getSignature())); | ||
| 1199 | + } | ||
| 1200 | + | ||
| 1201 | + public static void redeemCoupon(WarplyRedeemCouponRequest request, final CallbackReceiver<JSONObject> receiver) { | ||
| 1202 | + WarpUtils.log("************* WARPLY Redeem Coupon Request ********************"); | ||
| 1203 | + WarpUtils.log("[WARP Trace] WARPLY Redeem Coupon Request is active"); | ||
| 1204 | + WarpUtils.log("**************************************************"); | ||
| 1205 | + | ||
| 1206 | + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | ||
| 1207 | + @Override | ||
| 1208 | + public void onSuccess(JSONObject result) { | ||
| 1209 | + receiver.onSuccess(result); | ||
| 1210 | + } | ||
| 1211 | + | ||
| 1212 | + @Override | ||
| 1213 | + public void onFailure(int errorCode) { | ||
| 1214 | + if (errorCode == 401) { | ||
| 1215 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
| 1216 | + @Override | ||
| 1217 | + public void onSuccess(JSONObject result) { | ||
| 1218 | + int status = result.optInt("status", 2); | ||
| 1219 | + if (status == 1) | ||
| 1220 | + redeemCoupon(request, receiver); | ||
| 1221 | + else | ||
| 1222 | + receiver.onFailure(status); | ||
| 1223 | + } | ||
| 1224 | + | ||
| 1225 | + @Override | ||
| 1226 | + public void onFailure(int errorCode) { | ||
| 1227 | + receiver.onFailure(errorCode); | ||
| 1228 | + } | ||
| 1229 | + }); | ||
| 1230 | + } else | ||
| 1231 | + receiver.onFailure(errorCode); | ||
| 1232 | + } | ||
| 1233 | + }); | ||
| 1234 | + } | ||
| 1235 | + | ||
| 1236 | + public static void validateCoupon(WarplyValidateCouponRequest request, final CallbackReceiver<JSONObject> receiver) { | ||
| 1237 | + WarpUtils.log("************* WARPLY Validate Coupon Request ********************"); | ||
| 1238 | + WarpUtils.log("[WARP Trace] WARPLY Validate Coupon Request is active"); | ||
| 1239 | + WarpUtils.log("**************************************************"); | ||
| 1240 | + | ||
| 1241 | + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | ||
| 1242 | + @Override | ||
| 1243 | + public void onSuccess(JSONObject result) { | ||
| 1244 | + receiver.onSuccess(result); | ||
| 1245 | + } | ||
| 1246 | + | ||
| 1247 | + @Override | ||
| 1248 | + public void onFailure(int errorCode) { | ||
| 1249 | + if (errorCode == 401) { | ||
| 1250 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
| 1251 | + @Override | ||
| 1252 | + public void onSuccess(JSONObject result) { | ||
| 1253 | + int status = result.optInt("status", 2); | ||
| 1254 | + if (status == 1) | ||
| 1255 | + validateCoupon(request, receiver); | ||
| 1256 | + else | ||
| 1257 | + receiver.onFailure(status); | ||
| 1258 | + } | ||
| 1259 | + | ||
| 1260 | + @Override | ||
| 1261 | + public void onFailure(int errorCode) { | ||
| 1262 | + receiver.onFailure(errorCode); | ||
| 1263 | + } | ||
| 1264 | + }); | ||
| 1265 | + } else | ||
| 1266 | + receiver.onFailure(errorCode); | ||
| 1267 | + } | ||
| 1268 | + }); | ||
| 1269 | + } | ||
| 1176 | } | 1270 | } | ... | ... | 
- 
Please register or login to post a comment