Showing
7 changed files
with
462 additions
and
106 deletions
... | @@ -3,6 +3,8 @@ package ly.warp.sdk.activities; | ... | @@ -3,6 +3,8 @@ package ly.warp.sdk.activities; |
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | +import android.text.TextUtils; | ||
7 | +import android.util.Log; | ||
6 | import android.view.View; | 8 | import android.view.View; |
7 | import android.widget.ImageView; | 9 | import android.widget.ImageView; |
8 | import android.widget.LinearLayout; | 10 | import android.widget.LinearLayout; |
... | @@ -26,7 +28,9 @@ import ly.warp.sdk.io.models.Couponset; | ... | @@ -26,7 +28,9 @@ import ly.warp.sdk.io.models.Couponset; |
26 | import ly.warp.sdk.io.models.CouponsetsList; | 28 | import ly.warp.sdk.io.models.CouponsetsList; |
27 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | 29 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
28 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent; | 30 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent; |
31 | +import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; | ||
29 | import ly.warp.sdk.io.models.MergedGifts; | 32 | import ly.warp.sdk.io.models.MergedGifts; |
33 | +import ly.warp.sdk.utils.WarpJSONParser; | ||
30 | import ly.warp.sdk.utils.WarpUtils; | 34 | import ly.warp.sdk.utils.WarpUtils; |
31 | import ly.warp.sdk.utils.WarplyManagerHelper; | 35 | import ly.warp.sdk.utils.WarplyManagerHelper; |
32 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; | 36 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; |
... | @@ -45,13 +49,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -45,13 +49,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
45 | 49 | ||
46 | private ImageView mIvBack, mIvPopupClose; | 50 | private ImageView mIvBack, mIvPopupClose; |
47 | private TextView mTvTitle; | 51 | private TextView mTvTitle; |
48 | - /**** Old functionality ****/ | ||
49 | -// private RecyclerView mRecyclerGifts, mRecyclerRewards, mRecyclerCoupons; | ||
50 | -// private ProfileCampaignAdapter mAdapterGifts, mAdapterRewards; | ||
51 | -// private CouponsetsAdapter mAdapterCoupons; | ||
52 | -// private ConstraintLayout mClGiftsOuter, mClRewardsOuter, mClCouponsOuter; | ||
53 | private HashMap<String, CampaignList> mUniqueGiftsList = new HashMap<String, CampaignList>(); | 52 | private HashMap<String, CampaignList> mUniqueGiftsList = new HashMap<String, CampaignList>(); |
54 | - /**** Old functionality ****/ | ||
55 | private LinearLayout mLlGiftsPopup; | 53 | private LinearLayout mLlGiftsPopup; |
56 | private ArrayList<MergedGifts> mData = new ArrayList(); | 54 | private ArrayList<MergedGifts> mData = new ArrayList(); |
57 | private RecyclerView mRecyclerMergedGifts; | 55 | private RecyclerView mRecyclerMergedGifts; |
... | @@ -64,10 +62,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -64,10 +62,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
64 | public void onCreate(Bundle savedInstanceState) { | 62 | public void onCreate(Bundle savedInstanceState) { |
65 | super.onCreate(savedInstanceState); | 63 | super.onCreate(savedInstanceState); |
66 | setContentView(R.layout.activity_gifts_for_you); | 64 | setContentView(R.layout.activity_gifts_for_you); |
67 | - | 65 | + ArrayList<LoyaltyGiftsForYouPackage> list = new ArrayList(); |
68 | - /**** Old functionality ****/ | ||
69 | -// getCampaignsBySubcategory(); | ||
70 | - /**** Old functionality ****/ | ||
71 | mergeDatasets( | 66 | mergeDatasets( |
72 | WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"), | 67 | WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"), |
73 | WarplyManagerHelper.getCouponsets() | 68 | WarplyManagerHelper.getCouponsets() |
... | @@ -78,17 +73,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -78,17 +73,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
78 | mIvPopupClose = findViewById(R.id.iv_popup_gifts_close); | 73 | mIvPopupClose = findViewById(R.id.iv_popup_gifts_close); |
79 | mLlGiftsPopup = findViewById(R.id.ll_gifts_popup); | 74 | mLlGiftsPopup = findViewById(R.id.ll_gifts_popup); |
80 | 75 | ||
81 | - /**** Old functionality ****/ | ||
82 | -// mClGiftsOuter = findViewById(R.id.cl_recycler_inner); | ||
83 | -// mRecyclerGifts = findViewById(R.id.rv_gifts); | ||
84 | - | ||
85 | -// mClRewardsOuter = findViewById(R.id.cl_recycler_inner2); | ||
86 | -// mRecyclerRewards = findViewById(R.id.rv_rewards); | ||
87 | - | ||
88 | -// mClCouponsOuter = findViewById(R.id.cl_recycler_inner3); | ||
89 | -// mRecyclerCoupons = findViewById(R.id.rv_coupons); | ||
90 | - /**** Old functionality ****/ | ||
91 | - | ||
92 | mRecyclerMergedGifts = findViewById(R.id.rv_merged_gifts); | 76 | mRecyclerMergedGifts = findViewById(R.id.rv_merged_gifts); |
93 | 77 | ||
94 | initViews(); | 78 | initViews(); |
... | @@ -123,55 +107,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -123,55 +107,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
123 | if (WarpUtils.getGiftsPopup(this)) | 107 | if (WarpUtils.getGiftsPopup(this)) |
124 | mLlGiftsPopup.setVisibility(View.VISIBLE); | 108 | mLlGiftsPopup.setVisibility(View.VISIBLE); |
125 | 109 | ||
126 | - /**** Old functionality ****/ | ||
127 | -// if (mUniqueGiftsList.get("gifts") != null && mUniqueGiftsList.get("gifts").size() > 0) { | ||
128 | -// mRecyclerGifts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); | ||
129 | -// mAdapterGifts = new ProfileCampaignAdapter(this, mUniqueGiftsList.get("gifts")); | ||
130 | -// mRecyclerGifts.setAdapter(mAdapterGifts); | ||
131 | -// mAdapterGifts.getPositionClicks() | ||
132 | -// .doOnNext(gift -> { | ||
133 | -// startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift))); | ||
134 | -// }) | ||
135 | -// .doOnError(error -> { | ||
136 | -// }) | ||
137 | -// .subscribe(); | ||
138 | -// } else { | ||
139 | -// mClGiftsOuter.setVisibility(View.GONE); | ||
140 | -// } | ||
141 | - | ||
142 | -// if (mUniqueGiftsList.get("rewards") != null && mUniqueGiftsList.get("rewards").size() > 0) { | ||
143 | -// mRecyclerRewards.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); | ||
144 | -// mAdapterRewards = new ProfileCampaignAdapter(this, mUniqueGiftsList.get("rewards")); | ||
145 | -// mRecyclerRewards.setAdapter(mAdapterRewards); | ||
146 | -// mAdapterRewards.getPositionClicks() | ||
147 | -// .doOnNext(reward -> { | ||
148 | -// startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(reward))); | ||
149 | -// }) | ||
150 | -// .doOnError(error -> { | ||
151 | -// }) | ||
152 | -// .subscribe(); | ||
153 | -// } else { | ||
154 | -// mClRewardsOuter.setVisibility(View.GONE); | ||
155 | -// } | ||
156 | - | ||
157 | -// if (WarplyManagerHelper.getCouponsets() != null && WarplyManagerHelper.getCouponsets().size() > 0) { | ||
158 | -// mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); | ||
159 | -// mAdapterCoupons = new CouponsetsAdapter(this, WarplyManagerHelper.getCouponsets()); | ||
160 | -// mRecyclerCoupons.setAdapter(mAdapterCoupons); | ||
161 | -// mAdapterCoupons.getPositionClicks() | ||
162 | -// .doOnNext(couponset -> { | ||
163 | -// Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class); | ||
164 | -// intent.putExtra("couponset", (Serializable) couponset); | ||
165 | -// startActivity(intent); | ||
166 | -// }) | ||
167 | -// .doOnError(error -> { | ||
168 | -// }) | ||
169 | -// .subscribe(); | ||
170 | -// } else { | ||
171 | -// mClCouponsOuter.setVisibility(View.GONE); | ||
172 | -// } | ||
173 | - /**** Old functionality ****/ | ||
174 | - | ||
175 | if (mData != null && mData.size() > 0) { | 110 | if (mData != null && mData.size() > 0) { |
176 | mRecyclerMergedGifts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); | 111 | mRecyclerMergedGifts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); |
177 | mAdapterMergedGifts = new MergedGiftsAdapter(this, mData); | 112 | mAdapterMergedGifts = new MergedGiftsAdapter(this, mData); |
... | @@ -181,7 +116,21 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -181,7 +116,21 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
181 | if (dataItem.getDataType() == 1) { | 116 | if (dataItem.getDataType() == 1) { |
182 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent())); | 117 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent())); |
183 | 118 | ||
119 | + try { | ||
120 | + String key = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).keys().next(); | ||
121 | + if (!TextUtils.isEmpty(key) && key.equals("loyaltyCampaignId")) { | ||
122 | + String value = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).optString("loyaltyCampaignId"); | ||
123 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
124 | + if (ccms.getLoyaltyCampaignId().equals(value)) { | ||
125 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms.getSessionId()))); | ||
126 | + return; | ||
127 | + } | ||
128 | + } | ||
129 | + } | ||
130 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | ||
131 | + } catch (Exception exception) { | ||
184 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | 132 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); |
133 | + } | ||
185 | } else if (dataItem.getDataType() == 2) { | 134 | } else if (dataItem.getDataType() == 2) { |
186 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyContextualOfferModel())); | 135 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyContextualOfferModel())); |
187 | 136 | ||
... | @@ -193,33 +142,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -193,33 +142,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
193 | .doOnError(error -> { | 142 | .doOnError(error -> { |
194 | }) | 143 | }) |
195 | .subscribe(); | 144 | .subscribe(); |
196 | - } else { | ||
197 | -// mClCouponsOuter.setVisibility(View.GONE); | ||
198 | - } | ||
199 | - } | ||
200 | - | ||
201 | - private void getCampaignsBySubcategory() { | ||
202 | - if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) { | ||
203 | - for (Campaign campaign : WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you")) { | ||
204 | - JSONObject campaignExtra = null; | ||
205 | - try { | ||
206 | - campaignExtra = new JSONObject(campaign.getExtraFields()); | ||
207 | - } catch (JSONException e) { | ||
208 | - e.printStackTrace(); | ||
209 | - } | ||
210 | - | ||
211 | - if (campaignExtra != null) { | ||
212 | - if (mUniqueGiftsList.containsKey(campaignExtra.optString("subcategory").trim())) { | ||
213 | - CampaignList tempCampaignList = mUniqueGiftsList.get(campaignExtra.optString("subcategory").trim()); | ||
214 | - tempCampaignList.add(campaign); | ||
215 | - mUniqueGiftsList.put(campaignExtra.optString("subcategory").trim(), tempCampaignList); | ||
216 | - } else { | ||
217 | - CampaignList tempCampaignList = new CampaignList(); | ||
218 | - tempCampaignList.add(campaign); | ||
219 | - mUniqueGiftsList.put(campaignExtra.optString("subcategory").trim(), tempCampaignList); | ||
220 | - } | ||
221 | - } | ||
222 | - } | ||
223 | } | 145 | } |
224 | } | 146 | } |
225 | 147 | ... | ... |
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/CosmoteRetrieveSharingRequest.java
0 → 100644
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 23-June-22. | ||
17 | + */ | ||
18 | + | ||
19 | +public class CosmoteRetrieveSharingRequest { | ||
20 | + | ||
21 | + // =========================================================== | ||
22 | + // Constants | ||
23 | + // =========================================================== | ||
24 | + | ||
25 | + private final String KEY_MAPP = "wallet"; | ||
26 | + private final String KEY_ACTION = "action"; | ||
27 | + private final String KEY_ACTION_VALUE = "sharing_response"; | ||
28 | + private final String KEY_SHARING_ID_KEY = "sharing_id"; | ||
29 | + private final String KEY_ACCEPT_KEY = "accept"; | ||
30 | + | ||
31 | + // =========================================================== | ||
32 | + // Fields | ||
33 | + // =========================================================== | ||
34 | + | ||
35 | + private HashMap<String, String> mFilters; | ||
36 | + private long mCacheUpdateInterval = 0; | ||
37 | + private String mSharingId = ""; | ||
38 | + private boolean mIsAccept = false; | ||
39 | + | ||
40 | + // =========================================================== | ||
41 | + // Constructor | ||
42 | + // =========================================================== | ||
43 | + | ||
44 | + /** | ||
45 | + * Default constructor of CosmoteRetrieveSharingRequest, initializes an empty filters HashMap | ||
46 | + */ | ||
47 | + public CosmoteRetrieveSharingRequest() { | ||
48 | + mFilters = new HashMap<>(); | ||
49 | + } | ||
50 | + | ||
51 | + public CosmoteRetrieveSharingRequest(CosmoteRetrieveSharingRequest copy) { | ||
52 | + if (copy != null) { | ||
53 | + this.mFilters = copy.mFilters; | ||
54 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + // =========================================================== | ||
59 | + // Methods for/from SuperClass/Interfaces | ||
60 | + // =========================================================== | ||
61 | + | ||
62 | + @Override | ||
63 | + public boolean equals(Object object) { | ||
64 | + if (object instanceof CosmoteRetrieveSharingRequest) { | ||
65 | + CosmoteRetrieveSharingRequest other = (CosmoteRetrieveSharingRequest) object; | ||
66 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
67 | + } | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public int hashCode() { | ||
73 | + return mFilters.hashCode(); | ||
74 | + } | ||
75 | + | ||
76 | + // =========================================================== | ||
77 | + // Methods | ||
78 | + // =========================================================== | ||
79 | + | ||
80 | + // =========================================================== | ||
81 | + // Getter & Setter | ||
82 | + // =========================================================== | ||
83 | + | ||
84 | + public CosmoteRetrieveSharingRequest setSharingId(String sharingId) { | ||
85 | + mSharingId = sharingId; | ||
86 | + return this; | ||
87 | + } | ||
88 | + | ||
89 | + public CosmoteRetrieveSharingRequest setAccept(boolean acceptGift) { | ||
90 | + mIsAccept = acceptGift; | ||
91 | + return this; | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Call this to get how often the cached data will be updated. | ||
96 | + * | ||
97 | + * @return mCacheUpdateInterval | ||
98 | + */ | ||
99 | + public long getCacheUpdateInterval() { | ||
100 | + return mCacheUpdateInterval; | ||
101 | + } | ||
102 | + | ||
103 | + /** | ||
104 | + * Call this to set how often the cached data will be updated. | ||
105 | + * | ||
106 | + * @param updateInterval The time that data will be cached | ||
107 | + * @return CosmoteRetrieveSharingRequest | ||
108 | + */ | ||
109 | + public CosmoteRetrieveSharingRequest setCacheUpdateInterval(long updateInterval) { | ||
110 | + | ||
111 | + this.mCacheUpdateInterval = updateInterval; | ||
112 | + if (mCacheUpdateInterval < 0) { | ||
113 | + mCacheUpdateInterval = 0; | ||
114 | + } | ||
115 | + return this; | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * Call this to check if the Application uses Cache | ||
120 | + * | ||
121 | + * @return <p>true - the Application is using Cache</p> | ||
122 | + * <p>false - the Application is not using Cache</p> | ||
123 | + */ | ||
124 | + public boolean isUseCache() { | ||
125 | + return mCacheUpdateInterval > 0; | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * Call this to check whether the cached data need to be updated | ||
130 | + * | ||
131 | + * @param useCache <p>true - the Application is using Cache</p> | ||
132 | + * <p>false - the Application is not using Cache</p> | ||
133 | + * @return CosmoteRetrieveSharingRequest | ||
134 | + */ | ||
135 | + public CosmoteRetrieveSharingRequest setUseCache(boolean useCache) { | ||
136 | + | ||
137 | + if (useCache) { | ||
138 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
139 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
140 | + } else { | ||
141 | + mCacheUpdateInterval = 0; | ||
142 | + } | ||
143 | + return this; | ||
144 | + } | ||
145 | + | ||
146 | + /** | ||
147 | + * Call this to build the offers Json object | ||
148 | + * | ||
149 | + * @return bodyJsonObject | ||
150 | + */ | ||
151 | + public JSONObject toJson() { | ||
152 | + JSONObject bodyJsonObject = new JSONObject(); | ||
153 | + try { | ||
154 | + JSONObject extraJson = new JSONObject(); | ||
155 | + extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
156 | + extraJson.putOpt(KEY_SHARING_ID_KEY, mSharingId); | ||
157 | + extraJson.putOpt(KEY_ACCEPT_KEY, mIsAccept); | ||
158 | + bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ||
159 | + } catch (JSONException e) { | ||
160 | + if (WarpConstants.DEBUG) | ||
161 | + e.printStackTrace(); | ||
162 | + } | ||
163 | + return bodyJsonObject; | ||
164 | + } | ||
165 | + | ||
166 | + public String getSignature() { | ||
167 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_cosmote_retrieve_sharing_request"; | ||
168 | + try { | ||
169 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
170 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
171 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
172 | + | UnsupportedEncodingException e) { | ||
173 | + e.printStackTrace(); | ||
174 | + } | ||
175 | + return signature; | ||
176 | + } | ||
177 | +} |
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 23-June-22. | ||
19 | + */ | ||
20 | + | ||
21 | +public class CosmoteSharingRequest { | ||
22 | + | ||
23 | + // =========================================================== | ||
24 | + // Constants | ||
25 | + // =========================================================== | ||
26 | + | ||
27 | + private final String KEY_MAPP = "wallet"; | ||
28 | + private final String KEY_ACTION = "action"; | ||
29 | + private final String KEY_ACTION_VALUE = "sharing_info"; | ||
30 | + private final String KEY_SHARING_ID_KEY = "sharing_id"; | ||
31 | + | ||
32 | + // =========================================================== | ||
33 | + // Fields | ||
34 | + // =========================================================== | ||
35 | + | ||
36 | + private HashMap<String, String> mFilters; | ||
37 | + private long mCacheUpdateInterval = 0; | ||
38 | + private String mSharingId = ""; | ||
39 | + | ||
40 | + // =========================================================== | ||
41 | + // Constructor | ||
42 | + // =========================================================== | ||
43 | + | ||
44 | + /** | ||
45 | + * Default constructor of CosmoteSharingRequest, initializes an empty filters HashMap | ||
46 | + */ | ||
47 | + public CosmoteSharingRequest() { | ||
48 | + mFilters = new HashMap<>(); | ||
49 | + } | ||
50 | + | ||
51 | + public CosmoteSharingRequest(CosmoteSharingRequest copy) { | ||
52 | + if (copy != null) { | ||
53 | + this.mFilters = copy.mFilters; | ||
54 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + // =========================================================== | ||
59 | + // Methods for/from SuperClass/Interfaces | ||
60 | + // =========================================================== | ||
61 | + | ||
62 | + @Override | ||
63 | + public boolean equals(Object object) { | ||
64 | + if (object instanceof CosmoteSharingRequest) { | ||
65 | + CosmoteSharingRequest other = (CosmoteSharingRequest) object; | ||
66 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
67 | + } | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public int hashCode() { | ||
73 | + return mFilters.hashCode(); | ||
74 | + } | ||
75 | + | ||
76 | + // =========================================================== | ||
77 | + // Methods | ||
78 | + // =========================================================== | ||
79 | + | ||
80 | + // =========================================================== | ||
81 | + // Getter & Setter | ||
82 | + // =========================================================== | ||
83 | + | ||
84 | + public CosmoteSharingRequest setSharingId(String sharingId) { | ||
85 | + mSharingId = sharingId; | ||
86 | + return this; | ||
87 | + } | ||
88 | + | ||
89 | + /** | ||
90 | + * Call this to get how often the cached data will be updated. | ||
91 | + * | ||
92 | + * @return mCacheUpdateInterval | ||
93 | + */ | ||
94 | + public long getCacheUpdateInterval() { | ||
95 | + return mCacheUpdateInterval; | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Call this to set how often the cached data will be updated. | ||
100 | + * | ||
101 | + * @param updateInterval The time that data will be cached | ||
102 | + * @return CosmoteSharingRequest | ||
103 | + */ | ||
104 | + public CosmoteSharingRequest setCacheUpdateInterval(long updateInterval) { | ||
105 | + | ||
106 | + this.mCacheUpdateInterval = updateInterval; | ||
107 | + if (mCacheUpdateInterval < 0) { | ||
108 | + mCacheUpdateInterval = 0; | ||
109 | + } | ||
110 | + return this; | ||
111 | + } | ||
112 | + | ||
113 | + /** | ||
114 | + * Call this to check if the Application uses Cache | ||
115 | + * | ||
116 | + * @return <p>true - the Application is using Cache</p> | ||
117 | + * <p>false - the Application is not using Cache</p> | ||
118 | + */ | ||
119 | + public boolean isUseCache() { | ||
120 | + return mCacheUpdateInterval > 0; | ||
121 | + } | ||
122 | + | ||
123 | + /** | ||
124 | + * Call this to check whether the cached data need to be updated | ||
125 | + * | ||
126 | + * @param useCache <p>true - the Application is using Cache</p> | ||
127 | + * <p>false - the Application is not using Cache</p> | ||
128 | + * @return CosmoteSharingRequest | ||
129 | + */ | ||
130 | + public CosmoteSharingRequest setUseCache(boolean useCache) { | ||
131 | + | ||
132 | + if (useCache) { | ||
133 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
134 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
135 | + } else { | ||
136 | + mCacheUpdateInterval = 0; | ||
137 | + } | ||
138 | + return this; | ||
139 | + } | ||
140 | + | ||
141 | + /** | ||
142 | + * Call this to build the offers Json object | ||
143 | + * | ||
144 | + * @return bodyJsonObject | ||
145 | + */ | ||
146 | + public JSONObject toJson() { | ||
147 | + JSONObject bodyJsonObject = new JSONObject(); | ||
148 | + try { | ||
149 | + JSONObject extraJson = new JSONObject(); | ||
150 | + extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
151 | + extraJson.putOpt(KEY_SHARING_ID_KEY, mSharingId); | ||
152 | + bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ||
153 | + } catch (JSONException e) { | ||
154 | + if (WarpConstants.DEBUG) | ||
155 | + e.printStackTrace(); | ||
156 | + } | ||
157 | + return bodyJsonObject; | ||
158 | + } | ||
159 | + | ||
160 | + public String getSignature() { | ||
161 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_cosmote_sharing_request"; | ||
162 | + try { | ||
163 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
164 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
165 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
166 | + | UnsupportedEncodingException e) { | ||
167 | + e.printStackTrace(); | ||
168 | + } | ||
169 | + return signature; | ||
170 | + } | ||
171 | +} |
... | @@ -12,6 +12,7 @@ import java.security.NoSuchAlgorithmException; | ... | @@ -12,6 +12,7 @@ import java.security.NoSuchAlgorithmException; |
12 | import java.util.ArrayList; | 12 | import java.util.ArrayList; |
13 | import java.util.HashMap; | 13 | import java.util.HashMap; |
14 | 14 | ||
15 | +import ly.warp.sdk.utils.WarplyManagerHelper; | ||
15 | import ly.warp.sdk.utils.constants.WarpConstants; | 16 | import ly.warp.sdk.utils.constants.WarpConstants; |
16 | 17 | ||
17 | /** | 18 | /** |
... | @@ -145,15 +146,11 @@ public class WarplyIntegrationRequest { | ... | @@ -145,15 +146,11 @@ public class WarplyIntegrationRequest { |
145 | JSONObject extraJson = new JSONObject(); | 146 | JSONObject extraJson = new JSONObject(); |
146 | extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 147 | extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); |
147 | extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); | 148 | extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); |
148 | - ArrayList list = new ArrayList(); | ||
149 | - list.add("6982853746"); | ||
150 | - list.add("6982853747"); | ||
151 | - list.add("6982853748"); | ||
152 | JSONObject data = new JSONObject(); | 149 | JSONObject data = new JSONObject(); |
153 | - data.putOpt("nonTelco", false); | 150 | + data.putOpt("nonTelco", WarplyManagerHelper.loadCustomerState().isNonTelco()); |
154 | - data.putOpt("acceptedConsent", true); | 151 | + data.putOpt("acceptedConsent", WarplyManagerHelper.loadCustomerState().isAcceptedConsent()); |
155 | - data.putOpt("msisdnList", new JSONArray(list)); | 152 | + data.putOpt("msisdnList", new JSONArray(WarplyManagerHelper.loadCustomerState().getMsisdnList())); |
156 | - data.putOpt("guid", "12345678"); | 153 | + data.putOpt("guid", WarplyManagerHelper.loadCustomerState().getGuid()); |
157 | 154 | ||
158 | extraJson.putOpt(KEY_DATA, data); | 155 | extraJson.putOpt(KEY_DATA, data); |
159 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); | 156 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -60,6 +60,8 @@ import ly.warp.sdk.io.models.ProductList; | ... | @@ -60,6 +60,8 @@ import ly.warp.sdk.io.models.ProductList; |
60 | import ly.warp.sdk.io.models.TagsCategoriesList; | 60 | import ly.warp.sdk.io.models.TagsCategoriesList; |
61 | import ly.warp.sdk.io.models.TagsList; | 61 | import ly.warp.sdk.io.models.TagsList; |
62 | import ly.warp.sdk.io.models.TransactionsList; | 62 | import ly.warp.sdk.io.models.TransactionsList; |
63 | +import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; | ||
64 | +import ly.warp.sdk.io.request.CosmoteSharingRequest; | ||
63 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; | 65 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; |
64 | import ly.warp.sdk.io.request.WarplyAddCardRequest; | 66 | import ly.warp.sdk.io.request.WarplyAddCardRequest; |
65 | import ly.warp.sdk.io.request.WarplyAuthorizeRequest; | 67 | import ly.warp.sdk.io.request.WarplyAuthorizeRequest; |
... | @@ -1349,4 +1351,82 @@ public class WarplyManager { | ... | @@ -1349,4 +1351,82 @@ public class WarplyManager { |
1349 | } | 1351 | } |
1350 | }); | 1352 | }); |
1351 | } | 1353 | } |
1354 | + | ||
1355 | + public static void cosmoteSharing(CosmoteSharingRequest request, final CallbackReceiver<JSONObject> receiver) { | ||
1356 | + WarpUtils.log("************* WARPLY Cosmote Sharing Request ********************"); | ||
1357 | + WarpUtils.log("[WARP Trace] WARPLY Cosmote Sharing Request is active"); | ||
1358 | + WarpUtils.log("**************************************************"); | ||
1359 | + | ||
1360 | + Warply.postReceiveMicroappData(true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | ||
1361 | + @Override | ||
1362 | + public void onSuccess(JSONObject result) { | ||
1363 | + int status = result.optInt("status", 2); | ||
1364 | + if (status == 1) | ||
1365 | + receiver.onSuccess(result); | ||
1366 | + else | ||
1367 | + receiver.onFailure(status); | ||
1368 | + } | ||
1369 | + | ||
1370 | + @Override | ||
1371 | + public void onFailure(int errorCode) { | ||
1372 | + if (errorCode == 401) { | ||
1373 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
1374 | + @Override | ||
1375 | + public void onSuccess(JSONObject result) { | ||
1376 | + int status = result.optInt("status", 2); | ||
1377 | + if (status == 1) | ||
1378 | + cosmoteSharing(request, receiver); | ||
1379 | + else | ||
1380 | + receiver.onFailure(status); | ||
1381 | + } | ||
1382 | + | ||
1383 | + @Override | ||
1384 | + public void onFailure(int errorCode) { | ||
1385 | + receiver.onFailure(errorCode); | ||
1386 | + } | ||
1387 | + }); | ||
1388 | + } else | ||
1389 | + receiver.onFailure(errorCode); | ||
1390 | + } | ||
1391 | + }); | ||
1392 | + } | ||
1393 | + | ||
1394 | + public static void cosmoteRetrieveSharing(CosmoteRetrieveSharingRequest request, final CallbackReceiver<JSONObject> receiver) { | ||
1395 | + WarpUtils.log("************* WARPLY Cosmote Retrieve Sharing Request ********************"); | ||
1396 | + WarpUtils.log("[WARP Trace] WARPLY Cosmote Retrieve Sharing Request is active"); | ||
1397 | + WarpUtils.log("**************************************************"); | ||
1398 | + | ||
1399 | + Warply.postReceiveMicroappData(true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | ||
1400 | + @Override | ||
1401 | + public void onSuccess(JSONObject result) { | ||
1402 | + int status = result.optInt("status", 2); | ||
1403 | + if (status == 1) | ||
1404 | + receiver.onSuccess(result); | ||
1405 | + else | ||
1406 | + receiver.onFailure(status); | ||
1407 | + } | ||
1408 | + | ||
1409 | + @Override | ||
1410 | + public void onFailure(int errorCode) { | ||
1411 | + if (errorCode == 401) { | ||
1412 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
1413 | + @Override | ||
1414 | + public void onSuccess(JSONObject result) { | ||
1415 | + int status = result.optInt("status", 2); | ||
1416 | + if (status == 1) | ||
1417 | + cosmoteRetrieveSharing(request, receiver); | ||
1418 | + else | ||
1419 | + receiver.onFailure(status); | ||
1420 | + } | ||
1421 | + | ||
1422 | + @Override | ||
1423 | + public void onFailure(int errorCode) { | ||
1424 | + receiver.onFailure(errorCode); | ||
1425 | + } | ||
1426 | + }); | ||
1427 | + } else | ||
1428 | + receiver.onFailure(errorCode); | ||
1429 | + } | ||
1430 | + }); | ||
1431 | + } | ||
1352 | } | 1432 | } | ... | ... |
... | @@ -35,7 +35,6 @@ | ... | @@ -35,7 +35,6 @@ |
35 | <string name="cos_coupons_title">ΚΟΥΠΟΝΙΑ</string> | 35 | <string name="cos_coupons_title">ΚΟΥΠΟΝΙΑ</string> |
36 | <string name="cos_coupon_terms_title">Όροι χρήσης</string> | 36 | <string name="cos_coupon_terms_title">Όροι χρήσης</string> |
37 | <string name="cos_redeem_coupon">Απόκτησέ το</string> | 37 | <string name="cos_redeem_coupon">Απόκτησέ το</string> |
38 | - <string name="cos_dlg_success_title">Συγχαρητήρια</string> | ||
39 | <string name="cos_dlg_success_subtitle">Το κουπόνι εξαργυρώθηκε με επιτυχία</string> | 38 | <string name="cos_dlg_success_subtitle">Το κουπόνι εξαργυρώθηκε με επιτυχία</string> |
40 | <string name="cos_dlg_error_title">Αποτυχία</string> | 39 | <string name="cos_dlg_error_title">Αποτυχία</string> |
41 | <string name="cos_dlg_error_subtitle">Κάτι πήγε στραβά</string> | 40 | <string name="cos_dlg_error_subtitle">Κάτι πήγε στραβά</string> |
... | @@ -75,6 +74,16 @@ | ... | @@ -75,6 +74,16 @@ |
75 | <string name="cos_active_gifts_title">Ενεργά δώρα</string> | 74 | <string name="cos_active_gifts_title">Ενεργά δώρα</string> |
76 | <string name="cos_loyalty_analysis">Ανάλυση συναλλαγών</string> | 75 | <string name="cos_loyalty_analysis">Ανάλυση συναλλαγών</string> |
77 | <string name="cos_value">%1$s€</string> | 76 | <string name="cos_value">%1$s€</string> |
77 | + <string name="cos_dlg_success_title">Συγχαρητήρια!</string> | ||
78 | + <string name="cos_dlg_reject_title">Είσαι σίγουρος;</string> | ||
79 | + <string name="cod_dlg_return_title">Επιστροφή δώρου</string> | ||
80 | + <string name="cos_dlg_positive_button">Ενεργοποίηση</string> | ||
81 | + <string name="cos_dlg_negative_button">Απόρριψη</string> | ||
82 | + <string name="cos_dlg_positive_button2">ΟΚ</string> | ||
83 | + <string name="cos_dlg_positive_button_text">Μόλις έλαβες το δώρο σου!</string> | ||
84 | + <string name="cos_dlg_reject_text">Είσαι σίγουρος ότι θέλεις να απορρίψεις το δώρο που μόλις έλαβες;</string> | ||
85 | + <string name="cos_dlg_return_text">Έλαβες πίσω το δώρο σου, κουπόνι αξίας 100€ για τα Intersport</string> | ||
86 | + <string name="cos_dlg_negative_button2">Άκυρο</string> | ||
78 | 87 | ||
79 | <string-array name="coupons_array"> | 88 | <string-array name="coupons_array"> |
80 | <item>Κουπόνια</item> | 89 | <item>Κουπόνια</item> | ... | ... |
-
Please register or login to post a comment