init
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
class SupportTicket {
|
||||
const SupportTicket({
|
||||
required this.id,
|
||||
required this.userId,
|
||||
required this.username,
|
||||
required this.category,
|
||||
required this.categoryLabel,
|
||||
required this.status,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.lastMessageAt,
|
||||
required this.lastMessagePreview,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final int userId;
|
||||
final String username;
|
||||
final String category;
|
||||
final String categoryLabel;
|
||||
final String status;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final DateTime lastMessageAt;
|
||||
final String lastMessagePreview;
|
||||
|
||||
bool get isClosed => status == 'closed';
|
||||
|
||||
String get displayCategory =>
|
||||
categoryLabel.isNotEmpty ? categoryLabel : category;
|
||||
|
||||
String get statusLabel => isClosed ? 'Closed' : 'Open';
|
||||
|
||||
factory SupportTicket.fromJson(Map<String, dynamic> json) {
|
||||
return SupportTicket(
|
||||
id: json['id'] as String,
|
||||
userId: (json['userId'] as num).toInt(),
|
||||
username: json['username'] as String? ?? '',
|
||||
category: json['category'] as String? ?? '',
|
||||
categoryLabel: json['categoryLabel'] as String? ?? '',
|
||||
status: json['status'] as String? ?? 'open',
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||||
lastMessageAt: DateTime.parse(json['lastMessageAt'] as String),
|
||||
lastMessagePreview: json['lastMessagePreview'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user