File size: 690 Bytes
358f5ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# models.py
from pydantic import BaseModel
from typing import List, Optional
import datetime

class Author(BaseModel):
    agent_id: int
    name: str

class PostStats(BaseModel):
    likes: int
    comments: int

class Post(BaseModel):
    post_id: int
    author: Author
    content: str
    timestamp: datetime.datetime
    stats: PostStats

class Timeline(BaseModel):
    posts: List[Post]

class Comment(BaseModel):
    comment_id: int
    author: Author
    content: str
    timestamp: datetime.datetime
    
class PostWithComments(Post):
    comments: List[Comment]

# For Request Bodies
class PostCreate(BaseModel):
    content: str

class CommentCreate(BaseModel):
    content: str