Files
python-teos/watchtower-plugin/tower_info.py
Sergi Delgado Segura 6b025a2d9c 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
2020-04-20 17:30:16 +02:00

24 lines
778 B
Python

class TowerInfo:
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, appointments]):
raise ValueError("Wrong appointment data, some fields are missing")
return cls(endpoint, available_slots, appointments)
def to_dict(self):
return self.__dict__