import 'package:json_annotation/json_annotation.dart';

part 'anime_dto.g.dart';

@JsonSerializable(createToJson: false)
class AnimesDto {
  final List<AnimeDataDto>? data;
  final PaginationDto? pagination;

  const AnimesDto({this.data, this.pagination});

  factory AnimesDto.fromJson(Map<String, dynamic> json) => _$AnimesDtoFromJson(json);
}

@JsonSerializable(createToJson: false)
class AnimeDataDto {
  @JsonKey(name: 'mal_id')
  final int? id;
  final String? title;
  final String? synopsis;
  final double? score;
  final AnimeImagesDto? images;

  const AnimeDataDto(this.id, this.title, this.synopsis, this.images, this.score);
  factory AnimeDataDto.fromJson(Map<String, dynamic> json) => _$AnimeDataDtoFromJson(json);
}

@JsonSerializable(createToJson: false)
class AnimeImagesDto {
  final AnimeImagesJpgDto? jpg;

  const AnimeImagesDto({this.jpg});

  factory AnimeImagesDto.fromJson(Map<String, dynamic> json) => _$AnimeImagesDtoFromJson(json);
}

@JsonSerializable(createToJson: false)
class AnimeImagesJpgDto {
  @JsonKey(name: 'image_url')
  final String? image;
  @JsonKey(name: 'small_image_url')
  final String? smallImage;
  @JsonKey(name: 'large_image_url')
  final String? largeImage;

  const AnimeImagesJpgDto(this.image, this.smallImage, this.largeImage);
  factory AnimeImagesJpgDto.fromJson(Map<String, dynamic> json) =>
      _$AnimeImagesJpgDtoFromJson(json);
}

@JsonSerializable(createToJson: false)
class PaginationDto {
  @JsonKey(name: "last_visible_page")
  final int? last;
  @JsonKey(name: "current_page")
  final int? current;
  @JsonKey(name: "has_next_page")
  final bool? next;

  const PaginationDto({this.current, this.last, this.next});
  factory PaginationDto.fromJson(Map<String, dynamic> json) => _$PaginationDtoFromJson(json);
}