portfolioPrice method
The portfolioPrice method is used to get the portfolio price for a given portfolio.
The portfolio
argument is used to specify the portfolio.
// Get portfolio price for portfolio
final client = BavestRestClient(api_key);
final portfolioPrice = client.portfolioPrice(portfolio);
Implementation
@override
Future<Quote> portfolioPrice(Portfolio portfolio,
{String currency = "EUR"}) async {
const url = '$_baseUrl/portfolio/price';
final params = portfolio.toJson()..addAll({"currency": currency});
var response = await _post(url, params);
if (_isSuccess(response)) {
var parsedJson = json.decode(response!.data);
return Quote.fromJson(parsedJson);
}
throw Exception("could not receive portfolio price for $portfolio");
}