
- Set up project structure with FastAPI and SQLite - Implement user authentication with JWT - Create database models for users, events, bets, and transactions - Add API endpoints for user management - Add API endpoints for events and betting functionality - Add wallet management for deposits and withdrawals - Configure Alembic for database migrations - Add linting with Ruff - Add documentation in README
85 lines
1.6 KiB
Python
85 lines
1.6 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from app.models.event import EventStatus
|
|
|
|
|
|
class OutcomeBase(BaseModel):
|
|
name: str
|
|
odds: float
|
|
is_active: bool = True
|
|
|
|
|
|
class OutcomeCreate(OutcomeBase):
|
|
pass
|
|
|
|
|
|
class OutcomeUpdate(OutcomeBase):
|
|
name: Optional[str] = None
|
|
odds: Optional[float] = None
|
|
is_active: Optional[bool] = None
|
|
is_winner: Optional[bool] = None
|
|
|
|
|
|
class Outcome(OutcomeBase):
|
|
id: int
|
|
market_id: int
|
|
is_winner: Optional[bool] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class MarketBase(BaseModel):
|
|
name: str
|
|
is_active: bool = True
|
|
|
|
|
|
class MarketCreate(MarketBase):
|
|
outcomes: list[OutcomeCreate]
|
|
|
|
|
|
class MarketUpdate(MarketBase):
|
|
name: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
outcomes: Optional[list[OutcomeUpdate]] = None
|
|
|
|
|
|
class Market(MarketBase):
|
|
id: int
|
|
event_id: int
|
|
outcomes: list[Outcome] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class EventBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
start_time: datetime
|
|
end_time: Optional[datetime] = None
|
|
status: EventStatus = EventStatus.UPCOMING
|
|
|
|
|
|
class EventCreate(EventBase):
|
|
markets: list[MarketCreate]
|
|
|
|
|
|
class EventUpdate(EventBase):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
start_time: Optional[datetime] = None
|
|
end_time: Optional[datetime] = None
|
|
status: Optional[EventStatus] = None
|
|
markets: Optional[list[MarketUpdate]] = None
|
|
|
|
|
|
class Event(EventBase):
|
|
id: int
|
|
markets: list[Market] = []
|
|
|
|
class Config:
|
|
from_attributes = True |