pd-android-app/lib/models/notification_model.dart
saritabirare ff065bdc16 1) annaucement api integration done
2)Billto and shipTo api integration
2024-10-22 10:36:49 +05:30

48 lines
1.5 KiB
Dart

class NotificationModel {
final String id; // Notification ID
final String title; // Title of the notification
final String message; // Message of the notification
final String addedFor; // ID of the user/recipient
final DateTime createdAt; // Timestamp when created
final DateTime updatedAt; // Timestamp when updated
NotificationModel({
required this.id,
required this.title,
required this.message,
required this.addedFor,
required this.createdAt,
required this.updatedAt,
});
// Factory method to create a NotificationModel from JSON
factory NotificationModel.fromJson(Map<String, dynamic> json) {
return NotificationModel(
id: json['_id'].toString(),
title: json['title'].toString(),
message: json['msg'].toString(),
addedFor: json['added_for'],
createdAt: DateTime.parse(json['createdAt'] as String),
updatedAt: DateTime.parse(json['updatedAt']as String),
);
}
// Method to convert a NotificationModel to JSON
Map<String, dynamic> toJson() {
return {
'_id': id,
'title': title,
'msg': message,
'added_for': addedFor,
'createdAt': createdAt.toIso8601String(),
'updatedAt': updatedAt.toIso8601String(),
};
}
// Override toString method for better readability
@override
String toString() {
return 'NotificationModel{id: $id, title: $title, message: $message, addedFor: $addedFor, createdAt: $createdAt, updatedAt: $updatedAt}';
}
}