search method
The search method is used to get the search for given symbols.
The query
argument is used to specify the query to search for.
// Search for Apple
final client = BavestRestClient(api_key);
final search = client.search(SecurityIdentifier(symbol: "AAPL"));
Implementation
@override
Future<SearchResult> search(String query) async {
const url = '$_baseUrl/search';
final params = {
'query': query,
};
var response = await _post(url, params);
if (_isSuccess(response)) {
return SearchResult.fromJson(jsonDecode(response!.data));
}
throw Exception("could not receive search result for $query");
}