deleteUser method

Future<MmStatusOK?> deleteUser(
  1. String userId
)

Deactivate a user account.

Deactivates the user and revokes all its sessions by archiving its user object. As of server version 5.28, optionally use the permanent=true query parameter to permanently delete the user for compliance reasons. To use this feature ServiceSettings.EnableAPIUserDeletion must be set to true in the server's configuration. ##### Permissions Must be logged in as the user being deactivated or have the edit_other_users permission.

Parameters:

  • String userId (required): User GUID

Implementation

Future<MmStatusOK?> deleteUser(
  String userId,
) async {
  final response = await deleteUserWithHttpInfo(
    userId,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'MmStatusOK',
    ) as MmStatusOK;
  }
  return null;
}