listDerivativeExchanges method
List all derivative exchanges.
order
sets results order.
Use DerivativeExchangesOrder enumeration as values.
Default is DerivativeExchangesOrder.nameAscending.
itemsPerPage
sets total results per page.
page
sets page through results.
Query path: /derivatives/exchanges
Implementation
Future<CoinGeckoResult<List<DerivativeExchange>>> listDerivativeExchanges({
String order = DerivativeExchangesOrder.nameAscending,
int? itemsPerPage,
int? page,
}) async {
final Map<String, dynamic> queryParameters = {
'order': order,
};
if (itemsPerPage is int) {
queryParameters['per_page'] = itemsPerPage;
}
if (page is int) {
queryParameters['page'] = page;
}
final response = await _client.dio.get(
'/derivatives/exchanges',
queryParameters: queryParameters,
);
if (response.statusCode == 200) {
final data = Convert.toList(response.data, []);
final list = data.map((e) => DerivativeExchange.fromJson(e)).toList();
return CoinGeckoResult(list);
} else {
return CoinGeckoResult(
[],
errorCode: response.statusCode ?? null,
errorMessage: '${response.statusMessage} - ${response.data.toString()}',
isError: true,
);
}
}