diff --git a/ActiveCollabAPI/AcAccount.py b/ActiveCollabAPI/AcAccount.py index 292187a..0b3c254 100644 --- a/ActiveCollabAPI/AcAccount.py +++ b/ActiveCollabAPI/AcAccount.py @@ -10,3 +10,9 @@ class AcAccount: position: int class_: str status: str + + +def account_from_json(a) -> AcAccount: + a["class_"] = a["class"] + del a["class"] + return AcAccount(**a) diff --git a/ActiveCollabAPI/ActiveCollab.py b/ActiveCollabAPI/ActiveCollab.py index 20f24d8..f25750f 100644 --- a/ActiveCollabAPI/ActiveCollab.py +++ b/ActiveCollabAPI/ActiveCollab.py @@ -4,7 +4,7 @@ from ActiveCollabAPI import AC_API_VERSION from ActiveCollabAPI.ACAuthenticator import ACAuthenticator from ActiveCollabAPI.ACClient import ACClient from ActiveCollabAPI.ACTokenAuthenticator import ACTokenAuthenticator -from ActiveCollabAPI.AcAccount import AcAccount +from ActiveCollabAPI.AcAccount import AcAccount, account_from_json from ActiveCollabAPI.AcLoginResponse import AcLoginResponse from ActiveCollabAPI.AcProject import AcProject, project_from_json from ActiveCollabAPI.AcSession import AcSession @@ -37,13 +37,7 @@ class ActiveCollab: res_data = res.json() if res_data['is_ok'] != 1: raise Exception('Login failed! (2)') - - def map_acccount(a) -> AcAccount: - a["class_"] = a["class"] - del a["class"] - return AcAccount(**a) - - accounts = list(map(lambda a: map_acccount(a), res_data['accounts'])) + accounts = list(map(lambda a: account_from_json(a), res_data['accounts'])) return AcLoginResponse(AcUser(**res_data['user']), accounts) def select_first_account(self, accounts: list[AcAccount]) -> AcAccount: