mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 15:24:21 +01:00
Add support for new rest authenticated endpoints.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import List, Dict, Optional, Any, TypedDict, cast
|
||||
from typing import List, Dict, Union, Optional, Any, TypedDict, cast
|
||||
|
||||
from .labeler import _Serializer
|
||||
|
||||
@@ -6,7 +6,7 @@ class Notification(TypedDict):
|
||||
MTS: int
|
||||
TYPE: str
|
||||
MESSAGE_ID: Optional[int]
|
||||
NOTIFY_INFO: Dict[str, Any]
|
||||
NOTIFY_INFO: Union[Dict[str, Any], List[Dict[str, Any]]]
|
||||
CODE: Optional[int]
|
||||
STATUS: str
|
||||
TEXT: str
|
||||
@@ -14,15 +14,17 @@ class Notification(TypedDict):
|
||||
class _Notification(_Serializer):
|
||||
__LABELS = [ "MTS", "TYPE", "MESSAGE_ID", "_PLACEHOLDER", "NOTIFY_INFO", "CODE", "STATUS", "TEXT" ]
|
||||
|
||||
def __init__(self, serializer: Optional[_Serializer] = None):
|
||||
def __init__(self, serializer: Optional[_Serializer] = None, iterate: bool = False):
|
||||
super().__init__("Notification", _Notification.__LABELS, IGNORE = [ "_PLACEHOLDER" ])
|
||||
|
||||
self.serializer = serializer
|
||||
self.serializer, self.iterate = serializer, iterate
|
||||
|
||||
def parse(self, *values: Any, skip: Optional[List[str]] = None) -> Notification:
|
||||
notification = dict(self._serialize(*values))
|
||||
|
||||
if isinstance(self.serializer, _Serializer):
|
||||
notification["NOTIFY_INFO"] = dict(self.serializer._serialize(*notification["NOTIFY_INFO"], skip=skip))
|
||||
|
||||
if self.iterate == False:
|
||||
notification["NOTIFY_INFO"] = dict(self.serializer._serialize(*notification["NOTIFY_INFO"], skip=skip))
|
||||
else: notification["NOTIFY_INFO"] = [ dict(self.serializer._serialize(*data, skip=skip)) for data in notification["NOTIFY_INFO"] ]
|
||||
|
||||
return cast(Notification, notification)
|
||||
Reference in New Issue
Block a user