D1APP-48 new models added
This commit is contained in:
parent
4cab5a4c8c
commit
86dc173932
|
|
@ -0,0 +1,35 @@
|
|||
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(),
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
class LastMessage {
|
||||
final String? text;
|
||||
final String? audio;
|
||||
final bool writedByAdmin;
|
||||
final bool readed;
|
||||
|
||||
const LastMessage({
|
||||
this.text,
|
||||
this.audio,
|
||||
required this.writedByAdmin,
|
||||
required this.readed,
|
||||
});
|
||||
|
||||
factory LastMessage.fromJson(Map<String, dynamic> json) => LastMessage(
|
||||
text: json['text'],
|
||||
audio: json['audio'],
|
||||
writedByAdmin: json['writedByAdmin'],
|
||||
readed: json['readed'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'text': text,
|
||||
'audio': audio,
|
||||
'writedByAdmin': writedByAdmin,
|
||||
'readed': readed,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
import 'radar_attachment.dart';
|
||||
|
||||
class MessageData {
|
||||
final int id;
|
||||
final String? text;
|
||||
final String? audio;
|
||||
final bool writedByAdmin;
|
||||
final bool readed;
|
||||
final String createdAt;
|
||||
final RadarAttachment? radar;
|
||||
|
||||
const MessageData({
|
||||
required this.id,
|
||||
required this.writedByAdmin,
|
||||
required this.readed,
|
||||
required this.createdAt,
|
||||
required this.text,
|
||||
required this.audio,
|
||||
required this.radar,
|
||||
});
|
||||
|
||||
factory MessageData.fromJson(Map<String, dynamic> json) => MessageData(
|
||||
id: json['id'],
|
||||
text: json['text'],
|
||||
audio: json['audio'],
|
||||
writedByAdmin: json['writedByAdmin'],
|
||||
readed: json['readed'],
|
||||
createdAt: json['createdAt'],
|
||||
radar: json['radar'] == null
|
||||
? null
|
||||
: RadarAttachment.fromJson(json['radar'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'text': text,
|
||||
'audio': audio,
|
||||
'writedByAdmin': writedByAdmin,
|
||||
'readed': readed,
|
||||
'createdAt': createdAt,
|
||||
'radar': radar?.toJson(),
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
class RadarAttachment {
|
||||
final int id;
|
||||
final String title;
|
||||
final String description;
|
||||
final int timeToRead;
|
||||
final String image;
|
||||
final bool forManagers;
|
||||
|
||||
const RadarAttachment({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.timeToRead,
|
||||
required this.image,
|
||||
required this.forManagers,
|
||||
});
|
||||
|
||||
factory RadarAttachment.fromJson(Map<String, dynamic> json) =>
|
||||
RadarAttachment(
|
||||
id: json['id'],
|
||||
title: json['title'],
|
||||
description: json['description'],
|
||||
timeToRead: json['timeToRead'],
|
||||
image: json['image'],
|
||||
forManagers: json['forManagers'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'timeToRead': timeToRead,
|
||||
'image': image,
|
||||
'forManagers': forManagers,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
class User {
|
||||
final int id;
|
||||
final String phoneNumber;
|
||||
final String fullName;
|
||||
final String? username;
|
||||
final String? photo;
|
||||
|
||||
const User({
|
||||
required this.id,
|
||||
required this.username,
|
||||
required this.phoneNumber,
|
||||
required this.photo,
|
||||
required this.fullName,
|
||||
});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||
id: json['id'],
|
||||
username: json['username'],
|
||||
phoneNumber: json['phoneNumber'],
|
||||
photo: json['photo'],
|
||||
fullName: json['fullName']);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'username': username,
|
||||
'phoneNumber': phoneNumber,
|
||||
'photo': photo,
|
||||
'fullName': fullName,
|
||||
};
|
||||
|
||||
User copyWith({
|
||||
int? id,
|
||||
String? username,
|
||||
String? phoneNumber,
|
||||
String? photo,
|
||||
String? fullName,
|
||||
}) {
|
||||
return User(
|
||||
id: id ?? this.id,
|
||||
username: username ?? this.username,
|
||||
phoneNumber: phoneNumber ?? this.phoneNumber,
|
||||
photo: photo ?? this.photo,
|
||||
fullName: fullName ?? this.fullName,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue