Skip to content

Commit

Permalink
increase version
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Oct 27, 2024
1 parent b9b1fdc commit 0e81b11
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 4 additions & 0 deletions osrs/async_api/osrs/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
17 changes: 17 additions & 0 deletions osrs/async_api/osrs/itemdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 10 additions & 3 deletions tests/test_async_itemdb.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 0e81b11

Please sign in to comment.