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

from __future__ import annotations
from .payloadvalidationerrordto import PayloadValidationErrorDto
from dataclasses import dataclass, field
import httpx
from novu_py.models import NovuError
from novu_py.types import BaseModel, Nullable, OptionalNullable, UNSET
import pydantic
from typing import Any, Dict, List, Optional, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict


MessagePayloadValidationExceptionDto5TypedDict = TypeAliasType(
    "MessagePayloadValidationExceptionDto5TypedDict",
    Union[str, float, bool, Dict[str, Any]],
)


MessagePayloadValidationExceptionDto5 = TypeAliasType(
    "MessagePayloadValidationExceptionDto5", Union[str, float, bool, Dict[str, Any]]
)


class MessagePayloadValidationExceptionDto4TypedDict(TypedDict):
    pass


class MessagePayloadValidationExceptionDto4(BaseModel):
    pass


PayloadValidationExceptionDtoMessageTypedDict = TypeAliasType(
    "PayloadValidationExceptionDtoMessageTypedDict",
    Union[
        MessagePayloadValidationExceptionDto4TypedDict,
        str,
        float,
        bool,
        List[Nullable[MessagePayloadValidationExceptionDto5TypedDict]],
    ],
)
r"""Value that failed validation"""


PayloadValidationExceptionDtoMessage = TypeAliasType(
    "PayloadValidationExceptionDtoMessage",
    Union[
        MessagePayloadValidationExceptionDto4,
        str,
        float,
        bool,
        List[Nullable[MessagePayloadValidationExceptionDto5]],
    ],
)
r"""Value that failed validation"""


class SchemaTypedDict(TypedDict):
    r"""The JSON schema that was used for validation"""


class Schema(BaseModel):
    r"""The JSON schema that was used for validation"""


class PayloadValidationExceptionDtoData(BaseModel):
    status_code: Annotated[float, pydantic.Field(alias="statusCode")]
    r"""HTTP status code of the error response."""
    timestamp: str
    r"""Timestamp of when the error occurred."""
    path: str
    r"""The path where the error occurred."""
    type: str
    r"""Type identifier for payload validation errors"""
    errors: List[PayloadValidationErrorDto]
    r"""Array of detailed validation errors"""
    message: OptionalNullable[PayloadValidationExceptionDtoMessage] = UNSET
    r"""Value that failed validation"""
    ctx: Optional[Dict[str, Any]] = None
    r"""Optional context object for additional error details."""
    error_id: Annotated[Optional[str], pydantic.Field(alias="errorId")] = None
    r"""Optional unique identifier for the error, useful for tracking using Sentry and
    New Relic, only available for 500.
    """
    schema_: Annotated[Optional[Schema], pydantic.Field(alias="schema")] = None
    r"""The JSON schema that was used for validation"""


@dataclass(unsafe_hash=True)
class PayloadValidationExceptionDto(NovuError):
    data: PayloadValidationExceptionDtoData = field(hash=False)

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