Updated on 2026-08-14

This commit is contained in:
Tangem 2024-08-28 15:46:27 +03:00
parent 297a006e3d
commit 7b7cece46f
35 changed files with 436 additions and 422 deletions

View file

@ -27,7 +27,13 @@ data class TokenMarketInfo(
val liquidityChange: Change?,
val buyPressureChange: Change?,
val experiencedBuyerChange: Change?,
)
val sourceNetworks: List<SourceNetwork>,
) {
data class SourceNetwork(
val id: String,
val name: String,
)
}
data class Change(
val day: BigDecimal?,

View file

@ -0,0 +1,24 @@
package com.tangem.domain.markets
import arrow.core.*
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Quote
import com.tangem.domain.tokens.repository.QuotesRepository
import kotlinx.coroutines.flow.*
@Suppress("UnusedPrivateMember")
class GetCurrencyQuotesUseCase(
private val quotesRepository: QuotesRepository,
) {
// TODO apply interval parameter [REDACTED_TASK_KEY]
operator fun invoke(
currencyID: CryptoCurrency.ID,
interval: PriceChangeInterval,
refresh: Boolean,
): Flow<Option<Quote>> {
return quotesRepository.getQuotesUpdates(
currenciesIds = setOf(currencyID),
refresh = refresh,
).map { it.firstOrNull().toOption() }.catch { emit(None) }
}
}

View file

@ -1,26 +0,0 @@
package com.tangem.domain.markets
import arrow.core.Either
import com.tangem.domain.tokens.model.Quote
import com.tangem.domain.tokens.repository.QuotesRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
@Suppress("UnusedPrivateMember")
class GetTokenQuotesUseCase(
private val quotesRepository: QuotesRepository,
) {
operator fun invoke(tokenId: String, interval: PriceChangeInterval): Flow<Either<Unit, Quote>> {
return flowOf(
Either.catch {
Quote(
rawCurrencyId = "USD",
fiatRate = 100.toBigDecimal(), // mock
priceChange = 10.toBigDecimal(), // mock
)
}.mapLeft {},
)
// TODO implement quotes fetching from repository [REDACTED_TASK_KEY]
// quotesRepository.getQuotesUpdates()
}
}