q
This commit is contained in:
0
app/schemas/__init__.py
Normal file
0
app/schemas/__init__.py
Normal file
11
app/schemas/base.py
Normal file
11
app/schemas/base.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# Base schemas with shared attributes
|
||||
class BaseSchema(BaseModel):
|
||||
date_created: datetime
|
||||
date_modified: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Allows conversion from SQLAlchemy models
|
66
app/schemas/box.py
Normal file
66
app/schemas/box.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from schemas.base import BaseSchema
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
#BOX
|
||||
class BoxSchema(BaseSchema):
|
||||
product_id: str = Field(..., title="Product ID")
|
||||
type: str = Field(..., title="Box Type (collector, play, draft)")
|
||||
set_code: str = Field(..., title="Set Code")
|
||||
sku: Optional[str] = Field(None, title="SKU")
|
||||
num_cards_expected: Optional[int] = Field(None, title="Number of cards expected")
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
# CREATE
|
||||
# REQUEST
|
||||
class CreateBoxRequest(BaseModel):
|
||||
type: str = Field(..., title="Box Type (collector, play, draft)")
|
||||
set_code: str = Field(..., title="Set Code")
|
||||
sku: Optional[str] = Field(None, title="SKU")
|
||||
num_cards_expected: Optional[int] = Field(None, title="Number of cards expected")
|
||||
|
||||
# RESPONSE
|
||||
class CreateBoxResponse(BaseModel):
|
||||
status_code: int = Field(..., title="status_code")
|
||||
success: bool = Field(..., title="success")
|
||||
box: list[BoxSchema] = Field(..., title="box")
|
||||
|
||||
# UPDATE
|
||||
# REQUEST
|
||||
class UpdateBoxRequest(BaseModel):
|
||||
type: Optional[str] = Field(None, title="Box Type (collector, play, draft)")
|
||||
set_code: Optional[str] = Field(None, title="Set Code")
|
||||
sku: Optional[str] = Field(None, title="SKU")
|
||||
num_cards_expected: Optional[int] = Field(None, title="Number of cards expected")
|
||||
|
||||
# GET
|
||||
# RESPONSE
|
||||
class GetBoxResponse(BaseModel):
|
||||
status_code: int = Field(..., title="status_code")
|
||||
success: bool = Field(..., title="success")
|
||||
boxes: list[BoxSchema] = Field(..., title="boxes")
|
||||
|
||||
|
||||
# OPEN BOX
|
||||
class OpenBoxSchema(BaseModel):
|
||||
id: str = Field(..., title="id")
|
||||
num_cards_actual: Optional[int] = Field(None, title="Number of cards actual")
|
||||
date_opened: Optional[datetime] = Field(None, title="Date Opened")
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
# CREATE
|
||||
# REQUEST
|
||||
class CreateOpenBoxRequest(BaseModel):
|
||||
product_id: str = Field(..., title="Product ID")
|
||||
file_ids: list[str] = Field(None, title="File IDs")
|
||||
num_cards_actual: Optional[int] = Field(None, title="Number of cards actual")
|
||||
date_opened: Optional [str] = Field(None, title="Date Opened")
|
||||
|
||||
# RESPONSE
|
||||
class CreateOpenBoxResponse(BaseModel):
|
||||
status_code: int = Field(..., title="status_code")
|
||||
success: bool = Field(..., title="success")
|
||||
open_box: list[OpenBoxSchema] = Field(..., title="open_box")
|
51
app/schemas/file.py
Normal file
51
app/schemas/file.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# FILE
|
||||
class FileSchema(BaseModel):
|
||||
id: str = Field(..., title="id")
|
||||
filename: str = Field(..., title="filename")
|
||||
type: str = Field(..., title="type")
|
||||
filesize_kb: float = Field(..., title="filesize_kb")
|
||||
source: str = Field(..., title="source")
|
||||
status: str = Field(..., title="status")
|
||||
service: Optional[str] = Field(None, title="service")
|
||||
date_created: datetime = Field(..., title="date_created")
|
||||
date_modified: datetime = Field(..., title="date_modified")
|
||||
|
||||
# This enables ORM mode
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
# CREATE
|
||||
# REQUEST
|
||||
class CreateFileRequest(BaseModel):
|
||||
source: str = Field(..., title="source")
|
||||
type: str = Field(..., title="type")
|
||||
# optional
|
||||
service: Optional[str] = Field(None, title="Service")
|
||||
filename: Optional[str] = Field(None, title="Filename")
|
||||
|
||||
# RESPONSE
|
||||
class CreateFileResponse(BaseModel):
|
||||
status_code: int = Field(..., title="status_code")
|
||||
success: bool = Field(..., title="success")
|
||||
files: list[FileSchema] = Field(..., title="files")
|
||||
|
||||
# GET
|
||||
# RESPONSE
|
||||
class GetFileResponse(BaseModel):
|
||||
status_code: int = Field(..., title="status_code")
|
||||
success: bool = Field(..., title="success")
|
||||
files: list[FileSchema] = Field(..., title="files")
|
||||
# QUERY PARAMS
|
||||
class GetFileQueryParams(BaseModel):
|
||||
status: Optional[str] = Field(None, title="status")
|
||||
|
||||
# DELETE
|
||||
# RESPONSE
|
||||
class DeleteFileResponse(BaseModel):
|
||||
status_code: int = Field(..., title="status_code")
|
||||
success: bool = Field(..., title="success")
|
||||
files: list[FileSchema] = Field(..., title="files")
|
5
app/schemas/inventory.py
Normal file
5
app/schemas/inventory.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class UpdateInventoryResponse(BaseModel):
|
||||
success: bool = Field(..., title="Success")
|
19
app/schemas/order.py
Normal file
19
app/schemas/order.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# FILE
|
||||
class OrderSchema(BaseModel):
|
||||
id: str = Field(..., title="id")
|
||||
filename: str = Field(..., title="filename")
|
||||
type: str = Field(..., title="type")
|
||||
filesize_kb: float = Field(..., title="filesize_kb")
|
||||
source: str = Field(..., title="source")
|
||||
status: str = Field(..., title="status")
|
||||
service: Optional[str] = Field(None, title="service")
|
||||
date_created: datetime = Field(..., title="date_created")
|
||||
date_modified: datetime = Field(..., title="date_modified")
|
||||
|
||||
# This enables ORM mode
|
||||
model_config = ConfigDict(from_attributes=True)
|
Reference in New Issue
Block a user