"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .authenticationerrordetail import AuthenticationErrorDetail
from censys_platform.models import SDKBaseError
from censys_platform.types import BaseModel
from dataclasses import dataclass, field
import httpx
from typing import Optional


class AuthenticationErrorData(BaseModel):
    error: Optional[AuthenticationErrorDetail] = None


@dataclass(unsafe_hash=True)
class AuthenticationError(SDKBaseError):
    data: AuthenticationErrorData = field(hash=False)

    def __init__(
        self,
        data: AuthenticationErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.error.message) if data.error else fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)
