getAccountTransfers method

Future<Paginator<Transfer, DateTime>> getAccountTransfers({
  1. required String accountId,
  2. DateTime? before,
  3. DateTime? after,
  4. int? limit,
  5. TransferEnum? transferType,
})

Get a single account's transfers

Lists past withdrawals and deposits for an account.

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

Implementation

Future<Paginator<Transfer, DateTime>> getAccountTransfers({
  required String accountId,
  DateTime? before,
  DateTime? after,
  int? limit,
  TransferEnum? transferType,
}) async {
  var response = await _accountsRestClient.getAccountTransfers(
    accountId: accountId,
    before: before,
    after: after,
    limit: limit,
    transferType: transferType,
  );

  if (response.statusCode != 200) throw response;

  return Paginator(
    before: response.headers.containsKey('cb-before')
        ? DateTime.parse(response.headers['cb-before']!)
        : null,
    after: response.headers.containsKey('cb-after')
        ? DateTime.parse(response.headers['cb-after']!)
        : null,
    elements: listDecode(response.body)
        .map((hold) => Transfer.fromJson(hold))
        .toList(),
  );
}