updateUser method

Future<String> updateUser({
  1. required String userId,
  2. required String operator,
  3. String? defaultCurrency,
  4. String? contextId,
  5. List<AccountRef> accounts = const [],
})

Implementation

Future<String> updateUser({
  required String userId,
  required String operator,
  String? defaultCurrency,
  String? contextId,
  List<AccountRef> accounts = const [],
}) async {
  final dynamic builder = DocumentUpdate(AccountSet());
  builder.id(Uuid.parse(userId));
  if (defaultCurrency != null) {
    builder.defaultCurrency(defaultCurrency);
  }
  if (accounts.isNotEmpty) {
    builder.accounts(accounts);
  }
  final request = AccountSetExt.updateRequest(builder);
  final client = getServiceClient(operator);
  final envelop = await requestEnvelope(
    request: request,
    contextId: contextId != null ? hex.decode(contextId) : null,
  );
  await client.tx.createTransaction(envelop);
  return userId;
}