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

from __future__ import annotations
from dataclasses import dataclass, field
from flexprice.models import errors_errordetail as models_errors_errordetail
from flexprice.models.errors import FlexpriceError
from flexprice.types import BaseModel
import httpx
from typing import Optional


class ErrorsErrorResponseData(BaseModel):
    error: Optional[models_errors_errordetail.ErrorsErrorDetail] = None
    success: Optional[bool] = None


@dataclass(unsafe_hash=True)
class ErrorsErrorResponse(FlexpriceError):
    data: ErrorsErrorResponseData = field(hash=False)

    def __init__(
        self,
        data: ErrorsErrorResponseData,
        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)
