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

from __future__ import annotations
from dataclasses import dataclass, field
import httpx
from outpost_sdk.errors import OutpostError
from outpost_sdk.types import BaseModel
import pydantic
from typing import Any, Dict, Optional
from typing_extensions import Annotated


class UnauthorizedErrorData(BaseModel):
    message: Optional[str] = None
    additional_properties: Annotated[
        Optional[Dict[str, Any]], pydantic.Field(exclude=True)
    ] = None


@dataclass(unsafe_hash=True)
class UnauthorizedError(OutpostError):
    r"""A collection of codes that generally means the client was not authenticated correctly for the request they want to make"""

    data: UnauthorizedErrorData = field(hash=False)

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