2024-09-25 15:53:40 +04:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
2024-10-07 19:36:49 +04:00
|
|
|
|
2024-09-25 15:53:40 +04:00
|
|
|
part 'news_dto.g.dart';
|
2024-10-07 19:36:49 +04:00
|
|
|
|
2024-09-25 15:53:40 +04:00
|
|
|
@JsonSerializable(createToJson: false)
|
2024-10-07 19:36:49 +04:00
|
|
|
class NewsDto {
|
2024-10-06 23:20:02 +04:00
|
|
|
@JsonKey(name: 'articles')
|
2024-09-25 19:28:26 +04:00
|
|
|
final List<NewAttributesDataDto>? data;
|
2024-10-07 19:36:49 +04:00
|
|
|
final MetaDto? meta;
|
2024-09-25 15:53:40 +04:00
|
|
|
|
2024-10-07 19:36:49 +04:00
|
|
|
const NewsDto({
|
|
|
|
this.data,
|
|
|
|
this.meta,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory NewsDto.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$NewsDtoFromJson(json);
|
|
|
|
}
|
2024-09-25 15:53:40 +04:00
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
2024-10-07 19:36:49 +04:00
|
|
|
class NewAttributesDataDto {
|
2024-09-25 15:53:40 +04:00
|
|
|
final String? title;
|
2024-10-06 23:20:02 +04:00
|
|
|
final String? description;
|
|
|
|
@JsonKey(name: 'urlToImage')
|
2024-09-25 15:53:40 +04:00
|
|
|
final String? imagelink;
|
|
|
|
|
2024-10-07 19:36:49 +04:00
|
|
|
const NewAttributesDataDto({this.title, this.description, this.imagelink});
|
|
|
|
|
|
|
|
factory NewAttributesDataDto.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$NewAttributesDataDtoFromJson(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);
|
|
|
|
}
|