34 lines
752 B
Dart
34 lines
752 B
Dart
import '../utils/app_time.dart';
|
|
|
|
class ChatMessage {
|
|
ChatMessage({
|
|
required this.id,
|
|
required this.threadId,
|
|
required this.senderId,
|
|
required this.body,
|
|
required this.createdAt,
|
|
});
|
|
|
|
final String id;
|
|
final String threadId;
|
|
final String senderId;
|
|
final String body;
|
|
final DateTime createdAt;
|
|
|
|
factory ChatMessage.fromMap(Map<String, dynamic> map) {
|
|
return ChatMessage(
|
|
id: map['id'] as String,
|
|
threadId: map['thread_id'] as String,
|
|
senderId: map['sender_id'] as String,
|
|
body: map['body'] as String,
|
|
createdAt: AppTime.parse(map['created_at'] as String),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'thread_id': threadId,
|
|
'sender_id': senderId,
|
|
'body': body,
|
|
};
|
|
}
|