PMU_Salin_Oleg_PIbd-33/lib/data/dtos/character_dto.dart

60 lines
1.6 KiB
Dart
Raw Normal View History

2024-10-07 21:54:13 +04:00
import 'package:json_annotation/json_annotation.dart';
part 'character_dto.g.dart';
@JsonSerializable(createToJson: false)
class CharactersDto {
@JsonKey(name: 'characters')
final List<CharacterDataDto>? data;
final MetaDto? meta;
const CharactersDto({
this.data,
this.meta,
});
factory CharactersDto.fromJson(Map<String, dynamic> json) =>
_$CharactersDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class CharacterDataDto {
final int? id;
final String? name;
final List<String>? images;
@JsonKey(name: 'personal')
final CharacterDataAttributesDto? attributes;
const CharacterDataDto({this.id, this.name, this.images, this.attributes});
factory CharacterDataDto.fromJson(Map<String, dynamic> json) =>
_$CharacterDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class CharacterDataAttributesDto {
final String? birthdate;
final String? sex;
final String? clan;
const CharacterDataAttributesDto({this.birthdate, this.sex, this.clan});
factory CharacterDataAttributesDto.fromJson(Map<String, dynamic> json) =>
_$CharacterDataAttributesDtoFromJson(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);
}