mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
Remove inner class Connection.Authenticable (_connection.py).
This commit is contained in:
@@ -10,30 +10,11 @@ if TYPE_CHECKING:
|
||||
class Connection:
|
||||
HEARTBEAT = "hb"
|
||||
|
||||
class Authenticable:
|
||||
def __init__(self) -> None:
|
||||
self._authentication: bool = False
|
||||
|
||||
@property
|
||||
def authentication(self) -> bool:
|
||||
return self._authentication
|
||||
|
||||
@staticmethod
|
||||
def require_websocket_authentication(function):
|
||||
async def wrapper(self, *args, **kwargs):
|
||||
if not self.authentication:
|
||||
raise ActionRequiresAuthentication("To perform this action you need to " \
|
||||
"authenticate using your API_KEY and API_SECRET.")
|
||||
|
||||
internal = Connection.require_websocket_connection(function)
|
||||
|
||||
return await internal(self, *args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
def __init__(self, host: str) -> None:
|
||||
self._host = host
|
||||
|
||||
self._authentication: bool = False
|
||||
|
||||
self.__protocol: Optional["WebSocketClientProtocol"] = None
|
||||
|
||||
@property
|
||||
@@ -41,6 +22,10 @@ class Connection:
|
||||
return self.__protocol is not None and \
|
||||
self.__protocol.open
|
||||
|
||||
@property
|
||||
def authentication(self) -> bool:
|
||||
return self._authentication
|
||||
|
||||
@property
|
||||
def _websocket(self) -> "WebSocketClientProtocol":
|
||||
return cast("WebSocketClientProtocol", self.__protocol)
|
||||
@@ -58,3 +43,16 @@ class Connection:
|
||||
raise ConnectionNotOpen("No open connection with the server.")
|
||||
|
||||
return wrapper
|
||||
|
||||
@staticmethod
|
||||
def require_websocket_authentication(function):
|
||||
async def wrapper(self, *args, **kwargs):
|
||||
if not self.authentication:
|
||||
raise ActionRequiresAuthentication("To perform this action you need to " \
|
||||
"authenticate using your API_KEY and API_SECRET.")
|
||||
|
||||
internal = Connection.require_websocket_connection(function)
|
||||
|
||||
return await internal(self, *args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user