Updated on 2026-08-14
This commit is contained in:
parent
65a55cb5e3
commit
268b74cb0e
4 changed files with 49 additions and 11 deletions
|
|
@ -5,6 +5,8 @@ import com.tangem.common.services.performRequest
|
|||
import com.tangem.network.common.AddHeaderInterceptor
|
||||
import com.tangem.network.common.CacheControlHttpInterceptor
|
||||
import com.tangem.network.common.createRetrofitInstance
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -59,22 +61,22 @@ class CoinsRoute : TangemTechRoute {
|
|||
suspend fun prices(
|
||||
currency: String,
|
||||
ids: List<String>
|
||||
): Result<Coins.PricesResponse> {
|
||||
return performRequest { api.coinsPrices(currency, ids) }
|
||||
): Result<Coins.PricesResponse> = withContext(Dispatchers.IO) {
|
||||
performRequest { api.coinsPrices(currency, ids) }
|
||||
}
|
||||
|
||||
suspend fun checkAddress(
|
||||
contractAddress: String,
|
||||
networkId: String? = null
|
||||
): Result<Coins.CheckAddressResponse> {
|
||||
return performRequest { api.coinsCheckAddress(contractAddress, networkId) }
|
||||
): Result<Coins.CheckAddressResponse> = withContext(Dispatchers.IO) {
|
||||
performRequest { api.coinsCheckAddress(contractAddress, networkId) }
|
||||
}
|
||||
|
||||
suspend fun currencies(): Result<Coins.CurrenciesResponse> {
|
||||
return performRequest { api.coinsCurrencies() }
|
||||
suspend fun currencies(): Result<Coins.CurrenciesResponse> = withContext(Dispatchers.IO) {
|
||||
performRequest { api.coinsCurrencies() }
|
||||
}
|
||||
|
||||
suspend fun tokens(): Result<Coins.TokensResponse> {
|
||||
return performRequest { api.coinsTokens() }
|
||||
suspend fun tokens(): Result<Coins.TokensResponse> = withContext(Dispatchers.IO) {
|
||||
performRequest { api.coinsTokens() }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.network.common
|
||||
|
||||
import com.tangem.common.module.ModuleError
|
||||
import com.tangem.common.module.ModuleMessage
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
sealed interface NetworkModuleMessage : ModuleMessage
|
||||
|
||||
sealed class NetworkError(
|
||||
subCode: Int,
|
||||
override val message: String,
|
||||
override val data: Any?,
|
||||
) : NetworkModuleMessage, ModuleError {
|
||||
override val code: Int = ERROR_CODE_NETWORK + subCode
|
||||
|
||||
companion object {
|
||||
// base code used for all error in the module
|
||||
const val ERROR_CODE_NETWORK = 20000
|
||||
// const val CODE_ANY_OTHER = 100..199
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.network.common
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
interface NetworkInternalException
|
||||
|
||||
sealed class NetworkException(message: String?) : Throwable(message), NetworkInternalException {
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue