Skip to content
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

Feature: Raise a TooManyRequests error if get_partner_inventory was used too many times in a row. #363

Merged
Changes from all commits
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
8 changes: 6 additions & 2 deletions steampy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from steampy import guard
from steampy.confirmation import ConfirmationExecutor
from steampy.exceptions import SevenDaysHoldException, ApiException
from steampy.exceptions import SevenDaysHoldException, ApiException, TooManyRequests
from steampy.login import LoginExecutor, InvalidCredentials
from steampy.market import SteamMarket
from steampy.models import Asset, TradeOfferState, SteamUrl, GameOptions
Expand Down Expand Up @@ -163,7 +163,11 @@ def get_partner_inventory(
url = '/'.join((SteamUrl.COMMUNITY_URL, 'inventory', partner_steam_id, game.app_id, game.context_id))
params = {'l': 'english', 'count': count}

response_dict = self._session.get(url, params=params).json()
full_response = self._session.get(url, params=params)
response_dict = full_response.json()
if full_response.status_code == 429:
raise TooManyRequests('Too many requests, try again later.')

if response_dict is None or response_dict.get('success') != 1:
raise ApiException('Success value should be 1.')

Expand Down
Loading