metric method

  1. @override
Future<Metric> metric(
  1. SecurityIdentifier id
)
override

The metric method is used to get the metric for a given stock symbol.

The id argument is used to specify the stock id.

// Get metric for Apple
final client = BavestRestClient(api_key);
final metric = client.metric(SecurityIdentifier(symbol: "AAPL"));

Implementation

@override
Future<Metric> metric(SecurityIdentifier id) async {
  const url = '$_baseUrl/stock/metric';
  final params = id.toJson();

  var response = await _post(url, params);
  if (response != null && response.statusCode == 200) {
    return Metric.fromJson(jsonDecode(response.data));
  }

  throw Exception("could not fetch API");
}