mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 06:34:19 +01:00
Improves add_appointment method. Has some pending fixmes
- Start and end time have to be dealt with (changes required on the tower side) - Sends appointments to every register tower. We may want to manage this better
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
class TowerInfo:
|
||||
def __init__(self, endpoint, available_slots):
|
||||
def __init__(self, endpoint, available_slots, appointments=None):
|
||||
self.endpoint = endpoint
|
||||
self.available_slots = available_slots
|
||||
|
||||
if not appointments:
|
||||
self.appointments = {}
|
||||
else:
|
||||
self.appointments = appointments
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, tower_data):
|
||||
endpoint = tower_data.get("endpoint")
|
||||
available_slots = tower_data.get("available_slots")
|
||||
appointments = tower_data.get("appointments")
|
||||
|
||||
if any(v is None for v in [endpoint, available_slots]):
|
||||
if any(v is None for v in [endpoint, available_slots, appointments]):
|
||||
raise ValueError("Wrong appointment data, some fields are missing")
|
||||
if available_slots is None:
|
||||
raise ValueError("Wrong tower data, some fields are missing")
|
||||
|
||||
return cls(endpoint, available_slots)
|
||||
return cls(endpoint, available_slots, appointments)
|
||||
|
||||
def to_dict(self):
|
||||
return self.__dict__
|
||||
|
||||
Reference in New Issue
Block a user