feat: add etc and users
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
|
|
||||||
from itd.users import get_user
|
from itd.users import get_user, update_profile, follow, unfollow, get_followers, get_following
|
||||||
|
from itd.etc import get_top_clans, get_who_to_follow, get_platform_status
|
||||||
from itd.comments import get_comments, add_comment, delete_comment, like_comment, unlike_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.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.notifications import get_notifications, mark_as_read, mark_all_as_read, get_unread_notifications_count
|
||||||
@@ -48,6 +49,39 @@ class Client:
|
|||||||
def get_me(self) -> dict:
|
def get_me(self) -> dict:
|
||||||
return self.get_user('me')
|
return self.get_user('me')
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def update_profile(self, username: str | None = None, display_name: str | None = None, bio: str | None = None) -> dict:
|
||||||
|
return update_profile(self.token, bio, display_name, username)
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def follow(self, username: str) -> dict:
|
||||||
|
return follow(self.token, username)
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def unfollow(self, username: str) -> dict:
|
||||||
|
return unfollow(self.token, username)
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def get_followers(self, username: str) -> dict:
|
||||||
|
return get_followers(self.token, username)
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def get_following(self, username: str) -> dict:
|
||||||
|
return get_following(self.token, username)
|
||||||
|
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def get_who_to_follow(self) -> dict:
|
||||||
|
return get_who_to_follow(self.token)
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def get_top_clans(self) -> dict:
|
||||||
|
return get_top_clans(self.token)
|
||||||
|
|
||||||
|
@refresh_on_error
|
||||||
|
def get_platform_status(self) -> dict:
|
||||||
|
return get_platform_status(self.token)
|
||||||
|
|
||||||
|
|
||||||
@refresh_on_error
|
@refresh_on_error
|
||||||
def add_comment(self, post_id: str, content: str, reply_comment_id: str | None = None):
|
def add_comment(self, post_id: str, content: str, reply_comment_id: str | None = None):
|
||||||
|
|||||||
10
itd/etc.py
Normal file
10
itd/etc.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from itd.request import fetch
|
||||||
|
|
||||||
|
def get_top_clans(token: str):
|
||||||
|
return fetch(token, 'get', 'users/stats/top-clans')
|
||||||
|
|
||||||
|
def get_who_to_follow(token: str):
|
||||||
|
return fetch(token, 'get', 'users/suggestions/who-to-follow')
|
||||||
|
|
||||||
|
def get_platform_status(token: str):
|
||||||
|
return fetch(token, 'get', 'platform/status')
|
||||||
24
itd/users.py
24
itd/users.py
@@ -2,4 +2,26 @@ from itd.request import fetch
|
|||||||
|
|
||||||
|
|
||||||
def get_user(token: str, username: str):
|
def get_user(token: str, username: str):
|
||||||
return fetch(token, 'get', f'users/{username}')
|
return fetch(token, 'get', f'users/{username}')
|
||||||
|
|
||||||
|
def update_profile(token: str, bio: str | None = None, display_name: str | None = None, username: str | None = None):
|
||||||
|
data = {}
|
||||||
|
if bio:
|
||||||
|
data['bio'] = bio
|
||||||
|
if display_name:
|
||||||
|
data['displayName'] = display_name
|
||||||
|
if username:
|
||||||
|
data['username'] = username
|
||||||
|
return fetch(token, 'put', 'users/me', data)
|
||||||
|
|
||||||
|
def follow(token: str, username: str):
|
||||||
|
return fetch(token, 'post', f'users/{username}/follow')
|
||||||
|
|
||||||
|
def unfollow(token: str, username: str):
|
||||||
|
return fetch(token, 'delete', f'users/{username}/follow')
|
||||||
|
|
||||||
|
def get_followers(token: str, username: str, limit: int = 30, page: int = 1):
|
||||||
|
return fetch(token, 'get', f'users/{username}/followers', {'limit': limit, 'page': page})
|
||||||
|
|
||||||
|
def get_following(token: str, username: str, limit: int = 30, page: int = 1):
|
||||||
|
return fetch(token, 'get', f'users/{username}/following', {'limit': limit, 'page': page})
|
||||||
|
|||||||
Reference in New Issue
Block a user