mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
First commands with basic structure.
- Moves DBManager to common.
This commit is contained in:
19
watchtower-plugin/tower_info.py
Normal file
19
watchtower-plugin/tower_info.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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__
|
||||
Reference in New Issue
Block a user