Add _RecursiveSerializer class in bfxapi/labeler.py file. Add support to new pulse endpoints (with serializers and types). Add examples/rest/get_pulse_data.py demo.

This commit is contained in:
itsdeka
2023-01-24 12:10:57 +01:00
committed by Davide Casale
parent 36725a183e
commit ae42fb7d93
5 changed files with 131 additions and 4 deletions

View File

@@ -58,7 +58,7 @@ class _Requests(object):
raise RequestParametersError(f"The request was rejected with the following parameter error: <{data[2]}>")
if data[1] == None or data[1] == Error.ERR_UNK or data[1] == Error.ERR_GENERIC:
raise UnknownGenericError("The server replied to the request with a generic error with message: <{data[2]}>.")
raise UnknownGenericError(f"The server replied to the request with a generic error with message: <{data[2]}>.")
return data
@@ -255,6 +255,19 @@ class _RestPublicEndpoints(_Requests):
def conf(self, config: Config) -> Any:
return self._GET(f"conf/{config}")[0]
def get_pulse_profile(self, nickname: str) -> PulseProfile:
return serializers.PulseProfile.parse(*self._GET(f"pulse/profile/{nickname}"))
def get_pulse_history(self, end: Optional[str] = None, limit: Optional[int] = None) -> List[PulseMessage]:
messages = list()
for subdata in self._GET("pulse/hist", params={ "end": end, "limit": limit }):
subdata[18] = subdata[18][0]
message = serializers.PulseMessage.parse(*subdata)
messages.append(message)
return messages
class _RestAuthenticatedEndpoints(_Requests):
def get_wallets(self) -> List[Wallet]:
return [ serializers.Wallet.parse(*subdata) for subdata in self._POST("auth/r/wallets") ]