89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
class SupportConversationModel {
|
|
const SupportConversationModel({
|
|
required this.id,
|
|
required this.status,
|
|
this.unreadUser = 0,
|
|
});
|
|
|
|
final String id;
|
|
final String status;
|
|
final int unreadUser;
|
|
|
|
factory SupportConversationModel.fromJson(Map<String, dynamic> json) {
|
|
return SupportConversationModel(
|
|
id: json['id'] as String,
|
|
status: (json['status'] ?? 'open').toString(),
|
|
unreadUser: (json['unreadUser'] as num?)?.toInt() ?? 0,
|
|
);
|
|
}
|
|
}
|
|
|
|
class SupportMessageModel {
|
|
const SupportMessageModel({
|
|
required this.id,
|
|
required this.conversationId,
|
|
required this.senderType,
|
|
required this.createdAt,
|
|
this.senderDisplayName,
|
|
this.body,
|
|
this.attachmentUrl,
|
|
this.attachmentName,
|
|
this.attachmentMime,
|
|
this.readAt,
|
|
});
|
|
|
|
final String id;
|
|
final String conversationId;
|
|
final String senderType;
|
|
final String createdAt;
|
|
final String? senderDisplayName;
|
|
final String? body;
|
|
final String? attachmentUrl;
|
|
final String? attachmentName;
|
|
final String? attachmentMime;
|
|
final String? readAt;
|
|
|
|
bool get isMine => senderType == 'user' || senderType == 'visitor';
|
|
bool get isImage => attachmentMime?.startsWith('image/') == true;
|
|
|
|
SupportMessageModel copyWith({String? readAt}) {
|
|
return SupportMessageModel(
|
|
id: id,
|
|
conversationId: conversationId,
|
|
senderType: senderType,
|
|
createdAt: createdAt,
|
|
senderDisplayName: senderDisplayName,
|
|
body: body,
|
|
attachmentUrl: attachmentUrl,
|
|
attachmentName: attachmentName,
|
|
attachmentMime: attachmentMime,
|
|
readAt: readAt ?? this.readAt,
|
|
);
|
|
}
|
|
|
|
factory SupportMessageModel.fromJson(Map<String, dynamic> json) {
|
|
return SupportMessageModel(
|
|
id: json['id'] as String,
|
|
conversationId: (json['conversationId'] ?? '').toString(),
|
|
senderType: (json['senderType'] ?? 'staff').toString(),
|
|
createdAt: (json['createdAt'] ?? '').toString(),
|
|
senderDisplayName: json['senderDisplayName'] as String?,
|
|
body: json['body'] as String?,
|
|
attachmentUrl: json['attachmentUrl'] as String?,
|
|
attachmentName: json['attachmentName'] as String?,
|
|
attachmentMime: json['attachmentMime'] as String?,
|
|
readAt: json['readAt'] as String?,
|
|
);
|
|
}
|
|
}
|
|
|
|
class SupportMessagesPage {
|
|
const SupportMessagesPage({
|
|
required this.messages,
|
|
required this.staffTyping,
|
|
});
|
|
|
|
final List<SupportMessageModel> messages;
|
|
final bool staffTyping;
|
|
}
|