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

from __future__ import annotations
from .station import Station, StationTypedDict
import pydantic
from pydantic import model_serializer
from train_travel.types import BaseModel, UNSET_SENTINEL
from train_travel.utils import FieldMetadata, QueryParamMetadata
from typing import Dict, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class GetStationsRequestTypedDict(TypedDict):
    page: NotRequired[int]
    r"""The page number to return"""
    limit: NotRequired[int]
    r"""The number of items to return per page"""
    coordinates: NotRequired[str]
    r"""The latitude and longitude of the user's location, to narrow down the search results to sites within a proximity of this location.

    """
    search: NotRequired[str]
    r"""A search term to filter the list of stations by name or address.

    """
    country: NotRequired[str]
    r"""Filter stations by country code"""


class GetStationsRequest(BaseModel):
    page: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 1
    r"""The page number to return"""

    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 10
    r"""The number of items to return per page"""

    coordinates: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The latitude and longitude of the user's location, to narrow down the search results to sites within a proximity of this location.

    """

    search: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""A search term to filter the list of stations by name or address.

    """

    country: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter stations by country code"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["page", "limit", "coordinates", "search", "country"])
        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 GetStationsXMLLinksTypedDict(TypedDict):
    r"""Links to the next and previous pages of a paginated response."""

    self_: NotRequired[str]
    next: NotRequired[str]
    prev: NotRequired[str]


class GetStationsXMLLinks(BaseModel):
    r"""Links to the next and previous pages of a paginated response."""

    self_: Optional[str] = None

    next: Optional[str] = None

    prev: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["self", "next", "prev"])
        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 GetStationsXMLResponseBodyTypedDict(TypedDict):
    r"""This is a generic request/response wrapper which contains both data and links which serve as hypermedia controls (HATEOAS)."""

    data: NotRequired[List[StationTypedDict]]
    links: NotRequired[GetStationsXMLLinksTypedDict]


class GetStationsXMLResponseBody(BaseModel):
    r"""This is a generic request/response wrapper which contains both data and links which serve as hypermedia controls (HATEOAS)."""

    data: Optional[List[Station]] = None

    links: Optional[GetStationsXMLLinks] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["data", "links"])
        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 GetStationsLinksTypedDict(TypedDict):
    r"""Links to the next and previous pages of a paginated response."""

    self_: NotRequired[str]
    next: NotRequired[str]
    prev: NotRequired[str]


class GetStationsLinks(BaseModel):
    r"""Links to the next and previous pages of a paginated response."""

    self_: Annotated[Optional[str], pydantic.Field(alias="self")] = None

    next: Optional[str] = None

    prev: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["self", "next", "prev"])
        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 GetStationsResponseBodyTypedDict(TypedDict):
    r"""This is a generic request/response wrapper which contains both data and links which serve as hypermedia controls (HATEOAS)."""

    data: NotRequired[List[StationTypedDict]]
    links: NotRequired[GetStationsLinksTypedDict]


class GetStationsResponseBody(BaseModel):
    r"""This is a generic request/response wrapper which contains both data and links which serve as hypermedia controls (HATEOAS)."""

    data: Optional[List[Station]] = None

    links: Optional[GetStationsLinks] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["data", "links"])
        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


GetStationsResponseResultTypedDict = TypeAliasType(
    "GetStationsResponseResultTypedDict", Union[GetStationsResponseBodyTypedDict, bytes]
)


GetStationsResponseResult = TypeAliasType(
    "GetStationsResponseResult", Union[GetStationsResponseBody, bytes]
)


class GetStationsResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: GetStationsResponseResultTypedDict


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

    result: GetStationsResponseResult


try:
    GetStationsLinks.model_rebuild()
except NameError:
    pass
