login history + balance available

This commit is contained in:
itsdeka
2023-02-08 12:39:51 +01:00
committed by Davide Casale
parent 15a2e41e43
commit 48583786f7
4 changed files with 40 additions and 0 deletions

View File

@@ -14,6 +14,15 @@ class RestAuthenticatedEndpoints(Middleware):
def get_user_info(self) -> UserInfo: def get_user_info(self) -> UserInfo:
return serializers.UserInfo.parse(*self._POST(f"auth/r/info/user")) return serializers.UserInfo.parse(*self._POST(f"auth/r/info/user"))
def get_login_history(self) -> LoginHistory:
return [ serializers.LoginHistory.parse(*sub_data) for sub_data in self._POST("auth/r/logins/hist") ]
def get_balance_available_for_orders_or_offers(self, symbol: str, type: str, dir: Optional[int] = None, rate: Optional[str] = None, lev: Optional[str] = None) -> BalanceAvailable:
return serializers.BalanceAvailable.parse(*self._POST("auth/calc/order/avail", body={
"symbol": symbol, "type": type, "dir": dir,
"rate": rate, "lev": lev
}))
def get_wallets(self) -> List[Wallet]: def get_wallets(self) -> List[Wallet]:
return [ serializers.Wallet.parse(*sub_data) for sub_data in self._POST("auth/r/wallets") ] return [ serializers.Wallet.parse(*sub_data) for sub_data in self._POST("auth/r/wallets") ]

View File

@@ -326,6 +326,21 @@ UserInfo = generate_labeler_serializer("UserInfo", klass=types.UserInfo, labels=
"is_merchant_enterprise" "is_merchant_enterprise"
]) ])
LoginHistory = generate_labeler_serializer("LoginHistory", klass=types.LoginHistory, labels=[
"id",
"_PLACEHOLDER",
"time",
"_PLACEHOLDER",
"ip",
"_PLACEHOLDER",
"_PLACEHOLDER",
"extra_info"
])
BalanceAvailable = generate_labeler_serializer("BalanceAvailable", klass=types.BalanceAvailable, labels=[
"amount"
])
Order = generate_labeler_serializer("Order", klass=types.Order, labels=[ Order = generate_labeler_serializer("Order", klass=types.Order, labels=[
"id", "id",
"gid", "gid",

View File

@@ -228,6 +228,17 @@ class UserInfo(_Type):
compl_countries_resid: List[str] compl_countries_resid: List[str]
is_merchant_enterprise: int is_merchant_enterprise: int
@dataclass
class LoginHistory(_Type):
id: int
time: int
ip: str
extra_info: JSON
@dataclass
class BalanceAvailable(_Type):
amount: float
@dataclass @dataclass
class Order(_Type): class Order(_Type):
id: int id: int

View File

@@ -19,6 +19,11 @@ def log_user_info():
print(user_info) print(user_info)
def log_login_history():
login_history = bfx.rest.auth.get_login_history()
print(login_history)
def log_wallets(): def log_wallets():
wallets = bfx.rest.auth.get_wallets() wallets = bfx.rest.auth.get_wallets()
print("Wallets:") print("Wallets:")