Yassine Mhirsi
feat: Implement user management service with Supabase integration, including user registration, retrieval, and name update endpoints.
6e8d513
| """Pydantic models for user endpoints""" | |
| from pydantic import BaseModel, Field, ConfigDict | |
| from typing import Optional | |
| from datetime import datetime | |
| class UserRegisterRequest(BaseModel): | |
| """Request model for user registration""" | |
| model_config = ConfigDict( | |
| json_schema_extra={ | |
| "example": { | |
| "unique_id": "550e8400-e29b-41d4-a716-446655440000", | |
| "name": "John Doe" | |
| } | |
| } | |
| ) | |
| unique_id: str = Field( | |
| ..., min_length=1, max_length=255, | |
| description="Browser-generated unique identifier (stored in localStorage)" | |
| ) | |
| name: Optional[str] = Field( | |
| None, min_length=1, max_length=100, | |
| description="User's display name (optional, will generate random if not provided)" | |
| ) | |
| class UserResponse(BaseModel): | |
| """Response model for user data""" | |
| model_config = ConfigDict( | |
| json_schema_extra={ | |
| "example": { | |
| "id": "123e4567-e89b-12d3-a456-426614174000", | |
| "unique_id": "550e8400-e29b-41d4-a716-446655440000", | |
| "name": "John Doe", | |
| "created_at": "2024-01-01T12:00:00Z", | |
| "updated_at": "2024-01-01T12:00:00Z" | |
| } | |
| } | |
| ) | |
| id: str = Field(..., description="User UUID") | |
| unique_id: str = Field(..., description="Browser-generated unique identifier") | |
| name: str = Field(..., description="User's display name") | |
| created_at: str = Field(..., description="User creation timestamp") | |
| updated_at: str = Field(..., description="User last update timestamp") | |
| class UserUpdateNameRequest(BaseModel): | |
| """Request model for updating user name""" | |
| model_config = ConfigDict( | |
| json_schema_extra={ | |
| "example": { | |
| "name": "Jane Doe" | |
| } | |
| } | |
| ) | |
| name: str = Field( | |
| ..., min_length=1, max_length=100, | |
| description="New display name" | |
| ) | |
| class UserGetRequest(BaseModel): | |
| """Request model for getting user by unique_id""" | |
| model_config = ConfigDict( | |
| json_schema_extra={ | |
| "example": { | |
| "unique_id": "550e8400-e29b-41d4-a716-446655440000" | |
| } | |
| } | |
| ) | |
| unique_id: str = Field( | |
| ..., min_length=1, max_length=255, | |
| description="Browser-generated unique identifier" | |
| ) | |