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

from __future__ import annotations
from .taxratestatus import TaxRateStatus
from flexprice_py.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict


class DtoUpdateTaxRateRequestTypedDict(TypedDict):
    code: NotRequired[str]
    r"""code is the updated unique alphanumeric identifier for the tax rate"""
    description: NotRequired[str]
    r"""description is the updated text description for the tax rate"""
    metadata: NotRequired[Dict[str, str]]
    r"""metadata contains updated key-value pairs that will replace existing metadata"""
    name: NotRequired[str]
    r"""name is the updated human-readable name for the tax rate"""
    tax_rate_status: NotRequired[TaxRateStatus]


class DtoUpdateTaxRateRequest(BaseModel):
    code: Optional[str] = None
    r"""code is the updated unique alphanumeric identifier for the tax rate"""

    description: Optional[str] = None
    r"""description is the updated text description for the tax rate"""

    metadata: Optional[Dict[str, str]] = None
    r"""metadata contains updated key-value pairs that will replace existing metadata"""

    name: Optional[str] = None
    r"""name is the updated human-readable name for the tax rate"""

    tax_rate_status: Optional[TaxRateStatus] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["code", "description", "metadata", "name", "tax_rate_status"]
        )
        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
