From 380b04b4a315bc7ab93ec316c4b401f82ae7bc52 Mon Sep 17 00:00:00 2001 From: Preyea Regmi Date: Tue, 7 Jul 2020 12:08:37 +0545 Subject: [PATCH] Minor fixes in withdraw --- .idea/caches/build_file_checksums.ser | Bin 659 -> 659 bytes .../withdraw/gateway/WithdrawGateway.java | 13 +++- .../withdraw/presenter/WithdrawPresenter.java | 57 ++++++++++-------- .../withdraw/view/WithdrawActivity.java | 2 +- .../remit/android/utils/https/API_URL.java | 2 + .../android/utils/https/ApiEndpoints.java | 8 +++ .../fragment_cash_pickup_txn_detail.xml | 8 +-- .../main/res/layout/fragment_otp_request.xml | 2 + 8 files changed, 59 insertions(+), 33 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 0bac47527a9dbdda4a6b83908af8e9d93fc33319..2f218c9ff2c69e1883f4a4e7df9fc3a8a1f54c2a 100644 GIT binary patch delta 15 XcmbQtI+=CC3>Nj1jz>1m`OXLcFM$S^ delta 15 XcmbQtI+=CC3>KyRZ@+Gw^PLd@G!O@6 diff --git a/app/src/main/java/com/swifttech/remit/android/features/withdraw/gateway/WithdrawGateway.java b/app/src/main/java/com/swifttech/remit/android/features/withdraw/gateway/WithdrawGateway.java index 38d23a14..386afaee 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/withdraw/gateway/WithdrawGateway.java +++ b/app/src/main/java/com/swifttech/remit/android/features/withdraw/gateway/WithdrawGateway.java @@ -1,7 +1,9 @@ package com.swifttech.remit.android.features.withdraw.gateway; +import com.google.gson.JsonObject; import com.swifttech.remit.android.base.PrivilegedGateway; import com.swifttech.remit.android.features.withdraw.presenter.WithdrawGatewayInterface; +import com.swifttech.remit.android.utils.https.HttpClientV2; import io.reactivex.Observable; import okhttp3.ResponseBody; @@ -9,11 +11,18 @@ import okhttp3.ResponseBody; public class WithdrawGateway extends PrivilegedGateway implements WithdrawGatewayInterface { @Override public Observable checkWithdrawStatus(String auth, String userID, String selectedWithdrawAmount) { - return null; + JsonObject jsonObject=new JsonObject(); + jsonObject.addProperty("userID",userID); + jsonObject.addProperty("amount",selectedWithdrawAmount); + return HttpClientV2.getInstance().requestForBankDeposit(auth,jsonObject); } @Override public Observable performWithdraw(String auth, String userID, String amount, String password) { - return null; + JsonObject jsonObject=new JsonObject(); + jsonObject.addProperty("userID",userID); + jsonObject.addProperty("amount",amount); + jsonObject.addProperty("password",password); + return HttpClientV2.getInstance().proceedForBankDeposit(auth,jsonObject); } } diff --git a/app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenter.java b/app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenter.java index 0ec5e3a2..97fec7dd 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenter.java +++ b/app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenter.java @@ -4,9 +4,9 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; +import com.google.gson.reflect.TypeToken; import com.swifttech.remit.android.base.BaseViewModel; import com.swifttech.remit.android.common.customwidgets.CustomAlertDialog; -import com.swifttech.remit.android.common.model.FormInputStateDTO; import com.swifttech.remit.android.features.security.RemitAuthManager; import com.swifttech.remit.android.features.security.model.RemitAuthFailedResult; import com.swifttech.remit.android.features.security.model.RemitAuthSuccessResult; @@ -18,6 +18,8 @@ import com.swifttech.remit.android.utils.https.GenericApiObserverResponseV2; import com.swifttech.remit.android.utils.https.GenericResponseDataModel; import com.swifttech.remit.android.utils.https.MessageResponseDataModel; +import java.lang.reflect.Type; + import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; @@ -92,14 +94,15 @@ public class WithdrawPresenter extends BaseViewModel implements WithdrawPresente ).setListener(new RemitAuthManager.RemitAuthListener() { @Override public void onRemitAuthSuccess(RemitAuthSuccessResult result) { -// useCaseSubs.add( -// gateway.performWithdraw(gateway.getAuth(), gateway.getUserID(), selectedWithdrawAmount, result.getResult()) -// .doOnSubscribe(subs -> view.showProgressBar(true, "")) -// .subscribeOn(Schedulers.io()) -// .observeOn(AndroidSchedulers.mainThread()) -// .doFinally(() -> view.showProgressBar(false, "")) -// .subscribeWith(new WithdrawTxnbserver()) -// ); + useCaseSubs.add( + gateway.performWithdraw(gateway.getAuth(), gateway.getUserID(), selectedWithdrawAmount, result.getResult()) + .doOnSubscribe(subs -> view.showProgressBar(true, "")) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .doFinally(() -> view.showProgressBar(false, "")) + .subscribeWith(new WithdrawTxnbserver()) + ); + //TODO Mock Success Response view.showPopUpMessage("Withdraw Success", CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView()); } @@ -118,18 +121,19 @@ public class WithdrawPresenter extends BaseViewModel implements WithdrawPresente @Override public void getWithdrawDetail() { view.hideKeyBoard(); -// useCaseSubs.add( -// gateway.checkWithdrawStatus(gateway.getAuth(), gateway.getUserID(),selectedWithdrawAmount ) -// .doOnSubscribe(subs -> view.showProgressBar(true, "")) -// .subscribeOn(Schedulers.io()) -// .observeOn(AndroidSchedulers.mainThread()) -// .doFinally(() -> view.showProgressBar(false, "")) -// .subscribeWith(new WithdrawStatusObserver()) -// ); - WithdrawStatusResponseDTO dummyData = new WithdrawStatusResponseDTO(); - dummyData.seedDummyValues(); - - onReceivingWithdrawStatus(dummyData); + useCaseSubs.add( + gateway.checkWithdrawStatus(gateway.getAuth(), gateway.getUserID(),selectedWithdrawAmount ) + .doOnSubscribe(subs -> view.showProgressBar(true, "")) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .doFinally(() -> view.showProgressBar(false, "")) + .subscribeWith(new WithdrawStatusObserver()) + ); + + //TODO Mock Success Response +// WithdrawStatusResponseDTO dummyData = new WithdrawStatusResponseDTO(); +// dummyData.seedDummyValues(); +// onReceivingWithdrawStatus(dummyData); } @@ -166,24 +170,29 @@ public class WithdrawPresenter extends BaseViewModel implements WithdrawPresente public class WithdrawStatusObserver extends GenericApiObserverResponseV2 { + @Override + protected Type getDataType() { + return TypeToken.getParameterized(WithdrawStatusResponseDTO.class).getType(); + } + @Override protected void onSuccess(GenericResponseDataModel t) { if (Constants.SUCCESS_CODE_V2.equalsIgnoreCase(t.getErrorCode()) && t.getData() != null) { onReceivingWithdrawStatus(t.getData()); } else { - view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); + view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } } @Override public void onFailed(String message) { - view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); + view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } @Override protected void onConnectionNotEstablished(String message) { - view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); + view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } diff --git a/app/src/main/java/com/swifttech/remit/android/features/withdraw/view/WithdrawActivity.java b/app/src/main/java/com/swifttech/remit/android/features/withdraw/view/WithdrawActivity.java index 84fe4e8f..3a23038a 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/withdraw/view/WithdrawActivity.java +++ b/app/src/main/java/com/swifttech/remit/android/features/withdraw/view/WithdrawActivity.java @@ -51,7 +51,7 @@ public class WithdrawActivity extends BaseActivity implements WithdrawPresenterI } private void init() { - toolbarTitle.setText("Withdraw"); + toolbarTitle.setText("Bank Deposit"); viewModel = new ViewModelProvider(this, new WithdrawViewModelFactory(this)).get(WithdrawPresenter.class); setupViewPager(); } diff --git a/app/src/main/java/com/swifttech/remit/android/utils/https/API_URL.java b/app/src/main/java/com/swifttech/remit/android/utils/https/API_URL.java index 41dbed28..72b4bd58 100644 --- a/app/src/main/java/com/swifttech/remit/android/utils/https/API_URL.java +++ b/app/src/main/java/com/swifttech/remit/android/utils/https/API_URL.java @@ -96,5 +96,7 @@ public class API_URL { public static final String REGISTER_OTP_SUBMIT = BuildConfig.API_VERSION + "/mobile/submitOTP "; public static final String SEARCH_CASH_PICKUP_BY_CONTROL_NO = BuildConfig.API_VERSION + "/mobile/searchTxnByControlNumber "; public static final String REDEEM_CASH_PICKUP = BuildConfig.API_VERSION + "/mobile/redeemCashPayment "; + public static final String REQUEST_FOR_BANK_DEPOSIT =BuildConfig.API_VERSION + "/mobile/withdrawWalletRequest" ; + public static final String PROCEED_FOR_BANK_DEPOSIT = BuildConfig.API_VERSION + "/mobile/withdrawFromWallet"; } diff --git a/app/src/main/java/com/swifttech/remit/android/utils/https/ApiEndpoints.java b/app/src/main/java/com/swifttech/remit/android/utils/https/ApiEndpoints.java index 1be6a3e1..6fbd7d55 100644 --- a/app/src/main/java/com/swifttech/remit/android/utils/https/ApiEndpoints.java +++ b/app/src/main/java/com/swifttech/remit/android/utils/https/ApiEndpoints.java @@ -246,6 +246,14 @@ public interface ApiEndpoints { @Headers("Content-Type: application/json") Observable redeemCashPickup(@Header("Authorization") String token, @Body()JsonObject requestBody); + @POST(API_URL.REQUEST_FOR_BANK_DEPOSIT) + @Headers("Content-Type: application/json") + Observable requestForBankDeposit(@Header("Authorization") String token, @Body()JsonObject requestBody); + + @POST(API_URL.PROCEED_FOR_BANK_DEPOSIT) + @Headers("Content-Type: application/json") + Observable proceedForBankDeposit(@Header("Authorization") String token, @Body()JsonObject requestBody); + diff --git a/app/src/main/res/layout/fragment_cash_pickup_txn_detail.xml b/app/src/main/res/layout/fragment_cash_pickup_txn_detail.xml index d9c9da18..fcbdc8db 100644 --- a/app/src/main/res/layout/fragment_cash_pickup_txn_detail.xml +++ b/app/src/main/res/layout/fragment_cash_pickup_txn_detail.xml @@ -264,6 +264,7 @@ @@ -400,13 +402,7 @@ app:txtfontName="@string/semibold" /> - -