"""Pydantic schemas for Notification API requests/responses.""" from datetime import datetime from typing import Optional, List, Any from pydantic import BaseModel, Field class NotificationBase(BaseModel): """Base notification schema.""" title: str = Field(..., min_length=1, max_length=200) message: Optional[str] = None type: str = Field(default="info", pattern="^(info|success|warning|error|system)$") link: Optional[str] = Field(None, max_length=500) extra_data: Optional[dict] = None class NotificationCreate(NotificationBase): """Schema for creating a notification.""" user_id: str # Required for system/admin notifications class NotificationCreateForUser(NotificationBase): """Schema for creating a notification for a specific user (admin use).""" pass class Notification(BaseModel): """Schema for notification response.""" id: str user_id: str title: str message: Optional[str] = None type: str link: Optional[str] = None extra_data: Optional[dict] = None is_read: bool created_at: datetime read_at: Optional[datetime] = None class Config: from_attributes = True class NotificationList(BaseModel): """Schema for paginated notification list.""" items: List[Notification] total: int unread_count: int class NotificationStats(BaseModel): """Schema for notification statistics.""" total: int unread: int by_type: dict[str, int] class NotificationBulkAction(BaseModel): """Schema for bulk notification actions.""" notification_ids: List[str] class NotificationPreferences(BaseModel): """Schema for user notification preferences.""" email_notifications: bool = True push_notifications: bool = True notification_types: dict[str, bool] = Field( default_factory=lambda: { "info": True, "success": True, "warning": True, "error": True, "system": True } )