58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class CreditBalanceItemOut(BaseModel):
|
|
id: str
|
|
credit_scope: str
|
|
credit_scope_label: str = ""
|
|
team_id: str | None = None
|
|
credit_level: str
|
|
credit_level_label: str = ""
|
|
source_type: str
|
|
source_type_label: str = ""
|
|
source_id: str | None = None
|
|
product_id: str | None = None
|
|
payment_order_id: str | None = None
|
|
subscription_id: str | None = None
|
|
subscription_period_id: str | None = None
|
|
grant_amount: float
|
|
unspent_amount: float
|
|
consumed_amount: float
|
|
expired_amount: float
|
|
revoked_amount: float
|
|
valid_from: datetime
|
|
expires_at: datetime
|
|
last_usable_at: datetime
|
|
status: str
|
|
status_label: str = ""
|
|
created_at: datetime
|
|
|
|
|
|
class CreditBalanceSummaryOut(BaseModel):
|
|
credits: float
|
|
available_credits: float
|
|
personal_credits: float = 0
|
|
team_available_credits: float = 0
|
|
team_frozen_credits: float = 0
|
|
next_expiring_credits: float
|
|
next_expires_at: datetime | None = None
|
|
next_last_usable_at: datetime | None = None
|
|
|
|
|
|
class AdminCreditGrantRequest(BaseModel):
|
|
amount: float = Field(..., gt=0, le=999999999.99, multiple_of=0.01)
|
|
description: str = Field(..., min_length=1, max_length=256)
|
|
valid_from: datetime | None = None
|
|
validity_unit: str = Field(default="month", pattern="^(day|month)$")
|
|
validity_value: int = Field(default=1, ge=1, le=120)
|
|
credit_level: str = Field(default="general", pattern="^(promotional|general)$")
|
|
|
|
|
|
class AdminCreditDeductRequest(BaseModel):
|
|
amount: float = Field(..., gt=0, le=999999999.99, multiple_of=0.01)
|
|
description: str = Field(..., min_length=1, max_length=256)
|