create method

Future<void> create({
  1. required String loginName,
  2. required String password,
  3. required String fullName,
  4. List<String> groups = const [],
  5. UserCredentials? userCredentials,
  6. EventStoreClientOperationOptions? operationOptions,
})

Create user in EventStore with given loginName.

Implementation

Future<void> create({
  required String loginName,
  required String password,
  required String fullName,
  List<String> groups = const [],
  UserCredentials? userCredentials,
  EventStoreClientOperationOptions? operationOptions,
}) {
  if (loginName.isEmpty) {
    throw ArgumentOutOfRangeException("'loginName' is empty");
  }
  if (password.isEmpty) {
    throw ArgumentOutOfRangeException("'password' is empty");
  }
  if (fullName.isEmpty) {
    throw ArgumentOutOfRangeException("'fullName' is empty");
  }

  return $runRequest<void>(() async {
    final request = $a.CreateReq()
      ..options = (CreateReq_Options()
        ..loginName = loginName
        ..password = password
        ..fullName = fullName
        ..groups.addAll(groups));

    final client = await $getClient();
    await client.create(
      request,
      options: $getOptions(
        userCredentials: userCredentials,
        operationOptions: operationOptions,
      ),
    );
  });
}