Files
bakery-ia/services/external/app/schemas/calendar.py

135 lines
4.5 KiB
Python
Raw Normal View History

2025-11-02 20:24:44 +01:00
# services/external/app/schemas/calendar.py
"""
Calendar Schemas - Request/Response types for school calendars and location context
"""
from pydantic import BaseModel, Field
from typing import Optional, List, Dict, Any
from uuid import UUID
class SchoolCalendarResponse(BaseModel):
"""School calendar information"""
calendar_id: str
calendar_name: str
city_id: str
school_type: str
academic_year: str
holiday_periods: List[Dict[str, Any]]
school_hours: Dict[str, Any]
source: Optional[str] = None
enabled: bool = True
class Config:
json_schema_extra = {
"example": {
"calendar_id": "madrid_primary_2024_2025",
"calendar_name": "Madrid Primary School Calendar 2024-2025",
"city_id": "madrid",
"school_type": "primary",
"academic_year": "2024-2025",
"holiday_periods": [
{
"name": "Christmas Holiday",
"start_date": "2024-12-23",
"end_date": "2025-01-07",
"description": "Christmas and New Year break"
}
],
"school_hours": {
"morning_start": "09:00",
"morning_end": "14:00",
"has_afternoon_session": False
},
"source": "madrid_education_dept_2024",
"enabled": True
}
}
class SchoolCalendarListResponse(BaseModel):
"""List of school calendars for a city"""
city_id: str
calendars: List[SchoolCalendarResponse]
total: int
class CalendarCheckResponse(BaseModel):
"""Response for holiday check"""
date: str = Field(..., description="Date checked (ISO format)")
is_holiday: bool = Field(..., description="Whether the date is a school holiday")
holiday_name: Optional[str] = Field(None, description="Name of the holiday if applicable")
calendar_id: str
calendar_name: str
class TenantLocationContextResponse(BaseModel):
"""Tenant location context with calendar details"""
tenant_id: str
city_id: str
neighborhood: Optional[str] = None
local_events: Optional[List[Dict[str, Any]]] = None
notes: Optional[str] = None
calendar: Optional[Dict[str, Any]] = Field(
None,
description="Full calendar details if assigned"
)
class Config:
json_schema_extra = {
"example": {
"tenant_id": "fbffcf18-d02a-4104-b6e3-0b32006e3e47",
"city_id": "madrid",
"neighborhood": "Chamberí",
"local_events": [
{
"name": "Neighborhood Festival",
"date": "2025-06-15",
"impact": "high"
}
],
"notes": "Bakery near primary school",
"calendar": {
"calendar_id": "uuid",
"calendar_name": "Madrid Primary School Calendar 2024-2025",
"school_type": "primary",
"academic_year": "2024-2025",
"holiday_periods": [],
"school_hours": {},
"source": "madrid_education_dept_2024"
}
}
}
class TenantLocationContextCreateRequest(BaseModel):
"""Request to create/update tenant location context"""
city_id: str = Field(..., description="City ID (e.g., 'madrid')")
school_calendar_id: Optional[UUID] = Field(
None,
description="School calendar ID to assign"
)
neighborhood: Optional[str] = Field(None, description="Neighborhood name")
local_events: Optional[List[Dict[str, Any]]] = Field(
None,
description="Local events specific to this location"
)
notes: Optional[str] = Field(None, description="Additional notes")
class Config:
json_schema_extra = {
"example": {
"city_id": "madrid",
"school_calendar_id": "123e4567-e89b-12d3-a456-426614174000",
"neighborhood": "Chamberí",
"local_events": [
{
"name": "Local Market Day",
"date": "2025-05-20",
"impact": "medium"
}
],
"notes": "Bakery located near primary school entrance"
}
}