PIbd-32_Chubykina_P.P._mobilki/lib/data/dtos/characters_dto.dart

61 lines
1.5 KiB
Dart
Raw Normal View History

2024-10-07 17:59:30 +04:00
import 'package:json_annotation/json_annotation.dart';
part 'characters_dto.g.dart';
@JsonSerializable(createToJson: false)
class CharactersDto {
final List<CharacterDataDto>? data;
final MetaDto? meta;
2024-10-07 17:59:30 +04:00
const CharactersDto({
this.data,
this.meta,
});
2024-10-07 17:59:30 +04:00
factory CharactersDto.fromJson(Map<String, dynamic> json) => _$CharactersDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class CharacterDataDto {
2024-10-07 18:19:03 +04:00
final String? id;
final String? type;
final CharacterAttributesDataDto? attributes;
2024-10-07 17:59:30 +04:00
2024-10-07 18:19:03 +04:00
const CharacterDataDto({this.id, this.type, this.attributes});
2024-10-07 17:59:30 +04:00
2024-10-07 18:19:03 +04:00
factory CharacterDataDto.fromJson(Map<String, dynamic> json) => _$CharacterDataDtoFromJson(json);
2024-10-07 17:59:30 +04:00
}
@JsonSerializable(createToJson: false)
class CharacterAttributesDataDto {
2024-10-07 18:19:03 +04:00
final String? name;
final String? born;
final String? died;
final String? image;
2024-10-07 17:59:30 +04:00
2024-10-07 18:19:03 +04:00
const CharacterAttributesDataDto({this.name, this.born, this.died, this.image});
2024-10-07 17:59:30 +04:00
2024-10-07 18:19:03 +04:00
factory CharacterAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$CharacterAttributesDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class MetaDto {
final PaginationDto? pagination;
const MetaDto({this.pagination});
factory MetaDto.fromJson(Map<String, dynamic> json) => _$MetaDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PaginationDto {
final int? current;
final int? next;
final int? last;
const PaginationDto({this.current, this.next, this.last});
factory PaginationDto.fromJson(Map<String, dynamic> json) => _$PaginationDtoFromJson(json);
2024-10-16 23:18:15 +04:00
}