Added comments

This commit is contained in:
2024-02-15 16:58:37 +03:00
parent 19cf282e08
commit dba5c60080
42 changed files with 388 additions and 11 deletions

View File

@@ -1,18 +1,31 @@
from aiohttp import ClientSession
from .api_method import ApiMethod
from neuroapi.types import Admin as AdminType
from .api_method import ApiMethod
class Admin(ApiMethod):
"""Class for admin methods"""
async def get(self):
"""
Asynchronous function to retrieve data from the specified API endpoint and return a list of admins.
:return List[Admin]
"""
async with ClientSession() as session:
response = await session.get(self.api_url+'/admin/get')
return [AdminType.from_dict(admin) for admin in await response.json()]
async def is_admin(self, id: str):
"""
Asynchronous function to check if the user with the given ID is an admin.
Args:
id (str): The ID of the user to be checked.
Returns:
bool: True if the user is an admin, False otherwise.
"""
async with ClientSession() as session:
response = await session.get(self.api_url+f'/admin/is-admin/{id}')
if await response.text() == 'false':