banUser method

Future<BanUserResponse<T>> banUser({
  1. required String userId,
  2. String? banReason,
  3. int? banExpiresIn,
})

Ban a user

userId The ID of the user to ban banReason The reason for banning the user banExpiresIn The number of seconds to ban the user for

Implementation

Future<BanUserResponse<T>> banUser({
  required String userId,
  String? banReason,
  int? banExpiresIn,
}) async {
  try {
    final response = await super.dio.post(
      "/admin/ban-user",
      data: {
        "userId": userId,
        "banReason": banReason,
        "banExpiresIn": banExpiresIn,
      }..removeWhere((key, value) => value == null),
      options: await super.getOptions(isTokenRequired: true),
    );
    return BanUserResponse<T>.fromJson(response.data, super.fromJsonUser);
  } catch (e) {
    final message = getErrorMessage(e);
    if (message == null) rethrow;
    throw message;
  }
}