class WordBookStats {
  final int totalWords;
  final int masteredWords;
  final int learningWords;
  final int reviewingWords;
  final double masteryRate;

  WordBookStats({
    required this.totalWords,
    required this.masteredWords,
    required this.learningWords,
    required this.reviewingWords,
    required this.masteryRate,
  });

  factory WordBookStats.fromJson(Map<String, dynamic> json) {
    return WordBookStats(
      totalWords: (json['totalWords'] as num?)?.toInt() ?? 0,
      masteredWords: (json['masteredWords'] as num?)?.toInt() ?? 0,
      learningWords: (json['learningWords'] as num?)?.toInt() ?? 0,
      reviewingWords: (json['reviewingWords'] as num?)?.toInt() ?? 0,
      masteryRate: (json['masteryRate'] as num?)?.toDouble() ?? 0.0,
    );
  }
}