feat: add models part 2
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
from uuid import UUID
|
||||
|
||||
from itd.request import fetch
|
||||
|
||||
def add_comment(token: str, post_id: str, content: str, reply_comment_id: str | None = None):
|
||||
data = {'content': content}
|
||||
if reply_comment_id:
|
||||
data['replyTo'] = str(reply_comment_id)
|
||||
return fetch(token, 'post', f'posts/{post_id}/comments', data)
|
||||
def add_comment(token: str, post_id: UUID, content: str):
|
||||
return fetch(token, 'post', f'posts/{post_id}/comments', {'content': content})
|
||||
|
||||
def get_comments(token: str, post_id: str, limit: int = 20, cursor: int = 0, sort: str = 'popular'):
|
||||
def add_reply_comment(token: str, comment_id: UUID, content: str, author_id: UUID):
|
||||
return fetch(token, 'post', f'comments/{comment_id}/replies', {'content': content, 'replyToUserId': str(author_id)})
|
||||
|
||||
def get_comments(token: str, post_id: UUID, limit: int = 20, cursor: int = 0, sort: str = 'popular'):
|
||||
return fetch(token, 'get', f'posts/{post_id}/comments', {'limit': limit, 'sort': sort, 'cursor': cursor})
|
||||
|
||||
def like_comment(token: str, comment_id: str):
|
||||
def like_comment(token: str, comment_id: UUID):
|
||||
return fetch(token, 'post', f'comments/{comment_id}/like')
|
||||
|
||||
def unlike_comment(token: str, comment_id: str):
|
||||
def unlike_comment(token: str, comment_id: UUID):
|
||||
return fetch(token, 'delete', f'comments/{comment_id}/like')
|
||||
|
||||
def delete_comment(token: str, comment_id: str):
|
||||
def delete_comment(token: str, comment_id: UUID):
|
||||
return fetch(token, 'delete', f'comments/{comment_id}')
|
||||
|
||||
Reference in New Issue
Block a user