PMU/lib/data/dtos/characters_dto.dart

66 lines
1.6 KiB
Dart
Raw Normal View History

2024-09-22 20:35:55 +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;
const CharactersDto({
this.data,
this.meta,
});
2024-09-25 12:55:28 +04:00
factory CharactersDto.fromJson(Map<String, dynamic> json) =>
_$CharactersDtoFromJson(json);
2024-09-22 20:35:55 +04:00
}
@JsonSerializable(createToJson: false)
class CharacterDataDto {
final String? id;
final String? type;
final CharacterAttributesDataDto? attributes;
const CharacterDataDto({this.id, this.type, this.attributes});
2024-09-25 12:55:28 +04:00
factory CharacterDataDto.fromJson(Map<String, dynamic> json) =>
_$CharacterDataDtoFromJson(json);
2024-09-22 20:35:55 +04:00
}
@JsonSerializable(createToJson: false)
class CharacterAttributesDataDto {
final String? name;
2024-09-22 22:30:44 +04:00
final String? nationality;
final String? species;
2024-09-22 20:35:55 +04:00
final String? image;
2024-09-25 12:55:28 +04:00
const CharacterAttributesDataDto(
{this.name, this.nationality, this.species, this.image});
2024-09-22 20:35:55 +04:00
factory CharacterAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$CharacterAttributesDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class MetaDto {
final PaginationDto? pagination;
const MetaDto({this.pagination});
2024-09-25 12:55:28 +04:00
factory MetaDto.fromJson(Map<String, dynamic> json) =>
_$MetaDtoFromJson(json);
2024-09-22 20:35:55 +04:00
}
@JsonSerializable(createToJson: false)
class PaginationDto {
final int? current;
final int? next;
final int? last;
const PaginationDto({this.current, this.next, this.last});
2024-09-25 12:55:28 +04:00
factory PaginationDto.fromJson(Map<String, dynamic> json) =>
_$PaginationDtoFromJson(json);
}