class ParkingRequestMessage: location: Location = attr.ib(converter=ensure(Location)) # TODO: Maybe make a preferences class so that we can validate the content # of preferences. preferences: dict = attr.ib(validator=enforce_type, factory=dict) _type: int = attr.ib(default=WebSocketMessageType.PARKING_REQUEST.value, init=False)
class ParkingLot: capacity: int = attr.ib(validator=[enforce_type, validate_pos]) name: str = attr.ib(validator=enforce_type) price: float = attr.ib(converter=float, validator=validate_non_neg) location: Location = attr.ib( converter=ensure(Location), validator=attr.validators.instance_of(Location)) id: int = attr.ib(validator=enforce_type, default=0)
class ParkingLot: capacity: int = attr.ib( validator=[attr.validators.instance_of(int), validate_pos]) name: str = attr.ib(validator=attr.validators.instance_of(str)) price: float = attr.ib( validator=[attr.validators.instance_of(float), validate_non_neg]) location: Location = attr.ib( converter=ensure(Location), validator=attr.validators.instance_of(Location)) id: int = attr.ib(validator=attr.validators.instance_of(int), default=0)
class ParkingAllocationMessage: # TODO: Maybe have an error class to validate the error. lot: ParkingLot = attr.ib(converter=ensure(ParkingLot), validator=attr.validators.instance_of(ParkingLot)) error: dict = attr.ib(validator=attr.validators.instance_of(dict), factory=dict) _type: int = attr.ib(default=WebSocketMessageType.PARKING_ALLOCATION.value, init=False)
class LocationUpdateMessage: location: Location = attr.ib(converter=ensure(Location), validator=attr.validators.instance_of(Location)) _type: int = attr.ib(default=WebSocketMessageType.LOCATION_UPDATE.value, init=False)
class ParkingAllocationMessage: # TODO: Maybe have an error class to validate the error. lot: ParkingLotAllocation = attr.ib(converter=ensure(ParkingLotAllocation)) _type: int = attr.ib(default=WebSocketMessageType.PARKING_ALLOCATION.value, init=False)
class ErrorMessage: error: WsError = attr.ib(converter=ensure(WsError)) _type: int = attr.ib(default=WebSocketMessageType.ERROR.value, init=False)