dividends method
The dividends method is used to get the dividends for a given stock symbol.
By default, the dividends are returned in EUR. You can specify a different currency
by passing the currency
argument.
The id
argument is used to specify the stock id.
The currency
argument is used to specify the currency.
// Get dividends for Apple in EUR
final client = BavestRestClient(api_key);
final dividends = client.dividends(SecurityIdentifier(symbol: "AAPL"));
Implementation
@override
Future<Dividends> dividends(SecurityIdentifier id, {String? currency}) async {
const url = '$_baseUrl/stock/dividend';
final params = {
'currency': currency ?? 'EUR',
}..addAll(id.toJson());
var response = await _post(url, params);
if (_isSuccess(response)) {
return Dividends.fromJson({"data": jsonDecode(response!.data)});
}
throw Exception("Failed to get dividends for $id");
}