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

from __future__ import annotations
from dataclasses import dataclass, field
import httpx
from polar_sdk.models import PolarError
from polar_sdk.types import BaseModel
from polar_sdk.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import Literal, Optional
from typing_extensions import Annotated


class PaymentMethodInUseByActiveSubscriptionData(BaseModel):
    detail: str

    ERROR: Annotated[
        Annotated[
            Literal["PaymentMethodInUseByActiveSubscription"],
            AfterValidator(validate_const("PaymentMethodInUseByActiveSubscription")),
        ],
        pydantic.Field(alias="error"),
    ] = "PaymentMethodInUseByActiveSubscription"


@dataclass(frozen=True)
class PaymentMethodInUseByActiveSubscription(PolarError):
    data: PaymentMethodInUseByActiveSubscriptionData = field(hash=False)

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