Updated on 2026-08-14

This commit is contained in:
Tangem 2022-04-18 22:26:51 +03:00
parent 268b74cb0e
commit 704315ddaf
18 changed files with 169 additions and 103 deletions

View file

@ -9,12 +9,7 @@ interface HttpResponse
sealed interface TangemTechResponse : HttpResponse
sealed class Coins : TangemTechResponse {
data class PricesResponse(val prices: List<Price>) : Coins() {
data class Price(
val name: String,
val price: BigDecimal,
)
}
data class PricesResponse(val prices: Map<String, Double>) : Coins()
data class CheckAddressResponse(val imageHost: String?, val tokens: List<Token>, val total: Int) : Coins() {
data class Token(
@ -51,11 +46,15 @@ sealed class Coins : TangemTechResponse {
data class CurrenciesResponse(val currencies: List<Currency>) {
data class Currency(
val id: String,
val code: String,
val code: String, // this is an uppercase id
val name: String,
val rateBTC: String,
val unit: String,
val unit: String, // $, €, ₽
val type: String,
)
enum class CurrencyType(val type: String) {
Fiat("fiat"), Crypto("crypto")
}
}
}

View file

@ -11,7 +11,7 @@ interface TangemTechApi {
@GET("coins/prices")
suspend fun coinsPrices(
@Query("currency") currency: String,
@Query("ids") ids: List<String>,
@Query("ids") ids: String,
): Coins.PricesResponse
@GET("coins/check-address")

View file

@ -34,7 +34,8 @@ class TangemTechService {
private fun createApi(): TangemTechApi {
val retrofit = createRetrofitInstance(
baseUrl = baseUrl,
interceptors = headerInterceptors.toList()
interceptors = headerInterceptors.toList(),
// logEnabled = true,
)
return retrofit.create(TangemTechApi::class.java).apply {
techRoutes.forEach { it.setApi(this) }
@ -62,7 +63,9 @@ class CoinsRoute : TangemTechRoute {
currency: String,
ids: List<String>
): Result<Coins.PricesResponse> = withContext(Dispatchers.IO) {
performRequest { api.coinsPrices(currency, ids) }
performRequest {
api.coinsPrices(currency.lowercase(), ids.joinToString(","))
}
}
suspend fun checkAddress(