Skip to content

Commit

Permalink
refactor #1503: kyc usecase migrated to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
PratyushSingh07 authored and therajanmaurya committed Feb 14, 2024
1 parent 13c8c64 commit ddc29f8
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 300 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<FetchKYCLevel1Details.RequestValues, FetchKYCLevel1Details.ResponseValue>() {

class RequestValues(val clientId: Int) : UseCase.RequestValues
class ResponseValue(
val kycLevel1DetailsList: List<KYCLevel1Details?>
) : UseCase.ResponseValue

override fun executeUseCase(requestValues: RequestValues) {
mFineractRepository.fetchKYCLevel1Details(requestValues.clientId)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<List<KYCLevel1Details?>>() {
override fun onCompleted() {}
override fun onError(e: Throwable) {
useCaseCallback.onError(e.toString())
}

override fun onNext(kycLevel1Details: List<KYCLevel1Details?>) {
useCaseCallback.onSuccess(
ResponseValue(kycLevel1Details)
)
}
})

}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<UpdateKYCLevel1Details.RequestValues, UpdateKYCLevel1Details.ResponseValue>() {

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<GenericResponse>() {
override fun onCompleted() {}
override fun onError(e: Throwable) {
useCaseCallback.onError(e.toString())
}

override fun onNext(t: GenericResponse) {
useCaseCallback.onSuccess(ResponseValue())
}

})

}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<UploadKYCDocs.RequestValues, UploadKYCDocs.ResponseValue>() {

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<GenericResponse>() {
override fun onCompleted() {}
override fun onError(e: Throwable) {
useCaseCallback.onError(e.toString())
}

override fun onNext(t: GenericResponse) {
useCaseCallback.onSuccess(ResponseValue())
}
})

}
}
Loading

0 comments on commit ddc29f8

Please sign in to comment.