From 0f02ade8ffd730cb68984abb0b55cf635199d825 Mon Sep 17 00:00:00 2001 From: yaso Date: Wed, 12 Feb 2025 12:29:41 +0200 Subject: [PATCH] create appointment object --- Frontend/lib/mih_objects/appointment.dart | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Frontend/lib/mih_objects/appointment.dart diff --git a/Frontend/lib/mih_objects/appointment.dart b/Frontend/lib/mih_objects/appointment.dart new file mode 100644 index 00000000..92942996 --- /dev/null +++ b/Frontend/lib/mih_objects/appointment.dart @@ -0,0 +1,39 @@ +class Appointment { + final int idappointments; + final String app_id; + final String business_id; + final String date_time; + final String title; + final String description; + + const Appointment({ + required this.idappointments, + required this.app_id, + required this.business_id, + required this.date_time, + required this.title, + required this.description, + }); + + factory Appointment.fromJson(Map json) { + return switch (json) { + { + "idappointments": int idappointments, + 'app_id': String app_id, + 'business_id': String business_id, + 'date_time': String date_time, + 'title': String title, + 'description': String description, + } => + Appointment( + idappointments: idappointments, + app_id: app_id, + business_id: business_id, + date_time: date_time, + title: title, + description: description, + ), + _ => throw const FormatException('Failed to load album.'), + }; + } +}