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

from __future__ import annotations
from pydantic import model_serializer
from train_travel.types import BaseModel, UNSET_SENTINEL
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class StationTypedDict(TypedDict):
    r"""A train station."""

    id: str
    r"""Unique identifier for the station."""
    name: str
    r"""The name of the station"""
    address: str
    r"""The address of the station."""
    country_code: str
    r"""The country code of the station."""
    timezone: NotRequired[str]
    r"""The timezone of the station in the [IANA Time Zone Database format](https://www.iana.org/time-zones)."""


class Station(BaseModel):
    r"""A train station."""

    id: str
    r"""Unique identifier for the station."""

    name: str
    r"""The name of the station"""

    address: str
    r"""The address of the station."""

    country_code: str
    r"""The country code of the station."""

    timezone: Optional[str] = None
    r"""The timezone of the station in the [IANA Time Zone Database format](https://www.iana.org/time-zones)."""

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