getProductStats method

Future<Map<String, Stats>> getProductStats({
  1. required String productId,
})

Get product stats

Gets 30day and 24hour stats for a product.

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductstats

Implementation

Future<Map<String, Stats>> getProductStats({
  required String productId,
}) async {
  var response =
      await _productsRestClient.getProductStats(productId: productId);

  if (response.statusCode != 200) throw response;

  var body = json.decode(response.body);
  return body.map((String key, value) {
    return MapEntry(key, Stats.fromJson(value));
  });
}