diff --git a/animu/__init__.py b/animu/__init__.py index 9a583e7..9bd23db 100644 --- a/animu/__init__.py +++ b/animu/__init__.py @@ -16,4 +16,4 @@ __version__ = "0.1.0" -from animu.client import Client \ No newline at end of file +from animu.client import Client, AsyncClient \ No newline at end of file diff --git a/animu/client.py b/animu/client.py index 46f790e..38ca898 100644 --- a/animu/client.py +++ b/animu/client.py @@ -1,8 +1,40 @@ import aiohttp +import requests + from animu import model class Client: + def __init__(self, token: str): + self._header = {"Auth": token} + self._baseurl = "https://animu.ml/api/" + + def _endpoint(self, endpoint: str): + response = requests.get(f"{self._baseurl}{endpoint}", headers=self._header) + result = response.json() + return result + def fact(self): + data = self._endpoint('fact') + return model.Fact(data) + + def password(self): + data = self._endpoint('password') + return model.Password(data) + + def quote(self): + data = self._endpoint('quote') + return model.Quote(data) + + def roleplay(self, query: str): + data = self._endpoint(query) + return model.Roleplay(data) + + def waifu(self): + data = self._endpoint('waifu') + return model.Waifu(data) + + +class AsyncClient: def __init__(self, token: str): self._header = {"Auth": token} self._baseurl = "https://animu.ml/api/" diff --git a/requirements.txt b/requirements.txt index ce23571..3550c33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -aiohttp \ No newline at end of file +aiohttp +requests \ No newline at end of file