Showing
8 changed files
with
281 additions
and
7 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-cosbeta10' | 5 | + PUBLISH_VERSION = '4.5.4-cosbeta11' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ... | ... |
... | @@ -180,11 +180,11 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -180,11 +180,11 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
180 | mAdapterMergedGifts.getPositionClicks() | 180 | mAdapterMergedGifts.getPositionClicks() |
181 | .doOnNext(dataItem -> { | 181 | .doOnNext(dataItem -> { |
182 | if (dataItem.getDataType() == 1) { | 182 | if (dataItem.getDataType() == 1) { |
183 | - EventBus.getDefault().post(new WarplyEventBusManager().postWarplyEventBus("gifts", new LoyaltyGiftsForYouOfferClickEvent())); | 183 | + EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent())); |
184 | 184 | ||
185 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | 185 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); |
186 | } else if (dataItem.getDataType() == 2) { | 186 | } else if (dataItem.getDataType() == 2) { |
187 | - EventBus.getDefault().post(new WarplyEventBusManager().postWarplyEventBus("ccms", new LoyaltyContextualOfferModel())); | 187 | + EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyContextualOfferModel())); |
188 | 188 | ||
189 | Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class); | 189 | Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class); |
190 | intent.putExtra("couponset", (Serializable) dataItem.getCouponset()); | 190 | intent.putExtra("couponset", (Serializable) dataItem.getCouponset()); | ... | ... |
... | @@ -90,7 +90,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -90,7 +90,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
90 | mRecyclerMore.setAdapter(mAdapterMore); | 90 | mRecyclerMore.setAdapter(mAdapterMore); |
91 | mAdapterMore.getPositionClicks() | 91 | mAdapterMore.getPositionClicks() |
92 | .doOnNext(gift -> { | 92 | .doOnNext(gift -> { |
93 | - EventBus.getDefault().post(new WarplyEventBusManager().postWarplyEventBus("firebase", new LoyaltySDKFirebaseEventModel())); | 93 | + EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltySDKFirebaseEventModel())); |
94 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift))); | 94 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift))); |
95 | }) | 95 | }) |
96 | .doOnError(error -> { | 96 | .doOnError(error -> { | ... | ... |
... | @@ -9,10 +9,14 @@ import java.util.ArrayList; | ... | @@ -9,10 +9,14 @@ import java.util.ArrayList; |
9 | public class CustomerStateModel { | 9 | public class CustomerStateModel { |
10 | private boolean nonTelco = false; | 10 | private boolean nonTelco = false; |
11 | private boolean acceptedConsent = false; | 11 | private boolean acceptedConsent = false; |
12 | + private ArrayList<String> msisdnList = new ArrayList<>(); | ||
13 | + private String guid = ""; | ||
12 | 14 | ||
13 | public CustomerStateModel() { | 15 | public CustomerStateModel() { |
14 | this.nonTelco = false; | 16 | this.nonTelco = false; |
15 | this.acceptedConsent = false; | 17 | this.acceptedConsent = false; |
18 | + this.msisdnList = new ArrayList<>(); | ||
19 | + this.guid = ""; | ||
16 | } | 20 | } |
17 | 21 | ||
18 | public boolean isNonTelco() { | 22 | public boolean isNonTelco() { |
... | @@ -30,4 +34,20 @@ public class CustomerStateModel { | ... | @@ -30,4 +34,20 @@ public class CustomerStateModel { |
30 | public void setAcceptedConsent(boolean acceptedConsent) { | 34 | public void setAcceptedConsent(boolean acceptedConsent) { |
31 | this.acceptedConsent = acceptedConsent; | 35 | this.acceptedConsent = acceptedConsent; |
32 | } | 36 | } |
37 | + | ||
38 | + public ArrayList<String> getMsisdnList() { | ||
39 | + return msisdnList; | ||
40 | + } | ||
41 | + | ||
42 | + public void setMsisdnList(ArrayList<String> msisdnList) { | ||
43 | + this.msisdnList = msisdnList; | ||
44 | + } | ||
45 | + | ||
46 | + public String getGuid() { | ||
47 | + return guid; | ||
48 | + } | ||
49 | + | ||
50 | + public void setGuid(String guid) { | ||
51 | + this.guid = guid; | ||
52 | + } | ||
33 | } | 53 | } | ... | ... |
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.WarplyManagerHelper; | ||
16 | +import ly.warp.sdk.utils.constants.WarpConstants; | ||
17 | + | ||
18 | +/** | ||
19 | + * Created by Panagiotis Triantafyllou on 15-June-22. | ||
20 | + */ | ||
21 | + | ||
22 | +public class WarplyIntegrationRequest { | ||
23 | + | ||
24 | + // =========================================================== | ||
25 | + // Constants | ||
26 | + // =========================================================== | ||
27 | + | ||
28 | + private final String KEY_MAPP = "consumer_data"; | ||
29 | + private final String KEY_ACTION = "action"; | ||
30 | + private final String KEY_ACTION_VALUE = "integration"; | ||
31 | + private final String KEY_DATA = "data"; | ||
32 | + | ||
33 | + // =========================================================== | ||
34 | + // Fields | ||
35 | + // =========================================================== | ||
36 | + | ||
37 | + private HashMap<String, String> mFilters; | ||
38 | + private long mCacheUpdateInterval = 0; | ||
39 | + | ||
40 | + // =========================================================== | ||
41 | + // Constructor | ||
42 | + // =========================================================== | ||
43 | + | ||
44 | + /** | ||
45 | + * Default constructor of WarplyIntegrationRequest, initializes an empty filters HashMap | ||
46 | + */ | ||
47 | + public WarplyIntegrationRequest() { | ||
48 | + mFilters = new HashMap<>(); | ||
49 | + } | ||
50 | + | ||
51 | + public WarplyIntegrationRequest(WarplyIntegrationRequest 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 WarplyIntegrationRequest) { | ||
65 | + WarplyIntegrationRequest other = (WarplyIntegrationRequest) 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 | + /** | ||
85 | + * Call this to get how often the cached data will be updated. | ||
86 | + * | ||
87 | + * @return mCacheUpdateInterval | ||
88 | + */ | ||
89 | + public long getCacheUpdateInterval() { | ||
90 | + return mCacheUpdateInterval; | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Call this to set how often the cached data will be updated. | ||
95 | + * | ||
96 | + * @param updateInterval The time that data will be cached | ||
97 | + * @return WarplyIntegrationRequest | ||
98 | + */ | ||
99 | + public WarplyIntegrationRequest setCacheUpdateInterval(long updateInterval) { | ||
100 | + | ||
101 | + this.mCacheUpdateInterval = updateInterval; | ||
102 | + if (mCacheUpdateInterval < 0) { | ||
103 | + mCacheUpdateInterval = 0; | ||
104 | + } | ||
105 | + return this; | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * Call this to check if the Application uses Cache | ||
110 | + * | ||
111 | + * @return <p>true - the Application is using Cache</p> | ||
112 | + * <p>false - the Application is not using Cache</p> | ||
113 | + */ | ||
114 | + public boolean isUseCache() { | ||
115 | + return mCacheUpdateInterval > 0; | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * Call this to check whether the cached data need to be updated | ||
120 | + * | ||
121 | + * @param useCache <p>true - the Application is using Cache</p> | ||
122 | + * <p>false - the Application is not using Cache</p> | ||
123 | + * @return WarplyIntegrationRequest | ||
124 | + */ | ||
125 | + public WarplyIntegrationRequest setUseCache(boolean useCache) { | ||
126 | + | ||
127 | + if (useCache) { | ||
128 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
129 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
130 | + } else { | ||
131 | + mCacheUpdateInterval = 0; | ||
132 | + } | ||
133 | + return this; | ||
134 | + } | ||
135 | + | ||
136 | + /** | ||
137 | + * Call this to build the offers Json object | ||
138 | + * | ||
139 | + * @return bodyJsonObject | ||
140 | + */ | ||
141 | + public JSONObject toJson() { | ||
142 | + JSONObject bodyJsonObject = new JSONObject(); | ||
143 | + try { | ||
144 | + JSONObject extraJson = new JSONObject(); | ||
145 | + extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
146 | + | ||
147 | + JSONObject data = new JSONObject(); | ||
148 | + data.putOpt("nonTelco", WarplyManagerHelper.loadCustomerState().isNonTelco()); | ||
149 | + data.putOpt("acceptedConsent", WarplyManagerHelper.loadCustomerState().isAcceptedConsent()); | ||
150 | + data.putOpt("msisdnList", new JSONArray(WarplyManagerHelper.loadCustomerState().getMsisdnList())); | ||
151 | + data.putOpt("guid", WarplyManagerHelper.loadCustomerState().getGuid()); | ||
152 | + | ||
153 | + extraJson.putOpt(KEY_DATA, data); | ||
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_integration_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 | +} |
... | @@ -56,6 +56,7 @@ public class WarplyManagerHelper { | ... | @@ -56,6 +56,7 @@ public class WarplyManagerHelper { |
56 | private static HashMap<String, CampaignList> mUniqueCampaignList = new HashMap<String, CampaignList>(); | 56 | private static HashMap<String, CampaignList> mUniqueCampaignList = new HashMap<String, CampaignList>(); |
57 | private static CouponList mCouponList = new CouponList(); | 57 | private static CouponList mCouponList = new CouponList(); |
58 | private static CouponsetsList mCouponsetsList = new CouponsetsList(); | 58 | private static CouponsetsList mCouponsetsList = new CouponsetsList(); |
59 | + private static CustomerStateModel mCustomerStateModel; | ||
59 | 60 | ||
60 | // =========================================================== | 61 | // =========================================================== |
61 | // Methods for/from SuperClass/Interfaces | 62 | // Methods for/from SuperClass/Interfaces |
... | @@ -89,6 +90,30 @@ public class WarplyManagerHelper { | ... | @@ -89,6 +90,30 @@ public class WarplyManagerHelper { |
89 | } | 90 | } |
90 | 91 | ||
91 | /** | 92 | /** |
93 | + * Open Warply campaign with sharing id | ||
94 | + */ | ||
95 | + public static String constructCampaignUrlForShare(Campaign item, String deeplink) { | ||
96 | + item.setNew(false); | ||
97 | + String url = item.getIndexUrl() | ||
98 | + + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) | ||
99 | + + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) | ||
100 | + + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) | ||
101 | + + "&session_uuid=" + item.getSessionUUID() | ||
102 | + + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | ||
103 | + + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") | ||
104 | + + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") | ||
105 | + + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret"); | ||
106 | + /*+ "&sharing_id=" + sharingId;*/ | ||
107 | + | ||
108 | + if (mConsumer != null) | ||
109 | + url = url + "&auth_token=" + (mConsumer.getUuid()); | ||
110 | + else | ||
111 | + url = url + "&auth_token="; | ||
112 | + | ||
113 | + return url; | ||
114 | + } | ||
115 | + | ||
116 | + /** | ||
92 | * Open CCMS campaign | 117 | * Open CCMS campaign |
93 | */ | 118 | */ |
94 | public static String constructCcmsUrl(LoyaltyContextualOfferModel item) { | 119 | public static String constructCcmsUrl(LoyaltyContextualOfferModel item) { |
... | @@ -108,14 +133,25 @@ public class WarplyManagerHelper { | ... | @@ -108,14 +133,25 @@ public class WarplyManagerHelper { |
108 | * Open Questionnaire | 133 | * Open Questionnaire |
109 | */ | 134 | */ |
110 | public static void openQuestionnaire() { | 135 | public static void openQuestionnaire() { |
136 | + if (mUniqueCampaignList != null && mUniqueCampaignList.get("questionnaire") != null && mUniqueCampaignList.get("questionnaire").size() > 0) { | ||
137 | + constructCampaignUrl(mUniqueCampaignList.get("questionnaire").get(0)); | ||
138 | + } | ||
139 | + } | ||
111 | 140 | ||
141 | + /** | ||
142 | + * Save if customer is nonTelco and if he/she has accepted the consents, | ||
143 | + * And his msisdn list | ||
144 | + */ | ||
145 | + public static void saveCustomerState(CustomerStateModel customerState) { | ||
146 | + mCustomerStateModel = customerState; | ||
112 | } | 147 | } |
113 | 148 | ||
114 | /** | 149 | /** |
115 | - * Save if customer is nonTelco and if he/she has accepted the consents | 150 | + * Get if customer is nonTelco and if he/she has accepted the consents |
151 | + * And his msisdn list | ||
116 | */ | 152 | */ |
117 | - public static void loadCustomerState(CustomerStateModel customerState) { | 153 | + public static CustomerStateModel loadCustomerState() { |
118 | - //TODO: write code to save the parameter | 154 | + return mCustomerStateModel; |
119 | } | 155 | } |
120 | 156 | ||
121 | /** | 157 | /** | ... | ... |
... | @@ -22,6 +22,7 @@ public class WarplyEventBusManager { | ... | @@ -22,6 +22,7 @@ public class WarplyEventBusManager { |
22 | private WarplyPacingCardServiceEnabledModel pacingService; | 22 | private WarplyPacingCardServiceEnabledModel pacingService; |
23 | private WarplyDealsAnalysisEventModel dealsAnalysis; | 23 | private WarplyDealsAnalysisEventModel dealsAnalysis; |
24 | private WarplyCCMSEnabledModel ccmsActivated; | 24 | private WarplyCCMSEnabledModel ccmsActivated; |
25 | + private LoyaltyGiftsForYouOfferClickEvent giftsYou; | ||
25 | 26 | ||
26 | public WarplyEventBusManager() { | 27 | public WarplyEventBusManager() { |
27 | 28 | ||
... | @@ -73,6 +74,10 @@ public class WarplyEventBusManager { | ... | @@ -73,6 +74,10 @@ public class WarplyEventBusManager { |
73 | return this; | 74 | return this; |
74 | } | 75 | } |
75 | 76 | ||
77 | + public WarplyEventBusManager(LoyaltyGiftsForYouOfferClickEvent giftsYou) { | ||
78 | + this.giftsYou = giftsYou; | ||
79 | + } | ||
80 | + | ||
76 | public HashMap<String, Object> subscribeWarplyEventBus() { | 81 | public HashMap<String, Object> subscribeWarplyEventBus() { |
77 | return mWarplyEventBusManager; | 82 | return mWarplyEventBusManager; |
78 | } | 83 | } | ... | ... |
... | @@ -76,6 +76,7 @@ import ly.warp.sdk.io.request.WarplyGetAddressRequest; | ... | @@ -76,6 +76,7 @@ import ly.warp.sdk.io.request.WarplyGetAddressRequest; |
76 | import ly.warp.sdk.io.request.WarplyGetCampaignsRequest; | 76 | import ly.warp.sdk.io.request.WarplyGetCampaignsRequest; |
77 | import ly.warp.sdk.io.request.WarplyGetCardsRequest; | 77 | import ly.warp.sdk.io.request.WarplyGetCardsRequest; |
78 | import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest; | 78 | import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest; |
79 | +import ly.warp.sdk.io.request.WarplyIntegrationRequest; | ||
79 | import ly.warp.sdk.io.request.WarplyLoginRequest; | 80 | import ly.warp.sdk.io.request.WarplyLoginRequest; |
80 | import ly.warp.sdk.io.request.WarplyMerchantCategoriesRequest; | 81 | import ly.warp.sdk.io.request.WarplyMerchantCategoriesRequest; |
81 | import ly.warp.sdk.io.request.WarplyMerchantsRequest; | 82 | import ly.warp.sdk.io.request.WarplyMerchantsRequest; |
... | @@ -1309,4 +1310,43 @@ public class WarplyManager { | ... | @@ -1309,4 +1310,43 @@ public class WarplyManager { |
1309 | }, | 1310 | }, |
1310 | request.getSignature())); | 1311 | request.getSignature())); |
1311 | } | 1312 | } |
1313 | + | ||
1314 | + public static void consumerIntegration(WarplyIntegrationRequest request, final CallbackReceiver<JSONObject> receiver) { | ||
1315 | + WarpUtils.log("************* WARPLY Integration Consumer Request ********************"); | ||
1316 | + WarpUtils.log("[WARP Trace] WARPLY Integration Consumer Request is active"); | ||
1317 | + WarpUtils.log("**************************************************"); | ||
1318 | + | ||
1319 | + Warply.postReceiveMicroappData(true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | ||
1320 | + @Override | ||
1321 | + public void onSuccess(JSONObject result) { | ||
1322 | + int status = result.optInt("status", 2); | ||
1323 | + if (status == 1) | ||
1324 | + receiver.onSuccess(result); | ||
1325 | + else | ||
1326 | + receiver.onFailure(status); | ||
1327 | + } | ||
1328 | + | ||
1329 | + @Override | ||
1330 | + public void onFailure(int errorCode) { | ||
1331 | + if (errorCode == 401) { | ||
1332 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
1333 | + @Override | ||
1334 | + public void onSuccess(JSONObject result) { | ||
1335 | + int status = result.optInt("status", 2); | ||
1336 | + if (status == 1) | ||
1337 | + consumerIntegration(request, receiver); | ||
1338 | + else | ||
1339 | + receiver.onFailure(status); | ||
1340 | + } | ||
1341 | + | ||
1342 | + @Override | ||
1343 | + public void onFailure(int errorCode) { | ||
1344 | + receiver.onFailure(errorCode); | ||
1345 | + } | ||
1346 | + }); | ||
1347 | + } else | ||
1348 | + receiver.onFailure(errorCode); | ||
1349 | + } | ||
1350 | + }); | ||
1351 | + } | ||
1312 | } | 1352 | } | ... | ... |
-
Please register or login to post a comment