import 'media_model.dart'; // Asegúrate de importar tu modelo Media

class MediaToping {
  int? idToping;
  int? idMedia;
  bool? principal;
  String? tipo;
  Media? media;

  MediaToping({
    this.idToping,
    this.idMedia,
    this.principal,
    this.tipo,
    this.media,
  });

  factory MediaToping.fromJson(Map<String, dynamic> json) {
    return MediaToping(
      idToping: json['idToping'] as int?,
      idMedia: json['idMedia'] as int?,
      principal: json['principal'] as bool?,
      tipo: json['tipo'] as String?,
      media: json['media'] != null
          ? Media.fromJson(json['media'] as Map<String, dynamic>)
          : null,
    );
  }

  Map<String, dynamic> toJson() => {
        'idToping': idToping,
        'idMedia': idMedia,
        'principal': principal,
        'tipo': tipo,
        'media': media?.toJson(),
      };
}
