diff --git a/itd/client.py b/itd/client.py index 099de24..e49c758 100644 --- a/itd/client.py +++ b/itd/client.py @@ -1,6 +1,8 @@ from itd.users import get_user -from itd.comments import get_comments, add_comment, delete_comment, like_comment, unlike_comment, update_comment +from itd.comments import get_comments, add_comment, delete_comment, like_comment, unlike_comment from itd.hashtags import get_hastags, get_posts_by_hastag +from itd.notifications import get_notifications, mark_as_read, mark_all_as_read, get_unread_notifications_count +from itd.posts import create_post, get_posts, get_post, edit_post, delete_post, pin_post, repost, view_post class Client: def __init__(self, token: str): @@ -28,12 +30,47 @@ class Client: def delete_comment(self, id: str): return delete_comment(self.token, id) - def update_comment(self, id: str, content: str): - return update_comment(self.token, id, content) - def get_hastags(self, limit: int = 10): return get_hastags(self.token, limit) def get_posts_by_hashtag(self, hashtag: str, limit: int = 20, cursor: int = 0): - return get_posts_by_hastag(self.token, hashtag, limit, cursor) \ No newline at end of file + return get_posts_by_hastag(self.token, hashtag, limit, cursor) + + + def get_notifications(self, limit: int = 20, cursor: int = 0, type: str | None = None): + return get_notifications(self.token, limit, cursor, type) + + def mark_as_read(self, id: str): + return mark_as_read(self.token, id) + + def mark_all_as_read(self): + return mark_all_as_read(self.token) + + def get_unread_notifications_count(self): + return get_unread_notifications_count(self.token) + + + def create_post(self, content: str, wall_recipient_id: int | None = None, attach_ids: list[str] = []): + return create_post(self.token, content, wall_recipient_id, attach_ids) + + def get_posts(self, username: str | None = None, limit: int = 20, cursor: int = 0, sort: str = '', tab: str = ''): + return get_posts(self.token, username, limit, cursor, sort, tab) + + def get_post(self, id: str): + return get_post(self.token, id) + + def edit_post(self, id: str, content: str): + return edit_post(self.token, id, content) + + def delete_post(self, id: str): + return delete_post(self.token, id) + + def pin_post(self, id: str): + return pin_post(self.token, id) + + def repost(self, id: str, content: str | None = None): + return repost(self.token, id, content) + + def view_post(self, id: str): + return view_post(self.token, id) \ No newline at end of file diff --git a/itd/comments.py b/itd/comments.py index 06e7f9e..e0e7395 100644 --- a/itd/comments.py +++ b/itd/comments.py @@ -17,6 +17,3 @@ def unlike_comment(token: str, comment_id: str): def delete_comment(token: str, comment_id: str): return fetch(token, 'delete', f'comments/{comment_id}') - -def update_comment(token: str, comment_id: str, content: str): - return fetch(token, 'put', f'comments/{comment_id}', {'content': content}) \ No newline at end of file diff --git a/itd/posts.py b/itd/posts.py new file mode 100644 index 0000000..98aa18c --- /dev/null +++ b/itd/posts.py @@ -0,0 +1,42 @@ +from itd.request import fetch + +def create_post(token: str, content: str, wall_recipient_id: int | None = None, attach_ids: list[str] = []): + data: dict = {'content': content} + if wall_recipient_id: + data['wallRecipientId'] = wall_recipient_id + if attach_ids: + data['attachmentIds'] = attach_ids + + return fetch(token, 'post', 'posts', data) + +def get_posts(token: str, username: str | None = None, limit: int = 20, cursor: int = 0, sort: str = '', tab: str = ''): + data: dict = {'limit': limit, 'cursor': cursor} + if username: + data['username'] = username + if sort: + data['sort'] = sort + if tab: + data['tab'] = tab + + return fetch(token, 'get', 'posts', data) + +def get_post(token: str, id: str): + return fetch(token, 'get', f'posts/{id}') + +def edit_post(token: str, id: str, content: str): + return fetch(token, 'put', f'posts/{id}', {'content': content}) + +def delete_post(token: str, id: str): + return fetch(token, 'delete', f'posts/{id}') + +def pin_post(token: str, id: str): + return fetch(token, 'post', f'posts/{id}/pin') + +def repost(token: str, id: str, content: str | None = None): + data = {} + if content: + data['content'] = content + return fetch(token, 'post', f'posts/{id}/repost', data) + +def view_post(token: str, id: str): + return fetch(token, 'post', f'posts/{id}/view') \ No newline at end of file