First commands with basic structure.

- Moves DBManager to common.
This commit is contained in:
Sergi Delgado Segura
2020-04-09 17:45:34 +02:00
parent b5c587b7c5
commit ed8ff228d8
15 changed files with 603 additions and 6 deletions

View 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__