Skip to content

Commit

Permalink
refactored the remaining files to kotilin
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanNlc authored and therajanmaurya committed Apr 3, 2024
1 parent 47de8b7 commit 93a1006
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 518 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.mifos.mobilewallet.core.domain.usecase.account

import okhttp3.ResponseBody
import org.mifos.mobilewallet.core.base.UseCase
import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository
import org.mifos.mobilewallet.core.util.Constants
import rx.Subscriber
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
import javax.inject.Inject

/**
* Created by ankur on 06/June/2018
*/
class DownloadTransactionReceipt @Inject constructor(private val mFineractRepository: FineractRepository) :
UseCase<DownloadTransactionReceipt.RequestValues, DownloadTransactionReceipt.ResponseValue>() {
override fun executeUseCase(requestValues: RequestValues) {
requestValues.transactionId?.let {
mFineractRepository.getTransactionReceipt(Constants.PDF, it)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<ResponseBody>() {
override fun onCompleted() {}
override fun onError(e: Throwable) {
useCaseCallback.onError(e.toString())
}

override fun onNext(t: ResponseBody) {
val responseBody = t
useCaseCallback.onSuccess(ResponseValue(responseBody))
}
})
}
}

data class RequestValues( val transactionId: String?) : UseCase.RequestValues
data class ResponseValue(val responseBody: ResponseBody) : UseCase.ResponseValue
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.mifos.mobilewallet.core.domain.usecase.account

import com.mifos.mobilewallet.model.domain.Transaction
import com.mifos.mobilewallet.model.entity.accounts.savings.Transactions
import org.mifos.mobilewallet.core.base.UseCase
import org.mifos.mobilewallet.core.data.fineract.entity.mapper.TransactionMapper
import org.mifos.mobilewallet.core.data.fineract.repository.FineractRepository
import org.mifos.mobilewallet.core.util.Constants
import rx.Observer
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
import javax.inject.Inject

/**
* Created by Shivansh on 15/6/19.
*/
class FetchAccountTransaction @Inject constructor(
val fineractRepository: FineractRepository,
val transactionMapper: TransactionMapper
) :
UseCase<FetchAccountTransaction.RequestValues, FetchAccountTransaction.ResponseValue>() {
override fun executeUseCase(requestValues: RequestValues) {
fineractRepository.getSelfAccountTransactionFromId(
requestValues.accountId,
requestValues.transactionId
)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Observer<Transactions?> {
override fun onCompleted() {}
override fun onError(e: Throwable) {
if (e.message == "HTTP 401 Unauthorized") {
useCaseCallback.onError(Constants.UNAUTHORIZED_ERROR)
} else {
useCaseCallback.onError(
Constants.ERROR_FETCHING_REMOTE_ACCOUNT_TRANSACTIONS
)
}
}

override fun onNext(transaction: Transactions?) {
useCaseCallback.onSuccess(
ResponseValue(
transactionMapper
.transformInvoice(transaction)
)
)
}
})
}

data class RequestValues(
val accountId: Long,
val transactionId: Long
) : UseCase.RequestValues


data class ResponseValue(val transaction: Transaction) : UseCase.ResponseValue
}

This file was deleted.

Loading

0 comments on commit 93a1006

Please sign in to comment.