portfolioRegion method
The portfolioRegion method is used to get the portfolio regions for a given portfolio.
The portfolio
argument is used to specify the portfolio.
// Get portfolio regions for portfolio
final client = BavestRestClient(api_key);
// Create a portfolio
final portfolioRegion = client.portfolioRegion(portfolio);
Implementation
@override
Future<List<PortfolioRegion>> portfolioRegion(Portfolio portfolio) async {
const url = '$_baseUrl/portfolio/region';
final params = portfolio.toJson();
var response = await _post(url, params);
if (_isSuccess(response)) {
List<dynamic> filteredResults = jsonDecode(response!.data);
return filteredResults.map((e) => PortfolioRegion.fromJson(e)).toList();
}
throw Exception("could not receive portfolio region for $portfolio");
}