Vasilis

setLang added

1 -Prerequisites
2 -• Android 6 or greater
3 -• Android Studio 3.6 or greater
4 -• JDK 8 or greater
5 -
6 -Installation
7 -1. Top level build.gradle
8 -In repositories section of the buildscript and the allProjects block add
9 -mavenCentral()
10 -
11 -2. Module level build.gradle
12 -dependencies {
13 - implementation 'ly.warp:warply-android-sdk:4.5.0'
14 -}
15 -
16 -Configuration - SDK
17 -We need to add to the assets folder the below file
18 -warply.properties
19 -
20 -Uuid The app uuid the warply sdk need to connect to the engage server
21 -Business section will provide it for you
22 -Debug If we need to see logs in Logcat
23 -BaseURL Production or Development environment of the engage server
24 -Production: https://engage.warp.ly
25 -Development: https://engage-stage.warp.ly
26 -ProgressColor Replace the color with one you want the progress bar to have depending on you app theme coloring
27 -If not defined the colorPrimary will be used
28 -ProgressDrawable Replace the drawable with one you want (this will show when webview loading)
29 -If not defined the launcher icon will be used
30 -PushColor If not defined the colorPrimary will be used
31 -PushIcon If not defined the launcher icon will used (better use the clipart icons for support black/white icons on 24+)
32 -PushSound If not defined the default will be used
33 -SendPackages If the device packages need to be send to the engage server
34 -Language The app language
35 -MerchantId The merchant id for some requests
36 -LoginType The login type must be one of the below:
37 -email, msisdn, username
38 -DL_URL_SCHEME Only for react native app
39 -The deeplink url scheme for react native campaigns
40 -
41 -Configuration - Push Notifications (FCM/HMS)
42 -1. Top level build.gradle
43 -In repositories section of the buildscript and the allProjects block add
44 -maven { url 'https://developer.huawei.com/repo/' }
45 -This is only for HMS
46 -
47 -2. Top level build.gradle
48 -In dependencies section add
49 -classpath 'com.google.gms:google-services:4.3.10'
50 -classpath 'com.huawei.agconnect:agcp:1.6.2.300'
51 -
52 -3. Module level build.gradle, at the top of it add
53 -apply plugin: 'com.google.gms.google-services'
54 -apply plugin: 'com.huawei.agconnect'
55 -
56 -4. Inside the app folder we need to add each or both json file(s)
57 - google-services
58 -agconnect-services
59 -
60 -Initialization
61 -1. In the starting activity of the application (i.e SplashActivity), we have to add the lines below
62 -
63 -1a.
64 -private WarplyInitializer mWarplyInitializer;
65 -1b.
66 - @Override
67 - protected void onCreate(Bundle savedInstanceState) {
68 - super.onCreate(savedInstanceState);
69 - setContentView(R.layout.activity_splash);
70 -
71 - mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() {
72 - @Override
73 - public void onWarplyReady() {
74 - //Maybe go to next Activity or whatever
75 - }
76 -
77 - @Override
78 - public void onWarplyInitTimeOut() {
79 -
80 - }
81 -
82 - @Override
83 - public void onWarplyPermissionsDenied() {
84 -
85 - }
86 - });
87 -}
88 -
89 -
90 -
91 -
92 -1c.
93 -@Override
94 - protected void onResume() {
95 - super.onResume();
96 - mWarplyInitializer.initWithPermissions(this);
97 - }
98 -1d. If we have a BaseActivity that other activities extend it, optionally (or in the starting activity), we can track when our application created, resumed or paused.
99 -
100 -@Override
101 - public void onCreate(Bundle savedInstanceState) {
102 - super.onCreate(savedInstanceState);
103 - WarplySessionManager.onCreateActivity(this);
104 - }
105 -
106 - @Override
107 - protected void onStart() {
108 - super.onStart();
109 - WarplySessionManager.onStartActivity(this);
110 - }
111 -
112 - @Override
113 - protected void onStop() {
114 - super.onStop();
115 - WarplySessionManager.onStopActivity(this);
116 - }
117 -
118 -
119 -
120 -
121 -
122 -
123 -
124 -
125 -Requests
126 -
127 -1. Campaigns
128 -
129 -Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
130 -
131 -
132 -private CallbackReceiver<CampaignList> mInboxReceiver =
133 - new CallbackReceiver<CampaignList>() {
134 - @Override
135 - public void onSuccess(CampaignList result) {
136 -
137 - }
138 -
139 - @Override
140 - public void onFailure(int errorCode) {
141 -
142 - }
143 - };
144 -
145 -
146 -2. Products
147 -
148 -The “gift” parameter refers to the category of the product (gift, fruit, other custom category etc) that has been created on the engage platform. Empty parameter or without the .setProductFilter method, we will get all the products from all categories that have been created on the engage platform.
149 -* The setLanguage method is used to search on the language we provide.
150 -WarplyManager.getProducts(new WarplyProductsRequest().setProductFilter("gift"), mProductsReceiver);
151 -
152 -
153 -private CallbackReceiver<ProductList> mProductsReceiver = new CallbackReceiver<ProductList>() {
154 - @Override
155 - public void onSuccess(ProductList result) {
156 -
157 - }
158 -
159 - @Override
160 - public void onFailure(int errorCode) {
161 -
162 - }
163 -};
164 -
165 -
166 -3. Merchants
167 -
168 -Better use (30 : Merchants Multilingual request)
169 -WarplyManager.getMerchants(new WarplyMerchantsRequest(), mShopsReceiver);
170 -
171 -
172 -private CallbackReceiver<MerchantList> mShopsReceiver = new CallbackReceiver<MerchantList>() {
173 - @Override
174 - public void onSuccess(MerchantList result) {
175 -
176 - }
177 -
178 - @Override
179 - public void onFailure(int errorCode) {
180 -
181 - }
182 -};
183 -
184 -
185 -4. Content
186 -
187 -The “Article” parameter refers to the category that each content has been created on the engage platform. Empty parameter or without the .setContentCategory method, we will get all content from all categories that have been created on the engage platform.
188 -Respectively and in combination with content category we also have the .setTags method that refers to keywords every content item may has (i.e fun, beach, book etc).
189 -* The .setTags method takes an list with keyword names as string.
190 -* The setLanguage method is used to search on the language we provide.
191 -WarplyManager.getContent(new WarplyContentRequest().setContentCategory("Article").setTags(ArrayList<String>), mContentReceiver);
192 -
193 -
194 -private CallbackReceiver<ContentList> mContentReceiver = new CallbackReceiver<ContentList>() {
195 - @Override
196 - public void onSuccess(ContentList result) {
197 -
198 - }
199 -
200 - @Override
201 - public void onFailure(int errorCode) {
202 -
203 - }
204 -};
205 -
206 -
207 -5. Merchant Categories
208 -
209 -Returns the merchant categories the merchants belong to.
210 -* The setLanguage method is used to search on the language we provide.
211 -WarplyManager.getMerchantCategories(new WarplyMerchantCategoriesRequest(), mShopCategoriesReceiver);
212 -
213 -
214 -private CallbackReceiver<MerchantCategoriesList> mShopCategoriesReceiver = new CallbackReceiver<MerchantCategoriesList>() {
215 - @Override
216 - public void onSuccess(MerchantCategoriesList result) {
217 -
218 - }
219 -
220 - @Override
221 - public void onFailure(int errorCode) {
222 -
223 - }
224 -};
225 -
226 -
227 -6. Tags Categories
228 -
229 -Returns the categories of the tags that has been created on the engage platform.
230 -* The setLanguage method is used to search on the language we provide.
231 -WarplyManager.getTagsCategories(new WarplyTagsCategoriesRequest(), mTagsCategoriesReceiver);
232 -
233 -
234 -private CallbackReceiver<TagsCategoriesList> mTagsCategoriesReceiver = new CallbackReceiver<TagsCategoriesList>() {
235 - @Override
236 - public void onSuccess(TagsCategoriesList result) {
237 -
238 - }
239 -
240 - @Override
241 - public void onFailure(int errorCode) {
242 -
243 - }
244 -};
245 -
246 -
247 -7. Tags
248 -
249 -Returns the tags that has been created on the engage platform.
250 -Each tag item includes a category kay so in combination with the (6) to know in which category it belongs to.
251 -Each tag item has a name and a uuid key. The name can be used in (4 : setTags) and the uuid in (31 : setTags).
252 -* The setLanguage method is used to search on the language we provide.
253 -WarplyManager.getTags(new WarplyTagsRequest(), mTagsReceiver);
254 -
255 -
256 -private CallbackReceiver<TagsList> mTagsReceiver = new CallbackReceiver<TagsList>() {
257 - @Override
258 - public void onSuccess(TagsList result) {
259 -
260 - }
261 -
262 - @Override
263 - public void onFailure(int errorCode) {
264 -
265 - }
266 -};
267 -
268 -
269 -
270 -
271 -8. Contact
272 -
273 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
274 -WarplyManager.sendContact(new WarplyContactRequest()
275 - .setContactSubject("Other")
276 - .setContactName("Testaros")
277 - .setContactEmail("test@test.com")
278 - .setContactNumber("")
279 - .setContactMessage("Test comments"),
280 - mContactReceiver);
281 -
282 -
283 -private CallbackReceiver<JSONObject> mContactReceiver = new CallbackReceiver<JSONObject>() {
284 - @Override
285 - public void onSuccess(JSONObject result) {
286 -
287 - }
288 -
289 - @Override
290 - public void onFailure(int errorCode) {
291 -
292 - }
293 -};
294 -
295 -
296 -9. Login
297 -
298 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
299 -The .setId method must be one of email, msisdn or username and refers to the LoginType in warply.properties file.
300 -WarplyManager.login(new WarplyLoginRequest()
301 - .setId("email/msisdn/username")
302 - .setPassword(""),
303 - mLoginReceiver);
304 -
305 -
306 -private CallbackReceiver<JSONObject> mLoginReceiver = new CallbackReceiver<JSONObject>() {
307 - @Override
308 - public void onSuccess(JSONObject result) {
309 -
310 - }
311 -
312 - @Override
313 - public void onFailure(int errorCode) {
314 -
315 - }
316 -};
317 -
318 -
319 -10. Register
320 -
321 -The .setId and .setPassword methods are mandatory.
322 -The .setAutologin method is used if we want to autologin after the successful register flow.
323 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
324 -WarplyManager.register(new WarplyRegisterRequest()
325 - .setAutologin(true)
326 - .setId("panost+6@warp.ly")
327 - .setPassword("123456")
328 - .setFirstName("Test")
329 - .setLastName("Test")
330 - .setEmail("test@test.com")
331 - .setMsisdn("1234567890")
332 - .setSalutation("Mr")
333 - .setNickname("Testaros")
334 - .setGender("male")
335 - .setBirthDate("01/01/1970")
336 - .setNewsletter(false)
337 - .setSms(false)
338 - .setPersonalizedNewsletter(true)
339 - .setPersonalizedSms(true),
340 - mRegisterReceiver);
341 -
342 -
343 -private CallbackReceiver<JSONObject> mRegisterReceiver = new CallbackReceiver<JSONObject>() {
344 - @Override
345 - public void onSuccess(JSONObject result) {
346 -
347 - }
348 -
349 - @Override
350 - public void onFailure(int errorCode) {
351 -
352 - }
353 -};
354 -
355 -
356 -11. User Profile
357 -
358 -We have to be logged in.
359 -If the errorCode == 401 then a logout must follow.
360 -WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver);
361 -
362 -
363 -private CallbackReceiver<Consumer> mConsumerReceiver = new CallbackReceiver<Consumer>() {
364 - @Override
365 - public void onSuccess(Consumer result) {
366 -
367 - }
368 -
369 - @Override
370 - public void onFailure(int errorCode) {
371 -
372 - }
373 -};
374 -
375 -
376 -12. Logout
377 -
378 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
379 -WarplyManager.logout(mLogoutReceiver);
380 -
381 -
382 -private CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() {
383 - @Override
384 - public void onSuccess(JSONObject result) {
385 -
386 - }
387 -
388 - @Override
389 - public void onFailure(int errorCode) {
390 -
391 - }
392 -};
393 -
394 -
395 -13. Change Password
396 -
397 -WarplyManager.changePassword(new WarplyChangePasswordRequest()
398 - .setOldPassword("123456")
399 - .setNewPassword("1234567"),
400 - mChangePasswordReceiver);
401 -
402 -
403 -private CallbackReceiver<JSONObject> mChangePasswordReceiver = new CallbackReceiver<JSONObject>() {
404 - @Override
405 - public void onSuccess(JSONObject result) {
406 -
407 - }
408 -
409 - @Override
410 - public void onFailure(int errorCode) {
411 -
412 - }
413 -};
414 -
415 -
416 -14. Edit User Profile
417 -
418 -We have to be logged in.
419 -If the errorCode == 401 then a logout must follow.
420 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
421 -Fields that can be changed:
422 -* setFirstName, setLastName, setEmail, setSalutation, setMsisdn, setNickname, setGender, setBirthDate, setNameday, setTaxId
423 -* setOptin -> If we want to change the communications (i.e info via newsletter or sms or both, same for personalized), if true then we set the below fields (all are boolean):
424 -setNewsletter, setSms, setPersonalizedNewsletter, setPersonalizedSms
425 -* setHasProfileMetadata -> If we want to save custom info on consumer. If true then we set also the below field as a json object: setProfileMetadata
426 -* Note: We only use the fields we want to change.
427 -WarplyManager.editConsumer(new WarplyEditConsumerRequest()
428 - .setFirstName("test")
429 - .setLastName("test"), mEditConsumerReceiver);
430 -
431 -
432 -private CallbackReceiver<JSONObject> mEditConsumerReceiver = new CallbackReceiver<JSONObject>() {
433 - @Override
434 - public void onSuccess(JSONObject result) {
435 -
436 - }
437 -
438 - @Override
439 - public void onFailure(int errorCode) {
440 -
441 - }
442 -};
443 -
444 -
445 -15. Change User Photo
446 -
447 -We have to be logged in.
448 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
449 -The setUserId method must be the consumer.uuid, we can find it in Consumer object from (11 : User Profile request).
450 -The setImageBase64 method must be the base64 string of the image we want to upload.
451 -WarplyManager.uploadConsumerPhoto(new WarplyUploadConsumerPhotoRequest()
452 - .setUserId("")
453 - .setImageBase64(""), mUploadConsumerPhotoReceiver);
454 -
455 -
456 -private CallbackReceiver<JSONObject> mUploadConsumerPhotoReceiver = new CallbackReceiver<JSONObject>() {
457 - @Override
458 - public void onSuccess(JSONObject result) {
459 -
460 - }
461 -
462 - @Override
463 - public void onFailure(int errorCode) {
464 -
465 - }
466 -};
467 -
468 -
469 -16. Add Card
470 -
471 -We have to be logged in.
472 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
473 -If the errorCode == 4 then the card is already added.
474 -WarplyManager.addCard(new WarplyAddCardRequest()
475 - .setCardIssuer("Visa")
476 - .setCardNumber("1234567812345678")
477 - .setCardHolder("test test")
478 - .setCardExpMonth("01")
479 - .setCardExpYear("2026"), mAddCardReceiver);
480 -
481 -
482 -private CallbackReceiver<Card> mAddCardReceiver = new CallbackReceiver<Card>() {
483 - @Override
484 - public void onSuccess(Card result) {
485 -
486 - }
487 -
488 - @Override
489 - public void onFailure(int errorCode) {
490 -
491 - }
492 -};
493 -
494 -
495 -17. Get Cards
496 -
497 -We have to be logged in.
498 -If the errorCode == 401 then a logout must follow.
499 -WarplyManager.getCards(new WarplyGetCardsRequest(), mGetCardsReceiver);
500 -
501 -
502 -private CallbackReceiver<CardList> mGetCardsReceiver = new CallbackReceiver<CardList>() {
503 - @Override
504 - public void onSuccess(CardList result) {
505 -
506 - }
507 -
508 - @Override
509 - public void onFailure(int errorCode) {
510 -
511 - }
512 -};
513 -
514 -
515 -18. Delete Card
516 -
517 -We have to be logged in.
518 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
519 -If the errorCode == 401 then a logout must follow.
520 -WarplyManager.deleteCard(new WarplyDeleteCardRequest()
521 - .setCardToken("af993aead7d24abfbac716c276d8c6f5"), mDeleteCardReceiver);
522 -
523 -
524 -private CallbackReceiver<JSONObject> mDeleteCardReceiver = new CallbackReceiver<JSONObject>() {
525 - @Override
526 - public void onSuccess(JSONObject result) {
527 -
528 - }
529 -
530 - @Override
531 - public void onFailure(int errorCode) {
532 -
533 - }
534 -};
535 -
536 -
537 -19. Verify Ticket
538 -
539 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
540 -WarplyManager.verifyTicket(new WarplyVerifyTicketRequest()
541 - .setGuid("")
542 - .setTicket(""),
543 - mVerifyTicketReceiver);
544 -
545 -
546 -private CallbackReceiver<JSONObject> mVerifyTicketReceiver = new CallbackReceiver<JSONObject>() {
547 - @Override
548 - public void onSuccess(JSONObject result) {
549 -
550 - }
551 -
552 - @Override
553 - public void onFailure(int errorCode) {
554 -
555 - }
556 -};
557 -
558 -
559 -20. User Coupons
560 -
561 -We have to be logged in.
562 -If the errorCode == 401 then a logout must follow.
563 -WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
564 -
565 -
566 -private CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
567 - @Override
568 - public void onSuccess(CouponList result) {
569 -
570 - }
571 -
572 - @Override
573 - public void onFailure(int errorCode) {
574 -
575 - }
576 -};
577 -
578 -
579 -21. Transactions History
580 -
581 -We have to be logged in.
582 -If the errorCode == 401 then a logout must follow.
583 -WarplyManager.getTransactionHistory(new WarplyTransactionHistoryRequest(), mTransactionHistoryReceiver);
584 -
585 -
586 -private CallbackReceiver<TransactionsList> mTransactionHistoryReceiver = new CallbackReceiver<TransactionsList>() {
587 - @Override
588 - public void onSuccess(TransactionsList result) {
589 -
590 - }
591 -
592 - @Override
593 - public void onFailure(int errorCode) {
594 -
595 - }
596 -};
597 -
598 -
599 -22. Points History
600 -
601 -We have to be logged in.
602 -If the errorCode == 401 then a logout must follow.
603 -There is a relation between this and the (21 : Transactions History request).
604 -WarplyManager.getPointHistory(new WarplyPointHistoryRequest(), mPointHistoryReceiver);
605 -
606 -
607 -private CallbackReceiver<PointsList> mPointHistoryReceiver = new CallbackReceiver<PointsList>() {
608 - @Override
609 - public void onSuccess(PointsList result) {
610 -
611 - }
612 -
613 - @Override
614 - public void onFailure(int errorCode) {
615 -
616 - }
617 -};
618 -
619 -
620 -23. Add Address
621 -
622 -We have to be logged in.
623 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
624 -If the errorCode == 401 then a logout must follow.
625 -WarplyManager.addAddress(new WarplyAddAddressRequest()
626 - .setFriendlyName("panos")
627 - .setAddressName("moustaka 4")
628 - .setAddressNumber("4")
629 - .setPostalCode("32200")
630 - .setFloorNumber(1)
631 - .setDoorbell("triant")
632 - .setRegion("thiva")
633 - .setNotes("tel"), mAddAddressReceiver);
634 -
635 -
636 -private CallbackReceiver<JSONObject> mAddAddressReceiver = new CallbackReceiver<JSONObject>() {
637 - @Override
638 - public void onSuccess(JSONObject result) {
639 -
640 - }
641 -
642 - @Override
643 - public void onFailure(int errorCode) {
644 -
645 - }
646 -};
647 -
648 -
649 -24. Get Addresses
650 -
651 -We have to be logged in.
652 -If the errorCode == 401 then a logout must follow.
653 -WarplyManager.getAddressList(new WarplyGetAddressRequest(), mGetAddressReceiver);
654 -
655 -
656 -private CallbackReceiver<AddressList> mGetAddressReceiver = new CallbackReceiver<AddressList>() {
657 - @Override
658 - public void onSuccess(AddressList result) {
659 -
660 - }
661 -
662 - @Override
663 - public void onFailure(int errorCode) {
664 -
665 - }
666 -};
667 -
668 -
669 -25. Edit Address
670 -
671 -We have to be logged in.
672 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
673 -If the errorCode == 401 then a logout must follow.
674 -The fields are the same like the (24 : Add Address request).
675 -In addition to the other fields we must fill the uuid of the address we want to edit.
676 -* Note: We only use the fields we want to change.
677 -WarplyManager.editAddress(new WarplyEditAddressRequest()
678 - .setUuid("5f83af68ebc34e94b1ffd9143772bda1")
679 - .setAddressName("moustaka 2"), mEditAddressReceiver);
680 -
681 -
682 -private CallbackReceiver<JSONObject> mEditAddressReceiver = new CallbackReceiver<JSONObject>() {
683 - @Override
684 - public void onSuccess(JSONObject result) {
685 -
686 - }
687 -
688 - @Override
689 - public void onFailure(int errorCode) {
690 -
691 - }
692 -};
693 -
694 -
695 -26. Delete Address
696 -
697 -We have to be logged in.
698 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
699 -If the errorCode == 401 then a logout must follow.
700 -We must fill the uuid of the address we want to delete.
701 -WarplyManager.deleteAddress(new WarplyDeleteAddressRequest()
702 - .setUuid("5f83af68ebc34e94b1ffd9143772bda1"), mDeleteAddressReceiver);
703 -
704 -
705 -private CallbackReceiver<JSONObject> mDeleteAddressReceiver = new CallbackReceiver<JSONObject>() {
706 - @Override
707 - public void onSuccess(JSONObject result) {
708 -
709 - }
710 -
711 - @Override
712 - public void onFailure(int errorCode) {
713 -
714 - }
715 -};
716 -
717 -
718 -27. Redeem Product
719 -
720 -We have to be logged in.
721 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
722 -If the errorCode == 401 then a logout must follow.
723 -WarplyManager.redeemProduct(new WarplyRedeemCouponRequest()
724 - .setSku("")
725 - .setUuid(""),
726 - mRedeemCouponReceiver);
727 -
728 -
729 -private CallbackReceiver<JSONObject> mRedeemCouponReceiver = new CallbackReceiver<JSONObject>() {
730 - @Override
731 - public void onSuccess(JSONObject result) {
732 -
733 - }
734 -
735 - @Override
736 - public void onFailure(int errorCode) {
737 -
738 - }
739 -};
740 -
741 -
742 -28. Forgot Password
743 -
744 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
745 -The setId field must be one of email or msisdn.
746 -* Note: If the setId field is email then we first make the (28 : Forgot Password request) and then the (29 : Reset Password request).
747 -* Note: If the setId field is msisdn then we first make the (30 : Request OTP request) and then the (29 : Reset Password request) without the need of the (28 : Forgot Password request).
748 -WarplyManager.forgotPassword(new WarplyForgotPasswordRequest()
749 - .setId("")
750 - mForgotPasswordReceiver);
751 -
752 -
753 -private CallbackReceiver<JSONObject> mForgotPasswordReceiver = new CallbackReceiver<JSONObject>() {
754 - @Override
755 - public void onSuccess(JSONObject result) {
756 -
757 - }
758 -
759 - @Override
760 - public void onFailure(int errorCode) {
761 -
762 - }
763 -};
764 -
765 -
766 -29. Reset Password
767 -
768 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
769 -* If (28 : setId) is email then we only use the setPassword and setConfToken methods.
770 -* The setConfToken value is included as a parameter to the deeplink that we are redirected from the info email.
771 -* If (28 : setId) is msisdn then we only the setOtp and setOtpUuid methods with values from (30 : Request OTP request).
772 -WarplyManager.resetPassword(new WarplyResetPasswordRequest()
773 - .setPassword("")
774 - .setConfToken("")
775 - .setOtp("")
776 - .setOtpUuid(""),
777 - mResetPasswordReceiver);
778 -
779 -
780 -private CallbackReceiver<JSONObject> mResetPasswordReceiver = new CallbackReceiver<JSONObject>() {
781 - @Override
782 - public void onSuccess(JSONObject result) {
783 -
784 - }
785 -
786 - @Override
787 - public void onFailure(int errorCode) {
788 -
789 - }
790 -};
791 -
792 -
793 -30. Request OTP
794 -
795 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
796 -The setScope must be one of reset, edit or verify.
797 -WarplyManager.requestOTP(new WarplyRequestOTPRequest()
798 - .setMsisdn("")
799 - .setScope(""),
800 - mRequestOTPReceiver);
801 -
802 -
803 -private CallbackReceiver<JSONObject> mRequestOTPReceiver = new CallbackReceiver<JSONObject>() {
804 - @Override
805 - public void onSuccess(JSONObject result) {
806 -
807 - }
808 -
809 - @Override
810 - public void onFailure(int errorCode) {
811 -
812 - }
813 -};
814 -
815 -
816 -31. Merchants Multilingual
817 -
818 -We can request the merchants in multilingual way.
819 -* The setIsMultilingual method must be true.
820 -* The setLanguage method is used to search on the language we provide.
821 -* The setCategories method is used if we want to filter by category/ies. It’s a list of categories uuid.
822 -* The setTags method is used if we want to filter with keywords. It’s a list of tags uuid (7 : Tags request).
823 -* The setMerchantUuid method is used to search for a specific merchant. We need to add the uuid of that merchant.
824 -* The setCenter and setDistance are used to filter by location.
825 -WarplyManager.getMerchantsMultilingual(new WarplyMerchantsRequest()
826 - .setIsMultilingual(true)
827 - .setCategories(cat)
828 - .setTags(tag), mMerchantsMultilingualReceiver);
829 -
830 -
831 -private CallbackReceiver<MerchantList> mMerchantsMultilingualReceiver = new CallbackReceiver<MerchantList>() {
832 - @Override
833 - public void onSuccess(MerchantList result) {
834 -
835 - }
836 -
837 - @Override
838 - public void onFailure(int errorCode) {
839 -
840 - }
841 -};
842 -
843 -32. Get User Couponsets
844 -
845 -* The setLanguage method is used to get the user couponsets to the language that are configured on the engage platform.
846 -* The setUuids method is used to get specific couponsets, if we know the coupon_uuid of them. It’s a list of string uuid.
847 -WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest()
848 - .setLanguage("el")
849 - mCouponsetsReceiver);
850 -
851 -
852 -private CallbackReceiver<CouponsetsList> mCouponsetsReceiver = new CallbackReceiver<CouponsetsList>() {
853 - @Override
854 - public void onSuccess(CouponsetsList result) {
855 -
856 - }
857 -
858 - @Override
859 - public void onFailure(int errorCode) {
860 -
861 - }
862 -};
863 -
864 -
865 -
866 -33. Redeem Coupon
867 -
868 -We have to be logged in.
869 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
870 -Additionally the response includes a result key (json) that includes the coupon and it’s expiration date, if any.
871 -If the errorCode == 401 then a logout must follow.
872 -* The setCouponsetUuid method is used to get a coupon from the given couponset.
873 -WarplyManager.redeemCoupon(new WarplyRedeemCouponRequest()
874 - .setCouponsetUuid("7de77a1731d44a95a74a653f8e823fa4"),
875 - mRedeemCouponReceiver);
876 -
877 -
878 -private CallbackReceiver<JSONObject> mRedeemCouponReceiver = new CallbackReceiver<JSONObject>() {
879 - @Override
880 - public void onSuccess(JSONObject result) {
881 -
882 - }
883 -
884 - @Override
885 - public void onFailure(int errorCode) {
886 -
887 - }
888 -};
889 -
890 -
891 -34. Validate Coupon
892 -
893 -We have to be logged in.
894 -From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
895 -If status == 1, from result key, we have to check which items are satisfied == true. Only then is truly success.
896 -If the above case has no satisfied == true then we check the failed key that includes the different error messages in the msg key.
897 -If status == 4 means that no rule has been satisfied.
898 -If the errorCode == 401 then a logout must follow.
899 -* The setCoupon method is used to check the given coupon code we retrieved from (33 : Redeem Coupon request).
900 -WarplyManager.validateCoupon(new WarplyValidateCouponRequest()
901 - .setCoupon("CBGEJEYC"),
902 - mValidateCouponReceiver);
903 -
904 -
905 -private CallbackReceiver<JSONObject> mValidateCouponReceiver = new CallbackReceiver<JSONObject>() {
906 - @Override
907 - public void onSuccess(JSONObject result) {
908 -
909 - }
910 -
911 - @Override
912 - public void onFailure(int errorCode) {
913 -
914 - }
915 -};
916 -
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 13
14 + (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang; 14 + (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang;
15 - (void) setToStage; 15 - (void) setToStage;
16 +- (void) setLang:(NSString*) lang;
16 - (UIViewController *) openProfile:(UIViewController*)controller :(UIWindow*) window; 17 - (UIViewController *) openProfile:(UIViewController*)controller :(UIWindow*) window;
17 - (void) applicationDidEnterBackground:(UIApplication *)application; 18 - (void) applicationDidEnterBackground:(UIApplication *)application;
18 - (void) applicationWillEnterForeground:(UIApplication *)application; 19 - (void) applicationWillEnterForeground:(UIApplication *)application;
......
...@@ -36,6 +36,10 @@ NSString *LANG; ...@@ -36,6 +36,10 @@ NSString *LANG;
36 WARP_ERROR_DOMAIN = @"engage-stage.warp.ly"; 36 WARP_ERROR_DOMAIN = @"engage-stage.warp.ly";
37 } 37 }
38 38
39 +- (void) setLang:(NSString*) lang {
40 + LANG = lang;
41 +}
42 +
39 - (UIViewController *) openProfile:(UIViewController*)controller :(UIWindow*) window { 43 - (UIViewController *) openProfile:(UIViewController*)controller :(UIWindow*) window {
40 44
41 UIViewController *profileViewController = [ProfileViewInterface profileViewController]; 45 UIViewController *profileViewController = [ProfileViewInterface profileViewController];
......