Showing
5 changed files
with
309 additions
and
18 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-cosbeta33' | 5 | + PUBLISH_VERSION = '4.5.4-cosbeta34' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ... | ... |
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 15-July-22. | ||
17 | + */ | ||
18 | + | ||
19 | +public class CosmoteSubmitOrderRequest { | ||
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 = "add_product"; | ||
28 | + private final String KEY_PRODUCT_UUID = "product_uuid"; | ||
29 | + private final String KEY_PRODUCT_UUID_VALUE = "011d21908d984e3cbecbdfd2920a5d3b"; | ||
30 | + private final String KEY_COMMUNICATION_UUID = "communication_uuid"; | ||
31 | + private final String KEY_EXTRA_DATA = "extra_data"; | ||
32 | + private final String KEY_USER_MSISDN = "user_msisdn"; | ||
33 | + private final String KEY_BUSINESS_SERVICE = "businessService"; | ||
34 | + private final String KEY_OFFER_NAME = "offerName"; | ||
35 | + private final String KEY_PRODUCT_TYPE = "productType"; | ||
36 | + private final String KEY_PROV_DURATION = "provDuration"; | ||
37 | + private final String KEY_NO_OF_RECURRANCE = "noOfRecurrance"; | ||
38 | + private final String KEY_PRICE = "price"; | ||
39 | + private final String KEY_DISCOUNT = "discount"; | ||
40 | + private final String KEY_VOICE_CATEGORY = "voiceCategory"; | ||
41 | + private final String KEY_DATA_CATEGORY = "dataCategory"; | ||
42 | + private final String KEY_MINS_VALUE = "minsValue"; | ||
43 | + private final String KEY_DATA_VALUE = "dataValue"; | ||
44 | + private final String KEY_PROV_STEP_VALUE_MINS = "provStepValueMins"; | ||
45 | + | ||
46 | + // =========================================================== | ||
47 | + // Fields | ||
48 | + // =========================================================== | ||
49 | + | ||
50 | + private HashMap<String, String> mFilters; | ||
51 | + private long mCacheUpdateInterval = 0; | ||
52 | + private String mCommunicationUuid = ""; | ||
53 | + private String mUserMsisdn = ""; | ||
54 | + private String mBusinessService = ""; | ||
55 | + private String mOfferName = ""; | ||
56 | + private String mProductType = ""; | ||
57 | + private String mProvDuration = ""; | ||
58 | + private String mNoOfRecurrance = ""; | ||
59 | + private String mPrice = ""; | ||
60 | + private String mDiscount = ""; | ||
61 | + private String mVoiceCategory = ""; | ||
62 | + private String mDataCategory = ""; | ||
63 | + private String mMinsValue = ""; | ||
64 | + private String mDataValue = ""; | ||
65 | + private String mProvStepValueMins = ""; | ||
66 | + | ||
67 | + // =========================================================== | ||
68 | + // Constructor | ||
69 | + // =========================================================== | ||
70 | + | ||
71 | + /** | ||
72 | + * Default constructor of CosmoteSharingRequest, initializes an empty filters HashMap | ||
73 | + */ | ||
74 | + public CosmoteSubmitOrderRequest() { | ||
75 | + mFilters = new HashMap<>(); | ||
76 | + } | ||
77 | + | ||
78 | + public CosmoteSubmitOrderRequest(CosmoteSubmitOrderRequest copy) { | ||
79 | + if (copy != null) { | ||
80 | + this.mFilters = copy.mFilters; | ||
81 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
82 | + } | ||
83 | + } | ||
84 | + | ||
85 | + // =========================================================== | ||
86 | + // Methods for/from SuperClass/Interfaces | ||
87 | + // =========================================================== | ||
88 | + | ||
89 | + @Override | ||
90 | + public boolean equals(Object object) { | ||
91 | + if (object instanceof CosmoteSubmitOrderRequest) { | ||
92 | + CosmoteSubmitOrderRequest other = (CosmoteSubmitOrderRequest) object; | ||
93 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
94 | + } | ||
95 | + return false; | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public int hashCode() { | ||
100 | + return mFilters.hashCode(); | ||
101 | + } | ||
102 | + | ||
103 | + // =========================================================== | ||
104 | + // Methods | ||
105 | + // =========================================================== | ||
106 | + | ||
107 | + // =========================================================== | ||
108 | + // Getter & Setter | ||
109 | + // =========================================================== | ||
110 | + | ||
111 | + public CosmoteSubmitOrderRequest setCommunicationUuid(String communicationUuid) { | ||
112 | + mCommunicationUuid = communicationUuid; | ||
113 | + return this; | ||
114 | + } | ||
115 | + | ||
116 | + public CosmoteSubmitOrderRequest setUserMsisdn(String userMsisdn) { | ||
117 | + mUserMsisdn = userMsisdn; | ||
118 | + return this; | ||
119 | + } | ||
120 | + | ||
121 | + public CosmoteSubmitOrderRequest setBusinessService(String businessService) { | ||
122 | + mBusinessService = businessService; | ||
123 | + return this; | ||
124 | + } | ||
125 | + | ||
126 | + public CosmoteSubmitOrderRequest setOfferName(String offerName) { | ||
127 | + mOfferName = offerName; | ||
128 | + return this; | ||
129 | + } | ||
130 | + | ||
131 | + public CosmoteSubmitOrderRequest setProductType(String productType) { | ||
132 | + mProductType = productType; | ||
133 | + return this; | ||
134 | + } | ||
135 | + | ||
136 | + public CosmoteSubmitOrderRequest setProvDuration(String provDuration) { | ||
137 | + mProvDuration = provDuration; | ||
138 | + return this; | ||
139 | + } | ||
140 | + | ||
141 | + public CosmoteSubmitOrderRequest setNoOfRecurrance(String noOfRecurrance) { | ||
142 | + mNoOfRecurrance = noOfRecurrance; | ||
143 | + return this; | ||
144 | + } | ||
145 | + | ||
146 | + public CosmoteSubmitOrderRequest setPrice(String price) { | ||
147 | + mPrice = price; | ||
148 | + return this; | ||
149 | + } | ||
150 | + | ||
151 | + public CosmoteSubmitOrderRequest setDiscount(String discount) { | ||
152 | + mDiscount = discount; | ||
153 | + return this; | ||
154 | + } | ||
155 | + | ||
156 | + public CosmoteSubmitOrderRequest setVoiceCategory(String voiceCategory) { | ||
157 | + mVoiceCategory = voiceCategory; | ||
158 | + return this; | ||
159 | + } | ||
160 | + | ||
161 | + public CosmoteSubmitOrderRequest setDataCategory(String dataCategory) { | ||
162 | + mDataCategory = dataCategory; | ||
163 | + return this; | ||
164 | + } | ||
165 | + | ||
166 | + public CosmoteSubmitOrderRequest setMinsValue(String minsValue) { | ||
167 | + mMinsValue = minsValue; | ||
168 | + return this; | ||
169 | + } | ||
170 | + | ||
171 | + public CosmoteSubmitOrderRequest setDataValue(String dataValue) { | ||
172 | + mDataValue = dataValue; | ||
173 | + return this; | ||
174 | + } | ||
175 | + | ||
176 | + public CosmoteSubmitOrderRequest setProvStepValueMins(String provStepValueMins) { | ||
177 | + mProvStepValueMins = provStepValueMins; | ||
178 | + return this; | ||
179 | + } | ||
180 | + | ||
181 | + /** | ||
182 | + * Call this to get how often the cached data will be updated. | ||
183 | + * | ||
184 | + * @return mCacheUpdateInterval | ||
185 | + */ | ||
186 | + public long getCacheUpdateInterval() { | ||
187 | + return mCacheUpdateInterval; | ||
188 | + } | ||
189 | + | ||
190 | + /** | ||
191 | + * Call this to set how often the cached data will be updated. | ||
192 | + * | ||
193 | + * @param updateInterval The time that data will be cached | ||
194 | + * @return CosmoteSharingRequest | ||
195 | + */ | ||
196 | + public CosmoteSubmitOrderRequest setCacheUpdateInterval(long updateInterval) { | ||
197 | + | ||
198 | + this.mCacheUpdateInterval = updateInterval; | ||
199 | + if (mCacheUpdateInterval < 0) { | ||
200 | + mCacheUpdateInterval = 0; | ||
201 | + } | ||
202 | + return this; | ||
203 | + } | ||
204 | + | ||
205 | + /** | ||
206 | + * Call this to check if the Application uses Cache | ||
207 | + * | ||
208 | + * @return <p>true - the Application is using Cache</p> | ||
209 | + * <p>false - the Application is not using Cache</p> | ||
210 | + */ | ||
211 | + public boolean isUseCache() { | ||
212 | + return mCacheUpdateInterval > 0; | ||
213 | + } | ||
214 | + | ||
215 | + /** | ||
216 | + * Call this to check whether the cached data need to be updated | ||
217 | + * | ||
218 | + * @param useCache <p>true - the Application is using Cache</p> | ||
219 | + * <p>false - the Application is not using Cache</p> | ||
220 | + * @return CosmoteSharingRequest | ||
221 | + */ | ||
222 | + public CosmoteSubmitOrderRequest setUseCache(boolean useCache) { | ||
223 | + | ||
224 | + if (useCache) { | ||
225 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
226 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
227 | + } else { | ||
228 | + mCacheUpdateInterval = 0; | ||
229 | + } | ||
230 | + return this; | ||
231 | + } | ||
232 | + | ||
233 | + /** | ||
234 | + * Call this to build the offers Json object | ||
235 | + * | ||
236 | + * @return bodyJsonObject | ||
237 | + */ | ||
238 | + public JSONObject toJson() { | ||
239 | + JSONObject bodyJsonObject = new JSONObject(); | ||
240 | + try { | ||
241 | + JSONObject extraJson = new JSONObject(); | ||
242 | + extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
243 | + extraJson.putOpt(KEY_PRODUCT_UUID, KEY_PRODUCT_UUID_VALUE); | ||
244 | + | ||
245 | + bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ||
246 | + } catch (JSONException e) { | ||
247 | + if (WarpConstants.DEBUG) | ||
248 | + e.printStackTrace(); | ||
249 | + } | ||
250 | + return bodyJsonObject; | ||
251 | + } | ||
252 | + | ||
253 | + public String getSignature() { | ||
254 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_cosmote_sharing_request"; | ||
255 | + try { | ||
256 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
257 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
258 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
259 | + | UnsupportedEncodingException e) { | ||
260 | + e.printStackTrace(); | ||
261 | + } | ||
262 | + return signature; | ||
263 | + } | ||
264 | +} |
... | @@ -38,10 +38,10 @@ public class WarplyIntegrationRequest { | ... | @@ -38,10 +38,10 @@ public class WarplyIntegrationRequest { |
38 | 38 | ||
39 | private HashMap<String, String> mFilters; | 39 | private HashMap<String, String> mFilters; |
40 | private long mCacheUpdateInterval = 0; | 40 | private long mCacheUpdateInterval = 0; |
41 | - private boolean isNonTelco = false; | 41 | + private boolean mIsNonTelco = false; |
42 | - private boolean hasAcceptedConsent = false; | 42 | + private boolean mHasAcceptedConsent = false; |
43 | - private String guid = ""; | 43 | + private String mGuid = ""; |
44 | - private ArrayList<String> phoneList = new ArrayList<>(); | 44 | + private ArrayList<String> mPhoneList = new ArrayList<>(); |
45 | 45 | ||
46 | // =========================================================== | 46 | // =========================================================== |
47 | // Constructor | 47 | // Constructor |
... | @@ -51,7 +51,11 @@ public class WarplyIntegrationRequest { | ... | @@ -51,7 +51,11 @@ public class WarplyIntegrationRequest { |
51 | * Default constructor of WarplyIntegrationRequest, initializes an empty filters HashMap | 51 | * Default constructor of WarplyIntegrationRequest, initializes an empty filters HashMap |
52 | */ | 52 | */ |
53 | public WarplyIntegrationRequest() { | 53 | public WarplyIntegrationRequest() { |
54 | - mFilters = new HashMap<>(); | 54 | + this.mFilters = new HashMap<>(); |
55 | + this.mIsNonTelco = false; | ||
56 | + this.mHasAcceptedConsent = false; | ||
57 | + this.mGuid = ""; | ||
58 | + this.mPhoneList = new ArrayList<>(); | ||
55 | } | 59 | } |
56 | 60 | ||
57 | public WarplyIntegrationRequest(WarplyIntegrationRequest copy) { | 61 | public WarplyIntegrationRequest(WarplyIntegrationRequest copy) { |
... | @@ -88,22 +92,22 @@ public class WarplyIntegrationRequest { | ... | @@ -88,22 +92,22 @@ public class WarplyIntegrationRequest { |
88 | // =========================================================== | 92 | // =========================================================== |
89 | 93 | ||
90 | public WarplyIntegrationRequest setIsNoTelco(boolean isNonTelco) { | 94 | public WarplyIntegrationRequest setIsNoTelco(boolean isNonTelco) { |
91 | - isNonTelco = isNonTelco; | 95 | + this.mIsNonTelco = isNonTelco; |
92 | return this; | 96 | return this; |
93 | } | 97 | } |
94 | 98 | ||
95 | public WarplyIntegrationRequest setHasAcceptedConsent(boolean hasAcceptedConsent) { | 99 | public WarplyIntegrationRequest setHasAcceptedConsent(boolean hasAcceptedConsent) { |
96 | - hasAcceptedConsent = hasAcceptedConsent; | 100 | + this.mHasAcceptedConsent = hasAcceptedConsent; |
97 | return this; | 101 | return this; |
98 | } | 102 | } |
99 | 103 | ||
100 | public WarplyIntegrationRequest setMsisdnList(ArrayList<String> phoneList) { | 104 | public WarplyIntegrationRequest setMsisdnList(ArrayList<String> phoneList) { |
101 | - phoneList = phoneList; | 105 | + this.mPhoneList = phoneList; |
102 | return this; | 106 | return this; |
103 | } | 107 | } |
104 | 108 | ||
105 | public WarplyIntegrationRequest setGuid(String guid) { | 109 | public WarplyIntegrationRequest setGuid(String guid) { |
106 | - guid = guid; | 110 | + this.mGuid = guid; |
107 | return this; | 111 | return this; |
108 | } | 112 | } |
109 | 113 | ||
... | @@ -171,10 +175,10 @@ public class WarplyIntegrationRequest { | ... | @@ -171,10 +175,10 @@ public class WarplyIntegrationRequest { |
171 | extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 175 | extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); |
172 | extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); | 176 | extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); |
173 | JSONObject data = new JSONObject(); | 177 | JSONObject data = new JSONObject(); |
174 | - data.putOpt("nonTelco", isNonTelco); | 178 | + data.putOpt("nonTelco", mIsNonTelco); |
175 | - data.putOpt("acceptedConsent", hasAcceptedConsent); | 179 | + data.putOpt("acceptedConsent", mHasAcceptedConsent); |
176 | - data.putOpt("msisdnList", new JSONArray(phoneList)); | 180 | + data.putOpt("msisdnList", new JSONArray(mPhoneList)); |
177 | - data.putOpt("guid", guid); | 181 | + data.putOpt("guid", mGuid); |
178 | 182 | ||
179 | extraJson.putOpt(KEY_DATA, data); | 183 | extraJson.putOpt(KEY_DATA, data); |
180 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); | 184 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ... | ... |
... | @@ -579,10 +579,10 @@ public class WarplyManagerHelper { | ... | @@ -579,10 +579,10 @@ public class WarplyManagerHelper { |
579 | mCustomerStateModel = customerState; | 579 | mCustomerStateModel = customerState; |
580 | 580 | ||
581 | WarplyIntegrationRequest request = new WarplyIntegrationRequest(); | 581 | WarplyIntegrationRequest request = new WarplyIntegrationRequest(); |
582 | - request.setIsNoTelco(customerState.isNonTelco()); | 582 | + request.setIsNoTelco(customerState.isNonTelco()) |
583 | - request.setHasAcceptedConsent(customerState.isAcceptedConsent()); | 583 | + .setHasAcceptedConsent(customerState.isAcceptedConsent()) |
584 | - request.setGuid(customerState.getGuid()); | 584 | + .setGuid(customerState.getGuid()) |
585 | - request.setMsisdnList(customerState.getMsisdnList()); | 585 | + .setMsisdnList(customerState.getMsisdnList()); |
586 | WarplyManager.consumerIntegration(request, new CallbackReceiver<JSONObject>() { | 586 | WarplyManager.consumerIntegration(request, new CallbackReceiver<JSONObject>() { |
587 | @Override | 587 | @Override |
588 | public void onSuccess(JSONObject result) { | 588 | public void onSuccess(JSONObject result) { | ... | ... |
... | @@ -75,6 +75,7 @@ import ly.warp.sdk.io.models.TransactionsList; | ... | @@ -75,6 +75,7 @@ import ly.warp.sdk.io.models.TransactionsList; |
75 | import ly.warp.sdk.io.request.CosmoteCouponSharingRequest; | 75 | import ly.warp.sdk.io.request.CosmoteCouponSharingRequest; |
76 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; | 76 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; |
77 | import ly.warp.sdk.io.request.CosmoteSharingRequest; | 77 | import ly.warp.sdk.io.request.CosmoteSharingRequest; |
78 | +import ly.warp.sdk.io.request.CosmoteSubmitOrderRequest; | ||
78 | import ly.warp.sdk.io.request.PacingDetailsRequest; | 79 | import ly.warp.sdk.io.request.PacingDetailsRequest; |
79 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; | 80 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; |
80 | import ly.warp.sdk.io.request.WarplyAddCardRequest; | 81 | import ly.warp.sdk.io.request.WarplyAddCardRequest; |
... | @@ -2244,4 +2245,26 @@ public class WarplyManager { | ... | @@ -2244,4 +2245,26 @@ public class WarplyManager { |
2244 | } | 2245 | } |
2245 | }); | 2246 | }); |
2246 | } | 2247 | } |
2248 | + | ||
2249 | + public static void submitOrder(CosmoteSubmitOrderRequest request, final CallbackReceiver<JSONObject> receiver) { | ||
2250 | + WarpUtils.log("************* WARPLY Submit Order Request ********************"); | ||
2251 | + WarpUtils.log("[WARP Trace] WARPLY Submit Order Request is active"); | ||
2252 | + WarpUtils.log("**************************************************"); | ||
2253 | + | ||
2254 | + Warply.postReceiveMicroappData(true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | ||
2255 | + @Override | ||
2256 | + public void onSuccess(JSONObject result) { | ||
2257 | + int status = result.optInt("status", 2); | ||
2258 | + if (status == 1) { | ||
2259 | + | ||
2260 | + } else | ||
2261 | + receiver.onFailure(status); | ||
2262 | + } | ||
2263 | + | ||
2264 | + @Override | ||
2265 | + public void onFailure(int errorCode) { | ||
2266 | + receiver.onFailure(errorCode); | ||
2267 | + } | ||
2268 | + }); | ||
2269 | + } | ||
2247 | } | 2270 | } | ... | ... |
-
Please register or login to post a comment