Files
python-teos/watchtower-plugin/tower_info.py
Sergi Delgado Segura ed8ff228d8 First commands with basic structure.
- Moves DBManager to common.
2020-04-20 17:30:15 +02:00

20 lines
663 B
Python

class TowerInfo:
def __init__(self, endpoint, available_slots):
self.endpoint = endpoint
self.available_slots = available_slots
@classmethod
def from_dict(cls, tower_data):
endpoint = tower_data.get("endpoint")
available_slots = tower_data.get("available_slots")
if any(v is None for v in [endpoint, available_slots]):
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)
def to_dict(self):
return self.__dict__