36 lines
897 B
Dart
36 lines
897 B
Dart
import 'last_message.dart';
|
|
|
|
class ChatRoom {
|
|
final int id;
|
|
final String type;
|
|
final String updatedAt;
|
|
final int unread;
|
|
final LastMessage lastMessage;
|
|
|
|
const ChatRoom({
|
|
required this.id,
|
|
required this.type,
|
|
required this.updatedAt,
|
|
required this.unread,
|
|
required this.lastMessage,
|
|
});
|
|
|
|
factory ChatRoom.fromJson(Map<String, dynamic> json) => ChatRoom(
|
|
id: json['id'],
|
|
type: json['type'] == 'ادمین'
|
|
? 'پشتیبانی اپلیکیشن'
|
|
: 'سردبیر رادار' + json['type'],
|
|
updatedAt: json['updatedAt'],
|
|
unread: json['unread'],
|
|
lastMessage: LastMessage.fromJson(json['lastMessage']),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'type': type,
|
|
'updatedAt': updatedAt,
|
|
'unread': unread,
|
|
'lastMessage': lastMessage.toJson(),
|
|
};
|
|
}
|