- Add card import feature with fuzzy matching - Implement deck CRUD and management endpoints - Add user data APIs for groups, networks, preferences, activity, replays - Create comprehensive API documentation (API_DOCUMENTATION.md) - Add ENDPOINT_AUDIT.md for endpoint verification - Update documentation (README, ROADMAP, state.json) - Update architecture blueprint and Cockatrice analysis - All Phase 2 deliverables complete and documented
110 lines
2.6 KiB
Python
110 lines
2.6 KiB
Python
"""Pydantic schemas for card search and import features."""
|
|
from pydantic import BaseModel, Field
|
|
from typing import List, Optional, Dict, Any
|
|
from datetime import datetime
|
|
|
|
|
|
# ===== Card Search Schemas =====
|
|
|
|
class CardResponse(BaseModel):
|
|
"""Card response with details."""
|
|
id: int
|
|
name: str
|
|
mana_cost: Optional[str] = None
|
|
type_line: Optional[str] = None
|
|
oracle_text: Optional[str] = None
|
|
power: Optional[str] = None
|
|
toughness: Optional[str] = None
|
|
rarity: Optional[str] = None
|
|
layout: Optional[str] = None
|
|
colors: Optional[str] = None
|
|
set_code: Optional[str] = None
|
|
set_name: Optional[str] = None
|
|
identifiers: Optional[Dict[str, Any]] = None
|
|
images: Optional[Dict[str, Any]] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class SetResponse(BaseModel):
|
|
"""Set response."""
|
|
id: int
|
|
name: str
|
|
code: str
|
|
release_date: Optional[datetime] = None
|
|
card_count: Optional[int] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CardTypeResponse(BaseModel):
|
|
"""Card type response."""
|
|
type: str
|
|
|
|
|
|
class CardSearchResponse(BaseModel):
|
|
"""Card search response."""
|
|
cards: List[Dict[str, Any]]
|
|
total: int
|
|
page: int
|
|
page_size: int
|
|
total_pages: int
|
|
|
|
|
|
# ===== Card Import Schemas =====
|
|
|
|
class CardImportResponse(BaseModel):
|
|
"""Response after successful card import upload."""
|
|
message: str
|
|
batch_id: int
|
|
card_count: int
|
|
status: str
|
|
imported_at: datetime
|
|
|
|
|
|
class CardImportStatusResponse(BaseModel):
|
|
"""Response showing current import status."""
|
|
has_import: bool
|
|
batch_id: Optional[int] = None
|
|
status: Optional[str] = None
|
|
card_count: Optional[int] = None
|
|
matched_count: Optional[int] = None
|
|
unmatched_count: Optional[int] = None
|
|
last_imported: Optional[datetime] = None
|
|
error_message: Optional[str] = None
|
|
|
|
|
|
class CardMatchResult(BaseModel):
|
|
"""Result of matching imported card name to database card."""
|
|
card_id: Optional[int] = None
|
|
card_name: str
|
|
matched_name: str
|
|
match_type: str # 'exact', 'high_confidence', 'low_confidence'
|
|
confidence: float # 0.0 to 1.0
|
|
|
|
|
|
class CardImportSummary(BaseModel):
|
|
"""Summary of card import with match results."""
|
|
total_cards: int
|
|
matched_cards: List[CardMatchResult]
|
|
unmatched_cards: List[str]
|
|
import_id: Optional[int] = None
|
|
|
|
|
|
class MessageResponse(BaseModel):
|
|
"""Generic message response."""
|
|
message: str
|
|
|
|
|
|
class CountResponse(BaseModel):
|
|
"""Generic count response."""
|
|
count: int
|
|
|
|
|
|
class ErrorResponse(BaseModel):
|
|
"""Error response with details."""
|
|
detail: str
|
|
error_code: Optional[str] = None
|