pydantic stuff
This commit is contained in:
parent
90e0cf3d94
commit
1a0f55df8a
@ -1 +1,3 @@
|
|||||||
requests
|
requests
|
||||||
|
pydantic
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,24 @@
|
|||||||
# core.py
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import List, Optional
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
class User(BaseModel):
|
||||||
|
handle: str
|
||||||
|
name: str
|
||||||
|
enlisted: date # Datum
|
||||||
|
citizenrecord: Optional[int] # Integer oder None
|
||||||
|
languages: List[str] = Field(default_factory=list) # Liste von Strings
|
||||||
|
|
||||||
|
class OrgMember(User):
|
||||||
|
rang: str
|
||||||
|
star: int
|
||||||
|
affiliate: bool
|
||||||
|
|
||||||
|
class Org(BaseModel):
|
||||||
|
sid: str
|
||||||
|
name: str
|
||||||
|
membercount: int
|
||||||
|
fokus: List[str] = Field(default_factory=list)
|
||||||
|
|
||||||
def getOrg(org_id):
|
def getOrg(org_id):
|
||||||
"""
|
"""
|
||||||
@ -6,7 +26,12 @@ def getOrg(org_id):
|
|||||||
:param org_id: The ID of the organization.
|
:param org_id: The ID of the organization.
|
||||||
:return: A dictionary with organization details.
|
:return: A dictionary with organization details.
|
||||||
"""
|
"""
|
||||||
return {"id": org_id, "name": f"Org-{org_id}"}
|
return Org(
|
||||||
|
sid=f"org_{org_id}",
|
||||||
|
name=f"Organization {org_id}",
|
||||||
|
membercount=42, # Beispielwert
|
||||||
|
fokus=["Innovation", "Technology"] # Beispiel für Schwerpunkte
|
||||||
|
)
|
||||||
|
|
||||||
def getOrgMembers(org_id):
|
def getOrgMembers(org_id):
|
||||||
"""
|
"""
|
||||||
@ -14,7 +39,30 @@ def getOrgMembers(org_id):
|
|||||||
:param org_id: The ID of the organization.
|
:param org_id: The ID of the organization.
|
||||||
:return: A list of dictionaries representing members.
|
:return: A list of dictionaries representing members.
|
||||||
"""
|
"""
|
||||||
return [{"id": i, "name": f"Member-{i}"} for i in range(1, 6)]
|
return [
|
||||||
|
OrgMember(
|
||||||
|
handle=f"user_{org_id}_1",
|
||||||
|
name="John Doe",
|
||||||
|
mainorg=f"org_{org_id}",
|
||||||
|
enlisted=date(2020, 5, 1),
|
||||||
|
citizenrecord=101,
|
||||||
|
languages=["English", "Spanish"],
|
||||||
|
rang="Senior",
|
||||||
|
star=5,
|
||||||
|
affiliate=True
|
||||||
|
),
|
||||||
|
OrgMember(
|
||||||
|
handle=f"user_{org_id}_2",
|
||||||
|
name="Jane Smith",
|
||||||
|
mainorg=f"org_{org_id}",
|
||||||
|
enlisted=date(2021, 7, 15),
|
||||||
|
citizenrecord=None,
|
||||||
|
languages=["German"],
|
||||||
|
rang="Junior",
|
||||||
|
star=2,
|
||||||
|
affiliate=False
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
def getUser(user_id):
|
def getUser(user_id):
|
||||||
"""
|
"""
|
||||||
@ -22,4 +70,11 @@ def getUser(user_id):
|
|||||||
:param user_id: The ID of the user.
|
:param user_id: The ID of the user.
|
||||||
:return: A dictionary with user details.
|
:return: A dictionary with user details.
|
||||||
"""
|
"""
|
||||||
return {"id": user_id, "name": f"User-{user_id}"}
|
return User(
|
||||||
|
handle=f"user_{user_id}",
|
||||||
|
name=f"User {user_id}",
|
||||||
|
mainorg="ExampleCorp",
|
||||||
|
enlisted=date(2023, 1, 15), # Beispiel für ein Datum
|
||||||
|
citizenrecord=user_id if user_id % 2 == 0 else None, # Integer oder None
|
||||||
|
languages=["English", "German"]
|
||||||
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user