from typing import TypeVar, Dict, Any from dataclasses import dataclass from ApiLibrary import get_line_number_for_error from ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi # Type variable for class methods returning self T = TypeVar("T", bound="FilterAttributes") @dataclass class TokenModel: lang: str credentials: Dict[str, str] timezone: str def __post_init__(self): self.lang = str(self.lang or "tr").lower() self.credentials = self.credentials or {} if "GMT" in self.timezone: raise HTTPExceptionApi( error_code="HTTP_400_BAD_REQUEST", lang=self.lang, loc=get_line_number_for_error(), sys_msg="Invalid timezone format", ) @classmethod def set_user_define_properties(cls, token: Any) -> None: """ Set user-specific properties from the authentication token. Args: token: Authentication token containing user preferences """ from ApiLibrary.date_time_actions.date_functions import DateTimeLocal cls.credentials = token.credentials cls.client_arrow = DateTimeLocal(is_client=True, timezone=token.timezone) cls.lang = str(token.lang).lower()