-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
416 additions
and
450 deletions.
There are no files selected for viewing
38 changes: 0 additions & 38 deletions
38
mifospay/src/main/java/org/mifos/mobilewallet/mifospay/receipt/ReceiptContract.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
mifospay/src/main/java/org/mifos/mobilewallet/mifospay/receipt/ReceiptContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.mifos.mobilewallet.mifospay.receipt | ||
|
||
import okhttp3.ResponseBody | ||
import org.mifos.mobilewallet.core.data.fineract.entity.accounts.savings.TransferDetail | ||
import org.mifos.mobilewallet.core.domain.model.Transaction | ||
import org.mifos.mobilewallet.mifospay.base.BasePresenter | ||
import org.mifos.mobilewallet.mifospay.base.BaseView | ||
|
||
/** | ||
* Created by ankur on 06/June/2018 | ||
*/ | ||
interface ReceiptContract { | ||
interface ReceiptView : BaseView<ReceiptPresenter?> { | ||
fun showSnackbar(message: String?) | ||
fun writeReceiptToPDF(responseBody: ResponseBody?, filename: String?) | ||
fun hideProgressDialog() | ||
fun showTransactionDetail(transaction: Transaction?) | ||
fun showTransferDetail(transferDetail: TransferDetail?) | ||
fun openPassCodeActivity() | ||
} | ||
|
||
interface ReceiptPresenter : BasePresenter { | ||
fun downloadReceipt(transactionId: String?) | ||
fun fetchTransaction(transactionId: Long) | ||
} | ||
} |
106 changes: 0 additions & 106 deletions
106
...pay/src/main/java/org/mifos/mobilewallet/mifospay/receipt/presenter/ReceiptPresenter.java
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
mifospay/src/main/java/org/mifos/mobilewallet/mifospay/receipt/presenter/ReceiptPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.mifos.mobilewallet.mifospay.receipt.presenter | ||
|
||
import org.mifos.mobilewallet.core.base.UseCase.UseCaseCallback | ||
import org.mifos.mobilewallet.core.base.UseCaseHandler | ||
import org.mifos.mobilewallet.core.domain.usecase.account.DownloadTransactionReceipt | ||
import org.mifos.mobilewallet.core.domain.usecase.account.FetchAccountTransaction | ||
import org.mifos.mobilewallet.core.domain.usecase.account.FetchAccountTransfer | ||
import org.mifos.mobilewallet.mifospay.base.BaseView | ||
import org.mifos.mobilewallet.mifospay.data.local.PreferencesHelper | ||
import org.mifos.mobilewallet.mifospay.receipt.ReceiptContract | ||
import org.mifos.mobilewallet.mifospay.receipt.ReceiptContract.ReceiptView | ||
import org.mifos.mobilewallet.mifospay.utils.Constants | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by ankur on 06/June/2018 | ||
*/ | ||
class ReceiptPresenter @Inject constructor( | ||
private val mUseCaseHandler: UseCaseHandler, | ||
private val preferencesHelper: PreferencesHelper | ||
) : ReceiptContract.ReceiptPresenter { | ||
private lateinit var mDownloadTransactionReceiptUseCase: DownloadTransactionReceipt | ||
private lateinit var mFetchAccountTransfer: FetchAccountTransfer | ||
private lateinit var mFetchAccountTransaction: FetchAccountTransaction | ||
private lateinit var mReceiptView: ReceiptView | ||
override fun attachView(baseView: BaseView<*>?) { | ||
mReceiptView = baseView as ReceiptView | ||
mReceiptView.setPresenter(this) | ||
} | ||
|
||
override fun downloadReceipt(transactionId: String?) { | ||
mUseCaseHandler.execute(mDownloadTransactionReceiptUseCase, | ||
DownloadTransactionReceipt.RequestValues(transactionId), | ||
object : UseCaseCallback<DownloadTransactionReceipt.ResponseValue> { | ||
override fun onSuccess(response: DownloadTransactionReceipt.ResponseValue) { | ||
mReceiptView.writeReceiptToPDF( | ||
response.responseBody, | ||
Constants.RECEIPT + transactionId + Constants.PDF | ||
) | ||
} | ||
|
||
override fun onError(message: String) { | ||
mReceiptView.showSnackbar(Constants.ERROR_FETCHING_RECEIPT) | ||
} | ||
}) | ||
} | ||
|
||
override fun fetchTransaction(transactionId: Long) { | ||
val accountId = preferencesHelper.accountId | ||
mUseCaseHandler.execute(mFetchAccountTransaction, | ||
FetchAccountTransaction.RequestValues(accountId, transactionId), | ||
object : UseCaseCallback<FetchAccountTransaction.ResponseValue> { | ||
override fun onSuccess(response: FetchAccountTransaction.ResponseValue) { | ||
mReceiptView.showTransactionDetail(response.transaction) | ||
fetchTransfer(response.transaction.transferId) | ||
} | ||
|
||
override fun onError(message: String) { | ||
if (message == Constants.UNAUTHORIZED_ERROR) { | ||
mReceiptView.openPassCodeActivity() | ||
} else { | ||
mReceiptView.hideProgressDialog() | ||
mReceiptView.showSnackbar("Error fetching Transaction") | ||
} | ||
} | ||
} | ||
) | ||
} | ||
|
||
fun fetchTransfer(transferId: Long) { | ||
mUseCaseHandler.execute(mFetchAccountTransfer, | ||
FetchAccountTransfer.RequestValues(transferId), | ||
object : UseCaseCallback<FetchAccountTransfer.ResponseValue> { | ||
override fun onSuccess(response: FetchAccountTransfer.ResponseValue) { | ||
mReceiptView.showTransferDetail(response.transferDetail) | ||
} | ||
|
||
override fun onError(message: String) { | ||
mReceiptView.hideProgressDialog() | ||
mReceiptView.showSnackbar("Error fetching Account Transfer") | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.