diff --git a/osrs/async_api/osrs/__init__.py b/osrs/async_api/osrs/__init__.py index e69de29..6512d41 100644 --- a/osrs/async_api/osrs/__init__.py +++ b/osrs/async_api/osrs/__init__.py @@ -0,0 +1,4 @@ +from osrs.async_api.osrs.hiscores import Hiscore +from osrs.async_api.osrs.itemdb import Catalogue, Graph + +__all__ = ["Hiscore", "Catalogue", "Graph"] diff --git a/osrs/async_api/osrs/itemdb.py b/osrs/async_api/osrs/itemdb.py index b8ad2ba..4c7837d 100644 --- a/osrs/async_api/osrs/itemdb.py +++ b/osrs/async_api/osrs/itemdb.py @@ -157,6 +157,23 @@ async def get_detail( data = await response.text() return Detail(**json.loads(data)) + +class Graph: + BASE_URL = "https://secure.runescape.com" + + def __init__( + self, proxy: str = "", rate_limiter: RateLimiter = RateLimiter() + ) -> None: + """Initialize the Catalogue with an optional proxy and rate limiter. + + Args: + proxy (str): Proxy URL to use for API requests. Defaults to "". + rate_limiter (RateLimiter): Rate limiter to manage request throttling. + Defaults to a new RateLimiter instance. + """ + self.proxy = proxy + self.rate_limiter = rate_limiter + async def get_graph( self, session: ClientSession, diff --git a/pyproject.toml b/pyproject.toml index 61e475e..aa7fbc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [project] name = "osrs" -version = "0.0.9" +version = "0.0.10" authors = [ { name="extreme4all"}, ] description = "a wrapper around osrs api's" readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", diff --git a/tests/test_async_itemdb.py b/tests/test_async_itemdb.py index b684d34..58c7f80 100644 --- a/tests/test_async_itemdb.py +++ b/tests/test_async_itemdb.py @@ -1,7 +1,14 @@ import pytest from aiohttp import ClientSession -from osrs.async_api.osrs.itemdb import Catalogue, Detail, Items, Mode, TradeHistory +from osrs.async_api.osrs.itemdb import ( + Catalogue, + Detail, + Graph, + Items, + Mode, + TradeHistory, +) @pytest.mark.asyncio @@ -75,7 +82,7 @@ async def test_get_detail_invalid(): @pytest.mark.asyncio async def test_get_graph_valid(): """Test fetching trade history for a valid item ID""" - catalogue_instance = Catalogue() + catalogue_instance = Graph() async with ClientSession() as session: item_id = 4151 # Assume this is a valid item ID trade_history = await catalogue_instance.get_graph( @@ -93,7 +100,7 @@ async def test_get_graph_valid(): @pytest.mark.asyncio async def test_get_graph_invalid(): """Test fetching trade history for an invalid item ID""" - catalogue_instance = Catalogue() + catalogue_instance = Graph() async with ClientSession() as session: invalid_item_id = 9999999 # Assume this item ID does not exist with pytest.raises(