@guide https://proandroiddev.com/publishing-android-libraries-to-mavencentral-in-2021-8ac9975c3e52 @Create Release gradlew warply-android-sdk:publishReleasePublicationToSonatypeRepository @Close and Release Repository gradlew closeAndReleaseSonatypeStagingRepository Prerequisites • Android 6 or greater • Android Studio 3.6 or greater • JDK 8 or greater Installation 1. Top level build.gradle In repositories section of the buildscript and the allProjects block add mavenCentral() 2. Module level build.gradle dependencies { implementation 'ly.warp:warply-android-sdk:4.5.0' } Configuration - SDK We need to add to the assets folder the below file warply.properties Uuid The app uuid the warply sdk need to connect to the engage server Business section will provide it for you Debug If we need to see logs in Logcat BaseURL Production or Development environment of the engage server Production: https://engage.warp.ly Development: https://engage-stage.warp.ly ProgressColor Replace the color with one you want the progress bar to have depending on you app theme coloring If not defined the colorPrimary will be used ProgressDrawable Replace the drawable with one you want (this will show when webview loading) If not defined the launcher icon will be used PushColor If not defined the colorPrimary will be used PushIcon If not defined the launcher icon will used (better use the clipart icons for support black/white icons on 24+) PushSound If not defined the default will be used SendPackages If the device packages need to be send to the engage server Language The app language MerchantId The merchant id for some requests LoginType The login type must be one of the below: email, msisdn, username DL_URL_SCHEME Only for react native app The deeplink url scheme for react native campaigns Configuration - Push Notifications (FCM/HMS) 1. Top level build.gradle In repositories section of the buildscript and the allProjects block add maven { url 'https://developer.huawei.com/repo/' } This is only for HMS 2. Top level build.gradle In dependencies section add classpath 'com.google.gms:google-services:4.3.10' classpath 'com.huawei.agconnect:agcp:1.6.2.300' 3. Module level build.gradle, at the top of it add apply plugin: 'com.google.gms.google-services' apply plugin: 'com.huawei.agconnect' 4. Inside the app folder we need to add each or both json file(s) google-services agconnect-services Initialization 1. In the starting activity of the application (i.e SplashActivity), we have to add the lines below 1a. private WarplyInitializer mWarplyInitializer; 1b. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() { @Override public void onWarplyReady() { //Maybe go to next Activity or whatever } @Override public void onWarplyInitTimeOut() { } @Override public void onWarplyPermissionsDenied() { } }); } 1c. @Override protected void onResume() { super.onResume(); mWarplyInitializer.initWithPermissions(this); } 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. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WarplySessionManager.onCreateActivity(this); } @Override protected void onStart() { super.onStart(); WarplySessionManager.onStartActivity(this); } @Override protected void onStop() { super.onStop(); WarplySessionManager.onStopActivity(this); } Requests 1. Campaigns Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver); private CallbackReceiver<CampaignList> mInboxReceiver = new CallbackReceiver<CampaignList>() { @Override public void onSuccess(CampaignList result) { } @Override public void onFailure(int errorCode) { } }; 2. Products 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. * The setLanguage method is used to search on the language we provide. WarplyManager.getProducts(new WarplyProductsRequest().setProductFilter("gift"), mProductsReceiver); private CallbackReceiver<ProductList> mProductsReceiver = new CallbackReceiver<ProductList>() { @Override public void onSuccess(ProductList result) { } @Override public void onFailure(int errorCode) { } }; 3. Merchants Better use (30 : Merchants Multilingual request) WarplyManager.getMerchants(new WarplyMerchantsRequest(), mShopsReceiver); private CallbackReceiver<MerchantList> mShopsReceiver = new CallbackReceiver<MerchantList>() { @Override public void onSuccess(MerchantList result) { } @Override public void onFailure(int errorCode) { } }; 4. Content 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. 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). * The .setTags method takes an list with keyword names as string. * The setLanguage method is used to search on the language we provide. WarplyManager.getContent(new WarplyContentRequest().setContentCategory("Article").setTags(ArrayList<String>), mContentReceiver); private CallbackReceiver<ContentList> mContentReceiver = new CallbackReceiver<ContentList>() { @Override public void onSuccess(ContentList result) { } @Override public void onFailure(int errorCode) { } }; 5. Merchant Categories Returns the merchant categories the merchants belong to. * The setLanguage method is used to search on the language we provide. WarplyManager.getMerchantCategories(new WarplyMerchantCategoriesRequest(), mShopCategoriesReceiver); private CallbackReceiver<MerchantCategoriesList> mShopCategoriesReceiver = new CallbackReceiver<MerchantCategoriesList>() { @Override public void onSuccess(MerchantCategoriesList result) { } @Override public void onFailure(int errorCode) { } }; 6. Tags Categories Returns the categories of the tags that has been created on the engage platform. * The setLanguage method is used to search on the language we provide. WarplyManager.getTagsCategories(new WarplyTagsCategoriesRequest(), mTagsCategoriesReceiver); private CallbackReceiver<TagsCategoriesList> mTagsCategoriesReceiver = new CallbackReceiver<TagsCategoriesList>() { @Override public void onSuccess(TagsCategoriesList result) { } @Override public void onFailure(int errorCode) { } }; 7. Tags Returns the tags that has been created on the engage platform. Each tag item includes a category kay so in combination with the (6) to know in which category it belongs to. Each tag item has a name and a uuid key. The name can be used in (4 : setTags) and the uuid in (31 : setTags). * The setLanguage method is used to search on the language we provide. WarplyManager.getTags(new WarplyTagsRequest(), mTagsReceiver); private CallbackReceiver<TagsList> mTagsReceiver = new CallbackReceiver<TagsList>() { @Override public void onSuccess(TagsList result) { } @Override public void onFailure(int errorCode) { } }; 8. Contact From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.sendContact(new WarplyContactRequest() .setContactSubject("Other") .setContactName("Testaros") .setContactEmail("test@test.com") .setContactNumber("") .setContactMessage("Test comments"), mContactReceiver); private CallbackReceiver<JSONObject> mContactReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 9. Login From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The .setId method must be one of email, msisdn or username and refers to the LoginType in warply.properties file. WarplyManager.login(new WarplyLoginRequest() .setId("email/msisdn/username") .setPassword(""), mLoginReceiver); private CallbackReceiver<JSONObject> mLoginReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 10. Register The .setId and .setPassword methods are mandatory. The .setAutologin method is used if we want to autologin after the successful register flow. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.register(new WarplyRegisterRequest() .setAutologin(true) .setId("panost+6@warp.ly") .setPassword("123456") .setFirstName("Test") .setLastName("Test") .setEmail("test@test.com") .setMsisdn("1234567890") .setSalutation("Mr") .setNickname("Testaros") .setGender("male") .setBirthDate("01/01/1970") .setNewsletter(false) .setSms(false) .setPersonalizedNewsletter(true) .setPersonalizedSms(true), mRegisterReceiver); private CallbackReceiver<JSONObject> mRegisterReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 11. User Profile We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver); private CallbackReceiver<Consumer> mConsumerReceiver = new CallbackReceiver<Consumer>() { @Override public void onSuccess(Consumer result) { } @Override public void onFailure(int errorCode) { } }; 12. Logout From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.logout(mLogoutReceiver); private CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 13. Change Password WarplyManager.changePassword(new WarplyChangePasswordRequest() .setOldPassword("123456") .setNewPassword("1234567"), mChangePasswordReceiver); private CallbackReceiver<JSONObject> mChangePasswordReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 14. Edit User Profile We have to be logged in. If the errorCode == 401 then a logout must follow. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). Fields that can be changed: * setFirstName, setLastName, setEmail, setSalutation, setMsisdn, setNickname, setGender, setBirthDate, setNameday, setTaxId * 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): setNewsletter, setSms, setPersonalizedNewsletter, setPersonalizedSms * setHasProfileMetadata -> If we want to save custom info on consumer. If true then we set also the below field as a json object: setProfileMetadata * Note: We only use the fields we want to change. WarplyManager.editConsumer(new WarplyEditConsumerRequest() .setFirstName("test") .setLastName("test"), mEditConsumerReceiver); private CallbackReceiver<JSONObject> mEditConsumerReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 15. Change User Photo We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The setUserId method must be the consumer.uuid, we can find it in Consumer object from (11 : User Profile request). The setImageBase64 method must be the base64 string of the image we want to upload. WarplyManager.uploadConsumerPhoto(new WarplyUploadConsumerPhotoRequest() .setUserId("") .setImageBase64(""), mUploadConsumerPhotoReceiver); private CallbackReceiver<JSONObject> mUploadConsumerPhotoReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 16. Add Card We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 4 then the card is already added. WarplyManager.addCard(new WarplyAddCardRequest() .setCardIssuer("Visa") .setCardNumber("1234567812345678") .setCardHolder("test test") .setCardExpMonth("01") .setCardExpYear("2026"), mAddCardReceiver); private CallbackReceiver<Card> mAddCardReceiver = new CallbackReceiver<Card>() { @Override public void onSuccess(Card result) { } @Override public void onFailure(int errorCode) { } }; 17. Get Cards We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getCards(new WarplyGetCardsRequest(), mGetCardsReceiver); private CallbackReceiver<CardList> mGetCardsReceiver = new CallbackReceiver<CardList>() { @Override public void onSuccess(CardList result) { } @Override public void onFailure(int errorCode) { } }; 18. Delete Card We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. WarplyManager.deleteCard(new WarplyDeleteCardRequest() .setCardToken("af993aead7d24abfbac716c276d8c6f5"), mDeleteCardReceiver); private CallbackReceiver<JSONObject> mDeleteCardReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 19. Verify Ticket From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.verifyTicket(new WarplyVerifyTicketRequest() .setGuid("") .setTicket(""), mVerifyTicketReceiver); private CallbackReceiver<JSONObject> mVerifyTicketReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 20. User Coupons We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver); private CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { @Override public void onSuccess(CouponList result) { } @Override public void onFailure(int errorCode) { } }; 21. Transactions History We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getTransactionHistory(new WarplyTransactionHistoryRequest(), mTransactionHistoryReceiver); private CallbackReceiver<TransactionsList> mTransactionHistoryReceiver = new CallbackReceiver<TransactionsList>() { @Override public void onSuccess(TransactionsList result) { } @Override public void onFailure(int errorCode) { } }; 22. Points History We have to be logged in. If the errorCode == 401 then a logout must follow. There is a relation between this and the (21 : Transactions History request). WarplyManager.getPointHistory(new WarplyPointHistoryRequest(), mPointHistoryReceiver); private CallbackReceiver<PointsList> mPointHistoryReceiver = new CallbackReceiver<PointsList>() { @Override public void onSuccess(PointsList result) { } @Override public void onFailure(int errorCode) { } }; 23. Add Address We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. WarplyManager.addAddress(new WarplyAddAddressRequest() .setFriendlyName("panos") .setAddressName("moustaka 4") .setAddressNumber("4") .setPostalCode("32200") .setFloorNumber(1) .setDoorbell("triant") .setRegion("thiva") .setNotes("tel"), mAddAddressReceiver); private CallbackReceiver<JSONObject> mAddAddressReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 24. Get Addresses We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getAddressList(new WarplyGetAddressRequest(), mGetAddressReceiver); private CallbackReceiver<AddressList> mGetAddressReceiver = new CallbackReceiver<AddressList>() { @Override public void onSuccess(AddressList result) { } @Override public void onFailure(int errorCode) { } }; 25. Edit Address We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. The fields are the same like the (24 : Add Address request). In addition to the other fields we must fill the uuid of the address we want to edit. * Note: We only use the fields we want to change. WarplyManager.editAddress(new WarplyEditAddressRequest() .setUuid("5f83af68ebc34e94b1ffd9143772bda1") .setAddressName("moustaka 2"), mEditAddressReceiver); private CallbackReceiver<JSONObject> mEditAddressReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 26. Delete Address We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. We must fill the uuid of the address we want to delete. WarplyManager.deleteAddress(new WarplyDeleteAddressRequest() .setUuid("5f83af68ebc34e94b1ffd9143772bda1"), mDeleteAddressReceiver); private CallbackReceiver<JSONObject> mDeleteAddressReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 27. Redeem Product We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. WarplyManager.redeemProduct(new WarplyRedeemCouponRequest() .setSku("") .setUuid(""), mRedeemCouponReceiver); private CallbackReceiver<JSONObject> mRedeemCouponReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 28. Forgot Password From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The setId field must be one of email or msisdn. * Note: If the setId field is email then we first make the (28 : Forgot Password request) and then the (29 : Reset Password request). * 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). WarplyManager.forgotPassword(new WarplyForgotPasswordRequest() .setId("") mForgotPasswordReceiver); private CallbackReceiver<JSONObject> mForgotPasswordReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 29. Reset Password From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). * If (28 : setId) is email then we only use the setPassword and setConfToken methods. * The setConfToken value is included as a parameter to the deeplink that we are redirected from the info email. * If (28 : setId) is msisdn then we only the setOtp and setOtpUuid methods with values from (30 : Request OTP request). WarplyManager.resetPassword(new WarplyResetPasswordRequest() .setPassword("") .setConfToken("") .setOtp("") .setOtpUuid(""), mResetPasswordReceiver); private CallbackReceiver<JSONObject> mResetPasswordReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 30. Request OTP From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The setScope must be one of reset, edit or verify. WarplyManager.requestOTP(new WarplyRequestOTPRequest() .setMsisdn("") .setScope(""), mRequestOTPReceiver); private CallbackReceiver<JSONObject> mRequestOTPReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 31. Merchants Multilingual We can request the merchants in multilingual way. * The setIsMultilingual method must be true. * The setLanguage method is used to search on the language we provide. * The setCategories method is used if we want to filter by category/ies. It’s a list of categories uuid. * The setTags method is used if we want to filter with keywords. It’s a list of tags uuid (7 : Tags request). * The setMerchantUuid method is used to search for a specific merchant. We need to add the uuid of that merchant. * The setCenter and setDistance are used to filter by location. WarplyManager.getMerchantsMultilingual(new WarplyMerchantsRequest() .setIsMultilingual(true) .setCategories(cat) .setTags(tag), mMerchantsMultilingualReceiver); private CallbackReceiver<MerchantList> mMerchantsMultilingualReceiver = new CallbackReceiver<MerchantList>() { @Override public void onSuccess(MerchantList result) { } @Override public void onFailure(int errorCode) { } }; 32. Get User Couponsets * The setLanguage method is used to get the user couponsets to the language that are configured on the engage platform. * The setUuids method is used to get specific couponsets, if we know the coupon_uuid of them. It’s a list of string uuid. WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest() .setLanguage("el") mCouponsetsReceiver); private CallbackReceiver<CouponsetsList> mCouponsetsReceiver = new CallbackReceiver<CouponsetsList>() { @Override public void onSuccess(CouponsetsList result) { } @Override public void onFailure(int errorCode) { } }; 33. Redeem Coupon We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). Additionally the response includes a result key (json) that includes the coupon and it’s expiration date, if any. If the errorCode == 401 then a logout must follow. * The setCouponsetUuid method is used to get a coupon from the given couponset. WarplyManager.redeemCoupon(new WarplyRedeemCouponRequest() .setCouponsetUuid("7de77a1731d44a95a74a653f8e823fa4"), mRedeemCouponReceiver); private CallbackReceiver<JSONObject> mRedeemCouponReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } }; 34. Validate Coupon We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If status == 1, from result key, we have to check which items are satisfied == true. Only then is truly success. If the above case has no satisfied == true then we check the failed key that includes the different error messages in the msg key. If status == 4 means that no rule has been satisfied. If the errorCode == 401 then a logout must follow. * The setCoupon method is used to check the given coupon code we retrieved from (33 : Redeem Coupon request). WarplyManager.validateCoupon(new WarplyValidateCouponRequest() .setCoupon("CBGEJEYC"), mValidateCouponReceiver); private CallbackReceiver<JSONObject> mValidateCouponReceiver = new CallbackReceiver<JSONObject>() { @Override public void onSuccess(JSONObject result) { } @Override public void onFailure(int errorCode) { } };