- Standardize quote style (single to double quotes) - Reorder and group imports alphabetically - Fix line breaks and indentation for consistency - Apply PEP 8 formatting standards Also updated Makefile to exclude both venv and .venv from code quality checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
79 lines
2.1 KiB
Python
79 lines
2.1 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
|
|
class MarketplaceImportJobRequest(BaseModel):
|
|
"""Request schema for triggering marketplace import.
|
|
|
|
Note: vendor_id is injected by middleware, not from request body.
|
|
"""
|
|
|
|
source_url: str = Field(..., description="URL to CSV file from marketplace")
|
|
marketplace: str = Field(default="Letzshop", description="Marketplace name")
|
|
batch_size: Optional[int] = Field(
|
|
1000, description="Processing batch size", ge=100, le=10000
|
|
)
|
|
|
|
@field_validator("source_url")
|
|
@classmethod
|
|
def validate_url(cls, v):
|
|
# Basic URL security validation
|
|
if not v.startswith(("http://", "https://")):
|
|
raise ValueError("URL must start with http:// or https://")
|
|
return v.strip()
|
|
|
|
@field_validator("marketplace")
|
|
@classmethod
|
|
def validate_marketplace(cls, v):
|
|
return v.strip()
|
|
|
|
|
|
class MarketplaceImportJobResponse(BaseModel):
|
|
"""Response schema for marketplace import job."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
job_id: int
|
|
vendor_id: int
|
|
vendor_code: str # Populated from vendor relationship
|
|
vendor_name: str # Populated from vendor relationship
|
|
marketplace: str
|
|
source_url: str
|
|
status: str
|
|
|
|
# Counts
|
|
imported: int = 0
|
|
updated: int = 0
|
|
total_processed: int = 0
|
|
error_count: int = 0
|
|
|
|
# Error details
|
|
error_message: Optional[str] = None
|
|
|
|
# Timestamps
|
|
created_at: datetime
|
|
started_at: Optional[datetime] = None
|
|
completed_at: Optional[datetime] = None
|
|
|
|
|
|
class MarketplaceImportJobListResponse(BaseModel):
|
|
"""Response schema for list of import jobs."""
|
|
|
|
jobs: list[MarketplaceImportJobResponse]
|
|
total: int
|
|
skip: int
|
|
limit: int
|
|
|
|
|
|
class MarketplaceImportJobStatusUpdate(BaseModel):
|
|
"""Schema for updating import job status (internal use)."""
|
|
|
|
status: str
|
|
imported_count: Optional[int] = None
|
|
updated_count: Optional[int] = None
|
|
error_count: Optional[int] = None
|
|
total_processed: Optional[int] = None
|
|
error_message: Optional[str] = None
|