Skip to content

Commit

Permalink
add type alias for token price response
Browse files Browse the repository at this point in the history
  • Loading branch information
trbutler4 committed Oct 8, 2024
1 parent 6102c68 commit e962869
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Query

typealias GetTokenPriceResponse = Response<Map<String, Map<String, Double>>>;

interface CoinGeckoApi {
@Headers(
"accept: application/json",
Expand All @@ -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<Map<String, Map<String, Double>>>
): GetTokenPriceResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, Map<String, Double>>> {
): GetTokenPriceResponse {
return withContext(Dispatchers.IO) {
RetrofitClient.apiService.getTokenPrices(ids, vsCurrencies)
}
Expand Down

0 comments on commit e962869

Please sign in to comment.