|
from pydantic import BaseModel, Field |
|
from typing import Optional, List |
|
from decimal import Decimal |
|
|
|
|
|
class BaseResponse(BaseModel): |
|
code: int |
|
message: str |
|
payload: Optional[dict] = None |
|
|
|
|
|
class CreatePlanRequest(BaseModel): |
|
name: str = Field(..., description="Name of the subscription plan") |
|
amount: Decimal = Field(..., description="Cost of the plan") |
|
duration: int = Field(..., description="Duration of the subscription in hours") |
|
download_speed: float = Field(..., description="Download speed in Mbps") |
|
upload_speed: float = Field(..., description="Upload speed in Mbps") |
|
is_promo: Optional[bool] = Field(False, description="is it a promo") |
|
promo_days: Optional[int] = Field(None, description="promotion days") |
|
|
|
|
|
class UpdatePlanRequest(BaseModel): |
|
name: Optional[str] = Field(None, description="Name of the subscription plan") |
|
amount: Optional[Decimal] = Field(None, description="Cost of the plan") |
|
duration: Optional[int] = Field( |
|
None, description="Duration of the subscription in hours" |
|
) |
|
download_speed: Optional[float] = Field(None, description="Download speed in Mbps") |
|
upload_speed: Optional[float] = Field(None, description="Upload speed in Mbps") |
|
|
|
|
|
class PlanResponse(BaseModel): |
|
id: str |
|
name: str |
|
amount: Decimal |
|
duration: int |
|
download_speed: float |
|
upload_speed: float |
|
|
|
class Config: |
|
from_attributes = True |
|
|
|
|
|
class PlanListResponse(BaseModel): |
|
plans: List[PlanResponse] |
|
total_count: int |
|
|
|
class Config: |
|
from_attributes = True |
|
|