86 lines
2.0 KiB
Dart
86 lines
2.0 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'movies_dto.g.dart';
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class MoviesDto {
|
|
final List<MovieDataDto>? docs;
|
|
final MoviePaginationDto? pagination;
|
|
|
|
const MoviesDto({this.docs, this.pagination});
|
|
|
|
factory MoviesDto.fromJson(Map<String, dynamic> json) =>
|
|
_$MoviesDtoFromJson(json);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class MoviePaginationDto {
|
|
@JsonKey(name: 'current_page')
|
|
final int? currentPage;
|
|
@JsonKey(name: 'has_next_page')
|
|
final bool? hasNextPage;
|
|
@JsonKey(name: 'last_visible_page')
|
|
final int? lastVisiblePage;
|
|
|
|
const MoviePaginationDto({this.currentPage, this.hasNextPage, this.lastVisiblePage});
|
|
|
|
factory MoviePaginationDto.fromJson(Map<String, dynamic> json) =>
|
|
_$MoviePaginationDtoFromJson(json);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class MovieDataDto {
|
|
@JsonKey(name: 'id')
|
|
final int? id;
|
|
final String? name;
|
|
final String? description;
|
|
final PosterDto? poster;
|
|
@JsonKey(name: 'year', defaultValue: 0)
|
|
final int year;
|
|
final List<GenreDto>? genres;
|
|
final List<CountryDto>? countries;
|
|
|
|
const MovieDataDto(
|
|
this.name,
|
|
this.description,
|
|
this.poster, {
|
|
this.id,
|
|
this.year = 0,
|
|
this.genres,
|
|
this.countries,
|
|
});
|
|
|
|
factory MovieDataDto.fromJson(Map<String, dynamic> json) =>
|
|
_$MovieDataDtoFromJson(json);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class GenreDto {
|
|
final String? name;
|
|
|
|
const GenreDto({this.name});
|
|
|
|
factory GenreDto.fromJson(Map<String, dynamic> json) =>
|
|
_$GenreDtoFromJson(json);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class CountryDto {
|
|
final String? name;
|
|
|
|
const CountryDto({this.name});
|
|
|
|
factory CountryDto.fromJson(Map<String, dynamic> json) =>
|
|
_$CountryDtoFromJson(json);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class PosterDto {
|
|
final String? url;
|
|
final String? previewUrl;
|
|
|
|
const PosterDto({this.url, this.previewUrl});
|
|
|
|
factory PosterDto.fromJson(Map<String, dynamic> json) =>
|
|
_$PosterDtoFromJson(json);
|
|
} |