From e96286975991795843c8dd9f5f50ebc51c81cdd4 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 8 Oct 2024 18:25:20 -0500 Subject: [PATCH] add type alias for token price response --- .../com/example/walletapp/data/datasource/CoinGeckoApi.kt | 4 +++- .../com/example/walletapp/data/repository/CoinRepository.kt | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wallet_app/android/app/src/main/java/com/example/walletapp/data/datasource/CoinGeckoApi.kt b/wallet_app/android/app/src/main/java/com/example/walletapp/data/datasource/CoinGeckoApi.kt index 857b647d..c09d25a8 100644 --- a/wallet_app/android/app/src/main/java/com/example/walletapp/data/datasource/CoinGeckoApi.kt +++ b/wallet_app/android/app/src/main/java/com/example/walletapp/data/datasource/CoinGeckoApi.kt @@ -5,6 +5,8 @@ import retrofit2.http.GET import retrofit2.http.Headers import retrofit2.http.Query +typealias GetTokenPriceResponse = Response>>; + interface CoinGeckoApi { @Headers( "accept: application/json", @@ -14,5 +16,5 @@ interface CoinGeckoApi { suspend fun getTokenPrices( @Query("ids") ids: String, // Comma-separated token IDs @Query("vs_currencies") vsCurrencies: String // Comma-separated currency codes - ): Response>> + ): GetTokenPriceResponse } diff --git a/wallet_app/android/app/src/main/java/com/example/walletapp/data/repository/CoinRepository.kt b/wallet_app/android/app/src/main/java/com/example/walletapp/data/repository/CoinRepository.kt index 94378f74..45f7561c 100644 --- a/wallet_app/android/app/src/main/java/com/example/walletapp/data/repository/CoinRepository.kt +++ b/wallet_app/android/app/src/main/java/com/example/walletapp/data/repository/CoinRepository.kt @@ -4,12 +4,13 @@ import com.example.walletapp.di.RetrofitClient import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import retrofit2.Response +import com.example.walletapp.data.datasource.GetTokenPriceResponse class CoinRepository { suspend fun getTokenPrices( ids: String, vsCurrencies: String - ): Response>> { + ): GetTokenPriceResponse { return withContext(Dispatchers.IO) { RetrofitClient.apiService.getTokenPrices(ids, vsCurrencies) }