54 lines
1.6 KiB
Dart
54 lines
1.6 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; // Постер фильма
|
||
|
|
||
|
const MovieDataDto(this.name, this.description, this.poster, {this.id});
|
||
|
|
||
|
factory MovieDataDto.fromJson(Map<String, dynamic> json) =>
|
||
|
_$MovieDataDtoFromJson(json);
|
||
|
}
|
||
|
|
||
|
@JsonSerializable(createToJson: false)
|
||
|
class PosterDto {
|
||
|
final String? url; // URL постера
|
||
|
final String? previewUrl; // URL миниатюры постера
|
||
|
|
||
|
const PosterDto({this.url, this.previewUrl});
|
||
|
|
||
|
factory PosterDto.fromJson(Map<String, dynamic> json) =>
|
||
|
_$PosterDtoFromJson(json);
|
||
|
}
|