KonectarEvents/lib/contacts_module/model_class/event_model.dart

60 lines
1.5 KiB
Dart
Raw Normal View History

2024-10-08 12:01:59 +00:00
// To parse this JSON data, do
//
// final events = eventsFromJson(jsonString);
import 'dart:convert';
List<Events> eventsFromJson(String str) =>
List<Events>.from(json.decode(str).map((x) => Events.fromJson(x)));
String eventsToJson(List<Events> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
class Events {
int id;
int userId;
String eventName;
String sessionType;
String topic;
String role;
DateTime? createdAt;
DateTime? updatedAt;
Events({
required this.id,
required this.userId,
required this.eventName,
required this.sessionType,
required this.topic,
required this.role,
required this.createdAt,
required this.updatedAt,
});
factory Events.fromJson(Map<String, dynamic> json) => Events(
id: json["id"],
userId: json["user_id"],
eventName: json["event_name"],
sessionType: json["session_type"],
topic: json["topic"],
role: json["role"],
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"user_id": userId,
"event_name": eventName,
"session_type": sessionType,
"topic": topic,
"role": role,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
};
}