esg method
The esg method is used to get the ESG scores for a given stock symbol.
The id
argument is used to specify the stock id.
// Get ESG scores for Apple
final client = BavestRestClient(api_key);
final esg = client.esg(SecurityIdentifier(symbol: "AAPL"));
Implementation
@override
Future<Esg> esg(SecurityIdentifier id) async {
const url = '$_baseUrl/stock/esg';
final params = id.toJson();
var response = await _post(url, params);
if (_isSuccess(response)) {
return Esg.fromJson(jsonDecode(response!.data));
}
throw Exception("could not receive esg data for $id");
}