From 52ebb42aa2bdcfb2fb3b8dd5e5c4cb720732fb9e Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Wed, 2 Apr 2025 17:47:27 +0300 Subject: [PATCH] =?UTF-8?q?[~]=20=D0=9F=D1=80=D0=BE=D0=BC=D0=B5=D0=B6?= =?UTF-8?q?=D1=83=D1=82=D0=BE=D1=87=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=B0=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/auth.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/auth.py b/examples/auth.py index 59ec774..4c2c488 100644 --- a/examples/auth.py +++ b/examples/auth.py @@ -1,9 +1,19 @@ -from anixart import AnixartAPI, AnixartUserAccount, PROFILE +from anixart import AnixartAPI, AnixartAccount +from anixart import endpoints +from anixart.exceptions import AnixartAPIRequestError +from anixart.profile import Profile -user = AnixartUserAccount("SantaSpeen", "I_H@ve_Very_Secret_P@ssw0rd!") -anix = AnixartAPI(user) +anix = AnixartAPI() # По умолчанию используется гость +# acc = AnixartAccount("SantaSpeen", "I_H@ve_Very_Secret_P@ssw0rd!") +# # id у аккаунта появляется только после +# anix.use_account(acc) if __name__ == '__main__': - me = anix.execute("GET", PROFILE.format(user.id)) - print(me.json()) + try: + raw = anix.execute("GET", endpoints.PROFILE.format(1)) + profile = {"is_my_profile": raw['is_my_profile'], **raw['profile']} + print(Profile(**profile)) + except AnixartAPIRequestError as e: + print(e.message) + print(e.code)