PIbd-32_Stroev_V_M_PMD/lib/data/dtos/characters_dto.dart

62 lines
1.6 KiB
Dart
Raw Normal View History

2024-10-22 08:55:54 +04:00
import 'package:json_annotation/json_annotation.dart';
part 'characters_dto.g.dart';
@JsonSerializable(createToJson: false)
2024-12-08 18:49:37 +04:00
class CharactersDto {
2024-10-22 08:55:54 +04:00
final List<CharacterDataDto>? data;
2024-10-30 22:39:56 +04:00
final MetaDto? meta;
2024-10-22 08:55:54 +04:00
2024-10-30 22:39:56 +04:00
const CharactersDto({this.data, this.meta});
2024-10-22 08:55:54 +04:00
factory CharactersDto.fromJson(Map<String, dynamic> json) => _$CharactersDtoFromJson(json);
}
2024-10-30 22:39:56 +04:00
@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;
2024-12-08 18:49:37 +04:00
const PaginationDto({
this.current,
this.next,
this.last,
});
2024-10-30 22:39:56 +04:00
factory PaginationDto.fromJson(Map<String, dynamic> json) => _$PaginationDtoFromJson(json);
}
2024-10-22 08:55:54 +04:00
@JsonSerializable(createToJson: false)
class CharacterDataDto {
final String? id;
final String? type;
final CharacterAttributesDataDto? attributes;
const CharacterDataDto({this.id, this.type, this.attributes});
factory CharacterDataDto.fromJson(Map<String, dynamic> json) => _$CharacterDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
2024-12-08 18:49:37 +04:00
class CharacterAttributesDataDto {
2024-10-22 08:55:54 +04:00
final String? name;
final String? age;
final List<String>? courses;
@JsonKey(name: 'image')
final String? image;
const CharacterAttributesDataDto({this.name, this.age, this.courses, this.image});
factory CharacterAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$CharacterAttributesDataDtoFromJson(json);
2024-12-08 18:49:37 +04:00
}