// team_roles_model.dart

class TeamRolesResponse {
  final bool success;
  final String message;
  final List<TeamRole> data;
  final dynamic errors;
  final int statusCode;
  final DateTime timestamp;

  TeamRolesResponse({
    required this.success,
    required this.message,
    required this.data,
    this.errors,
    required this.statusCode,
    required this.timestamp,
  });

  factory TeamRolesResponse.fromJson(Map<String, dynamic> json) {
    return TeamRolesResponse(
      success: json['success'] as bool,
      message: json['message'] as String,
      data: (json['data'] as List<dynamic>)
          .map((e) => TeamRole.fromJson(e as Map<String, dynamic>))
          .toList(),
      errors: json['errors'],
      statusCode: json['statusCode'] as int,
      timestamp: DateTime.parse(json['timestamp'] as String),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'success': success,
      'message': message,
      'data': data.map((e) => e.toJson()).toList(),
      'errors': errors,
      'statusCode': statusCode,
      'timestamp': timestamp.toIso8601String(),
    };
  }
}

class TeamRole {
  final String id;
  final String name;
  final String description;

  TeamRole({
    required this.id,
    required this.name,
    required this.description,
  });

  factory TeamRole.fromJson(Map<String, dynamic> json) {
    return TeamRole(
      id: json['id'] as String,
      name: json['name'] as String,
      description: json['description'] as String,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'description': description,
    };
  }
}
