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

from __future__ import annotations
from paygentic_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from paygentic_sdk.utils import FieldMetadata, PathParamMetadata, RequestMetadata
import pydantic
from pydantic import model_serializer
from typing import Dict, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


TaxRatesTypedDict = TypeAliasType("TaxRatesTypedDict", Union[float, Dict[str, float]])


TaxRates = TypeAliasType("TaxRates", Union[float, Dict[str, float]])


class UpdateCustomerRequestBodyTypedDict(TypedDict):
    tax_id: NotRequired[Nullable[str]]
    r"""Business tax registration identifier. Sample values: 'GB123456789' for UK VAT, 'DE123456789' for German VAT, 'FR12345678901' for French VAT. Enables inter-company tax handling and exemption from standard tax collection. Assign null to delete the identifier."""
    tax_rates: NotRequired[TaxRatesTypedDict]


class UpdateCustomerRequestBody(BaseModel):
    tax_id: Annotated[OptionalNullable[str], pydantic.Field(alias="taxId")] = UNSET
    r"""Business tax registration identifier. Sample values: 'GB123456789' for UK VAT, 'DE123456789' for German VAT, 'FR12345678901' for French VAT. Enables inter-company tax handling and exemption from standard tax collection. Assign null to delete the identifier."""

    tax_rates: Annotated[Optional[TaxRates], pydantic.Field(alias="taxRates")] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["taxId", "taxRates"])
        nullable_fields = set(["taxId"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

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

        return m


class UpdateCustomerRequestTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the customer."""
    request_body: UpdateCustomerRequestBodyTypedDict


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

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


try:
    UpdateCustomerRequestBody.model_rebuild()
except NameError:
    pass
