Mobile/lib/data/dtos/anime_dto.dart
2024-11-11 22:32:44 +04:00

47 lines
1.3 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
part 'anime_dto.g.dart';
@JsonSerializable(createToJson: false)
class AnimesDto {
final List<AnimeDataDto>? data;
const AnimesDto({this.data});
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);
}