//! `OData` filter field definitions for City resources.

use time::OffsetDateTime;
use toolkit_odata_macros::ODataFilterable;
use toolkit_sdk::odata::{FieldRef, Schema};
use uuid::Uuid;

use toolkit_odata::filter::FilterField as _;

/// City filterable fields schema.
///
/// This struct defines which fields can be used in `OData` $filter queries
/// for city resources. The field names match the wire format.
#[derive(ODataFilterable)]
pub struct CityQuery {
    #[odata(filter(kind = "Uuid"))]
    pub id: Uuid,

    #[odata(filter(kind = "String"))]
    pub name: String,

    #[odata(filter(kind = "String"))]
    pub country: String,

    #[odata(filter(kind = "DateTimeUtc"))]
    pub created_at: OffsetDateTime,
}

/// Type alias for the generated filter field enum.
///
/// This enum is auto-generated by the `ODataFilterable` derive macro
/// and represents all filterable fields for cities.
pub use CityQueryFilterField as CityFilterField;

#[derive(Debug, Clone, Copy)]
pub struct CitySchema;

impl Schema for CitySchema {
    type Field = CityFilterField;

    fn field_name(field: Self::Field) -> &'static str {
        field.name()
    }
}

pub const CITY_ID: FieldRef<CitySchema, Uuid> = FieldRef::new(CityFilterField::Id);
pub const CITY_NAME: FieldRef<CitySchema, String> = FieldRef::new(CityFilterField::Name);
pub const CITY_COUNTRY: FieldRef<CitySchema, String> = FieldRef::new(CityFilterField::Country);
pub const CITY_CREATED_AT: FieldRef<CitySchema, OffsetDateTime> =
    FieldRef::new(CityFilterField::CreatedAt);
