You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.1 KiB
Dart
134 lines
4.1 KiB
Dart
class SystemNotificationModel {
|
|
String? userId;
|
|
String? userName;
|
|
String? title;
|
|
String? text;
|
|
int? referenceId;
|
|
int? sourceId;
|
|
String? sourceName;
|
|
bool? readed;
|
|
String? readingDate;
|
|
String? id; // Changed from int? to String? to match API response
|
|
String? createdOn;
|
|
String? modifiedOn;
|
|
String? priorityName;
|
|
String? statusName;
|
|
int? transactionType;
|
|
String? moduleName;
|
|
String? subModuleName;
|
|
String? channelName;
|
|
|
|
// New fields from the API
|
|
bool? sent;
|
|
String? sentDate;
|
|
int? noOfFailure;
|
|
int? totalUnreadCount; // Added from API payload
|
|
|
|
SystemNotificationModel(
|
|
{this.userId,
|
|
this.userName,
|
|
this.title,
|
|
this.text,
|
|
this.referenceId,
|
|
this.sourceId,
|
|
this.sourceName,
|
|
this.readed,
|
|
this.readingDate,
|
|
this.id,
|
|
this.createdOn,
|
|
this.modifiedOn,
|
|
this.priorityName,
|
|
this.transactionType,
|
|
this.statusName,
|
|
this.moduleName,
|
|
this.subModuleName,
|
|
this.channelName,
|
|
this.sent,
|
|
this.sentDate,
|
|
this.noOfFailure,
|
|
this.totalUnreadCount});
|
|
|
|
SystemNotificationModel.fromJson(Map<String, dynamic>? json) {
|
|
// Allow json to be null
|
|
if (json != null) {
|
|
// Fix: Handle id as String (API returns String like "6a3b8af78200480d80d8dbb8")
|
|
id = json['id']?.toString();
|
|
userId = json['userId'] ?? json['userEmail'];
|
|
userName = json['userName'];
|
|
title = json['title'] ?? json['notificationTitle'];
|
|
text = json['text'] ?? json['notificationBody'];
|
|
referenceId = json['referenceId'];
|
|
sourceId = json['sourceId'];
|
|
sourceName = json['sourceName'] ?? json['moduleName'];
|
|
readed = json['readed'] ?? (json['isRead'] == true);
|
|
readingDate = json['readingDate'];
|
|
createdOn = json['createdDate'] ?? json['createdOn'];
|
|
modifiedOn = json['modifiedOn'];
|
|
priorityName = json['priorityName'];
|
|
statusName = json['statusName'];
|
|
transactionType = json['transactionType'];
|
|
moduleName = json['moduleName'];
|
|
subModuleName = json['subModuleName'];
|
|
channelName = json['channelName'];
|
|
|
|
// Map new fields
|
|
sent = json['sent'];
|
|
sentDate = json['sentDate'];
|
|
noOfFailure = json['noOfFailure'];
|
|
totalUnreadCount = json['totalUnreadCount'];
|
|
}
|
|
}
|
|
|
|
Map<String, dynamic> toNotificationJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{}; // Use <String, dynamic> for type safety
|
|
data['userId'] = userId;
|
|
data['userName'] = userName;
|
|
data['title'] = title;
|
|
data['text'] = text;
|
|
data['requestNumber'] = referenceId;
|
|
data['sourceId'] = sourceId;
|
|
data['requestType'] = sourceName;
|
|
data['readed'] = readed;
|
|
data['readingDate'] = readingDate;
|
|
data['id'] = id;
|
|
data['createdOn'] = createdOn;
|
|
data['modifiedOn'] = modifiedOn;
|
|
data['priorityName'] = priorityName;
|
|
data['priority'] = priorityName;
|
|
data['statusName'] = statusName;
|
|
data['transactionType'] = transactionType;
|
|
data['channelName'] = channelName;
|
|
data['sent'] = sent;
|
|
data['sentDate'] = sentDate;
|
|
data['noOfFailure'] = noOfFailure;
|
|
data['totalUnreadCount'] = totalUnreadCount;
|
|
return data;
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{}; // Use <String, dynamic> for type safety
|
|
data['userId'] = userId;
|
|
data['userName'] = userName;
|
|
data['title'] = title;
|
|
data['text'] = text;
|
|
data['referenceId'] = referenceId;
|
|
data['sourceId'] = sourceId;
|
|
data['sourceName'] = sourceName;
|
|
data['readed'] = readed;
|
|
data['readingDate'] = readingDate;
|
|
data['id'] = id;
|
|
data['createdOn'] = createdOn;
|
|
data['modifiedOn'] = modifiedOn;
|
|
data['priorityName'] = priorityName;
|
|
data['statusName'] = statusName;
|
|
data['transactionType'] = transactionType;
|
|
data['moduleName'] = moduleName;
|
|
data['subModuleName'] = subModuleName;
|
|
data['channelName'] = channelName;
|
|
data['sent'] = sent;
|
|
data['sentDate'] = sentDate;
|
|
data['noOfFailure'] = noOfFailure;
|
|
data['totalUnreadCount'] = totalUnreadCount;
|
|
return data;
|
|
}
|
|
} |