feat: update Pydantic schemas for unified order model

- Add AddressSnapshot and CustomerSnapshot schemas
- Update OrderItemResponse with gtin fields and item_state
- Update OrderResponse with all snapshot fields
- Add OrderListItem for simplified list views
- Add Letzshop-specific schemas (LetzshopOrderImport, LetzshopShippingInfo)
- Update AdminOrderItem with new fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-19 21:17:47 +01:00
parent 6f3a07c7d7
commit 2e3edcf197
2 changed files with 368 additions and 57 deletions

View File

@@ -91,6 +91,9 @@ class LetzshopOrderBase(BaseModel):
letzshop_state: str | None = None
customer_email: str | None = None
customer_name: str | None = None
customer_locale: str | None = None
shipping_country_iso: str | None = None
billing_country_iso: str | None = None
total_amount: str | None = None
currency: str = "EUR"
@@ -120,6 +123,7 @@ class LetzshopOrderResponse(LetzshopOrderBase):
tracking_number: str | None
tracking_carrier: str | None
inventory_units: list[dict[str, Any]] | None
order_date: datetime | None
created_at: datetime
updated_at: datetime
@@ -368,3 +372,55 @@ class LetzshopJobsListResponse(BaseModel):
jobs: list[LetzshopJobItem]
total: int
# ============================================================================
# Historical Import Job Schemas
# ============================================================================
class LetzshopHistoricalImportJobResponse(BaseModel):
"""Schema for historical import job status (polling endpoint)."""
model_config = ConfigDict(from_attributes=True)
id: int
vendor_id: int
status: str # pending, fetching, processing, completed, failed
current_phase: str | None = None # "confirmed" or "declined"
# Fetch progress
current_page: int = 0
total_pages: int | None = None
shipments_fetched: int = 0
# Processing progress
orders_processed: int = 0
orders_imported: int = 0
orders_updated: int = 0
orders_skipped: int = 0
# EAN matching stats
products_matched: int = 0
products_not_found: int = 0
# Phase-specific stats (when complete)
confirmed_stats: dict[str, Any] | None = None
declined_stats: dict[str, Any] | None = None
# Error handling
error_message: str | None = None
# Timing
started_at: datetime | None = None
completed_at: datetime | None = None
created_at: datetime
updated_at: datetime
class LetzshopHistoricalImportStartResponse(BaseModel):
"""Schema for starting a historical import job."""
job_id: int
status: str = "pending"
message: str = "Historical import job started"