didvan-app/lib/models/monthly/monthly_model.dart

71 lines
1.6 KiB
Dart

class MonthlyListResponse {
final List<MonthlyItem> result;
MonthlyListResponse({required this.result});
factory MonthlyListResponse.fromJson(Map<String, dynamic> json) {
return MonthlyListResponse(
result: List<MonthlyItem>.from(
json['result'].map((x) => MonthlyItem.fromJson(x)),
),
);
}
}
class MonthlyItem {
final int id;
final String title;
final String image;
final String description;
final int pageNumber;
final String publishedAt;
final String file;
final List<MonthlyTag> tags;
bool isLiked;
bool isBookmarked;
MonthlyItem({
required this.id,
required this.title,
required this.image,
required this.description,
required this.pageNumber,
required this.publishedAt,
required this.file,
required this.tags,
this.isLiked = false,
this.isBookmarked = false,
});
factory MonthlyItem.fromJson(Map<String, dynamic> json) {
return MonthlyItem(
id: json['id'],
title: json['title'],
image: json['image'],
description: json['description'] ?? '',
pageNumber: json['pageNumber'],
publishedAt: json['publishedAt'],
file: json['file'],
tags: List<MonthlyTag>.from(
json['tags'].map((x) => MonthlyTag.fromJson(x)),
),
isLiked: json['isLiked'] ?? false,
isBookmarked: json['isBookmarked'] ?? false,
);
}
}
class MonthlyTag {
final int id;
final String label;
MonthlyTag({required this.id, required this.label});
factory MonthlyTag.fromJson(Map<String, dynamic> json) {
return MonthlyTag(
id: json['id'],
label: json['label'],
);
}
}