updateAccount method

  1. @override
Future<AccountV1?> updateAccount(
  1. String? correlationId,
  2. AccountV1? account
)
override

Updates an account.

  • correlation_id (optional) transaction id to trace execution through call chain.
  • account an account to be updated. Return (optional) Future that receives updated account Throws error.

Implementation

@override
Future<AccountV1?> updateAccount(
    String? correlationId, AccountV1? account) async {
  var index = _accounts.indexWhere((el) => el.id == account?.id).toInt();

  if (index < 0 || account == null) {
    return null;
  }

  var newAccount = AccountV1();
  newAccount.fromJson(account.toJson());
  _accounts[index] = newAccount;

  return newAccount;
}