getCompaniesData method

Future<CoinGeckoResult<CompaniesData?>> getCompaniesData({
  1. String coinId = CompanyHoldingsCoin.bitcoin,
})

Get public companies data. Filters companies by specific holding coin (ethereum or bitcoin).

coinId: The ID of the coin to filter companies by. Default is CompanyHoldingsCoin.bitcoin.

Query path: /companies/public_treasury/{coin_id}

Implementation

Future<CoinGeckoResult<CompaniesData?>> getCompaniesData({
  String coinId = CompanyHoldingsCoin.bitcoin,
}) async {
  final response = await _client.dio.get(
    '/companies/public_treasury/$coinId',
  );
  if (response.statusCode == 200) {
    final data = CompaniesData.fromJson(response.data);
    return CoinGeckoResult(data);
  } else {
    return CoinGeckoResult(
      null,
      errorCode: response.statusCode ?? null,
      errorMessage: '${response.statusMessage} - ${response.data.toString()}',
      isError: true,
    );
  }
}