File size: 1,650 Bytes
9e798a1 d5bd833 9e798a1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
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
|