/// Mirrors `adminUserView` from internal/api/admin_users.go. Distinct
/// from MyProfile because admin endpoints expose `auto_approve_requests`
/// and the canonical `created_at` that the user-scoped /me response
/// intentionally omits.
///
/// The list endpoint wraps these in `{"users": [...]}`; the parsing of
/// the envelope is done in `AdminUsersApi`, not here.
class AdminUser {
  const AdminUser({
    required this.id,
    required this.username,
    this.displayName,
    required this.isAdmin,
    required this.autoApproveRequests,
    required this.createdAt,
  });

  final String id;
  final String username;
  final String? displayName;
  final bool isAdmin;
  final bool autoApproveRequests;
  final String createdAt;

  factory AdminUser.fromJson(Map<String, dynamic> j) => AdminUser(
        id: j['id'] as String? ?? '',
        username: j['username'] as String? ?? '',
        displayName: j['display_name'] as String?,
        isAdmin: j['is_admin'] as bool? ?? false,
        autoApproveRequests: j['auto_approve_requests'] as bool? ?? false,
        createdAt: j['created_at'] as String? ?? '',
      );
}
