2023-06-09 11:50:48 +00:00
|
|
|
from datetime import datetime
|
|
|
|
from enum import Enum
|
|
|
|
from typing import Literal
|
|
|
|
|
|
|
|
from pydantic import Field
|
|
|
|
|
|
|
|
from simnet.models.base import APIModel
|
|
|
|
|
|
|
|
__all__ = ("BaseTransaction", "ItemTransaction", "Transaction", "TransactionKind")
|
|
|
|
|
|
|
|
|
|
|
|
class TransactionKind(str, Enum):
|
|
|
|
"""Possible kind of transaction.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
PRIMOGEM: Primogem currency.
|
|
|
|
CRYSTAL: Genesis crystal currency.
|
|
|
|
RESIN: Resin currency.
|
|
|
|
ARTIFACT: Artifact items from domains.
|
|
|
|
WEAPON: Weapon items from domains and wishes.
|
|
|
|
"""
|
|
|
|
|
|
|
|
PRIMOGEM = "primogem"
|
|
|
|
CRYSTAL = "crystal"
|
|
|
|
RESIN = "resin"
|
|
|
|
ARTIFACT = "artifact"
|
|
|
|
WEAPON = "weapon"
|
|
|
|
|
|
|
|
|
|
|
|
class BaseTransaction(APIModel):
|
|
|
|
"""Genshin transaction."""
|
|
|
|
|
|
|
|
kind: TransactionKind
|
|
|
|
|
|
|
|
id: int
|
2023-07-17 05:14:40 +00:00
|
|
|
time: datetime = Field(alias="datetime")
|
2023-06-09 11:50:48 +00:00
|
|
|
amount: int = Field(alias="add_num")
|
2023-07-17 05:14:40 +00:00
|
|
|
reason: str
|
2023-06-09 11:50:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Transaction(BaseTransaction):
|
|
|
|
"""Genshin transaction of currency."""
|
|
|
|
|
|
|
|
kind: Literal[TransactionKind.PRIMOGEM, TransactionKind.CRYSTAL, TransactionKind.RESIN]
|
|
|
|
|
|
|
|
|
|
|
|
class ItemTransaction(BaseTransaction):
|
|
|
|
"""Genshin transaction of artifacts or weapons."""
|
|
|
|
|
|
|
|
kind: Literal[TransactionKind.ARTIFACT, TransactionKind.WEAPON]
|
|
|
|
|
|
|
|
name: str
|
2023-07-17 05:14:40 +00:00
|
|
|
rarity: int = Field(alias="quality")
|