getUserTransactions method

Future<M4eTransactionList> getUserTransactions (M4eUniqueId userId)

Returns [M4eTransactionList] of authenticated m4e user.

Throws [M4eServerException] if call to server fails

Throws [M4eServerException] with NO_INTERNET_CONNECTION error code device is not connected to the internet

Implementation

Future<M4eTransactionList> getUserTransactions(M4eUniqueId userId) async {
  if ((await _connectionChecker.hasConnection) ?? false) {
    try {
      final _transactionList =
          await _transactionApi.getUserTransactions(userId);

      if (_transactionList.transactions.isEmpty) {
        throw M4eExceptionMessages.kNotFoundException;
      }

      return _transactionList;
    } catch (e) {
      rethrow;
    }
  }

  throw M4eExceptionMessages.kNoInternetConnectionException;
}