Updated on 2026-08-14

This commit is contained in:
Tangem 2024-02-07 19:27:16 +03:00
parent 710e944eae
commit c22dc2df3b
11 changed files with 259 additions and 7 deletions

View file

@ -19,4 +19,5 @@ dependencies {
/** Libs - Other */
implementation(deps.jodatime)
implementation(deps.androidx.paging.runtime)
}

View file

@ -0,0 +1,32 @@
package com.tangem.domain.visa
import androidx.paging.PagingData
import arrow.core.Either
import arrow.core.left
import arrow.core.right
import com.tangem.domain.visa.model.VisaTxHistoryItem
import com.tangem.domain.visa.repository.VisaRepository
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
class GetVisaTxHistoryUseCase(
private val visaRepository: VisaRepository,
) {
suspend operator fun invoke(
userWalletId: UserWalletId,
pageSize: Int = DEFAULT_PAGE_SIZE,
isRefresh: Boolean = false,
): Flow<Either<Throwable, PagingData<VisaTxHistoryItem>>> {
return visaRepository
.getTxHistory(userWalletId, pageSize, isRefresh)
.map<PagingData<VisaTxHistoryItem>, Either<Throwable, PagingData<VisaTxHistoryItem>>> { it.right() }
.catch { emit(it.left()) }
}
companion object {
const val DEFAULT_PAGE_SIZE = 10
}
}

View file

@ -0,0 +1,15 @@
package com.tangem.domain.visa.model
import org.joda.time.DateTime
import java.math.BigDecimal
import java.util.Currency
data class VisaTxHistoryItem(
val id: String,
val date: DateTime,
val amount: BigDecimal,
val fiatAmount: BigDecimal,
val merchantName: String?,
val status: String,
val fiatCurrency: Currency,
)

View file

@ -1,9 +1,18 @@
package com.tangem.domain.visa.repository
import androidx.paging.PagingData
import com.tangem.domain.visa.model.VisaCurrency
import com.tangem.domain.visa.model.VisaTxHistoryItem
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
interface VisaRepository {
suspend fun getVisaCurrency(userWalletId: UserWalletId, isRefresh: Boolean = false): VisaCurrency
suspend fun getTxHistory(
userWalletId: UserWalletId,
pageSize: Int,
isRefresh: Boolean = false,
): Flow<PagingData<VisaTxHistoryItem>>
}