Showing
8 changed files
with
612 additions
and
29 deletions
| ... | @@ -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.4-cosbeta15' | 5 | + PUBLISH_VERSION = '4.5.4-cosbeta16' |
| 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
| 7 | } | 7 | } |
| 8 | 8 | ... | ... |
| 1 | package ly.warp.sdk.activities; | 1 | package ly.warp.sdk.activities; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | -import android.content.Intent; | ||
| 5 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 6 | import android.text.TextUtils; | 5 | import android.text.TextUtils; |
| 7 | -import android.util.Log; | ||
| 8 | import android.view.View; | 6 | import android.view.View; |
| 9 | import android.widget.ImageView; | 7 | import android.widget.ImageView; |
| 10 | import android.widget.LinearLayout; | 8 | import android.widget.LinearLayout; |
| ... | @@ -14,18 +12,13 @@ import androidx.recyclerview.widget.LinearLayoutManager; | ... | @@ -14,18 +12,13 @@ import androidx.recyclerview.widget.LinearLayoutManager; |
| 14 | import androidx.recyclerview.widget.RecyclerView; | 12 | import androidx.recyclerview.widget.RecyclerView; |
| 15 | 13 | ||
| 16 | import org.greenrobot.eventbus.EventBus; | 14 | import org.greenrobot.eventbus.EventBus; |
| 17 | -import org.json.JSONException; | ||
| 18 | -import org.json.JSONObject; | ||
| 19 | 15 | ||
| 20 | -import java.io.Serializable; | ||
| 21 | import java.util.ArrayList; | 16 | import java.util.ArrayList; |
| 22 | import java.util.HashMap; | 17 | import java.util.HashMap; |
| 23 | 18 | ||
| 24 | import ly.warp.sdk.R; | 19 | import ly.warp.sdk.R; |
| 25 | import ly.warp.sdk.io.models.Campaign; | 20 | import ly.warp.sdk.io.models.Campaign; |
| 26 | import ly.warp.sdk.io.models.CampaignList; | 21 | import ly.warp.sdk.io.models.CampaignList; |
| 27 | -import ly.warp.sdk.io.models.Couponset; | ||
| 28 | -import ly.warp.sdk.io.models.CouponsetsList; | ||
| 29 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | 22 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
| 30 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent; | 23 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent; |
| 31 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; | 24 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; |
| ... | @@ -62,10 +55,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -62,10 +55,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 62 | public void onCreate(Bundle savedInstanceState) { | 55 | public void onCreate(Bundle savedInstanceState) { |
| 63 | super.onCreate(savedInstanceState); | 56 | super.onCreate(savedInstanceState); |
| 64 | setContentView(R.layout.activity_gifts_for_you); | 57 | setContentView(R.layout.activity_gifts_for_you); |
| 65 | - ArrayList<LoyaltyGiftsForYouPackage> list = new ArrayList(); | ||
| 66 | mergeDatasets( | 58 | mergeDatasets( |
| 67 | WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"), | 59 | WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"), |
| 68 | - WarplyManagerHelper.getCouponsets() | 60 | + WarplyManagerHelper.getSeasonalList() |
| 69 | ); | 61 | ); |
| 70 | 62 | ||
| 71 | mIvBack = findViewById(R.id.iv_list_close); | 63 | mIvBack = findViewById(R.id.iv_list_close); |
| ... | @@ -132,11 +124,11 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -132,11 +124,11 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 132 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | 124 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); |
| 133 | } | 125 | } |
| 134 | } else if (dataItem.getDataType() == 2) { | 126 | } else if (dataItem.getDataType() == 2) { |
| 135 | - EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyContextualOfferModel())); | 127 | + LoyaltyGiftsForYouOfferClickEvent seasonalCLick = new LoyaltyGiftsForYouOfferClickEvent(); |
| 136 | - | 128 | + seasonalCLick.setTitle(dataItem.getSeasonalList().getTitle()); |
| 137 | - Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class); | 129 | + seasonalCLick.setLoyaltyPackageId(dataItem.getSeasonalList().getLoyaltyPackageId()); |
| 138 | - intent.putExtra("couponset", (Serializable) dataItem.getCouponset()); | 130 | + seasonalCLick.setImageUrl(dataItem.getSeasonalList().getImageUrl()); |
| 139 | - startActivity(intent); | 131 | + EventBus.getDefault().post(new WarplyEventBusManager(seasonalCLick)); |
| 140 | } | 132 | } |
| 141 | }) | 133 | }) |
| 142 | .doOnError(error -> { | 134 | .doOnError(error -> { |
| ... | @@ -145,22 +137,22 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -145,22 +137,22 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 145 | } | 137 | } |
| 146 | } | 138 | } |
| 147 | 139 | ||
| 148 | - private ArrayList<MergedGifts> mergeDatasets(CampaignList campaignList, CouponsetsList couponsetsList) { | 140 | + private ArrayList<MergedGifts> mergeDatasets(CampaignList campaignList, ArrayList<LoyaltyGiftsForYouPackage> seasonalList) { |
| 149 | if (campaignList != null && campaignList.size() > 0) { | 141 | if (campaignList != null && campaignList.size() > 0) { |
| 150 | for (Campaign campaign : campaignList) { | 142 | for (Campaign campaign : campaignList) { |
| 151 | MergedGifts data = new MergedGifts(); | 143 | MergedGifts data = new MergedGifts(); |
| 152 | data.setCampaign(campaign); | 144 | data.setCampaign(campaign); |
| 153 | - data.setCouponset(null); | 145 | + data.setSeasonalList(null); |
| 154 | data.setDataType(1); | 146 | data.setDataType(1); |
| 155 | mData.add(data); | 147 | mData.add(data); |
| 156 | } | 148 | } |
| 157 | } | 149 | } |
| 158 | 150 | ||
| 159 | - if (couponsetsList != null && couponsetsList.size() > 0) { | 151 | + if (seasonalList != null && seasonalList.size() > 0) { |
| 160 | - for (Couponset couponset : couponsetsList) { | 152 | + for (LoyaltyGiftsForYouPackage seasonal : seasonalList) { |
| 161 | MergedGifts data = new MergedGifts(); | 153 | MergedGifts data = new MergedGifts(); |
| 162 | data.setCampaign(null); | 154 | data.setCampaign(null); |
| 163 | - data.setCouponset(couponset); | 155 | + data.setSeasonalList(seasonal); |
| 164 | data.setDataType(2); | 156 | data.setDataType(2); |
| 165 | mData.add(data); | 157 | mData.add(data); |
| 166 | } | 158 | } | ... | ... |
| 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.JSONObject; | ||
| 29 | + | ||
| 30 | +import ly.warp.sdk.io.models.PacingDetails; | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * Created by Panagiotis Triantafyllou on 24-June-22. | ||
| 34 | + */ | ||
| 35 | + | ||
| 36 | +public class PacingDetailsHook implements CallbackReceiver<JSONObject> { | ||
| 37 | + | ||
| 38 | + private final CallbackReceiver<PacingDetails> mListener; | ||
| 39 | + private final String mRequestSignature; | ||
| 40 | + | ||
| 41 | + public PacingDetailsHook(CallbackReceiver<PacingDetails> listener, String requestSignature) { | ||
| 42 | + this.mListener = listener; | ||
| 43 | + this.mRequestSignature = requestSignature; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public void onSuccess(JSONObject result) { | ||
| 48 | + if (mListener != null) { | ||
| 49 | + int status = result.optInt("status", 2); | ||
| 50 | + if (status == 1) { | ||
| 51 | + mListener.onSuccess(new PacingDetails(result)); | ||
| 52 | + } else | ||
| 53 | + mListener.onFailure(status); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public void onFailure(int errorCode) { | ||
| 60 | + if (mListener != null) | ||
| 61 | + mListener.onFailure(errorCode); | ||
| 62 | + } | ||
| 63 | +} |
| ... | @@ -31,16 +31,13 @@ package ly.warp.sdk.io.models; | ... | @@ -31,16 +31,13 @@ package ly.warp.sdk.io.models; |
| 31 | 31 | ||
| 32 | public class MergedGifts { | 32 | public class MergedGifts { |
| 33 | private int dataType = 0; | 33 | private int dataType = 0; |
| 34 | - private Couponset couponset; | 34 | + private LoyaltyGiftsForYouPackage seasonalList; |
| 35 | private Campaign campaign; | 35 | private Campaign campaign; |
| 36 | 36 | ||
| 37 | public void setDataType(int dataType) { | 37 | public void setDataType(int dataType) { |
| 38 | this.dataType = dataType; | 38 | this.dataType = dataType; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | - public void setCouponset(Couponset couponset) { | ||
| 42 | - this.couponset = couponset; | ||
| 43 | - } | ||
| 44 | 41 | ||
| 45 | public void setCampaign(Campaign campaign) { | 42 | public void setCampaign(Campaign campaign) { |
| 46 | this.campaign = campaign; | 43 | this.campaign = campaign; |
| ... | @@ -50,8 +47,12 @@ public class MergedGifts { | ... | @@ -50,8 +47,12 @@ public class MergedGifts { |
| 50 | return dataType; | 47 | return dataType; |
| 51 | } | 48 | } |
| 52 | 49 | ||
| 53 | - public Couponset getCouponset() { | 50 | + public LoyaltyGiftsForYouPackage getSeasonalList() { |
| 54 | - return couponset; | 51 | + return seasonalList; |
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setSeasonalList(LoyaltyGiftsForYouPackage seasonalList) { | ||
| 55 | + this.seasonalList = seasonalList; | ||
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | public Campaign getCampaign() { | 58 | public Campaign getCampaign() { | ... | ... |
| 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 org.json.JSONArray; | ||
| 29 | +import org.json.JSONException; | ||
| 30 | +import org.json.JSONObject; | ||
| 31 | + | ||
| 32 | +import java.util.ArrayList; | ||
| 33 | + | ||
| 34 | +import ly.warp.sdk.utils.WarpUtils; | ||
| 35 | +import ly.warp.sdk.utils.constants.WarpConstants; | ||
| 36 | + | ||
| 37 | +/** | ||
| 38 | + * Created by Panagiotis Triantafyllou on 24-June-22. | ||
| 39 | + */ | ||
| 40 | + | ||
| 41 | +public class PacingDetails { | ||
| 42 | + | ||
| 43 | + private static final long serialVersionUID = -4754964462459705285L; | ||
| 44 | + | ||
| 45 | + /* Constants used to export the campaign in JSON formal and vice versa */ | ||
| 46 | + private static final String STEPS = "steps"; | ||
| 47 | + private static final String METERS = "meters"; | ||
| 48 | + private static final String RESULT = "result"; | ||
| 49 | + | ||
| 50 | + /* Member variables of the Campaign object */ | ||
| 51 | + private PacingInner steps = new PacingInner(); | ||
| 52 | + private PacingInner meters = new PacingInner(); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Basic constructor used to create an object from a String, representing a | ||
| 56 | + * JSON Object | ||
| 57 | + * | ||
| 58 | + * @param json The String, representing the JSON Object | ||
| 59 | + * @throws JSONException Thrown if the String cannot be converted to JSON | ||
| 60 | + */ | ||
| 61 | + public PacingDetails(String json) throws JSONException { | ||
| 62 | + this(new JSONObject(json)); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * Constructor used to create an Object from a given JSON Object | ||
| 67 | + * | ||
| 68 | + * @param json JSON Object used to create the Campaign | ||
| 69 | + */ | ||
| 70 | + public PacingDetails(JSONObject json) { | ||
| 71 | + if (json != null) { | ||
| 72 | + JSONObject result = new JSONObject(); | ||
| 73 | + result = json.optJSONObject(RESULT); | ||
| 74 | + if (result != null) { | ||
| 75 | + if (result.optJSONObject(STEPS) != null) { | ||
| 76 | + this.steps = new PacingInner(result.optJSONObject(STEPS)); | ||
| 77 | + } | ||
| 78 | + if (result.optJSONObject(METERS) != null) { | ||
| 79 | + this.meters = new PacingInner(result.optJSONObject(METERS)); | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * Converts the Campaign into a JSON Object | ||
| 87 | + * | ||
| 88 | + * @return The JSON Object created from this campaign | ||
| 89 | + */ | ||
| 90 | + public JSONObject toJSONObject() { | ||
| 91 | + JSONObject jObj = new JSONObject(); | ||
| 92 | + try { | ||
| 93 | + jObj.putOpt(STEPS, this.steps); | ||
| 94 | + jObj.putOpt(METERS, this.meters); | ||
| 95 | + } catch (JSONException e) { | ||
| 96 | + if (WarpConstants.DEBUG) { | ||
| 97 | + e.printStackTrace(); | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + return jObj; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * String representation of the Campaign, as a JSON object | ||
| 105 | + * | ||
| 106 | + * @return A String representation of JSON object | ||
| 107 | + */ | ||
| 108 | + public String toString() { | ||
| 109 | + if (toJSONObject() != null) | ||
| 110 | + return toJSONObject().toString(); | ||
| 111 | + return null; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * String representation of the Campaign, as a human readable JSON object | ||
| 116 | + * | ||
| 117 | + * @return A human readable String representation of JSON object | ||
| 118 | + */ | ||
| 119 | + public String toHumanReadableString() { | ||
| 120 | + String humanReadableString = null; | ||
| 121 | + try { | ||
| 122 | + humanReadableString = toJSONObject().toString(2); | ||
| 123 | + } catch (JSONException e) { | ||
| 124 | + WarpUtils.warn("Failed converting Campaign JSON object to String", | ||
| 125 | + e); | ||
| 126 | + } | ||
| 127 | + return humanReadableString; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + private class PacingInner { | ||
| 131 | + private static final String TOTAL = "total"; | ||
| 132 | + private static final String MONTH = "month"; | ||
| 133 | + private static final String WEEK = "week"; | ||
| 134 | + private static final String DAY = "day"; | ||
| 135 | + | ||
| 136 | + private PacingDetailsInner total = new PacingDetailsInner(); | ||
| 137 | + private PacingDetailsInner month = new PacingDetailsInner(); | ||
| 138 | + private PacingDetailsInner week = new PacingDetailsInner(); | ||
| 139 | + private PacingDetailsInner day = new PacingDetailsInner(); | ||
| 140 | + | ||
| 141 | + public PacingInner() { | ||
| 142 | + this.total = new PacingDetailsInner(); | ||
| 143 | + this.month = new PacingDetailsInner(); | ||
| 144 | + this.week = new PacingDetailsInner(); | ||
| 145 | + this.day = new PacingDetailsInner(); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + public PacingInner(JSONObject json) { | ||
| 149 | + if (json != null) { | ||
| 150 | + if (json.optJSONObject(TOTAL) != null) { | ||
| 151 | + this.total = new PacingDetailsInner(json.optJSONObject(TOTAL)); | ||
| 152 | + } | ||
| 153 | + if (json.optJSONObject(MONTH) != null) { | ||
| 154 | + this.total = new PacingDetailsInner(json.optJSONObject(MONTH)); | ||
| 155 | + } | ||
| 156 | + if (json.optJSONObject(WEEK) != null) { | ||
| 157 | + this.total = new PacingDetailsInner(json.optJSONObject(WEEK)); | ||
| 158 | + } | ||
| 159 | + if (json.optJSONObject(DAY) != null) { | ||
| 160 | + this.total = new PacingDetailsInner(json.optJSONObject(DAY)); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + public PacingDetailsInner getTotal() { | ||
| 166 | + return total; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + public void setTotal(PacingDetailsInner total) { | ||
| 170 | + this.total = total; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public PacingDetailsInner getMonth() { | ||
| 174 | + return month; | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + public void setMonth(PacingDetailsInner month) { | ||
| 178 | + this.month = month; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + public PacingDetailsInner getWeek() { | ||
| 182 | + return week; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + public void setWeek(PacingDetailsInner week) { | ||
| 186 | + this.week = week; | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + public PacingDetailsInner getDay() { | ||
| 190 | + return day; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + public void setDay(PacingDetailsInner day) { | ||
| 194 | + this.day = day; | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + private class PacingDetailsInner { | ||
| 199 | + private static final String GOAL = "goal"; | ||
| 200 | + private static final String VALLUE = "value"; | ||
| 201 | + private static final String PER_DAY = "per_day"; | ||
| 202 | + | ||
| 203 | + private double goal = 0.0d; | ||
| 204 | + private double value = 0.0d; | ||
| 205 | + private ArrayList<PacingDetailsDay> per_day = new ArrayList<>(); | ||
| 206 | + | ||
| 207 | + public PacingDetailsInner() { | ||
| 208 | + this.goal = 0.0f; | ||
| 209 | + this.value = 0.0f; | ||
| 210 | + this.per_day = new ArrayList<>(); | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + public PacingDetailsInner(JSONObject json) { | ||
| 214 | + if (json != null) { | ||
| 215 | + this.goal = json.optDouble(GOAL); | ||
| 216 | + this.value = json.optDouble(VALLUE); | ||
| 217 | + if (json.optJSONArray(PER_DAY) != null) { | ||
| 218 | + JSONArray perDay = new JSONArray(); | ||
| 219 | + perDay = json.optJSONArray(PER_DAY); | ||
| 220 | + if (perDay != null) { | ||
| 221 | + ArrayList<PacingDetailsDay> list = new ArrayList<>(); | ||
| 222 | + for (int i = 0; i < perDay.length(); i++) { | ||
| 223 | + JSONObject object = perDay.optJSONObject(i); | ||
| 224 | + if (object != null) { | ||
| 225 | + list.add(new PacingDetailsDay(object)); | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + this.per_day = list; | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + } | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + public double getGoal() { | ||
| 235 | + return goal; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + public void setGoal(double goal) { | ||
| 239 | + this.goal = goal; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + public double getValue() { | ||
| 243 | + return value; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + public void setValue(double value) { | ||
| 247 | + this.value = value; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + public ArrayList<PacingDetailsDay> getPer_day() { | ||
| 251 | + return per_day; | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + public void setPer_day(ArrayList<PacingDetailsDay> per_day) { | ||
| 255 | + this.per_day = per_day; | ||
| 256 | + } | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + private class PacingDetailsDay { | ||
| 260 | + private static final String DAY = "day"; | ||
| 261 | + private static final String VALLUE = "value"; | ||
| 262 | + | ||
| 263 | + private String day = ""; | ||
| 264 | + private double value = 0.0d; | ||
| 265 | + | ||
| 266 | + public PacingDetailsDay() { | ||
| 267 | + this.day = ""; | ||
| 268 | + this.value = 0.0f; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + public PacingDetailsDay(JSONObject json) { | ||
| 272 | + if (json != null) { | ||
| 273 | + this.day = json.optString(DAY); | ||
| 274 | + this.value = json.optDouble(VALLUE); | ||
| 275 | + } | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + public String getDay() { | ||
| 279 | + return day; | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + public void setDay(String day) { | ||
| 283 | + this.day = day; | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + public double getValue() { | ||
| 287 | + return value; | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + public void setValue(double value) { | ||
| 291 | + this.value = value; | ||
| 292 | + } | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + // ================================================================================ | ||
| 296 | + // Getters | ||
| 297 | + // ================================================================================ | ||
| 298 | + | ||
| 299 | + | ||
| 300 | + public PacingInner getSteps() { | ||
| 301 | + return steps; | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + public void setSteps(PacingInner steps) { | ||
| 305 | + this.steps = steps; | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + public PacingInner getMeters() { | ||
| 309 | + return meters; | ||
| 310 | + } | ||
| 311 | + | ||
| 312 | + public void setMeters(PacingInner meters) { | ||
| 313 | + this.meters = meters; | ||
| 314 | + } | ||
| 315 | +} |
| 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 24-June-22. | ||
| 17 | + */ | ||
| 18 | + | ||
| 19 | +public class PacingDetailsRequest { | ||
| 20 | + | ||
| 21 | + // =========================================================== | ||
| 22 | + // Constants | ||
| 23 | + // =========================================================== | ||
| 24 | + | ||
| 25 | + private final String KEY_MAPP = "consumer_data"; | ||
| 26 | + private final String KEY_ACTION = "action"; | ||
| 27 | + private final String KEY_ACTION_VALUE = "integration"; | ||
| 28 | + private final String KEY_METHOD = "method"; | ||
| 29 | + private final String KEY_METHOD_VALUE = "steps"; | ||
| 30 | + private final String KEY_OPERATION = "operation"; | ||
| 31 | + private final String KEY_OPERATION_VALUE = "get"; | ||
| 32 | + | ||
| 33 | + // =========================================================== | ||
| 34 | + // Fields | ||
| 35 | + // =========================================================== | ||
| 36 | + | ||
| 37 | + private HashMap<String, String> mFilters; | ||
| 38 | + private long mCacheUpdateInterval = 0; | ||
| 39 | + private String mSharingId = ""; | ||
| 40 | + | ||
| 41 | + // =========================================================== | ||
| 42 | + // Constructor | ||
| 43 | + // =========================================================== | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Default constructor of CosmoteSharingRequest, initializes an empty filters HashMap | ||
| 47 | + */ | ||
| 48 | + public PacingDetailsRequest() { | ||
| 49 | + mFilters = new HashMap<>(); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public PacingDetailsRequest(PacingDetailsRequest copy) { | ||
| 53 | + if (copy != null) { | ||
| 54 | + this.mFilters = copy.mFilters; | ||
| 55 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + // =========================================================== | ||
| 60 | + // Methods for/from SuperClass/Interfaces | ||
| 61 | + // =========================================================== | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public boolean equals(Object object) { | ||
| 65 | + if (object instanceof PacingDetailsRequest) { | ||
| 66 | + PacingDetailsRequest other = (PacingDetailsRequest) object; | ||
| 67 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
| 68 | + } | ||
| 69 | + return false; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public int hashCode() { | ||
| 74 | + return mFilters.hashCode(); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + // =========================================================== | ||
| 78 | + // Methods | ||
| 79 | + // =========================================================== | ||
| 80 | + | ||
| 81 | + // =========================================================== | ||
| 82 | + // Getter & Setter | ||
| 83 | + // =========================================================== | ||
| 84 | + | ||
| 85 | + public PacingDetailsRequest setSharingId(String sharingId) { | ||
| 86 | + mSharingId = sharingId; | ||
| 87 | + return this; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * Call this to get how often the cached data will be updated. | ||
| 92 | + * | ||
| 93 | + * @return mCacheUpdateInterval | ||
| 94 | + */ | ||
| 95 | + public long getCacheUpdateInterval() { | ||
| 96 | + return mCacheUpdateInterval; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * Call this to set how often the cached data will be updated. | ||
| 101 | + * | ||
| 102 | + * @param updateInterval The time that data will be cached | ||
| 103 | + * @return CosmoteSharingRequest | ||
| 104 | + */ | ||
| 105 | + public PacingDetailsRequest setCacheUpdateInterval(long updateInterval) { | ||
| 106 | + | ||
| 107 | + this.mCacheUpdateInterval = updateInterval; | ||
| 108 | + if (mCacheUpdateInterval < 0) { | ||
| 109 | + mCacheUpdateInterval = 0; | ||
| 110 | + } | ||
| 111 | + return this; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * Call this to check if the Application uses Cache | ||
| 116 | + * | ||
| 117 | + * @return <p>true - the Application is using Cache</p> | ||
| 118 | + * <p>false - the Application is not using Cache</p> | ||
| 119 | + */ | ||
| 120 | + public boolean isUseCache() { | ||
| 121 | + return mCacheUpdateInterval > 0; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + /** | ||
| 125 | + * Call this to check whether the cached data need to be updated | ||
| 126 | + * | ||
| 127 | + * @param useCache <p>true - the Application is using Cache</p> | ||
| 128 | + * <p>false - the Application is not using Cache</p> | ||
| 129 | + * @return CosmoteSharingRequest | ||
| 130 | + */ | ||
| 131 | + public PacingDetailsRequest setUseCache(boolean useCache) { | ||
| 132 | + | ||
| 133 | + if (useCache) { | ||
| 134 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
| 135 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
| 136 | + } else { | ||
| 137 | + mCacheUpdateInterval = 0; | ||
| 138 | + } | ||
| 139 | + return this; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * Call this to build the offers Json object | ||
| 144 | + * | ||
| 145 | + * @return bodyJsonObject | ||
| 146 | + */ | ||
| 147 | + public JSONObject toJson() { | ||
| 148 | + JSONObject bodyJsonObject = new JSONObject(); | ||
| 149 | + try { | ||
| 150 | + JSONObject extraJson = new JSONObject(); | ||
| 151 | + extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
| 152 | + extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); | ||
| 153 | + extraJson.putOpt(KEY_OPERATION, KEY_OPERATION_VALUE); | ||
| 154 | + bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ||
| 155 | + } catch (JSONException e) { | ||
| 156 | + if (WarpConstants.DEBUG) | ||
| 157 | + e.printStackTrace(); | ||
| 158 | + } | ||
| 159 | + return bodyJsonObject; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public String getSignature() { | ||
| 163 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_pacing_details_request"; | ||
| 164 | + try { | ||
| 165 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
| 166 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
| 167 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
| 168 | + | UnsupportedEncodingException e) { | ||
| 169 | + e.printStackTrace(); | ||
| 170 | + } | ||
| 171 | + return signature; | ||
| 172 | + } | ||
| 173 | +} |
| ... | @@ -40,6 +40,7 @@ import ly.warp.sdk.io.callbacks.CouponsetsHook; | ... | @@ -40,6 +40,7 @@ import ly.warp.sdk.io.callbacks.CouponsetsHook; |
| 40 | import ly.warp.sdk.io.callbacks.MerchantCategoriesHook; | 40 | import ly.warp.sdk.io.callbacks.MerchantCategoriesHook; |
| 41 | import ly.warp.sdk.io.callbacks.MerchantsHook; | 41 | import ly.warp.sdk.io.callbacks.MerchantsHook; |
| 42 | import ly.warp.sdk.io.callbacks.NewCampaignsHook; | 42 | import ly.warp.sdk.io.callbacks.NewCampaignsHook; |
| 43 | +import ly.warp.sdk.io.callbacks.PacingDetailsHook; | ||
| 43 | import ly.warp.sdk.io.callbacks.PointsHook; | 44 | import ly.warp.sdk.io.callbacks.PointsHook; |
| 44 | import ly.warp.sdk.io.callbacks.ProductsHook; | 45 | import ly.warp.sdk.io.callbacks.ProductsHook; |
| 45 | import ly.warp.sdk.io.callbacks.TagsCategoriesHook; | 46 | import ly.warp.sdk.io.callbacks.TagsCategoriesHook; |
| ... | @@ -55,6 +56,7 @@ import ly.warp.sdk.io.models.CouponsetsList; | ... | @@ -55,6 +56,7 @@ import ly.warp.sdk.io.models.CouponsetsList; |
| 55 | import ly.warp.sdk.io.models.MerchantCategoriesList; | 56 | import ly.warp.sdk.io.models.MerchantCategoriesList; |
| 56 | import ly.warp.sdk.io.models.MerchantList; | 57 | import ly.warp.sdk.io.models.MerchantList; |
| 57 | import ly.warp.sdk.io.models.NewCampaignList; | 58 | import ly.warp.sdk.io.models.NewCampaignList; |
| 59 | +import ly.warp.sdk.io.models.PacingDetails; | ||
| 58 | import ly.warp.sdk.io.models.PointsList; | 60 | import ly.warp.sdk.io.models.PointsList; |
| 59 | import ly.warp.sdk.io.models.ProductList; | 61 | import ly.warp.sdk.io.models.ProductList; |
| 60 | import ly.warp.sdk.io.models.TagsCategoriesList; | 62 | import ly.warp.sdk.io.models.TagsCategoriesList; |
| ... | @@ -62,6 +64,7 @@ import ly.warp.sdk.io.models.TagsList; | ... | @@ -62,6 +64,7 @@ import ly.warp.sdk.io.models.TagsList; |
| 62 | import ly.warp.sdk.io.models.TransactionsList; | 64 | import ly.warp.sdk.io.models.TransactionsList; |
| 63 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; | 65 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; |
| 64 | import ly.warp.sdk.io.request.CosmoteSharingRequest; | 66 | import ly.warp.sdk.io.request.CosmoteSharingRequest; |
| 67 | +import ly.warp.sdk.io.request.PacingDetailsRequest; | ||
| 65 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; | 68 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; |
| 66 | import ly.warp.sdk.io.request.WarplyAddCardRequest; | 69 | import ly.warp.sdk.io.request.WarplyAddCardRequest; |
| 67 | import ly.warp.sdk.io.request.WarplyAuthorizeRequest; | 70 | import ly.warp.sdk.io.request.WarplyAuthorizeRequest; |
| ... | @@ -1429,4 +1432,40 @@ public class WarplyManager { | ... | @@ -1429,4 +1432,40 @@ public class WarplyManager { |
| 1429 | } | 1432 | } |
| 1430 | }); | 1433 | }); |
| 1431 | } | 1434 | } |
| 1435 | + | ||
| 1436 | + public static void getPacingDetails(PacingDetailsRequest request, final CallbackReceiver<PacingDetails> receiver) { | ||
| 1437 | + WarpUtils.log("************* WARPLY Pacing Details Request ********************"); | ||
| 1438 | + WarpUtils.log("[WARP Trace] WARPLY Pacing Details Request is active"); | ||
| 1439 | + WarpUtils.log("**************************************************"); | ||
| 1440 | + | ||
| 1441 | + Warply.postReceiveMicroappData(true, "context", request.toJson(), new PacingDetailsHook(new CallbackReceiver<PacingDetails>() { | ||
| 1442 | + @Override | ||
| 1443 | + public void onSuccess(PacingDetails result) { | ||
| 1444 | + receiver.onSuccess(result); | ||
| 1445 | + } | ||
| 1446 | + | ||
| 1447 | + @Override | ||
| 1448 | + public void onFailure(int errorCode) { | ||
| 1449 | + if (errorCode == 401) { | ||
| 1450 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
| 1451 | + @Override | ||
| 1452 | + public void onSuccess(JSONObject result) { | ||
| 1453 | + int status = result.optInt("status", 2); | ||
| 1454 | + if (status == 1) | ||
| 1455 | + getPacingDetails(request, receiver); | ||
| 1456 | + else | ||
| 1457 | + receiver.onFailure(status); | ||
| 1458 | + } | ||
| 1459 | + | ||
| 1460 | + @Override | ||
| 1461 | + public void onFailure(int errorCode) { | ||
| 1462 | + receiver.onFailure(errorCode); | ||
| 1463 | + } | ||
| 1464 | + }); | ||
| 1465 | + } else | ||
| 1466 | + receiver.onFailure(errorCode); | ||
| 1467 | + } | ||
| 1468 | + }, | ||
| 1469 | + request.getSignature())); | ||
| 1470 | + } | ||
| 1432 | } | 1471 | } | ... | ... |
| ... | @@ -91,13 +91,13 @@ public class MergedGiftsAdapter extends RecyclerView.Adapter<MergedGiftsAdapter. | ... | @@ -91,13 +91,13 @@ public class MergedGiftsAdapter extends RecyclerView.Adapter<MergedGiftsAdapter. |
| 91 | 91 | ||
| 92 | holder.tvMergedGiftsTitle.setText(mergedgiftsItem.getCampaign().getTitle()); | 92 | holder.tvMergedGiftsTitle.setText(mergedgiftsItem.getCampaign().getTitle()); |
| 93 | } else if (mergedgiftsItem != null && mergedgiftsItem.getDataType() == 2) { | 93 | } else if (mergedgiftsItem != null && mergedgiftsItem.getDataType() == 2) { |
| 94 | - if (!TextUtils.isEmpty(mergedgiftsItem.getCouponset().getImgPreview())) { | 94 | + if (!TextUtils.isEmpty(mergedgiftsItem.getSeasonalList().getImageUrl())) { |
| 95 | Glide.with(mContext) | 95 | Glide.with(mContext) |
| 96 | // .setDefaultRequestOptions( | 96 | // .setDefaultRequestOptions( |
| 97 | // RequestOptions | 97 | // RequestOptions |
| 98 | // .placeholderOf(R.drawable.ic_default_contact_photo) | 98 | // .placeholderOf(R.drawable.ic_default_contact_photo) |
| 99 | // .error(R.drawable.ic_default_contact_photo)) | 99 | // .error(R.drawable.ic_default_contact_photo)) |
| 100 | - .load(mergedgiftsItem.getCouponset().getImgPreview()) | 100 | + .load(mergedgiftsItem.getSeasonalList().getImageUrl()) |
| 101 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 101 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 102 | .into(holder.ivMergedGiftsLogo); | 102 | .into(holder.ivMergedGiftsLogo); |
| 103 | } else { | 103 | } else { |
| ... | @@ -106,7 +106,7 @@ public class MergedGiftsAdapter extends RecyclerView.Adapter<MergedGiftsAdapter. | ... | @@ -106,7 +106,7 @@ public class MergedGiftsAdapter extends RecyclerView.Adapter<MergedGiftsAdapter. |
| 106 | .into(holder.ivMergedGiftsLogo); | 106 | .into(holder.ivMergedGiftsLogo); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | - holder.tvMergedGiftsTitle.setText(mergedgiftsItem.getCouponset().getName()); | 109 | + holder.tvMergedGiftsTitle.setText(mergedgiftsItem.getSeasonalList().getTitle()); |
| 110 | // holder.tvMergedGiftsTitle.setText(Html.fromHtml(mergedgiftsItem.getCouponset().getDescription())); | 110 | // holder.tvMergedGiftsTitle.setText(Html.fromHtml(mergedgiftsItem.getCouponset().getDescription())); |
| 111 | 111 | ||
| 112 | // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 112 | // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | ... | ... |
-
Please register or login to post a comment