Skip to content

v2.2.0 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add custom inventory api provider
  • Loading branch information
suchmax committed Mar 25, 2024
commit d832e2dc438924f39b1f30d97b1456ffb3a218dc
6 changes: 6 additions & 0 deletions src/tf2_utils/inventory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .providers.steamcommunity import SteamCommunity
from .providers.steamsupply import SteamSupply
from .providers.steamapis import SteamApis
from .providers.custom import Custom
from .sku import get_sku

import requests
Expand Down Expand Up @@ -45,6 +46,11 @@ def __init__(
# already set
return

# if provider_name is a url, assign it as a custom provider address
if provider_name.lower().startswith("http"):
self.provider = Custom(api_key, provider_name.lower())
return

# loop through providers create object
for i in self.PROVIDERS:
if provider_name.lower() == i.__name__.lower():
Expand Down
12 changes: 12 additions & 0 deletions src/tf2_utils/providers/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Custom:
def __init__(self, api_key: str, url: str) -> None:
self.api_key = api_key
self.url = url.rstrip('/')

def get_url_and_params(
self, steam_id: str, app_id: int, context_id: int
) -> tuple[str, dict]:
return (
f"{self.url}/inventory/{steam_id}/{app_id}/{context_id}",
{"api_key": self.api_key},
)