Skip to content

Commit

Permalink
refactor #1501: invoice usecase to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
PratyushSingh07 authored and therajanmaurya committed Feb 3, 2024
1 parent 102ac04 commit 74f78b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import javax.inject.Inject
class FetchInvoice @Inject constructor(private val mFineractRepository: FineractRepository) :
UseCase<FetchInvoice.RequestValues, FetchInvoice.ResponseValue>() {

class RequestValues(val uniquePaymentLink: Uri) : UseCase.RequestValues
class RequestValues(val uniquePaymentLink: Uri?) : UseCase.RequestValues
class ResponseValue(
val invoices: List<Invoice?>
) : UseCase.ResponseValue

override fun executeUseCase(requestValues: RequestValues) {
val paymentLink = requestValues.uniquePaymentLink
val scheme = paymentLink.scheme // "https"
val host = paymentLink.host // "invoice.mifospay.com"
val scheme = paymentLink?.scheme // "https"
val host = paymentLink?.host // "invoice.mifospay.com"
try {
val params = paymentLink.pathSegments
val params = paymentLink?.pathSegments
val clientId = params?.get(0) // "clientId"
val invoiceId = params?.get(1) // "invoiceId"
if (clientId != null && invoiceId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface InvoiceContract {
}

interface InvoicePresenter : BasePresenter {
fun getInvoiceDetails(data: Uri)
fun getInvoiceDetails(data: Uri?)
}

interface InvoicesView : BaseView<InvoicesPresenter?> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class InvoicePresenter @Inject constructor(
mInvoiceView!!.setPresenter(this)
}

override fun getInvoiceDetails(data: Uri) {
override fun getInvoiceDetails(data: Uri?) {
mUseCaseHandler.execute(fetchInvoiceUseCase, FetchInvoice.RequestValues(data),
object : UseCaseCallback<FetchInvoice.ResponseValue?> {
override fun onSuccess(response: FetchInvoice.ResponseValue?) {
object : UseCaseCallback<FetchInvoice.ResponseValue> {
override fun onSuccess(response: FetchInvoice.ResponseValue) {
mInvoiceView?.showInvoiceDetails(
response?.invoices?.get(0),
response.invoices[0],
mPreferencesHelper.fullName + " "
+ mPreferencesHelper.clientId, data.toString()
)
Expand Down

0 comments on commit 74f78b0

Please sign in to comment.