getAccount function

Future<Account> getAccount(
  1. String accountIndex
)

GET request to the /accounts/:accountIndex endpoint. Returns a specific token account for an accountIndex @param {string} accountIndex - Account index in the format hez:DAI:4444 @returns {object} Response data with the token account

Implementation

Future<Account> getAccount(String accountIndex) async {
  final response = await get(baseApiUrl, ACCOUNTS_URL + '/' + accountIndex);
  if (response.statusCode == 200) {
    final jsonResponse = await extractJSON(response);
    final Account accountResponse = Account.fromJson(json.decode(jsonResponse));
    return accountResponse;
  } else {
    throw ('Error: $response.statusCode');
  }
}