Skip to content

Commit

Permalink
fix(subscription_games): Remove no longer existing key from API response
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGoogle committed May 30, 2022
1 parent 8e5861e commit 74c92c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/model/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,9 @@ def __init__(self, data: dict):

class ContentChoiceOptions:
def __init__(self, data: dict):
self.MAX_CHOICES: int = data['MAX_CHOICES']
self.gamekey: t.Optional[str] = data.get('gamekey')
self.is_active_content: bool = data['isActiveContent']
self.product_url_path: str = data['productUrlPath']
self.is_active_content: t.Optional[bool] = data.get('isActiveContent')
self.product_url_path: t.Optional[str] = data.get('productUrlPath')
self.uses_choices: t.Optional[bool] = data.get("usesChoices")
self.product_is_choiceless: t.Optional[bool] = data.get("productIsChoiceless")
self.includes_any_uplay_tpkds: t.Optional[bool] = data.get('includesAnyUplayTpkds')
Expand All @@ -193,8 +192,8 @@ def __init__(self, data: dict):

content_choice_data = data['contentChoiceData']

# since Martch 2022 when choices are dropped again, there is 'game_data' (can't confirm if API responses for older data has changed)
if 'game_data' in content_choice_data: # or as in js public client -> if not self.uses_choices:
# since Martch 2022 when choices are dropped again, there is 'game_data'
if not self.uses_choices:
game_data = content_choice_data['game_data']
else:
# Since August 2020 there is no simple 'initial' key, games may be stored under different keys eg.:
Expand Down
2 changes: 1 addition & 1 deletion src/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def get_subscription_products_with_gamekeys(self) -> t.AsyncGenerator[dict
"gamekey": "wqheRstssFcHGcfP", # when the month is unlocked already
"isActiveContent": false, # is current month
"title": "May 2020",
"MAX_CHOICES": 9,
"MAX_CHOICES": 9, # dropped after 05.2022
"productUrlPath": "may-2020",
"includesAnyUplayTpkds": false,
"unlockedContentEvents": [
Expand Down
5 changes: 2 additions & 3 deletions tests/common/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,11 @@ async def test_get_subscriptions_current_month_not_unlocked_yet(
"productMachineName": "may_2020_choice"
},
"contentChoiceOptions": {
"contentChoiceData": "{}", # removed a big object
"contentChoiceData": "{}", # redacted a big object
"isActiveContent": True,
"title": "May 2020",
"MAX_CHOICES": 10,
"productUrlPath": "may-2020",
"usesChoices": True, #
"usesChoices": True,
"canRedeemGames": True,
"productMachineName": "may_2020_choice"
}
Expand Down

0 comments on commit 74c92c6

Please sign in to comment.