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

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


GetTaxRatesOrder = Literal[
    "asc",
    "desc",
]


Scope = Literal[
    "INTERNAL",
    "EXTERNAL",
    "ONETIME",
]


GetTaxRatesStatus = Literal[
    "published",
    "deleted",
    "archived",
]


class GetTaxRatesRequestTypedDict(TypedDict):
    end_time: NotRequired[str]
    expand: NotRequired[str]
    limit: NotRequired[int]
    offset: NotRequired[int]
    order: NotRequired[GetTaxRatesOrder]
    scope: NotRequired[Scope]
    start_time: NotRequired[str]
    status: NotRequired[GetTaxRatesStatus]
    taxrate_codes: NotRequired[List[str]]
    taxrate_ids: NotRequired[List[str]]


class GetTaxRatesRequest(BaseModel):
    end_time: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    expand: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    offset: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    order: Annotated[
        Optional[GetTaxRatesOrder],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    scope: Annotated[
        Optional[Scope],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    start_time: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    status: Annotated[
        Optional[GetTaxRatesStatus],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    taxrate_codes: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None

    taxrate_ids: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "end_time",
                "expand",
                "limit",
                "offset",
                "order",
                "scope",
                "start_time",
                "status",
                "taxrate_codes",
                "taxrate_ids",
            ]
        )
        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
