import 'statistic_record.dart';
import 'subtitle_record.dart';
import 'playback_record.dart';

class Response {
  final List<PlaybackRecord> playbacks;
  final List<StatisticRecord> statistics;
  final List<PlayerSubtitleRecord> subtitles;

  Response({required this.playbacks, required this.statistics, required this.subtitles});

  factory Response.fromJson(dynamic data) {
    var playbacks = data['playback'].map((item) => PlaybackRecord.fromJson(item)).toList();
    var statistics = data['stat'].map((item) => StatisticRecord.fromJson(item)).toList();
    var subtitles = data['subtitle'].map((item) => PlayerSubtitleRecord.fromJson(item)).toList();

    return Response(
        playbacks: List<PlaybackRecord>.from(playbacks),
        statistics: List<StatisticRecord>.from(statistics),
        subtitles: List<PlayerSubtitleRecord>.from(subtitles)
    );
  }
}