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

from __future__ import annotations
from moovio_sdk.models.components import (
    itemlistnextpage as components_itemlistnextpage,
    ticket as components_ticket,
    ticketstatus as components_ticketstatus,
)
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
from moovio_sdk.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListTicketsRequestTypedDict(TypedDict):
    account_id: str
    cursor: NotRequired[str]
    count: NotRequired[int]
    status: NotRequired[components_ticketstatus.TicketStatus]
    foreign_id: NotRequired[str]


class ListTicketsRequest(BaseModel):
    account_id: Annotated[
        str,
        pydantic.Field(alias="accountID"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]

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

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

    status: Annotated[
        Optional[components_ticketstatus.TicketStatus],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None

    foreign_id: Annotated[
        Optional[str],
        pydantic.Field(alias="foreignID"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["cursor", "count", "status", "foreignID"])
        serialized = handler(self)
        m = {}

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

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

        return m


class ListTicketsResponseBodyTypedDict(TypedDict):
    r"""A paginated list of items. The `nextPage` field is omitted if there are no more pages available."""

    items: List[components_ticket.TicketTypedDict]
    next_page: NotRequired[components_itemlistnextpage.ItemListNextPageTypedDict]


class ListTicketsResponseBody(BaseModel):
    r"""A paginated list of items. The `nextPage` field is omitted if there are no more pages available."""

    items: List[components_ticket.Ticket]

    next_page: Annotated[
        Optional[components_itemlistnextpage.ItemListNextPage],
        pydantic.Field(alias="nextPage"),
    ] = None

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

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

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

        return m


class ListTicketsResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: ListTicketsResponseBodyTypedDict


class ListTicketsResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: ListTicketsResponseBody


try:
    ListTicketsResponseBody.model_rebuild()
except NameError:
    pass
