getGlobalDefiData method

Future<CoinGeckoResult<GlobalDefiData?>> getGlobalDefiData()

Get cryptocurrency global decentralized finance (defi) data.

Query path: /global/decentralized_finance_defi

Implementation

Future<CoinGeckoResult<GlobalDefiData?>> getGlobalDefiData() async {
  final response = await _client.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,
    );
  }
}