PMU/lib/data/dtos/words_dto.dart
2024-12-21 15:24:04 +04:00

53 lines
1.4 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
part 'words_dto.g.dart';
@JsonSerializable(createToJson: false)
class WordsDto {
final List<WordDataDto>? data;
final MetaDto? meta;
const WordsDto({this.data, this.meta});
factory WordsDto.fromJson(Map<String, dynamic> json) => _$WordsDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class WordDataDto {
final String? id;
final String? type;
final WordAttributesDataDto? attributes;
const WordDataDto({this.id, this.type, this.attributes});
factory WordDataDto.fromJson(Map<String, dynamic> json) => _$WordDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class WordAttributesDataDto {
final String? word;
final String? translation;
final String? image;
factory WordAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$WordAttributesDataDtoFromJson(json);
WordAttributesDataDto(this.word, this.translation, this.image);
}
@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);
}