mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-22 22:37:24 +00:00
4250481727
- Fix issue with Daily Reward Client not running - Update Wish Client to support multiple banner retrieval - Fix issue with setting salt for dynamic secret - Improve APIModel to support multiple aliases - Add asyncio.sleep() to Wish paginator to prevent excessive requests Co-authored-by: xtaodada <xtao@xtaolink.cn>
26 lines
712 B
Python
26 lines
712 B
Python
from typing import Any
|
|
|
|
from pydantic import BaseModel
|
|
|
|
try:
|
|
import ujson as jsonlib
|
|
except ImportError:
|
|
import json as jsonlib
|
|
|
|
|
|
class APIModel(BaseModel):
|
|
"""A Pydantic BaseModel class used for modeling JSON data returned by an API."""
|
|
|
|
def __init__(self, **data: Any) -> None:
|
|
for field_name, field in self.__fields__.items():
|
|
aliases = field.field_info.extra.get("aliases")
|
|
if aliases and aliases in data:
|
|
data[field_name] = data.pop(aliases)
|
|
super().__init__(**data)
|
|
|
|
class Config:
|
|
"""A nested class defining configuration options for the APIModel."""
|
|
|
|
json_dumps = jsonlib.dumps
|
|
json_loads = jsonlib.loads
|