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

from __future__ import annotations
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
from paygentic_sdk.utils import FieldMetadata, PathParamMetadata, RequestMetadata
import pydantic
from pydantic import model_serializer
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


UpdatePlanTaxBehavior = Literal[
    "exclusive",
    "inclusive",
]
r"""Whether tax is added on top of the price (exclusive) or included in the price (inclusive)"""


class UpdatePlanRequestBodyTypedDict(TypedDict):
    billing_interval: NotRequired[str]
    r"""Recurring billing period frequency. Sample values: 'monthly' for monthly billing, 'yearly' for annual billing, 'weekly' for weekly billing"""
    default_tax_code: NotRequired[str]
    r"""Default tax code for plan line items. Common values: 'eservice' (electronically supplied services), 'saas' (software as a service), 'consulting', 'ebook', 'standard', 'reduced', 'exempt'. Full list available via GET /tax/codes endpoint."""
    default_tax_rate: NotRequired[float]
    r"""Fallback tax rate (as percentage) if automatic tax calculation is unavailable"""
    description: NotRequired[str]
    r"""Plan details explaining included features and limits. Sample values: 'Claude API access with 500K tokens monthly allowance', 'Unlimited cloud storage plus real-time analytics tools', 'Complete machine learning infrastructure with GPU access', 'Flexible usage-based pricing with no monthly commitment'"""
    invoice_display_name: NotRequired[str]
    r"""Plan name shown on billing statements. Sample values: 'LLM API Basic Plan', 'Data Warehouse Business', 'ML Platform Enterprise', 'Pay-Per-Use Model'"""
    name: NotRequired[str]
    r"""Plan identifier visible to customers. Sample values: 'Basic Tier', 'Business Package', 'Enterprise Solution', 'Metered Billing', 'Free Tier', 'Premium Access'"""
    prices: NotRequired[List[str]]
    r"""Array of price IDs to associate with this plan"""
    tax_behavior: NotRequired[UpdatePlanTaxBehavior]
    r"""Whether tax is added on top of the price (exclusive) or included in the price (inclusive)"""
    renewal_reminder_enabled: NotRequired[bool]
    r"""Whether to send renewal reminder emails to customers before their subscription renews"""
    renewal_reminder_days: NotRequired[int]
    r"""Number of days before renewal to send the reminder email"""


class UpdatePlanRequestBody(BaseModel):
    billing_interval: Annotated[
        Optional[str], pydantic.Field(alias="billingInterval")
    ] = None
    r"""Recurring billing period frequency. Sample values: 'monthly' for monthly billing, 'yearly' for annual billing, 'weekly' for weekly billing"""

    default_tax_code: Annotated[
        Optional[str], pydantic.Field(alias="defaultTaxCode")
    ] = None
    r"""Default tax code for plan line items. Common values: 'eservice' (electronically supplied services), 'saas' (software as a service), 'consulting', 'ebook', 'standard', 'reduced', 'exempt'. Full list available via GET /tax/codes endpoint."""

    default_tax_rate: Annotated[
        Optional[float], pydantic.Field(alias="defaultTaxRate")
    ] = None
    r"""Fallback tax rate (as percentage) if automatic tax calculation is unavailable"""

    description: Optional[str] = None
    r"""Plan details explaining included features and limits. Sample values: 'Claude API access with 500K tokens monthly allowance', 'Unlimited cloud storage plus real-time analytics tools', 'Complete machine learning infrastructure with GPU access', 'Flexible usage-based pricing with no monthly commitment'"""

    invoice_display_name: Annotated[
        Optional[str], pydantic.Field(alias="invoiceDisplayName")
    ] = None
    r"""Plan name shown on billing statements. Sample values: 'LLM API Basic Plan', 'Data Warehouse Business', 'ML Platform Enterprise', 'Pay-Per-Use Model'"""

    name: Optional[str] = None
    r"""Plan identifier visible to customers. Sample values: 'Basic Tier', 'Business Package', 'Enterprise Solution', 'Metered Billing', 'Free Tier', 'Premium Access'"""

    prices: Optional[List[str]] = None
    r"""Array of price IDs to associate with this plan"""

    tax_behavior: Annotated[
        Optional[UpdatePlanTaxBehavior], pydantic.Field(alias="taxBehavior")
    ] = None
    r"""Whether tax is added on top of the price (exclusive) or included in the price (inclusive)"""

    renewal_reminder_enabled: Annotated[
        Optional[bool], pydantic.Field(alias="renewalReminderEnabled")
    ] = None
    r"""Whether to send renewal reminder emails to customers before their subscription renews"""

    renewal_reminder_days: Annotated[
        Optional[int], pydantic.Field(alias="renewalReminderDays")
    ] = None
    r"""Number of days before renewal to send the reminder email"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "billingInterval",
                "defaultTaxCode",
                "defaultTaxRate",
                "description",
                "invoiceDisplayName",
                "name",
                "prices",
                "taxBehavior",
                "renewalReminderEnabled",
                "renewalReminderDays",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class UpdatePlanRequestTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the plan"""
    request_body: UpdatePlanRequestBodyTypedDict


class UpdatePlanRequest(BaseModel):
    id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The unique identifier of the plan"""

    request_body: Annotated[
        UpdatePlanRequestBody,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]


try:
    UpdatePlanRequestBody.model_rebuild()
except NameError:
    pass
