File size: 1,195 Bytes
b4f2238 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | """Module for auth."""
from dataclasses import dataclass
from typing import Any
@dataclass
class LoginAttemptResult:
success: bool
token: str | None
account: str
error_message: str | None
attempt_duration: float
retry_count: int
def to_dict(self) -> dict[str, Any]:
return {
"success": self.success,
"token": self.token,
"account": self.account,
"error_message": self.error_message,
"attempt_duration": self.attempt_duration,
"retry_count": self.retry_count,
}
@dataclass
class TokenAcquisitionResult:
success: bool
token: str | None
acquisition_method: str
total_duration: float
login_attempts: list[LoginAttemptResult]
error_details: dict[str, Any] | None = None
def to_dict(self) -> dict[str, Any]:
return {
"success": self.success,
"token": self.token,
"acquisition_method": self.acquisition_method,
"total_duration": self.total_duration,
"login_attempts": [attempt.to_dict() for attempt in self.login_attempts],
"error_details": self.error_details,
}
|