From 5cd91d8341660045bb8b707a95a24a7f70eae09c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 15 Oct 2022 09:32:41 +0200 Subject: [PATCH] Fixed error and dto handling #70 --- src/bot_api/model/auth_user_dto.py | 28 +++++------ .../model/auth_user_filtered_result_dto.py | 8 ++-- src/bot_api/model/email_string_dto.py | 4 +- src/bot_api/model/error_dto.py | 4 +- src/bot_api/model/reset_password_dto.py | 8 ++-- src/bot_api/model/settings_dto.py | 48 +++++++++---------- src/bot_api/model/token_dto.py | 8 ++-- src/bot_api/model/update_auth_user_dto.py | 12 ++--- src/bot_api/model/version_dto.py | 12 ++--- 9 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/bot_api/model/auth_user_dto.py b/src/bot_api/model/auth_user_dto.py index 304ce047e0..1992389053 100644 --- a/src/bot_api/model/auth_user_dto.py +++ b/src/bot_api/model/auth_user_dto.py @@ -82,21 +82,21 @@ class AuthUserDTO(DtoABC): self.auth_role = value def from_dict(self, values: dict): - self._id = values['Id'] - self._first_name = values['FirstName'] - self._last_name = values['LastName'] - self._email = values['EMail'] - self._password = values['Password'] - self._is_confirmed = values['IsConfirmed'] - self._auth_role = values['AuthRole'] + self._id = values['id'] + self._first_name = values['firstName'] + self._last_name = values['lastName'] + self._email = values['email'] + self._password = values['password'] + self._is_confirmed = values['isConfirmed'] + self._auth_role = values['authRole'] def to_dict(self) -> dict: return { - "Id": self._id, - "FirstName": self._first_name, - "LastName": self._last_name, - "EMail": self._email, - "Password": self._password, - "IsConfirmed": self._is_confirmed, - "AuthRole": self._auth_role, + 'id': self._id, + 'firstName': self._first_name, + 'lastName': self._last_name, + 'email': self._email, + 'password': self._password, + 'isConfirmed': self._is_confirmed, + 'authRole': self._auth_role, } diff --git a/src/bot_api/model/auth_user_filtered_result_dto.py b/src/bot_api/model/auth_user_filtered_result_dto.py index 6edbdb4462..a3125d25e5 100644 --- a/src/bot_api/model/auth_user_filtered_result_dto.py +++ b/src/bot_api/model/auth_user_filtered_result_dto.py @@ -11,11 +11,11 @@ class AuthUserFilteredResultDTO(DtoABC, FilteredResult): FilteredResult.__init__(self, result, total_count) def from_dict(self, values: dict): - self._result = values['Users'] - self._total_count = values['TotalCount'] + self._result = values['users'] + self._total_count = values['totalCount'] def to_dict(self) -> dict: return { - 'Users': self.result, - 'TotalCount': self.total_count + 'users': self.result, + 'totalCount': self.total_count } diff --git a/src/bot_api/model/email_string_dto.py b/src/bot_api/model/email_string_dto.py index 1f5ef08738..5ad6eecb8d 100644 --- a/src/bot_api/model/email_string_dto.py +++ b/src/bot_api/model/email_string_dto.py @@ -13,9 +13,9 @@ class EMailStringDTO(DtoABC): self._email = email def from_dict(self, values: dict): - self._email = values['EMail'] + self._email = values['email'] def to_dict(self) -> dict: return { - 'EMail': self._email + 'email': self._email } diff --git a/src/bot_api/model/error_dto.py b/src/bot_api/model/error_dto.py index b55cc1c508..39c7d6a114 100644 --- a/src/bot_api/model/error_dto.py +++ b/src/bot_api/model/error_dto.py @@ -29,6 +29,6 @@ class ErrorDTO(DtoABC): def to_dict(self) -> dict: return { - 'ErrorCode': int(self._error_code.value), - 'Message': self._message + 'errorCode': int(self._error_code.value), + 'message': self._message } diff --git a/src/bot_api/model/reset_password_dto.py b/src/bot_api/model/reset_password_dto.py index 0bacce596e..64de816d37 100644 --- a/src/bot_api/model/reset_password_dto.py +++ b/src/bot_api/model/reset_password_dto.py @@ -22,11 +22,11 @@ class ResetPasswordDTO(DtoABC): return self._password def from_dict(self, values: dict): - self._id = values['Id'] - self._password = values['Password'] + self._id = values['id'] + self._password = values['password'] def to_dict(self) -> dict: return { - 'Id': self._id, - 'Password': self._password + 'id': self._id, + 'password': self._password } diff --git a/src/bot_api/model/settings_dto.py b/src/bot_api/model/settings_dto.py index ce3ec436cc..567f393126 100644 --- a/src/bot_api/model/settings_dto.py +++ b/src/bot_api/model/settings_dto.py @@ -37,31 +37,31 @@ class SettingsDTO(DtoABC): self._mail_transceiver_address = mail_transceiver_address def from_dict(self, values: dict): - self._web_version = values['WebVersion'] - self._api_version.from_dict(values['ApiVersion']) - self._config_path = values['ConfigPath'] - self._web_base_url = values['WebBaseURL'] - self._api_base_url = values['ApiBaseURL'] - self._token_expire_time = values['TokenExpireTime'] - self._refresh_token_expire_time = values['RefreshTokenExpireTime'] - self._mail_user = values['MailUser'] - self._mail_port = values['MailPort'] - self._mail_host = values['MailHost'] - self._mail_transceiver = values['MailTransceiver'] - self._mail_transceiver_address = values['MailTransceiverAddress'] + self._web_version = values['webVersion'] + self._api_version.from_dict(values['apiVersion']) + self._config_path = values['configPath'] + self._web_base_url = values['webBaseURL'] + self._api_base_url = values['apiBaseURL'] + self._token_expire_time = values['tokenExpireTime'] + self._refresh_token_expire_time = values['refreshTokenExpireTime'] + self._mail_user = values['mailUser'] + self._mail_port = values['mailPort'] + self._mail_host = values['mailHost'] + self._mail_transceiver = values['mailTransceiver'] + self._mail_transceiver_address = values['mailTransceiverAddress'] def to_dict(self) -> dict: return { - 'WebVersion': self._web_version, - 'ApiVersion': self._api_version.to_dict(), - 'ConfigPath': self._config_path, - 'WebBaseURL': self._web_base_url, - 'ApiBaseURL': self._api_base_url, - 'TokenExpireTime': self._token_expire_time, - 'RefreshTokenExpireTime': self._refresh_token_expire_time, - 'MailUser': self._mail_user, - 'MailPort': self._mail_port, - 'MailHost': self._mail_host, - 'MailTransceiver': self._mail_transceiver, - 'MailTransceiverAddress': self._mail_transceiver_address, + 'webVersion': self._web_version, + 'apiVersion': self._api_version.to_dict(), + 'configPath': self._config_path, + 'webBaseURL': self._web_base_url, + 'apiBaseURL': self._api_base_url, + 'tokenExpireTime': self._token_expire_time, + 'refreshTokenExpireTime': self._refresh_token_expire_time, + 'mailUser': self._mail_user, + 'mailPort': self._mail_port, + 'mailHost': self._mail_host, + 'mailTransceiver': self._mail_transceiver, + 'mailTransceiverAddress': self._mail_transceiver_address, } diff --git a/src/bot_api/model/token_dto.py b/src/bot_api/model/token_dto.py index 987d9ad296..d5fc308780 100644 --- a/src/bot_api/model/token_dto.py +++ b/src/bot_api/model/token_dto.py @@ -22,11 +22,11 @@ class TokenDTO(DtoABC): return self._refresh_token def from_dict(self, values: dict): - self._token = values['Token'] - self._refresh_token = values['RefreshToken'] + self._token = values['token'] + self._refresh_token = values['refreshToken'] def to_dict(self) -> dict: return { - 'Token': self._token, - 'RefreshToken': self._refresh_token + 'token': self._token, + 'refreshToken': self._refresh_token } diff --git a/src/bot_api/model/update_auth_user_dto.py b/src/bot_api/model/update_auth_user_dto.py index 7c481330a4..682f0122b4 100644 --- a/src/bot_api/model/update_auth_user_dto.py +++ b/src/bot_api/model/update_auth_user_dto.py @@ -33,13 +33,13 @@ class UpdateAuthUserDTO(DtoABC): return self._change_password def from_dict(self, values: dict): - self._auth_user = values['AuthUser'] - self._new_auth_user = values['NewAuthUser'] - self._change_password = False if 'ChangePassword' not in values else values['ChangePassword'] + self._auth_user = values['authUser'] + self._new_auth_user = values['newAuthUser'] + self._change_password = False if 'changePassword' not in values else values['changePassword'] def to_dict(self) -> dict: return { - 'AuthUser': self._auth_user, - 'NewAuthUser': self._new_auth_user, - 'ChangePassword': self._change_password + 'authUser': self._auth_user, + 'newAuthUser': self._new_auth_user, + 'changePassword': self._change_password } diff --git a/src/bot_api/model/version_dto.py b/src/bot_api/model/version_dto.py index 8ef98dc401..c1504478e9 100644 --- a/src/bot_api/model/version_dto.py +++ b/src/bot_api/model/version_dto.py @@ -15,13 +15,13 @@ class VersionDTO(DtoABC): self._micro = micro def from_dict(self, values: dict): - self._major = values['Major'] - self._minor = values['Minor'] - self._micro = values['Micro'] + self._major = values['major'] + self._minor = values['minor'] + self._micro = values['micro'] def to_dict(self) -> dict: return { - 'Major': self._major, - 'Minor': self._minor, - 'Micro': self._micro, + 'major': self._major, + 'minor': self._minor, + 'micro': self._micro, }