mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-02-27 06:42:24 +00:00
- Add pyproject.toml with uv and ruff configuration - Pin Python version to 3.13 via .python-version - Add Makefile commands: lint, format, fix - Apply ruff formatting to entire codebase - Remove unused imports (base64 in yookassa/simple_subscription) - Update .gitignore for new config files
72 lines
1.7 KiB
Python
72 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.database.models import PromoCodeType
|
|
|
|
|
|
class PromoCodeResponse(BaseModel):
|
|
id: int
|
|
code: str
|
|
type: PromoCodeType
|
|
balance_bonus_kopeks: int
|
|
balance_bonus_rubles: float
|
|
subscription_days: int
|
|
max_uses: int
|
|
current_uses: int
|
|
uses_left: int
|
|
is_active: bool
|
|
is_valid: bool
|
|
valid_from: datetime
|
|
valid_until: datetime | None = None
|
|
created_by: int | None = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class PromoCodeListResponse(BaseModel):
|
|
items: list[PromoCodeResponse]
|
|
total: int
|
|
limit: int
|
|
offset: int
|
|
|
|
|
|
class PromoCodeCreateRequest(BaseModel):
|
|
code: str
|
|
type: PromoCodeType
|
|
balance_bonus_kopeks: int = 0
|
|
subscription_days: int = 0
|
|
max_uses: int = Field(default=1, ge=0)
|
|
valid_from: datetime | None = None
|
|
valid_until: datetime | None = None
|
|
is_active: bool = True
|
|
created_by: int | None = None
|
|
|
|
|
|
class PromoCodeUpdateRequest(BaseModel):
|
|
code: str | None = None
|
|
type: PromoCodeType | None = None
|
|
balance_bonus_kopeks: int | None = None
|
|
subscription_days: int | None = None
|
|
max_uses: int | None = Field(default=None, ge=0)
|
|
valid_from: datetime | None = None
|
|
valid_until: datetime | None = None
|
|
is_active: bool | None = None
|
|
|
|
|
|
class PromoCodeRecentUse(BaseModel):
|
|
id: int
|
|
user_id: int
|
|
user_username: str | None = None
|
|
user_full_name: str | None = None
|
|
user_telegram_id: int | None = None
|
|
used_at: datetime
|
|
|
|
|
|
class PromoCodeDetailResponse(PromoCodeResponse):
|
|
total_uses: int
|
|
today_uses: int
|
|
recent_uses: list[PromoCodeRecentUse] = Field(default_factory=list)
|