Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-30 11:18:15 +03:00
parent 1474d83756
commit 725705ecf2
9 changed files with 64 additions and 36 deletions

View file

@ -34,18 +34,6 @@ data class CoinsResponse(
//rates.keys = networkId's
data class RatesResponse(val rates: Map<String, Double>) : TangemTechResponse
data class CurrenciesResponse(val currencies: List<Currency>) {
data class Currency(
val id: String,
val code: String, // this is an uppercase id
val name: String,
val rateBTC: String,
val unit: String, // $, €, ₽
val type: String,
) : TangemTechResponse
}
data class GeoResponse(
val code: String,
) : TangemTechResponse

View file

@ -1,5 +1,6 @@
package com.tangem.datasource.api.tangemTech
import com.tangem.datasource.api.tangemTech.models.CurrenciesResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PUT
@ -29,7 +30,7 @@ interface TangemTechApi {
): RatesResponse
@GET("currencies")
suspend fun currencies(): CurrenciesResponse
suspend fun getCurrencyList(): CurrenciesResponse
@GET("geo")
suspend fun geo(): GeoResponse

View file

@ -19,7 +19,7 @@ class TangemTechService(
CacheControlHttpInterceptor(cacheMaxAge),
)
private var api: TangemTechApi = createApi()
var api: TangemTechApi = createApi()
suspend fun coins(
contractAddress: String? = null,
@ -54,10 +54,6 @@ class TangemTechService(
performRequest { api.geo() }
}
suspend fun currencies(): Result<CurrenciesResponse> = withContext(Dispatchers.IO) {
performRequest { api.currencies() }
}
suspend fun getUserTokens(userId: String): Result<UserTokensResponse> = withContext(Dispatchers.IO) {
performRequest { api.getUserTokens(userId) }
}

View file

@ -0,0 +1,16 @@
package com.tangem.datasource.api.tangemTech.models
import com.squareup.moshi.Json
data class CurrenciesResponse(
@Json(name = "currencies") val currencies: List<Currency>
)
data class Currency(
@Json(name = "id") val id: String,
@Json(name = "code") val code: String, // this is an uppercase id
@Json(name = "name") val name: String,
@Json(name = "rateBTC") val rateBTC: String,
@Json(name = "unit") val unit: String, // $, €, ₽
@Json(name = "type") val type: String
)