diff --git a/src/edutap/wallet_google/api.py b/src/edutap/wallet_google/api.py index 4d9a473..df50ed5 100644 --- a/src/edutap/wallet_google/api.py +++ b/src/edutap/wallet_google/api.py @@ -99,7 +99,7 @@ def create( elif response.status_code != 200: raise Exception(f"Error at {url}: {response.status_code} - {response.text}") - logger.debug(f"RAW-Response: {response.content}") + logger.debug(f"RAW-Response: {response.content!r}") return model.model_validate_json(response.content) @@ -126,7 +126,7 @@ def read( if response.status_code == 200: model = lookup_model(name) - logger.debug(f"RAW-Response: {response.content}") + logger.debug(f"RAW-Response: {response.content!r}") # print(f"RAW-Response: {response.content}") return model.model_validate_json(response.content) @@ -185,7 +185,6 @@ def update( data=verified_json.encode("utf-8"), ) logger.debug(verified_json.encode("utf-8")) - # print(verified_json.encode("utf-8")) if response.status_code == 404: raise LookupError( f"Error 404, {name} {getattr(data, 'id', 'No ID')} not found: - {response.text}" @@ -194,7 +193,7 @@ def update( if response.status_code != 200: raise Exception(f"Error: {response.status_code} - {response.text}") - logger.debug(f"RAW-Response: {response.content}") + logger.debug(f"RAW-Response: {response.content!r}") return model.model_validate_json(response.content) @@ -259,7 +258,7 @@ def message( if response.status_code != 200: raise Exception(f"Error: {response.status_code} - {response.text}") - logger.debug(f"RAW-Response: {response.content}") + logger.debug(f"RAW-Response: {response.content!r}") response_data = json.loads(response.content) return model.model_validate(response_data.get("resource")) @@ -426,9 +425,10 @@ def save_link( } signer = crypt.RSASigner.from_service_account_file(session_manager.credentials_file) jwt_string = jwt.encode(signer, claims).decode("utf-8") - logger.warning( - "JWT-Length: %d, is larger than recommended 1800 bytes: %s", - len(jwt_string), - len(jwt_string) >= 1800, - ) + if len(jwt_string) >= 1800: + logger.debug( + "JWT-Length: %d, is larger than recommended 1800 bytes: %s", + len(jwt_string), + len(jwt_string) >= 1800, + ) return f"{session_manager.save_url}/{jwt_string}" diff --git a/src/edutap/wallet_google/modelbase.py b/src/edutap/wallet_google/modelbase.py index 64e0f7e..a98a2fe 100644 --- a/src/edutap/wallet_google/modelbase.py +++ b/src/edutap/wallet_google/modelbase.py @@ -18,7 +18,7 @@ from pydantic import Field -class GoogleWalletClassModel(GoogleWalletWithIdModel): +class GoogleWalletClassModel(GoogleWalletModel, GoogleWalletWithIdModel): """ BaseModel for all Google Wallet Class Models. """ @@ -72,7 +72,7 @@ class GoogleWalletClassModel(GoogleWalletWithIdModel): ) -class GoogleWalletObjectModel(GoogleWalletWithIdModel): +class GoogleWalletObjectModel(GoogleWalletModel, GoogleWalletWithIdModel): """ Base model for all Google Wallet Object models. """ diff --git a/src/edutap/wallet_google/models/issuer.py b/src/edutap/wallet_google/models/issuer.py index dcf0107..e8bbc98 100644 --- a/src/edutap/wallet_google/models/issuer.py +++ b/src/edutap/wallet_google/models/issuer.py @@ -16,7 +16,7 @@ can_list=False, can_message=False, ) -class SmartTap(GoogleWalletWithIdModel): +class SmartTap(GoogleWalletModel, GoogleWalletWithIdModel): """ see: https://developers.google.com/wallet/generic/rest/v1/smarttap#resource:-smarttap """ diff --git a/src/edutap/wallet_google/registry.py b/src/edutap/wallet_google/registry.py index 085a61c..0e621f8 100644 --- a/src/edutap/wallet_google/registry.py +++ b/src/edutap/wallet_google/registry.py @@ -1,3 +1,5 @@ +from .modelbase import GoogleWalletClassModel +from .modelbase import GoogleWalletObjectModel from .modelcore import GoogleWalletModel from typing import TypedDict @@ -72,7 +74,10 @@ def __init__( "can_message": can_message, } - def __call__(self, cls: type[GoogleWalletModel]) -> type[GoogleWalletModel]: + def __call__( + self, + cls: type[GoogleWalletModel | GoogleWalletClassModel | GoogleWalletObjectModel], + ) -> type[GoogleWalletModel | GoogleWalletClassModel | GoogleWalletObjectModel]: """ Registers the given class in the registry. """