data model change and some new services
This commit is contained in:
0
schemas/__init__.py
Normal file
0
schemas/__init__.py
Normal file
13
schemas/base.py
Normal file
13
schemas/base.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from pydantic import BaseModel, Field, validator
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
# Base schemas with shared attributes
|
||||
class BaseSchema(BaseModel):
|
||||
date_created: datetime
|
||||
date_modified: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Allows conversion from SQLAlchemy models
|
25
schemas/box.py
Normal file
25
schemas/box.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from schemas.base import BaseSchema
|
||||
|
||||
class CreateBoxResponse(BaseModel):
|
||||
success: bool = Field(..., title="Success")
|
||||
|
||||
class CreateOpenBoxResponse(CreateBoxResponse):
|
||||
open_box_id: str
|
||||
|
||||
class CreateSealedBoxResponse(CreateBoxResponse):
|
||||
product_id: str
|
||||
quantity: int
|
||||
|
||||
class CreateBoxRequestData(BaseModel):
|
||||
type: str = Field(..., title="Box Type (collector, play, draft)")
|
||||
name: str = Field(..., title="Name")
|
||||
product_line: str = Field(..., title="Product Line (MTG, Pokemon, etc)")
|
||||
set_name: str = Field(..., title="Set Name")
|
||||
set_code: str = Field(..., title="Set Code")
|
||||
sealed: bool = Field(..., title="Sealed: Boolean")
|
||||
sku: str = Field(..., title="SKU")
|
||||
num_cards_expected: int = Field(..., title="Number of cards expected")
|
||||
num_cards_actual: int = Field(None, title="Number of cards actual")
|
||||
date_purchased: str = Field(..., title="Date purchased")
|
||||
date_opened: str = Field(None, title="Date opened")
|
29
schemas/file.py
Normal file
29
schemas/file.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from schemas.base import BaseSchema
|
||||
from fastapi import UploadFile
|
||||
|
||||
# For additional metadata about the upload
|
||||
class FileMetadata(BaseModel):
|
||||
source: str = Field(..., title="Source")
|
||||
type: str = Field(..., title="Type")
|
||||
# optional
|
||||
service: Optional[str] = Field(None, title="Service")
|
||||
|
||||
# For the response after upload
|
||||
class FileUploadResponse(BaseSchema):
|
||||
id: str
|
||||
filename: str
|
||||
type: str
|
||||
file_size_kb: float
|
||||
source: str
|
||||
status: str
|
||||
service: str
|
||||
|
||||
class FileDeleteResponse(BaseModel):
|
||||
id: str
|
||||
status: str
|
||||
|
||||
class GetPreparedFilesResponse(BaseModel):
|
||||
files: list[FileUploadResponse]
|
6
schemas/inventory.py
Normal file
6
schemas/inventory.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from schemas.base import BaseSchema
|
||||
|
||||
|
||||
class UpdateInventoryResponse(BaseModel):
|
||||
success: bool = Field(..., title="Success")
|
Reference in New Issue
Block a user