SimpleCloudNotifier/flutter/lib/models/client.dart

52 lines
1.3 KiB
Dart
Raw Permalink Normal View History

2024-05-27 17:21:29 +02:00
class Client {
final String clientID;
final String userID;
final String type;
final String fcmToken;
final String timestampCreated;
final String agentModel;
final String agentVersion;
2024-06-01 14:00:16 +02:00
final String? name;
2024-05-27 17:21:29 +02:00
const Client({
required this.clientID,
required this.userID,
required this.type,
required this.fcmToken,
required this.timestampCreated,
required this.agentModel,
required this.agentVersion,
2024-06-01 14:00:16 +02:00
required this.name,
2024-05-27 17:21:29 +02:00
});
factory Client.fromJson(Map<String, dynamic> json) {
return Client(
clientID: json['client_id'] as String,
userID: json['user_id'] as String,
type: json['type'] as String,
fcmToken: json['fcm_token'] as String,
timestampCreated: json['timestamp_created'] as String,
agentModel: json['agent_model'] as String,
agentVersion: json['agent_version'] as String,
2024-06-01 14:00:16 +02:00
name: json['name'] as String?,
2024-05-27 17:21:29 +02:00
);
}
Map<String, dynamic> toJson() {
return {
'client_id': clientID,
'user_id': userID,
'type': type,
'fcm_token': fcmToken,
'timestamp_created': timestampCreated,
'agent_model': agentModel,
'agent_version': agentVersion,
'name': name,
};
}
2024-05-27 17:21:29 +02:00
static List<Client> fromJsonArray(List<dynamic> jsonArr) {
return jsonArr.map<Client>((e) => Client.fromJson(e as Map<String, dynamic>)).toList();
}
}