etfCountry method

  1. @override
Future<EtfCountry> etfCountry(
  1. SecurityIdentifier id
)
override

The etfCountry method is used to get the ETF country for a given ETF symbol.

The id argument is used to specify the ETF id e.g. symbol

// Get ETF country for SPY
final client = BavestRestClient(api_key);
final etfCountry = client.etfCountry('SPY');

Implementation

@override
Future<EtfCountry> etfCountry(SecurityIdentifier id) async {
  const url = '$_baseUrl/etf/country';
  final params = id.toJson();

  var response = await _post(url, params);
  if (_isSuccess(response)) {
    return EtfCountry.fromJson(jsonDecode(response!.data));
  }

  throw Exception("could not receive etf profile for $id");
}