getGlobalDefiData method
Get cryptocurrency global decentralized finance (defi) data.
Query: /global/decentralized_finance_defi
Implementation
Future<CoinGeckoResult<GlobalDefiData?>> getGlobalDefiData() async {
final response = await _dio.get(
'/global/decentralized_finance_defi',
);
if (response.statusCode == 200) {
final data = Convert.toMapN<String, dynamic>(response.data['data']);
final result = data != null ? GlobalDefiData.fromJson(data) : null;
return CoinGeckoResult(result);
} else {
return CoinGeckoResult(
null,
errorCode: response.statusCode ?? null,
errorMessage: '${response.statusMessage} - ${response.data.toString()}',
isError: true,
);
}
}