Merge branch 'v1' into Typo
This commit is contained in:
@@ -367,12 +367,14 @@ class Client:
|
|||||||
|
|
||||||
|
|
||||||
@refresh_on_error
|
@refresh_on_error
|
||||||
def add_comment(self, post_id: UUID, content: str) -> Comment:
|
def add_comment(self, post_id: UUID, content: str, attachment_ids: list[UUID] = []) -> Comment:
|
||||||
"""Добавить комментарий
|
"""Добавить комментарий
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
post_id (str): UUID поста
|
post_id (str): UUID поста
|
||||||
content (str): Содержание
|
content (str): Содержание
|
||||||
|
attachment_ids (list[UUID]): Список UUID прикреплённых файлов
|
||||||
|
reply_comment_id (UUID | None, optional): ID коммента для ответа. Defaults to None.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValidationError: Ошибка валидации
|
ValidationError: Ошибка валидации
|
||||||
@@ -381,7 +383,7 @@ class Client:
|
|||||||
Returns:
|
Returns:
|
||||||
Comment: Комментарий
|
Comment: Комментарий
|
||||||
"""
|
"""
|
||||||
res = add_comment(self.token, post_id, content)
|
res = add_comment(self.token, post_id, content, attachment_ids)
|
||||||
if res.status_code == 422 and 'found' in res.json():
|
if res.status_code == 422 and 'found' in res.json():
|
||||||
raise ValidationError(*list(res.json()['found'].items())[0])
|
raise ValidationError(*list(res.json()['found'].items())[0])
|
||||||
if res.json().get('error', {}).get('code') == 'NOT_FOUND':
|
if res.json().get('error', {}).get('code') == 'NOT_FOUND':
|
||||||
@@ -392,13 +394,14 @@ class Client:
|
|||||||
|
|
||||||
|
|
||||||
@refresh_on_error
|
@refresh_on_error
|
||||||
def add_reply_comment(self, comment_id: UUID, content: str, author_id: UUID) -> Comment:
|
def add_reply_comment(self, comment_id: UUID, content: str, author_id: UUID, attachment_ids: list[UUID] = []) -> Comment:
|
||||||
"""Добавить ответный комментарий
|
"""Добавить ответный комментарий
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
comment_id (str): UUID комментария
|
comment_id (str): UUID комментария
|
||||||
content (str): Содержание
|
content (str): Содержание
|
||||||
author_id (UUID | None, optional): ID пользователя, отправившего комментарий. Defaults to None.
|
author_id (UUID | None, optional): ID пользователя, отправившего комментарий. Defaults to None.
|
||||||
|
attachment_ids (list[UUID]): Список UUID прикреплённых файлов
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValidationError: Ошибка валидации
|
ValidationError: Ошибка валидации
|
||||||
@@ -407,7 +410,7 @@ class Client:
|
|||||||
Returns:
|
Returns:
|
||||||
Comment: Комментарий
|
Comment: Комментарий
|
||||||
"""
|
"""
|
||||||
res = add_reply_comment(self.token, comment_id, content, author_id)
|
res = add_reply_comment(self.token, comment_id, content, author_id, attachment_ids)
|
||||||
if res.status_code == 500 and 'Failed query' in res.text:
|
if res.status_code == 500 and 'Failed query' in res.text:
|
||||||
raise NotFound('User')
|
raise NotFound('User')
|
||||||
if res.status_code == 422 and 'found' in res.json():
|
if res.status_code == 422 and 'found' in res.json():
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class File(BaseModel):
|
|||||||
id: UUID
|
id: UUID
|
||||||
url: str
|
url: str
|
||||||
filename: str
|
filename: str
|
||||||
mime_type: str = Field('image/png', alias='mimeType')
|
mime_type: str = Field(alias='mimeType')
|
||||||
size: int
|
size: int
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ from uuid import UUID
|
|||||||
|
|
||||||
from itd.request import fetch
|
from itd.request import fetch
|
||||||
|
|
||||||
def add_comment(token: str, post_id: UUID, content: str):
|
def add_comment(token: str, post_id: UUID, content: str, attachment_ids: list[UUID] = []):
|
||||||
return fetch(token, 'post', f'posts/{post_id}/comments', {'content': content})
|
return fetch(token, 'post', f'posts/{post_id}/comments', {'content': content, "attachmentIds": list(map(str, attachment_ids))})
|
||||||
|
|
||||||
def add_reply_comment(token: str, comment_id: UUID, content: str, author_id: UUID):
|
def add_reply_comment(token: str, comment_id: UUID, content: str, author_id: UUID, attachment_ids: list[UUID] = []):
|
||||||
return fetch(token, 'post', f'comments/{comment_id}/replies', {'content': content, 'replyToUserId': str(author_id)})
|
return fetch(token, 'post', f'comments/{comment_id}/replies', {'content': content, 'replyToUserId': str(author_id), "attachmentIds": list(map(str, attachment_ids))})
|
||||||
|
|
||||||
def get_comments(token: str, post_id: UUID, limit: int = 20, cursor: int = 0, sort: str = 'popular'):
|
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})
|
return fetch(token, 'get', f'posts/{post_id}/comments', {'limit': limit, 'sort': sort, 'cursor': cursor})
|
||||||
|
|||||||
Reference in New Issue
Block a user