diff options
-rw-r--r-- | bot/seasons/evergreen/space.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bot/seasons/evergreen/space.py b/bot/seasons/evergreen/space.py index a4f60041..7d471d47 100644 --- a/bot/seasons/evergreen/space.py +++ b/bot/seasons/evergreen/space.py @@ -1,4 +1,6 @@ import logging +from typing import Any, Dict +from urllib.parse import urlencode from discord.ext.commands import Cog @@ -25,6 +27,12 @@ class Space(Cog): self.bot = bot self.http_session = bot.http_session + async def fetch_from_nasa(self, endpoint: str, params: Dict[str, Any]) -> Dict[str, Any]: + """Fetch information from NASA API, return result.""" + # Generate request URL from base URL, endpoint and parsed params + async with self.http_session.get(url=f"{BASE_URL}{endpoint}?{urlencode(params)}") as resp: + return await resp.json() + def setup(bot: SeasonalBot) -> None: """Load Space Cog.""" |