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

from __future__ import annotations
from dataclasses import dataclass, field
from gsmservice_gateway.models import ClientError
from gsmservice_gateway.types import BaseModel
import httpx
from typing import Optional


class ErrorResponseErrorData(BaseModel):
    type: Optional[str] = None
    r"""A URI reference that identifies the problem type"""

    status: Optional[int] = None
    r"""The HTTP status code generated by the origin server for this occurrence of the problem"""

    title: Optional[str] = None
    r"""A short, human-readable summary of the problem type"""

    detail: Optional[str] = None
    r"""A human-readable explanation specific to this occurrence of the problem"""

    code: Optional[str] = None
    r"""An API specific error code aiding the provider team understand the error based on their own potential taxonomy or registry"""

    instance: Optional[str] = None
    r"""A URI reference that identifies the specific occurrence of the problem"""


@dataclass(frozen=True)
class ErrorResponseError(ClientError):
    r"""An object that complies with RFC 9457 containing information about a request error"""

    data: ErrorResponseErrorData = field(hash=False)

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