Refactor of each primary class for asyncio and cli interface support.
Long term goal has been for this library to be used beyond the scope of just the home assistant component. Ideally with a CLI interface that users can use to getting logged in, view information, etc.
This issue is effectively to refactor and rework the code such that it supports this goal, but also makes the code more robust and reusable within the HA component as well.
I'd like to take the following approach:
-
Refactor the login class converting all methods to async and unifying the AlexaLogin class into a structure to represent a logged in session and all methods to perform the login. Storage and usage of cookies should be parameterized and made optional, resetting the login should probably just be a destructor that deletes the cookies, testing the login should be abstracted into the login class and made re-useable within the context of login. Session revalidation can occur within the login class a wrapper for the other classes to use. (I'll have to think about this some more)
-
Refactor the AlexaAPI class again parameterizing some methods that need to be made more flexible, focusing on restructuring of how the login and the api class interact, maybe with wrappers to help facilitate gathering session information and providing it to the API.
-
Refactor the WebSocket class. This is essentially to make the connection more robust and to remove some of the more hard coded values within the class. I believe this class is also mostly async, but we could ensure that it is properly setup for async for HA and other users of this library.