Currently, this is a very thin layer between the application and the API. We are basically not doing any validation of either input or output. We are blindly sending whatever the application give us, and just return whatever the API returns.
E.g.
|
async def set_name(self, name: str) -> Any: |
|
return await self._post("device_name", json={"name": name}) |
|
async def set_mode(self, mode: str) -> Any: |
|
return await self._post("led/mode", json={"mode": mode}) |
- No validation of the name or the mode we receieve from an application.
And
|
async def get_brightness(self) -> Any: |
|
return await self._get("led/out/brightness") |
|
async def get_firmware_version(self) -> Any: |
|
return await self._get("fw/version") |
- No validation of the data we send back to the application.
In some ways, that is fine. This makes ttls very simple and we probably do not need to make many changes even if the API changes somewhat.
But in other ways, it makes a bigger burden for the applications to validate input and output, and all applications need to be updated if the API changes, instead of making the change only here in ttls.
So this is more of a design discussion than an issue. But something I wanted to raise.
Currently, this is a very thin layer between the application and the API. We are basically not doing any validation of either input or output. We are blindly sending whatever the application give us, and just return whatever the API returns.
E.g.
ttls/ttls/client.py
Lines 262 to 263 in a0e64e2
ttls/ttls/client.py
Lines 300 to 301 in a0e64e2
And
ttls/ttls/client.py
Lines 289 to 290 in a0e64e2
ttls/ttls/client.py
Lines 271 to 272 in a0e64e2
In some ways, that is fine. This makes ttls very simple and we probably do not need to make many changes even if the API changes somewhat.
But in other ways, it makes a bigger burden for the applications to validate input and output, and all applications need to be updated if the API changes, instead of making the change only here in ttls.
So this is more of a design discussion than an issue. But something I wanted to raise.