File size: 1,099 Bytes
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
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 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