Updated on 2026-08-14
This commit is contained in:
parent
8312c85fa6
commit
2d0393be5d
32 changed files with 543 additions and 306 deletions
|
|
@ -9,7 +9,7 @@ interface HttpResponse
|
|||
sealed interface TangemTechResponse : HttpResponse
|
||||
|
||||
data class CoinsResponse(
|
||||
val imageHost: String,
|
||||
val imageHost: String?,
|
||||
val coins: List<Coin>,
|
||||
val total: Int
|
||||
) : TangemTechResponse {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,11 @@ interface TangemTechApi {
|
|||
@GET("coins")
|
||||
suspend fun coins(
|
||||
@Query("contractAddress") contractAddress: String? = null,
|
||||
@Query("networkIds") networkId: String? = null,
|
||||
@Query("networkIds") networkIds: String? = null,
|
||||
@Query("active") active: Boolean? = null,
|
||||
@Query("searchText") searchText: String? = null,
|
||||
@Query("offset") offset: Int? = null,
|
||||
@Query("limit") limit: Int? = null
|
||||
): CoinsResponse
|
||||
|
||||
@GET("rates")
|
||||
|
|
|
|||
|
|
@ -15,15 +15,37 @@ class TangemTechService {
|
|||
private val headerInterceptors = mutableListOf<AddHeaderInterceptor>(
|
||||
CacheControlHttpInterceptor(cacheMaxAge)
|
||||
)
|
||||
|
||||
|
||||
private var api: TangemTechApi = createApi()
|
||||
|
||||
suspend fun coins(
|
||||
contractAddress: String? = null,
|
||||
suspend fun getTokens(
|
||||
contractAddress: String,
|
||||
networkId: String? = null,
|
||||
active: Boolean? = null,
|
||||
): Result<CoinsResponse> = withContext(Dispatchers.IO) {
|
||||
performRequest { api.coins(contractAddress, networkId, active) }
|
||||
performRequest {
|
||||
api.coins(
|
||||
contractAddress = contractAddress,
|
||||
networkIds = networkId,
|
||||
active = active
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getListOfCoins(
|
||||
networkIds: List<String>,
|
||||
searchText: String? = null,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
): Result<CoinsResponse> = withContext(Dispatchers.IO) {
|
||||
performRequest {
|
||||
api.coins(
|
||||
networkIds = networkIds.joinToString(","),
|
||||
searchText = searchText,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun rates(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue