getCoinsChart method

Future<CoinsPriceResponse> getCoinsChart(
  1. String currency,
  2. int nbDays
)

Get Uniris Coin infos (Prices, Marketcaps, Total Volumes) @param {String} currency @param {int} nbDays

Implementation

Future<CoinsPriceResponse> getCoinsChart(String currency, int nbDays) async {
  CoinsPriceResponse? coinsPriceResponse;
  final Map<String, String> requestHeaders = {
    'Content-type': 'application/json'
  };

  try {
    final http.Response responseHttp = await http.get(
        Uri.parse(
            'https://api.coingecko.com/api/v3/coins/uniris/market_chart?vs_currency=' +
                currency +
                '&days=' +
                nbDays.toString()),
        headers: requestHeaders);
    if (responseHttp.statusCode == 200) {
      coinsPriceResponse = coinsPriceResponseFromJson(responseHttp.body);
    }
  } catch (e) {
    logger.e(e.toString());
  }
  return coinsPriceResponse!;
}