80 lines
2.0 KiB
Dart
80 lines
2.0 KiB
Dart
class NotificationResponse {
|
|
final String status;
|
|
final int? draw;
|
|
final int recordsTotal;
|
|
final int recordsFiltered;
|
|
final List<NotificationModel> data;
|
|
|
|
NotificationResponse({
|
|
required this.status,
|
|
required this.draw,
|
|
required this.recordsTotal,
|
|
required this.recordsFiltered,
|
|
required this.data,
|
|
});
|
|
|
|
factory NotificationResponse.fromJson(Map<String, dynamic> json) {
|
|
return NotificationResponse(
|
|
status: json['status'] ?? '',
|
|
draw: json['draw'],
|
|
recordsTotal: json['recordsTotal'] ?? 0,
|
|
recordsFiltered: json['recordsFiltered'] ?? 0,
|
|
data: (json['data'] as List<dynamic>? ?? [])
|
|
.map((e) => NotificationModel.fromJson(e))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"status": status,
|
|
"draw": draw,
|
|
"recordsTotal": recordsTotal,
|
|
"recordsFiltered": recordsFiltered,
|
|
"data": data.map((e) => e.toJson()).toList(),
|
|
};
|
|
}
|
|
}
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
class NotificationModel {
|
|
final int id;
|
|
final String title;
|
|
final String description;
|
|
final int? pageId;
|
|
final String page;
|
|
final String createdAt; // Keeping as string because format is custom
|
|
|
|
NotificationModel({
|
|
required this.id,
|
|
required this.title,
|
|
required this.description,
|
|
required this.pageId,
|
|
required this.page,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory NotificationModel.fromJson(Map<String, dynamic> json) {
|
|
return NotificationModel(
|
|
id: json['id'] ?? 0,
|
|
title: json['tittle'] ?? '', // API spelled as "tittle"
|
|
description: json['description'] ?? '',
|
|
pageId: json['page_id'],
|
|
page: json['page'] ?? '',
|
|
createdAt: json['created_at'] ?? '',
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"id": id,
|
|
"tittle": title,
|
|
"description": description,
|
|
"page_id": pageId,
|
|
"page": page,
|
|
"created_at": createdAt,
|
|
};
|
|
}
|
|
}
|