Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-16 22:34:07 +03:00
parent d3cb89b1a1
commit a94db85dfd
7 changed files with 65 additions and 13 deletions

View file

@ -11,4 +11,17 @@ data class TokenQuotes(
val m6ChangePercent: BigDecimal?,
val yearChangePercent: BigDecimal?,
val allTimeChangePercent: BigDecimal?,
)
)
fun TokenQuotes.populateWith(quotes: TokenQuotes): TokenQuotes {
return TokenQuotes(
currentPrice = quotes.currentPrice,
h24ChangePercent = quotes.h24ChangePercent ?: this.h24ChangePercent,
weekChangePercent = quotes.weekChangePercent ?: this.weekChangePercent,
monthChangePercent = quotes.monthChangePercent ?: this.monthChangePercent,
m3ChangePercent = quotes.m3ChangePercent ?: this.m3ChangePercent,
m6ChangePercent = quotes.m6ChangePercent ?: this.m6ChangePercent,
yearChangePercent = quotes.yearChangePercent ?: this.yearChangePercent,
allTimeChangePercent = quotes.allTimeChangePercent ?: this.allTimeChangePercent,
)
}

View file

@ -7,4 +7,15 @@ data class TokenQuotesShort(
val h24ChangePercent: BigDecimal,
val weekChangePercent: BigDecimal,
val monthChangePercent: BigDecimal,
)
fun TokenQuotesShort.toFull() = TokenQuotes(
currentPrice = currentPrice,
h24ChangePercent = h24ChangePercent,
weekChangePercent = weekChangePercent,
monthChangePercent = monthChangePercent,
m3ChangePercent = null,
m6ChangePercent = null,
yearChangePercent = null,
allTimeChangePercent = null,
)

View file

@ -7,11 +7,16 @@ import com.tangem.domain.markets.repositories.MarketsTokenRepository
class GetTokenFullQuotesUseCase(
private val marketsTokenRepository: MarketsTokenRepository,
) {
suspend operator fun invoke(appCurrency: AppCurrency, tokenId: String): Either<Unit, TokenQuotes> {
suspend operator fun invoke(
appCurrency: AppCurrency,
tokenId: String,
tokenSymbol: String,
): Either<Unit, TokenQuotes> {
return Either.catch {
marketsTokenRepository.getTokenQuotes(
fiatCurrencyCode = appCurrency.code,
tokenId = tokenId,
tokenSymbol = tokenSymbol,
)
}.mapLeft {}
}

View file

@ -33,7 +33,7 @@ interface MarketsTokenRepository {
languageCode: String,
): TokenMarketInfo
suspend fun getTokenQuotes(fiatCurrencyCode: String, tokenId: String): TokenQuotes
suspend fun getTokenQuotes(fiatCurrencyCode: String, tokenId: String, tokenSymbol: String): TokenQuotes
suspend fun createCryptoCurrency(
userWalletId: UserWalletId,