getBtcExchangeRates method
Get BTC-to-Currency exchange rates.
Query: /exchange_rates
Implementation
Future<CoinGeckoResult<Map<String, ExchangeRate>>>
getBtcExchangeRates() async {
final response = await _dio.get(
'/exchange_rates',
);
if (response.statusCode == 200) {
final responseMap = Convert.toMapN(response.data['rates']) ?? {};
final map = responseMap.map((key, value) =>
MapEntry(key.toString(), ExchangeRate.fromJson(value)));
return CoinGeckoResult(map);
} else {
return CoinGeckoResult(
{},
errorCode: response.statusCode ?? null,
errorMessage: '${response.statusMessage} - ${response.data.toString()}',
isError: true,
);
}
}