getDelegations method

Future<List<Delegation>> getDelegations({
  1. String delegator = "",
  2. String validator = "",
  3. PaginationOptions? options,
})

Implementation

Future<List<Delegation>> getDelegations(
    {String delegator = "",
    String validator = "",
    PaginationOptions? options}) async {
  if (delegator.isNotEmpty && validator.isNotEmpty) {
    return (await DelegationHelper.getDelegationsForAllValuesReady(
            apiRequester, delegator, validator,
            options: options))
        .map((w) => Delegation.fromJSON(w))
        .toList();
  } else if (delegator.isNotEmpty && validator.isEmpty) {
    return (await DelegationHelper.getDelegationsForDelegatorsOnly(
            apiRequester, delegator,
            options: options))
        .map((w) => Delegation.fromJSON(w))
        .toList();
  } else if (delegator.isEmpty && validator.isNotEmpty) {
    return (await DelegationHelper.getDelegationsForValidatorsOnly(
            apiRequester, validator,
            options: options))
        .map((w) => Delegation.fromJSON(w))
        .toList();
  }

  throw Exception("arguments delegator and validator cannot both be empty");
}