mirror of
https://github.com/boticord/boticordpy.git
synced 2024-09-22 19:32:01 +03:00
http make_request typehint + get_user_info
This commit is contained in:
parent
c5c1708ac1
commit
dcd77bacc3
2 changed files with 21 additions and 1 deletions
|
@ -87,6 +87,22 @@ class BoticordClient:
|
||||||
"""
|
"""
|
||||||
response = await self.http.get_server_info(server_id)
|
response = await self.http.get_server_info(server_id)
|
||||||
return boticord_types.ResourceServer.from_dict(response)
|
return boticord_types.ResourceServer.from_dict(response)
|
||||||
|
|
||||||
|
async def get_user_info(
|
||||||
|
self, user_id: typing.Union[str, int]
|
||||||
|
) -> boticord_types.UserProfile:
|
||||||
|
"""Gets information about specified user.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (Union[:obj:`str`, :obj:`int`])
|
||||||
|
Id of the user
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~.types.UserProfile`:
|
||||||
|
UserProfile object.
|
||||||
|
"""
|
||||||
|
response = await self.http.get_user_info(user_id)
|
||||||
|
return boticord_types.UserProfile.from_dict(response)
|
||||||
|
|
||||||
def autopost(self) -> AutoPost:
|
def autopost(self) -> AutoPost:
|
||||||
"""Returns a helper instance for auto-posting.
|
"""Returns a helper instance for auto-posting.
|
||||||
|
|
|
@ -29,7 +29,7 @@ class HttpClient:
|
||||||
|
|
||||||
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=loop)
|
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=loop)
|
||||||
|
|
||||||
async def make_request(self, method: str, endpoint: str, **kwargs):
|
async def make_request(self, method: str, endpoint: str, **kwargs) -> dict:
|
||||||
"""Send requests to the API"""
|
"""Send requests to the API"""
|
||||||
|
|
||||||
kwargs["headers"] = {"Content-Type": "application/json"}
|
kwargs["headers"] = {"Content-Type": "application/json"}
|
||||||
|
@ -60,3 +60,7 @@ class HttpClient:
|
||||||
def get_server_info(self, server_id: typing.Union[str, int]):
|
def get_server_info(self, server_id: typing.Union[str, int]):
|
||||||
"""Get information about specified server"""
|
"""Get information about specified server"""
|
||||||
return self.make_request("GET", f"servers/{server_id}")
|
return self.make_request("GET", f"servers/{server_id}")
|
||||||
|
|
||||||
|
def get_user_info(self, user_id: typing.Union[str, int]):
|
||||||
|
"""Get information about specified user"""
|
||||||
|
return self.make_request("GET", f"users/{user_id}")
|
||||||
|
|
Loading…
Reference in a new issue