Mbonea's picture
updated the db
d5bd833
from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime
class BaseResponse(BaseModel):
code: int
message: str
payload: Optional[dict] = None
class CreateSubscriptionRequest(BaseModel):
user_id: str = Field(..., description="ID of the user to create subscription for")
plan_id: str = Field(..., description="ID of the plan to base the subscription on")
class CreateCustomSubscriptionRequest(BaseModel):
user_id: Optional[str] = Field(
None, description="ID of the user to create subscription for"
)
phone_number: Optional[str] = Field(
None, description="The Phone Number of the user to create subscription for"
)
plan_id: str = Field(..., description="ID of the plan to base the subscription on")
expiration_time: str = Field(
...,
description="The expiration time of the subscription in 'day/month' format (e.g., 12/1 for 12th January)",
)
class UpdateUsageRequest(BaseModel):
download_mb: float = Field(0.0, ge=0, description="Download usage in megabytes")
upload_mb: float = Field(0.0, ge=0, description="Upload usage in megabytes")
class SubscriptionResponse(BaseModel):
id: str
user_id: str
plan_id: Optional[str]
active: bool
duration: int
download_mb: float
upload_mb: float
remaining_hours: float
created_time: datetime
expiration_time: datetime
class Config:
from_attributes = True
class SubscriptionListResponse(BaseModel):
subscriptions: List[SubscriptionResponse]
total_count: int
class Config:
from_attributes = True