From ddc29f8407df00b791ece630703599a9e41dcf16 Mon Sep 17 00:00:00 2001 From: Pratyush Singh Date: Sat, 3 Feb 2024 20:22:45 +0530 Subject: [PATCH] refactor #1503: kyc usecase migrated to kotlin --- .../usecase/kyc/FetchKYCLevel1Details.java | 78 ------------------- .../usecase/kyc/FetchKYCLevel1Details.kt | 40 ++++++++++ .../usecase/kyc/UpdateKYCLevel1Details.java | 68 ---------------- .../usecase/kyc/UpdateKYCLevel1Details.kt | 45 +++++++++++ .../domain/usecase/kyc/UploadKYCDocs.java | 74 ------------------ .../core/domain/usecase/kyc/UploadKYCDocs.kt | 44 +++++++++++ .../usecase/kyc/UploadKYCLevel1Details.java | 68 ---------------- .../usecase/kyc/UploadKYCLevel1Details.kt | 43 ++++++++++ .../kyc/presenter/KYCLevel2Presenter.kt | 26 ++++--- 9 files changed, 186 insertions(+), 300 deletions(-) delete mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.java create mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.kt delete mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.java create mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.kt delete mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.java create mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.kt delete mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.java create mode 100644 core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.kt diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.java b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.java deleted file mode 100644 index 0329e41b5..000000000 --- a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.mifos.mobilewallet.core.domain.usecase.kyc; - -import org.mifos.mobilewallet.core.base.UseCase; -import org.mifos.mobilewallet.core.data.fineract.entity.kyc.KYCLevel1Details; -import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository; - -import java.util.List; - -import javax.inject.Inject; - -import rx.Subscriber; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; - -/** - * Created by ankur on 24/May/2018 - */ - -public class FetchKYCLevel1Details extends - UseCase { - - private final FineractRepository mFineractRepository; - - @Inject - public FetchKYCLevel1Details(FineractRepository fineractRepository) { - mFineractRepository = fineractRepository; - } - - @Override - protected void executeUseCase(RequestValues requestValues) { - - mFineractRepository.fetchKYCLevel1Details(requestValues.clientId) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber>() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - getUseCaseCallback().onError(e.toString()); - } - - @Override - public void onNext(List kycLevel1Details) { - getUseCaseCallback().onSuccess( - new ResponseValue(kycLevel1Details)); - } - }); - - - } - - public static final class RequestValues implements UseCase.RequestValues { - - private final int clientId; - - public RequestValues(int clientId) { - this.clientId = clientId; - } - } - - public static final class ResponseValue implements UseCase.ResponseValue { - - private final List mKYCLevel1DetailsList; - - public ResponseValue( - List kycLevel1Details) { - mKYCLevel1DetailsList = kycLevel1Details; - } - - public List getKYCLevel1DetailsList() { - return mKYCLevel1DetailsList; - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.kt b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.kt new file mode 100644 index 000000000..608aec613 --- /dev/null +++ b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/FetchKYCLevel1Details.kt @@ -0,0 +1,40 @@ +package org.mifos.mobilewallet.core.domain.usecase.kyc + +import org.mifos.mobilewallet.core.base.UseCase +import org.mifos.mobilewallet.core.data.fineract.entity.kyc.KYCLevel1Details +import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository +import rx.Subscriber +import rx.android.schedulers.AndroidSchedulers +import rx.schedulers.Schedulers +import javax.inject.Inject + +/** + * Created by ankur on 24/May/2018 + */ +class FetchKYCLevel1Details @Inject constructor(private val mFineractRepository: FineractRepository) : + UseCase() { + + class RequestValues(val clientId: Int) : UseCase.RequestValues + class ResponseValue( + val kycLevel1DetailsList: List + ) : UseCase.ResponseValue + + override fun executeUseCase(requestValues: RequestValues) { + mFineractRepository.fetchKYCLevel1Details(requestValues.clientId) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(object : Subscriber>() { + override fun onCompleted() {} + override fun onError(e: Throwable) { + useCaseCallback.onError(e.toString()) + } + + override fun onNext(kycLevel1Details: List) { + useCaseCallback.onSuccess( + ResponseValue(kycLevel1Details) + ) + } + }) + + } +} diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.java b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.java deleted file mode 100644 index 3a6f90858..000000000 --- a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.mifos.mobilewallet.core.domain.usecase.kyc; - -import org.mifos.mobilewallet.core.base.UseCase; -import org.mifos.mobilewallet.core.data.fineract.api.GenericResponse; -import org.mifos.mobilewallet.core.data.fineract.entity.kyc.KYCLevel1Details; -import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository; - -import javax.inject.Inject; - -import rx.Subscriber; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; - -/** - * Created by ankur on 25/May/2018 - */ - -public class UpdateKYCLevel1Details extends - UseCase { - - private final FineractRepository mFineractRepository; - - @Inject - public UpdateKYCLevel1Details(FineractRepository fineractRepository) { - this.mFineractRepository = fineractRepository; - } - - @Override - protected void executeUseCase(RequestValues requestValues) { - - mFineractRepository.updateKYCLevel1Details(requestValues.clientId, - requestValues.kycLevel1Details) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - getUseCaseCallback().onError(e.toString()); - } - - @Override - public void onNext(GenericResponse genericResponse) { - getUseCaseCallback().onSuccess(new ResponseValue()); - } - }); - } - - public static final class RequestValues implements UseCase.RequestValues { - - private final int clientId; - private final KYCLevel1Details kycLevel1Details; - - public RequestValues(int clientId, - KYCLevel1Details kycLevel1Details) { - this.clientId = clientId; - this.kycLevel1Details = kycLevel1Details; - } - } - - public static final class ResponseValue implements UseCase.ResponseValue { - - } -} diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.kt b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.kt new file mode 100644 index 000000000..df44f4ffc --- /dev/null +++ b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UpdateKYCLevel1Details.kt @@ -0,0 +1,45 @@ +package org.mifos.mobilewallet.core.domain.usecase.kyc + +import org.mifos.mobilewallet.core.base.UseCase +import org.mifos.mobilewallet.core.data.fineract.api.GenericResponse +import org.mifos.mobilewallet.core.data.fineract.entity.kyc.KYCLevel1Details +import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository +import rx.Subscriber +import rx.android.schedulers.AndroidSchedulers +import rx.schedulers.Schedulers +import javax.inject.Inject + +/** + * Created by ankur on 25/May/2018 + */ +class UpdateKYCLevel1Details @Inject constructor(private val mFineractRepository: FineractRepository) : + UseCase() { + + class RequestValues( + val clientId: Int, + val kycLevel1Details: KYCLevel1Details + ) : UseCase.RequestValues + + class ResponseValue : UseCase.ResponseValue + + override fun executeUseCase(requestValues: RequestValues) { + mFineractRepository.updateKYCLevel1Details( + requestValues.clientId, + requestValues.kycLevel1Details + ) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(object : Subscriber() { + override fun onCompleted() {} + override fun onError(e: Throwable) { + useCaseCallback.onError(e.toString()) + } + + override fun onNext(t: GenericResponse) { + useCaseCallback.onSuccess(ResponseValue()) + } + + }) + + } +} diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.java b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.java deleted file mode 100644 index f40c8751a..000000000 --- a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.mifos.mobilewallet.core.domain.usecase.kyc; - -import org.mifos.mobilewallet.core.base.UseCase; -import org.mifos.mobilewallet.core.data.fineract.api.GenericResponse; -import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository; - -import javax.inject.Inject; - -import okhttp3.MultipartBody; -import rx.Subscriber; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; - -/** - * Created by ankur on 16/May/2018 - */ - -public class UploadKYCDocs extends UseCase { - - private final FineractRepository apiRepository; - - @Inject - public UploadKYCDocs(FineractRepository apiRepository) { - this.apiRepository = apiRepository; - } - - @Override - protected void executeUseCase(RequestValues requestValues) { - - apiRepository.uploadKYCDocs(requestValues.entitytype, requestValues.clientId, - requestValues.docname, requestValues.identityType, requestValues.file) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - getUseCaseCallback().onError(e.toString()); - } - - @Override - public void onNext(GenericResponse genericResponse) { - getUseCaseCallback().onSuccess(new ResponseValue()); - } - }); - } - - public static final class RequestValues implements UseCase.RequestValues { - public final String entitytype; - private final long clientId; - private final String docname; - private final String identityType; - private final MultipartBody.Part file; - - public RequestValues(String entitytype, long clientId, String docname, - String identityType, MultipartBody.Part file) { - this.entitytype = entitytype; - this.clientId = clientId; - this.docname = docname; - this.identityType = identityType; - this.file = file; - } - } - - public static final class ResponseValue implements UseCase.ResponseValue { - public ResponseValue() { - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.kt b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.kt new file mode 100644 index 000000000..62aeafac3 --- /dev/null +++ b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCDocs.kt @@ -0,0 +1,44 @@ +package org.mifos.mobilewallet.core.domain.usecase.kyc + +import okhttp3.MultipartBody +import org.mifos.mobilewallet.core.base.UseCase +import org.mifos.mobilewallet.core.data.fineract.api.GenericResponse +import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository +import rx.Subscriber +import rx.android.schedulers.AndroidSchedulers +import rx.schedulers.Schedulers +import javax.inject.Inject + +/** + * Created by ankur on 16/May/2018 + */ +class UploadKYCDocs @Inject constructor(private val apiRepository: FineractRepository) : + UseCase() { + + class RequestValues( + val entitytype: String, val clientId: Long, val docname: String, + val identityType: String, val file: MultipartBody.Part + ) : UseCase.RequestValues + + class ResponseValue : UseCase.ResponseValue + + override fun executeUseCase(requestValues: RequestValues) { + apiRepository.uploadKYCDocs( + requestValues.entitytype, requestValues.clientId, + requestValues.docname, requestValues.identityType, requestValues.file + ) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(object : Subscriber() { + override fun onCompleted() {} + override fun onError(e: Throwable) { + useCaseCallback.onError(e.toString()) + } + + override fun onNext(t: GenericResponse) { + useCaseCallback.onSuccess(ResponseValue()) + } + }) + + } +} diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.java b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.java deleted file mode 100644 index 8f73013fa..000000000 --- a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.mifos.mobilewallet.core.domain.usecase.kyc; - -import org.mifos.mobilewallet.core.base.UseCase; -import org.mifos.mobilewallet.core.data.fineract.api.GenericResponse; -import org.mifos.mobilewallet.core.data.fineract.entity.kyc.KYCLevel1Details; -import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository; - -import javax.inject.Inject; - -import rx.Subscriber; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; - -/** - * Created by ankur on 24/May/2018 - */ - -public class UploadKYCLevel1Details extends - UseCase { - - FineractRepository mFineractRepository; - - @Inject - public UploadKYCLevel1Details(FineractRepository fineractRepository) { - mFineractRepository = fineractRepository; - } - - @Override - protected void executeUseCase(RequestValues requestValues) { - - mFineractRepository.uploadKYCLevel1Details(requestValues.clientId, - requestValues.mKYCLevel1Details) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - getUseCaseCallback().onError(e.toString()); - } - - @Override - public void onNext(GenericResponse genericResponse) { - getUseCaseCallback().onSuccess(new ResponseValue()); - } - }); - - } - - public static final class RequestValues implements UseCase.RequestValues { - private final int clientId; - private final KYCLevel1Details mKYCLevel1Details; - - public RequestValues(int clientId, - KYCLevel1Details kycLevel1Details) { - this.clientId = clientId; - mKYCLevel1Details = kycLevel1Details; - } - } - - public static final class ResponseValue implements UseCase.ResponseValue { - - } -} diff --git a/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.kt b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.kt new file mode 100644 index 000000000..acea67108 --- /dev/null +++ b/core/data/src/main/java/org/mifos/mobilewallet/core/domain/usecase/kyc/UploadKYCLevel1Details.kt @@ -0,0 +1,43 @@ +package org.mifos.mobilewallet.core.domain.usecase.kyc + +import org.mifos.mobilewallet.core.base.UseCase +import org.mifos.mobilewallet.core.data.fineract.api.GenericResponse +import org.mifos.mobilewallet.core.data.fineract.entity.kyc.KYCLevel1Details +import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository +import rx.Subscriber +import rx.android.schedulers.AndroidSchedulers +import rx.schedulers.Schedulers +import javax.inject.Inject + +/** + * Created by ankur on 24/May/2018 + */ +class UploadKYCLevel1Details @Inject constructor(var mFineractRepository: FineractRepository) : + UseCase() { + class RequestValues( + val clientId: Int, + val mKYCLevel1Details: KYCLevel1Details + ) : UseCase.RequestValues + + class ResponseValue : UseCase.ResponseValue + + override fun executeUseCase(requestValues: RequestValues) { + mFineractRepository.uploadKYCLevel1Details( + requestValues.clientId, + requestValues.mKYCLevel1Details + ) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(object : Subscriber() { + override fun onCompleted() {} + override fun onError(e: Throwable) { + useCaseCallback.onError(e.toString()) + } + + override fun onNext(t: GenericResponse) { + useCaseCallback.onSuccess(ResponseValue()) + } + }) + + } +} diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel2Presenter.kt b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel2Presenter.kt index dd43d0c56..466ce3e91 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel2Presenter.kt +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/kyc/presenter/KYCLevel2Presenter.kt @@ -69,31 +69,33 @@ class KYCLevel2Presenter @Inject constructor( override fun uploadKYCDocs(identityType: String?) { if (file != null) { - uploadKYCDocsUseCase!!.requestValues = UploadKYCDocs.RequestValues( - org.mifos.mobilewallet.core.utils.Constants.ENTITY_TYPE_CLIENTS, - preferencesHelper.clientId, file!!.name, identityType, - getRequestFileBody(file!!) - ) + uploadKYCDocsUseCase!!.requestValues = identityType?.let { + UploadKYCDocs.RequestValues( + org.mifos.mobilewallet.core.utils.Constants.ENTITY_TYPE_CLIENTS, + preferencesHelper.clientId, file!!.name, it, + getRequestFileBody(file!!) + ) + } val requestValues = uploadKYCDocsUseCase!!.requestValues mUseCaseHandler.execute(uploadKYCDocsUseCase, requestValues, object : UseCaseCallback { override fun onSuccess(response: UploadKYCDocs.ResponseValue?) { - mKYCLevel2View!!.hideProgressDialog() - mKYCLevel2View!!.showToast( + mKYCLevel2View?.hideProgressDialog() + mKYCLevel2View?.showToast( Constants.KYC_LEVEL_2_DOCUMENTS_ADDED_SUCCESSFULLY ) - mKYCLevel2View!!.goBack() + mKYCLevel2View?.goBack() } override fun onError(message: String) { - mKYCLevel2View!!.hideProgressDialog() - mKYCLevel2View!!.showToast(Constants.ERROR_UPLOADING_DOCS) + mKYCLevel2View?.hideProgressDialog() + mKYCLevel2View?.showToast(Constants.ERROR_UPLOADING_DOCS) } }) } else { // choose a file first - mKYCLevel2View!!.showToast(Constants.CHOOSE_A_FILE_TO_UPLOAD) - mKYCLevel2View!!.hideProgressDialog() + mKYCLevel2View?.showToast(Constants.CHOOSE_A_FILE_TO_UPLOAD) + mKYCLevel2View?.hideProgressDialog() } }