diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0fc6b9d..3e23182 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -25,14 +25,19 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 + - name: Lint with bandit run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + bandit blizzardapi + - name: Lint with mypy + run: | + mypy blizzardapi + - name: Lint with pydocstyle + run: | + pydocstyle blizzardapi + - name: Lint with pylint + run: | + pylint blizzardapi --exit-zero - name: Test with pytest run: | pytest diff --git a/Makefile b/Makefile index 0e845a3..dbaabb0 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,23 @@ +.PHONY: devinstall clean lint + devinstall: pip install -r requirements.txt clean: - rm -rf dist + find . -type d -name __pycache__ -delete + find . -type f -name '*.py[co]' -delete + rm -rf .coverage + rm -rf .pytest_cache rm -rf build + rm -rf dist + rm -rf docs rm -rf htmlcov + rm -rf .mypy_cache rm -rf python_blizzardapi.egg-info - rm -rf .coverage - rm -rf docs - rm -rf .pytest_cache - find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete \ No newline at end of file + +lint: + black . -l 200 && black . -l 79 + bandit blizzardapi + mypy blizzardapi + pydocstyle blizzardapi + pylint blizzardapi --exit-zero \ No newline at end of file diff --git a/README.md b/README.md index bc0451b..12f3172 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,12 @@ python-blizzardapi is a client library for Blizzard's APIs. Current supported features include: - Battle.net User -- WoW Profile -- WoW Game Data -- WoW Classic Game Data +- Wow Profile +- Wow Game Data +- Wow Classic Game Data - Diablo 3 Community - Diablo 3 Game Data +- Hearthstone Game Data To gain access to Blizzard's API please register [here](https://develop.battle.net/access/) to obtain a client id and client secret. @@ -40,7 +41,7 @@ categories_index = api_client.wow.game_data.get_achievement_categories_index("us # Protected API endpoint summary = api_client.wow.profile.get_account_profile_summary("us", "en_US", "access_token") -# WoW Classic endpoint +# Wow Classic endpoint connected_realms_index = api_client.wow.game_data.get_connected_realms_index("us", "en_US", is_classic=True) ``` diff --git a/blizzardapi/__init__.py b/blizzardapi/__init__.py index 5aa1d03..246392d 100644 --- a/blizzardapi/__init__.py +++ b/blizzardapi/__init__.py @@ -1,2 +1,4 @@ +"""__init__.py file.""" +from requests.exceptions import * # noqa + from .blizzard_api import BlizzardApi # noqa -from .exceptions import BlizzardApiRequestException # noqa diff --git a/blizzardapi/api.py b/blizzardapi/api.py index b915ddd..aa22f44 100644 --- a/blizzardapi/api.py +++ b/blizzardapi/api.py @@ -1,11 +1,23 @@ +"""api.py file.""" import requests -from requests.exceptions import RequestException - -from .exceptions import BlizzardApiRequestException class Api: + """Base API class. + + Attributes: + _client_id: A string client id supplied by Blizzard. + _client_secret: A string client secret supplied by Blizzard. + _access_token: A string access token that is used to access Blizzard's API. + _api_url: A string url used to call the API endpoints. + _api_url_cn: A string url used to call the china API endpoints. + _oauth_url: A string url used to call the OAuth API endpoints. + _oauth_url_cn: A string url used to call the china OAuth API endpoints. + _session: An open requests.Session instance. + """ + def __init__(self, client_id, client_secret): + """Init Api.""" self._client_id = client_id self._client_secret = client_secret self._access_token = None @@ -19,24 +31,29 @@ def __init__(self, client_id, client_secret): self._session = requests.Session() def _get_client_token(self, region): + """Fetch an access token based on client id and client secret credentials. + + Args: + region: + A string containing a region. + """ url = self._format_oauth_url("/oauth/token", region) query_params = {"grant_type": "client_credentials"} - try: - response = self._session.post( - url, - params=query_params, - auth=(self._client_id, self._client_secret), - ) - except RequestException as e: - raise BlizzardApiRequestException(str(e)) + response = self._session.post( + url, + params=query_params, + auth=(self._client_id, self._client_secret), + ) return self._response_handler(response) def _response_handler(self, response): + """Handle the response.""" return response.json() def _request_handler(self, url, region, query_params): + """Handle the request.""" if self._access_token is None: json = self._get_client_token(region) self._access_token = json["access_token"] @@ -44,14 +61,12 @@ def _request_handler(self, url, region, query_params): if query_params.get("access_token") is None: query_params["access_token"] = self._access_token - try: - response = self._session.get(url, params=query_params) - except RequestException as e: - raise BlizzardApiRequestException(str(e)) + response = self._session.get(url, params=query_params) return self._response_handler(response) def _format_api_url(self, resource, region): + """Format the API url into a usable url.""" if region == "cn": url = self._api_url_cn.format(resource) else: @@ -60,10 +75,12 @@ def _format_api_url(self, resource, region): return url def get_resource(self, resource, region, query_params={}): + """Direction handler for when fetching resources.""" url = self._format_api_url(resource, region) return self._request_handler(url, region, query_params) def _format_oauth_url(self, resource, region): + """Format the oauth url into a usable url.""" if region == "cn": url = self._oauth_url_cn.format(resource) else: @@ -72,5 +89,6 @@ def _format_oauth_url(self, resource, region): return url def get_oauth_resource(self, resource, region, query_params={}): + """Direction handler for when fetching oauth resources.""" url = self._format_oauth_url(resource, region) return self._request_handler(url, region, query_params) diff --git a/blizzardapi/battlenet/__init__.py b/blizzardapi/battlenet/__init__.py index e69de29..5308e18 100644 --- a/blizzardapi/battlenet/__init__.py +++ b/blizzardapi/battlenet/__init__.py @@ -0,0 +1 @@ +"""__init__.py file.""" diff --git a/blizzardapi/battlenet/battlenet_api.py b/blizzardapi/battlenet/battlenet_api.py index 7133d8f..3e6bfdf 100644 --- a/blizzardapi/battlenet/battlenet_api.py +++ b/blizzardapi/battlenet/battlenet_api.py @@ -1,6 +1,15 @@ +"""battlenet_api.py file.""" from .battlenet_oauth_api import BattlenetOauthApi class BattlenetApi: + """Battle.net API class. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ + def __init__(self, client_id, client_secret): + """Init BattlenetApi.""" self.oauth = BattlenetOauthApi(client_id, client_secret) diff --git a/blizzardapi/battlenet/battlenet_oauth_api.py b/blizzardapi/battlenet/battlenet_oauth_api.py index 0c456c2..bbfa6b5 100644 --- a/blizzardapi/battlenet/battlenet_oauth_api.py +++ b/blizzardapi/battlenet/battlenet_oauth_api.py @@ -1,19 +1,23 @@ +"""battlenet_oauth_api.py file.""" from ..api import Api class BattlenetOauthApi(Api): - """All OAuth API methods""" + """All Battle.net OAuth API methods. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ def __init__(self, client_id, client_secret): + """Init BattlenetOauthApi.""" super().__init__(client_id, client_secret) # User Authentication def get_user_info(self, region, access_token): - """ - User Authentication - Returns basic information about the user - associated with the current bearer token. - """ + """Return basic information about the user associated with the current bearer token.""" resource = "/oauth/userinfo" query_params = { "access_token": access_token, diff --git a/blizzardapi/blizzard_api.py b/blizzardapi/blizzard_api.py index 9bd21f4..3c0a03e 100644 --- a/blizzardapi/blizzard_api.py +++ b/blizzardapi/blizzard_api.py @@ -1,10 +1,21 @@ +"""blizzard_api.py file.""" from .battlenet.battlenet_api import BattlenetApi from .diablo3.diablo3_api import Diablo3Api +from .hearthstone.hearthstone_api import HearthstoneApi from .wow.wow_api import WowApi class BlizzardApi: + """Blizzard API class. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ + def __init__(self, client_id, client_secret): + """Init BlizzardApi.""" self.battlenet = BattlenetApi(client_id, client_secret) self.diablo3 = Diablo3Api(client_id, client_secret) + self.hearthstone = HearthstoneApi(client_id, client_secret) self.wow = WowApi(client_id, client_secret) diff --git a/blizzardapi/diablo3/__init__.py b/blizzardapi/diablo3/__init__.py index e69de29..5308e18 100644 --- a/blizzardapi/diablo3/__init__.py +++ b/blizzardapi/diablo3/__init__.py @@ -0,0 +1 @@ +"""__init__.py file.""" diff --git a/blizzardapi/diablo3/diablo3_api.py b/blizzardapi/diablo3/diablo3_api.py index 34e3a9f..1c7ba58 100644 --- a/blizzardapi/diablo3/diablo3_api.py +++ b/blizzardapi/diablo3/diablo3_api.py @@ -1,8 +1,17 @@ +"""diablo3_api.py file.""" from .diablo3_community_api import Diablo3CommunityApi from .diablo3_game_data_api import Diablo3GameDataApi class Diablo3Api: + """Diablo3 API class. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ + def __init__(self, client_id, client_secret): + """Init Diablo3Api.""" self.community = Diablo3CommunityApi(client_id, client_secret) self.game_data = Diablo3GameDataApi(client_id, client_secret) diff --git a/blizzardapi/diablo3/diablo3_community_api.py b/blizzardapi/diablo3/diablo3_community_api.py index cd92f73..d684994 100644 --- a/blizzardapi/diablo3/diablo3_community_api.py +++ b/blizzardapi/diablo3/diablo3_community_api.py @@ -1,26 +1,29 @@ +"""diablo3_community_api.py file.""" from ..api import Api class Diablo3CommunityApi(Api): - """All Community API methods""" + """All Diablo 3 Community API methods. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ def __init__(self, client_id, client_secret): + """Init Diablo3CommunityApi.""" super().__init__(client_id, client_secret) # D3 Act API def get_act_index(self, region, locale): - """ - D3 Act API - Returns an index of acts. - """ + """Return an index of acts.""" resource = "/d3/data/act" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) def get_act(self, region, locale, act_id): - """ - D3 Act API - Returns a single act by ID. - """ + """Return a single act by ID.""" resource = f"/d3/data/act/{act_id}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) @@ -28,18 +31,13 @@ def get_act(self, region, locale, act_id): # D3 Artisan and Recipe API def get_artisan(self, region, locale, artisan_slug): - """ - D3 Artisan and Recipe API - Returns a single artisan by slug. - """ + """Return a single artisan by slug.""" resource = f"/d3/data/artisan/{artisan_slug}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) def get_recipe(self, region, locale, artisan_slug, recipe_slug): - """ - D3 Artisan and Recipe API - Returns a single recipe by slug for the - specified artisan. - """ + """Return a single recipe by slug for the specified artisan.""" resource = f"/d3/data/artisan/{artisan_slug}/recipe/{recipe_slug}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) @@ -47,9 +45,7 @@ def get_recipe(self, region, locale, artisan_slug, recipe_slug): # D3 Follower API def get_follower(self, region, locale, follower_slug): - """ - D3 Follower API - Returns a single follower by slug. - """ + """Return a single follower by slug.""" resource = f"/d3/data/follower/{follower_slug}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) @@ -57,19 +53,13 @@ def get_follower(self, region, locale, follower_slug): # D3 Character Class and Skill API def get_character_class(self, region, locale, class_slug): - """ - D3 Character Class and Skill API - Returns a single character class by - slug. - """ + """Return a single character class by slug.""" resource = f"/d3/data/hero/{class_slug}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) def get_api_skill(self, region, locale, class_slug, skill_slug): - """ - D3 Character Class and Skill API - Returns a single skill by slug for a - specific character class. - """ + """Return a single skill by slug for a specific character class.""" resource = f"/d3/data/hero/{class_slug}/skill/{skill_slug}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) @@ -77,17 +67,13 @@ def get_api_skill(self, region, locale, class_slug, skill_slug): # D3 Item Type API def get_item_type_index(self, region, locale): - """ - D3 Item Type API - Returns an index of item types. - """ + """Return an index of item types.""" resource = "/d3/data/item-type" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) def get_item_type(self, region, locale, item_type_slug): - """ - D3 Item Type API - Returns a single item type by slug. - """ + """Return a single item type by slug.""" resource = f"/d3/data/item-type/{item_type_slug}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) @@ -95,9 +81,7 @@ def get_item_type(self, region, locale, item_type_slug): # D3 Item API def get_item(self, region, locale, item_slug_id): - """ - D3 Item API - Returns a single item by item slug and ID. - """ + """Return a single item by item slug and ID.""" resource = f"/d3/data/item/{item_slug_id}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) @@ -105,25 +89,19 @@ def get_item(self, region, locale, item_slug_id): # D3 Profile API def get_api_account(self, region, locale, account_id): - """ - D3 Profile API - Returns the specified account profile. - """ + """Return the specified account profile.""" resource = f"/d3/profile/{account_id}/" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) def get_api_hero(self, region, locale, account_id, hero_id): - """ - D3 Profile API - Returns a single hero. - """ + """Return a single hero.""" resource = f"/d3/profile/{account_id}/hero/{hero_id}" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) def get_api_detailed_hero_items(self, region, locale, account_id, hero_id): - """ - D3 Profile API - Returns a list of items for the specified hero. - """ + """Return a list of items for the specified hero.""" resource = f"/d3/profile/{account_id}/hero/{hero_id}/items" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) @@ -131,9 +109,7 @@ def get_api_detailed_hero_items(self, region, locale, account_id, hero_id): def get_api_detailed_follower_items( self, region, locale, account_id, hero_id ): - """ - D3 Profile API - Returns a single item by item slug and ID. - """ + """Return a single item by item slug and ID.""" resource = f"/d3/profile/{account_id}/hero/{hero_id}/follower-items" query_params = {"locale": locale} return super().get_resource(resource, region, query_params) diff --git a/blizzardapi/diablo3/diablo3_game_data_api.py b/blizzardapi/diablo3/diablo3_game_data_api.py index 4295651..7ec49f5 100644 --- a/blizzardapi/diablo3/diablo3_game_data_api.py +++ b/blizzardapi/diablo3/diablo3_game_data_api.py @@ -1,52 +1,47 @@ +"""diablo3_game_data_api.py file.""" from ..api import Api class Diablo3GameDataApi(Api): - """All Game Data API methods""" + """All Diablo 3 Game Data API methods. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ def __init__(self, client_id, client_secret): + """Init Diablo3GameDataApi.""" super().__init__(client_id, client_secret) # D3 def get_season_index(self, region): - """ - D3 - Returns an index of available seasons. - """ + """Return an index of available seasons.""" resource = "/data/d3/season/" return super().get_resource(resource, region) def get_season(self, region, season_id): - """ - D3 - Returns a leaderboard list for the specified season. - """ + """Return a leaderboard list for the specified season.""" resource = f"/data/d3/season/{season_id}" return super().get_resource(resource, region) def get_season_leaderboard(self, region, season_id, leaderboard_id): - """ - D3 - Returns a the specified leaderboard for the specified season. - """ + """Return a the specified leaderboard for the specified season.""" resource = f"/data/d3/season/{season_id}/leaderboard/{leaderboard_id}" return super().get_resource(resource, region) def get_era_index(self, region): - """ - D3 - Returns an index of available eras. - """ + """Return an index of available eras.""" resource = "/data/d3/era/" return super().get_resource(resource, region) def get_era(self, region, era_id): - """ - D3 - Returns a leaderboard list for a particular era. - """ + """Return a leaderboard list for a particular era.""" resource = f"/data/d3/era/{era_id}" return super().get_resource(resource, region) def get_era_leaderboard(self, region, era_id, leaderboard_id): - """ - D3 - Returns the specified leaderboard for the specified era. - """ + """Return the specified leaderboard for the specified era.""" resource = f"/data/d3/era/{era_id}/leaderboard/{leaderboard_id}" return super().get_resource(resource, region) diff --git a/blizzardapi/exceptions.py b/blizzardapi/exceptions.py deleted file mode 100644 index 9c88c6a..0000000 --- a/blizzardapi/exceptions.py +++ /dev/null @@ -1,6 +0,0 @@ -class BlizzardApiException(Exception): - pass - - -class BlizzardApiRequestException(BlizzardApiException): - pass diff --git a/blizzardapi/hearthstone/__init__.py b/blizzardapi/hearthstone/__init__.py new file mode 100644 index 0000000..5308e18 --- /dev/null +++ b/blizzardapi/hearthstone/__init__.py @@ -0,0 +1 @@ +"""__init__.py file.""" diff --git a/blizzardapi/hearthstone/hearthstone_api.py b/blizzardapi/hearthstone/hearthstone_api.py new file mode 100644 index 0000000..7d60b21 --- /dev/null +++ b/blizzardapi/hearthstone/hearthstone_api.py @@ -0,0 +1,15 @@ +"""hearthstone_api.py file.""" +from .hearthstone_game_data_api import HearthstoneGameDataApi + + +class HearthstoneApi: + """Hearthstone API class. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ + + def __init__(self, client_id, client_secret): + """Init HearthstoneApi.""" + self.game_data = HearthstoneGameDataApi(client_id, client_secret) diff --git a/blizzardapi/hearthstone/hearthstone_game_data_api.py b/blizzardapi/hearthstone/hearthstone_game_data_api.py new file mode 100644 index 0000000..6612113 --- /dev/null +++ b/blizzardapi/hearthstone/hearthstone_game_data_api.py @@ -0,0 +1,65 @@ +"""hearthstone_game_data_api.py file.""" +from ..api import Api + + +class HearthstoneGameDataApi(Api): + """All Hearthstone Game Data API methods. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ + + def __init__(self, client_id, client_secret): + """Init HearthstoneGameDataApi.""" + super().__init__(client_id, client_secret) + + # Cards + + def search_cards(self, region, locale, **query_params): + """Return an up-to-date list of all cards matching the search criteria.""" + resource = "/hearthstone/cards" + query_params.update({"locale": locale}) + return super().get_resource(resource, region, query_params) + + def get_card(self, region, locale, id_or_slug, game_mode="constructed"): + """Return the card with an ID or slug that matches the one you specify.""" + resource = f"/hearthstone/cards/{id_or_slug}" + query_params = {"locale": locale, "game_mode": game_mode} + return super().get_resource(resource, region, query_params) + + # Card Backs + + def search_card_backs(self, region, locale, **query_params): + """Return an up-to-date list of all card backs matching the search criteria.""" + resource = "/hearthstone/cardbacks" + query_params.update({"locale": locale}) + return super().get_resource(resource, region, query_params) + + def get_card_back(self, region, locale, id_or_slug): + """Return a specific card back by using card back ID or slug.""" + resource = f"/hearthstone/cardbacks/{id_or_slug}" + query_params = {"locale": locale} + return super().get_resource(resource, region, query_params) + + # Decks + + def get_deck(self, region, locale, **query_params): + """Find a deck by list of cards or code, including the hero.""" + resource = "/hearthstone/deck" + query_params = {"locale": locale} + return super().get_resource(resource, region, query_params) + + # Metadata + + def get_metadata(self, region, locale): + """Return information about the categorization of cards.""" + resource = "/hearthstone/metadata" + query_params = {"locale": locale} + return super().get_resource(resource, region, query_params) + + def get_metadata_type(self, region, locale, type_id): + """Return information about just one type of metadata.""" + resource = f"/hearthstone/metadata/{type_id}" + query_params = {"locale": locale} + return super().get_resource(resource, region, query_params) diff --git a/blizzardapi/wow/__init__.py b/blizzardapi/wow/__init__.py index e69de29..5308e18 100644 --- a/blizzardapi/wow/__init__.py +++ b/blizzardapi/wow/__init__.py @@ -0,0 +1 @@ +"""__init__.py file.""" diff --git a/blizzardapi/wow/wow_api.py b/blizzardapi/wow/wow_api.py index 9fe2237..9af6241 100644 --- a/blizzardapi/wow/wow_api.py +++ b/blizzardapi/wow/wow_api.py @@ -1,8 +1,17 @@ +"""wow_api.py file.""" from .wow_game_data_api import WowGameDataApi from .wow_profile_api import WowProfileApi class WowApi: + """Wow API class. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ + def __init__(self, client_id, client_secret): + """Init WowApi.""" self.game_data = WowGameDataApi(client_id, client_secret) self.profile = WowProfileApi(client_id, client_secret) diff --git a/blizzardapi/wow/wow_game_data_api.py b/blizzardapi/wow/wow_game_data_api.py index 3cfab55..d5b67b7 100644 --- a/blizzardapi/wow/wow_game_data_api.py +++ b/blizzardapi/wow/wow_game_data_api.py @@ -1,18 +1,23 @@ +"""wow_game_data_api.py file.""" from ..api import Api class WowGameDataApi(Api): - """All Game Data API methods""" + """All Wow Game Data API methods. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ def __init__(self, client_id, client_secret): + """Init WowApi.""" super().__init__(client_id, client_secret) # Achievement API def get_achievement_categories_index(self, region, locale): - """ - Achievement API - Returns an index of achievement categories. - """ + """Return an index of achievement categories.""" resource = "/data/wow/achievement-category/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -20,33 +25,25 @@ def get_achievement_categories_index(self, region, locale): def get_achievement_category( self, region, locale, achievement_category_id ): - """ - Achievement API - Returns an achievement category by ID. - """ + """Return an achievement category by ID.""" resource = f"/data/wow/achievement-category/{achievement_category_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_achievements_index(self, region, locale): - """ - Achievement API - Returns an index of achievements. - """ + """Return an index of achievements.""" resource = "/data/wow/achievement/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_achievement(self, region, locale, achievement_id): - """ - Achievement API - Returns an achievement by ID. - """ + """Return an achievement by ID.""" resource = f"/data/wow/achievement/{achievement_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_achievement_media(self, region, locale, achievement_id): - """ - Achievement API - Returns media for an achievement by ID. - """ + """Return media for an achievement by ID.""" resource = f"/data/wow/media/achievement/{achievement_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -54,9 +51,7 @@ def get_achievement_media(self, region, locale, achievement_id): # Auction House API def get_auctions(self, region, locale, connected_realm_id): - """ - Auction House API - Returns all active auctions for a connected realm. - """ + """Return all active auctions for a connected realm.""" resource = f"/data/wow/connected-realm/{connected_realm_id}/auctions" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -64,25 +59,19 @@ def get_auctions(self, region, locale, connected_realm_id): # Azerite Essence API def get_azerite_essences_index(self, region, locale): - """ - Azerite Essence API - Returns an index of azerite essences. - """ + """Return an index of azerite essences.""" resource = "/data/wow/azerite-essence/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_azerite_essence(self, region, locale, azerite_essence_id): - """ - Azerite Essence API - Returns an azerite essence by ID. - """ + """Return an azerite essence by ID.""" resource = f"/data/wow/azerite-essence/{azerite_essence_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_azerite_essence_media(self, region, locale, azerite_essence_id): - """ - Azerite Essence API - Returns media for an azerite essence by ID. - """ + """Return media for an azerite essence by ID.""" resource = f"/data/wow/media/azerite-essence/{azerite_essence_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -90,9 +79,7 @@ def get_azerite_essence_media(self, region, locale, azerite_essence_id): # Connected Realm API def get_connected_realms_index(self, region, locale, is_classic=False): - """ - Connected Realm API - Returns an index of connected realms. - """ + """Return an index of connected realms.""" resource = "/data/wow/connected-realm/index" namespace = ( f"dynamic-classic-{region}" if is_classic else f"dynamic-{region}" @@ -103,9 +90,7 @@ def get_connected_realms_index(self, region, locale, is_classic=False): def get_connected_realm( self, region, locale, connected_realm_id, is_classic=False ): - """ - Connected Realm API - Returns a connected realm by ID. - """ + """Return a connected realm by ID.""" resource = f"/data/wow/connected-realm/{connected_realm_id}" namespace = ( f"dynamic-classic-{region}" if is_classic else f"dynamic-{region}" @@ -116,9 +101,7 @@ def get_connected_realm( # Creature API def get_creature_families_index(self, region, locale, is_classic=False): - """ - Creature API - Returns an index of creature families. - """ + """Return an index of creature families.""" resource = "/data/wow/creature-family/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -129,9 +112,7 @@ def get_creature_families_index(self, region, locale, is_classic=False): def get_creature_family( self, region, locale, creature_family_id, is_classic=False ): - """ - Creature API - Returns a creature family by ID. - """ + """Return a creature family by ID.""" resource = f"/data/wow/creature-family/{creature_family_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -140,9 +121,7 @@ def get_creature_family( return super().get_resource(resource, region, query_params) def get_creature_types_index(self, region, locale, is_classic=False): - """ - Creature API - Returns an index of creature types. - """ + """Return an index of creature types.""" resource = "/data/wow/creature-type/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -153,9 +132,7 @@ def get_creature_types_index(self, region, locale, is_classic=False): def get_creature_type( self, region, locale, creature_type_id, is_classic=False ): - """ - Creature API - Returns a creature type by ID. - """ + """Return a creature type by ID.""" resource = f"/data/wow/creature-type/{creature_type_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -164,9 +141,7 @@ def get_creature_type( return super().get_resource(resource, region, query_params) def get_creature(self, region, locale, creature_id, is_classic=False): - """ - Creature API - Returns a creature by ID. - """ + """Return a creature by ID.""" resource = f"/data/wow/creature/{creature_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -177,9 +152,7 @@ def get_creature(self, region, locale, creature_id, is_classic=False): def get_creature_display_media( self, region, locale, creature_display_id, is_classic=False ): - """ - Creature API - Returns media for a creature display by ID. - """ + """Return media for a creature display by ID.""" resource = f"/data/wow/media/creature-display/{creature_display_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -190,9 +163,7 @@ def get_creature_display_media( def get_creature_family_media( self, region, locale, creature_family_id, is_classic=False ): - """ - Creature API - Returns media for a creature family by ID. - """ + """Return media for a creature family by ID.""" resource = f"/data/wow/media/creature-family/{creature_family_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -205,9 +176,7 @@ def get_creature_family_media( def get_guild_crest_components_index( self, region, locale, is_classic=False ): - """ - Guild Crest API - Returns an index of guild crest media. - """ + """Return an index of guild crest media.""" resource = "/data/wow/guild-crest/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -218,9 +187,7 @@ def get_guild_crest_components_index( def get_guild_crest_border_media( self, region, locale, border_id, is_classic=False ): - """ - Guild Crest API - Returns media for a guild crest border by ID. - """ + """Return media for a guild crest border by ID.""" resource = f"/data/wow/media/guild-crest/border/{border_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -231,9 +198,7 @@ def get_guild_crest_border_media( def get_guild_crest_emblem_media( self, region, locale, emblem_id, is_classic=False ): - """ - Guild Crest API - Returns media for a guild crest emblem by ID. - """ + """Return media for a guild crest emblem by ID.""" resource = f"/data/wow/media/guild-crest/emblem/{emblem_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -244,9 +209,7 @@ def get_guild_crest_emblem_media( # Item API def get_item_classes_index(self, region, locale, is_classic=False): - """ - Item API - Returns an index of item classes. - """ + """Return an index of item classes.""" resource = "/data/wow/item-class/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -255,9 +218,7 @@ def get_item_classes_index(self, region, locale, is_classic=False): return super().get_resource(resource, region, query_params) def get_item_class(self, region, locale, item_class_id, is_classic=False): - """ - Item API - Returns an item class by ID. - """ + """Return an item class by ID.""" resource = f"/data/wow/item-class/{item_class_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -266,9 +227,7 @@ def get_item_class(self, region, locale, item_class_id, is_classic=False): return super().get_resource(resource, region, query_params) def get_item_sets_index(self, region, locale, is_classic=False): - """ - Item API - Returns an index of item sets. - """ + """Return an index of item sets.""" resource = "/data/wow/item-set/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -277,9 +236,7 @@ def get_item_sets_index(self, region, locale, is_classic=False): return super().get_resource(resource, region, query_params) def get_item_set(self, region, locale, item_set_id, is_classic=False): - """ - Item API - Returns an item set by ID. - """ + """Return an item set by ID.""" resource = f"/data/wow/item-set/{item_set_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -290,9 +247,7 @@ def get_item_set(self, region, locale, item_set_id, is_classic=False): def get_item_subclass( self, region, locale, item_class_id, item_subclass_id, is_classic=False ): - """ - Item API - Returns an item subclass by ID. - """ + """Return an item subclass by ID.""" resource = f"/data/wow/item-class/{item_class_id}/item-subclass/{item_subclass_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -301,9 +256,7 @@ def get_item_subclass( return super().get_resource(resource, region, query_params) def get_item(self, region, locale, item_id, is_classic=False): - """ - Item API - Returns an item by ID. - """ + """Return an item by ID.""" resource = f"/data/wow/item/{item_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -312,9 +265,7 @@ def get_item(self, region, locale, item_id, is_classic=False): return super().get_resource(resource, region, query_params) def get_item_media(self, region, locale, item_id, is_classic=False): - """ - Item API - Returns media for an item by ID. - """ + """Return media for an item by ID.""" resource = f"/data/wow/media/item/{item_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -325,57 +276,43 @@ def get_item_media(self, region, locale, item_id, is_classic=False): # Journal API def get_journal_expansions_index(self, region, locale): - """ - Journal API - Returns an index of journal expansions. - """ + """Return an index of journal expansions.""" resource = "/data/wow/journal-expansion/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_journal_expansion(self, region, locale, journal_expansion_id): - """ - Journal API - Returns a journal expansion by ID. - """ + """Return a journal expansion by ID.""" resource = f"/data/wow/journal-expansion/{journal_expansion_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_journal_encounters_index(self, region, locale): - """ - Journal API - Returns an index of journal encounters. - """ + """Return an index of journal encounters.""" resource = "/data/wow/journal-encounter/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_journal_encounter(self, region, locale, journal_encounter_id): - """ - Journal API - Returns a journal encounter by ID. - """ + """Return a journal encounter by ID.""" resource = f"/data/wow/journal-encounter/{journal_encounter_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_journal_instances_index(self, region, locale): - """ - Journal API - Returns an index of journal instances. - """ + """Return an index of journal instances.""" resource = "/data/wow/journal-instance/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_journal_instance(self, region, locale, journal_instance_id): - """ - Journal API - Returns a journal instance. - """ + """Return a journal instance.""" resource = f"/data/wow/journal-instance/{journal_instance_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_journal_instance_media(self, region, locale, journal_instance_id): - """ - Journal API - Returns media for a journal instance by ID. - """ + """Return media for a journal instance by ID.""" resource = f"/data/wow/media/journal-instance/{journal_instance_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -383,36 +320,25 @@ def get_journal_instance_media(self, region, locale, journal_instance_id): # Modified Crafting API def get_modified_crafting_index(self, region, locale): - """ - Modified Crafting API - Returns the parent index for Modified Crafting. - """ + """Return the parent index for Modified Crafting.""" resource = "/data/wow/modified-crafting/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_modified_crafting_category_index(self, region, locale): - """ - Modified Crafting API - Returns the index of Modified Crafting - categories. - """ + """Return the index of Modified Crafting categories.""" resource = "/data/wow/modified-crafting/category/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_modified_crafting_category(self, region, locale, category_id): - """ - Modified Crafting API - Returns the index of Modified Crafting - categories. - """ + """Return the index of Modified Crafting categories.""" resource = f"/data/wow/modified-crafting/category/{category_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_modified_crafting_reagent_slot_type_index(self, region, locale): - """ - Modified Crafting API - Returns the index of Modified Crafting reagent - slot types. - """ + """Return the index of Modified Crafting reagent slot types.""" resource = "/data/wow/modified-crafting/reagent-slot-type/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -420,10 +346,7 @@ def get_modified_crafting_reagent_slot_type_index(self, region, locale): def get_modified_crafting_reagent_slot_type( self, region, locale, slot_type_id ): - """ - Modified Crafting API - Returns a Modified Crafting reagent slot type - by ID. - """ + """Return a Modified Crafting reagent slot type by ID.""" resource = ( f"/data/wow/modified-crafting/reagent-slot-type/{slot_type_id}" ) @@ -433,17 +356,13 @@ def get_modified_crafting_reagent_slot_type( # Mount API def get_mounts_index(self, region, locale): - """ - Mount API - Returns an index of mounts. - """ + """Return an index of mounts.""" resource = "/data/wow/mount/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mount(self, region, locale, mount_id): - """ - Mount API - Returns a mount by ID. - """ + """Return a mount by ID.""" resource = f"/data/wow/mount/{mount_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -451,18 +370,13 @@ def get_mount(self, region, locale, mount_id): # Mythic Keystone Affix API def get_mythic_keystone_affixes_index(self, region, locale): - """ - Mythic Keystone Affix API - Returns an index of mythic keystone - affixes. - """ + """Return an index of mythic keystone affixes.""" resource = "/data/wow/keystone-affix/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mythic_keystone_affix(self, region, locale, keystone_affix_id): - """ - Mythic Keystone Affix API - Returns a mythic keystone affix by ID. - """ + """Return a mythic keystone affix by ID.""" resource = f"/data/wow/keystone-affix/{keystone_affix_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -470,10 +384,7 @@ def get_mythic_keystone_affix(self, region, locale, keystone_affix_id): def get_mythic_keystone_affix_media( self, region, locale, keystone_affix_id ): - """ - Mythic Keystone Affix API - Returns media for a mythic keystone affix - by ID. - """ + """Return media for a mythic keystone affix by ID.""" resource = f"/data/wow/media/keystone-affix/{keystone_affix_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -481,62 +392,43 @@ def get_mythic_keystone_affix_media( # Mythic Keystone Dungeon API def get_mythic_keystone_dungeons_index(self, region, locale): - """ - Mythic Keystone Dungeon API - Returns an index of Mythic Keystone - dungeons. - """ + """Return an index of Mythic Keystone dungeons.""" resource = "/data/wow/mythic-keystone/dungeon/index" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mythic_keystone_dungeon(self, region, locale, dungeon_id): - """ - Mythic Keystone Dungeon API - Returns a Mythic Keystone dungeon by ID. - """ + """Return a Mythic Keystone dungeon by ID.""" resource = f"/data/wow/mythic-keystone/dungeon/{dungeon_id}" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mythic_keystone_index(self, region, locale): - """ - Mythic Keystone Dungeon API - Returns an index of links to other - documents related to - Mythic Keystone dungeons. - """ + """Return an index of links to other documents related to Mythic Keystone dungeons.""" resource = "/data/wow/mythic-keystone/index" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mythic_keystone_periods_index(self, region, locale): - """ - Mythic Keystone Dungeon API - Returns an index of Mythic Keystone - periods. - """ + """Return an index of Mythic Keystone periods.""" resource = "/data/wow/mythic-keystone/period/index" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mythic_keystone_period(self, region, locale, period_id): - """ - Mythic Keystone Dungeon API - Returns a Mythic Keystone period by ID. - """ + """Return a Mythic Keystone period by ID.""" resource = f"/data/wow/mythic-keystone/period/{period_id}" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mythic_keystone_seasons_index(self, region, locale): - """ - Mythic Keystone Dungeon API - Returns an index of Mythic Keystone - seasons. - """ + """Return an index of Mythic Keystone seasons.""" resource = "/data/wow/mythic-keystone/season/index" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_mythic_keystone_season(self, region, locale, season_id): - """ - Mythic Keystone Dungeon API - Returns a Mythic Keystone season by ID. - """ + """Return a Mythic Keystone season by ID.""" resource = f"/data/wow/mythic-keystone/season/{season_id}" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -546,10 +438,7 @@ def get_mythic_keystone_season(self, region, locale, season_id): def get_mythic_keystone_leaderboards_index( self, region, locale, connected_realm_id ): - """ - Mythic Keystone Leaderboard API - Returns an index of Mythic Keystone - Leaderboard dungeon instances for a connected realm. - """ + """Return an index of Mythic Keystone Leaderboard dungeon instances for a connected realm.""" resource = f"/data/wow/connected-realm/{connected_realm_id}/mythic-leaderboard/index" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -557,10 +446,7 @@ def get_mythic_keystone_leaderboards_index( def get_mythic_keystone_leaderboard( self, region, locale, connected_realm_id, dungeon_id, period_id ): - """ - Mythic Keystone Leaderboard API - Returns a weekly Mythic Keystone - Leaderboard by period. - """ + """Return a weekly Mythic Keystone Leaderboard by period.""" resource = f"/data/wow/connected-realm/{connected_realm_id}/mythic-leaderboard/{dungeon_id}/period/{period_id}" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -568,10 +454,7 @@ def get_mythic_keystone_leaderboard( # Mythic Raid Leaderboard API def get_mythic_raid_leaderboard(self, region, locale, raid, faction): - """ - Mythic Raid Leaderboard API - Returns the leaderboard for a given raid - and faction. - """ + """Return the leaderboard for a given raid and faction.""" resource = f"/data/wow/leaderboard/hall-of-fame/{raid}/{faction}" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -579,49 +462,37 @@ def get_mythic_raid_leaderboard(self, region, locale, raid, faction): # Pet API def get_pets_index(self, region, locale): - """ - Pet API - Returns an index of battle pets. - """ + """Return an index of battle pets.""" resource = "/data/wow/pet/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pet(self, region, locale, pet_id): - """ - Pet API - Returns a battle pets by ID. - """ + """Return a battle pets by ID.""" resource = f"/data/wow/pet/{pet_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pet_media(self, region, locale, pet_id): - """ - Pet API - Returns media for a battle pet by ID. - """ + """Return media for a battle pet by ID.""" resource = f"/data/wow/media/pet/{pet_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pet_abilities_index(self, region, locale): - """ - Pet API - Returns an index of pet abilities. - """ + """Return an index of pet abilities.""" resource = "/data/wow/pet-ability/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pet_ability(self, region, locale, pet_ability_id): - """ - Pet API - Returns a pet ability by ID. - """ + """Return a pet ability by ID.""" resource = f"/data/wow/pet-ability/{pet_ability_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pet_ability_media(self, region, locale, pet_ability_id): - """ - Pet API - Returns media for a pet ability by ID. - """ + """Return media for a pet ability by ID.""" resource = f"/data/wow/media/pet-ability/{pet_ability_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -629,9 +500,7 @@ def get_pet_ability_media(self, region, locale, pet_ability_id): # Playable Class API def get_playable_classes_index(self, region, locale, is_classic=False): - """ - Playable Class API - Returns an index of playable classes. - """ + """Return an index of playable classes.""" resource = "/data/wow/playable-class/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -640,9 +509,7 @@ def get_playable_classes_index(self, region, locale, is_classic=False): return super().get_resource(resource, region, query_params) def get_playable_class(self, region, locale, class_id, is_classic=False): - """ - Playable Class API - Returns a playable class by ID. - """ + """Return a playable class by ID.""" resource = f"/data/wow/playable-class/{class_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -653,9 +520,7 @@ def get_playable_class(self, region, locale, class_id, is_classic=False): def get_playable_class_media( self, region, locale, playable_class_id, is_classic=False ): - """ - Playable Class API - Returns media for a playable class by ID. - """ + """Return media for a playable class by ID.""" resource = f"/data/wow/media/playable-class/{playable_class_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -664,10 +529,7 @@ def get_playable_class_media( return super().get_resource(resource, region, query_params) def get_pvp_talent_slots(self, region, locale, class_id): - """ - Playable Class API - Returns the PvP talent slots for a playable class - by ID. - """ + """Return the Pvp talent slots for a playable class by ID.""" resource = f"/data/wow/playable-class/{class_id}/pvp-talent-slots" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -675,9 +537,7 @@ def get_pvp_talent_slots(self, region, locale, class_id): # Playable Race API def get_playable_races_index(self, region, locale, is_classic=False): - """ - Playable Race API - Returns an index of playable races. - """ + """Return an index of playable races.""" resource = "/data/wow/playable-race/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -688,9 +548,7 @@ def get_playable_races_index(self, region, locale, is_classic=False): def get_playable_race( self, region, locale, playable_race_id, is_classic=False ): - """ - Playable Race API - Returns a playable race by ID. - """ + """Return a playable race by ID.""" resource = f"/data/wow/playable-race/{playable_race_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -701,27 +559,19 @@ def get_playable_race( # Playable Specialization API def get_playable_specializations_index(self, region, locale): - """ - Playable Specialization API - Returns an index of playable - specializations. - """ + """Return an index of playable specializations.""" resource = "/data/wow/playable-specialization/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_playable_specialization(self, region, locale, spec_id): - """ - Playable Specialization API - Returns a playable specialization by ID. - """ + """Return a playable specialization by ID.""" resource = f"/data/wow/playable-specialization/{spec_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_playable_specialization_media(self, region, locale, spec_id): - """ - Playable Specialization API - Returns media for a playable - specialization by ID. - """ + """Return media for a playable specialization by ID.""" resource = f"/data/wow/media/playable-specialization/{spec_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -729,9 +579,7 @@ def get_playable_specialization_media(self, region, locale, spec_id): # Power Type API def get_power_types_index(self, region, locale, is_classic=False): - """ - Power Type API - Returns an index of power types. - """ + """Return an index of power types.""" resource = "/data/wow/power-type/index" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -740,9 +588,7 @@ def get_power_types_index(self, region, locale, is_classic=False): return super().get_resource(resource, region, query_params) def get_power_type(self, region, locale, power_type_id, is_classic=False): - """ - Power Type API - Returns a power type by ID. - """ + """Return a power type by ID.""" resource = f"/data/wow/power-type/{power_type_id}" namespace = ( f"static-classic-{region}" if is_classic else f"static-{region}" @@ -753,25 +599,19 @@ def get_power_type(self, region, locale, power_type_id, is_classic=False): # Profession API def get_professions_index(self, region, locale): - """ - Profession API - Returns an index of professions. - """ + """Return an index of professions.""" resource = "/data/wow/profession/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_profession(self, region, locale, profession_id): - """ - Profession API - Returns a profession by ID. - """ + """Return a profession by ID.""" resource = f"/data/wow/profession/{profession_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_profession_media(self, region, locale, profession_id): - """ - Profession API - Returns media for a profession by ID. - """ + """Return media for a profession by ID.""" resource = f"/data/wow/media/profession/{profession_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -779,9 +619,7 @@ def get_profession_media(self, region, locale, profession_id): def get_profession_skill_tier( self, region, locale, profession_id, skill_tier_id ): - """ - Profession API - Returns a skill tier for a profession by ID. - """ + """Return a skill tier for a profession by ID.""" resource = ( f"/data/wow/profession/{profession_id}/skill-tier/{skill_tier_id}" ) @@ -789,43 +627,33 @@ def get_profession_skill_tier( return super().get_resource(resource, region, query_params) def get_recipe(self, region, locale, recipe_id): - """ - Profession API - Returns a recipe by ID. - """ + """Return a recipe by ID.""" resource = f"/data/wow/recipe/{recipe_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_recipe_media(self, region, locale, recipe_id): - """ - Profession API - Returns media for a recipe by ID. - """ + """Return media for a recipe by ID.""" resource = f"/data/wow/media/recipe/{recipe_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) - # PvP Season API + # Pvp Season API def get_pvp_seasons_index(self, region, locale): - """ - PvP Season API - Returns an index of PvP seasons. - """ + """Return an index of Pvp seasons.""" resource = "/data/wow/pvp-season/index" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pvp_season(self, region, locale, pvp_season_id): - """ - PvP Season API - Returns a PvP season by ID. - """ + """Return a Pvp season by ID.""" resource = f"/data/wow/pvp-season/{pvp_season_id}" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pvp_leaderboards_index(self, region, locale, pvp_season_id): - """ - PvP Season API - Returns an index of PvP leaderboards for a PvP season. - """ + """Return an index of Pvp leaderboards for a Pvp season.""" resource = ( f"/data/wow/pvp-season/{pvp_season_id}/pvp-leaderboard/index" ) @@ -833,44 +661,33 @@ def get_pvp_leaderboards_index(self, region, locale, pvp_season_id): return super().get_resource(resource, region, query_params) def get_pvp_leaderboard(self, region, locale, pvp_season_id, pvp_bracket): - """ - PvP Season API - Returns the PvP leaderboard of a specific PvP bracket - for a PvP season. - """ + """Return the Pvp leaderboard of a specific Pvp bracket for a Pvp season.""" resource = f"/data/wow/pvp-season/{pvp_season_id}/pvp-leaderboard/{pvp_bracket}" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pvp_rewards_index(self, region, locale, pvp_season_id): - """ - PvP Season API - Returns an index of PvP rewards for a PvP season. - """ + """Return an index of Pvp rewards for a Pvp season.""" resource = f"/data/wow/pvp-season/{pvp_season_id}/pvp-reward/index" query_params = {"namespace": f"dynamic-{region}", "locale": locale} return super().get_resource(resource, region, query_params) - # PvP Tier API + # Pvp Tier API def get_pvp_tier_media(self, region, locale, pvp_tier_id): - """ - PvP Tier API - Returns media for a PvP tier by ID. - """ + """Return media for a Pvp tier by ID.""" resource = f"/data/wow/media/pvp-tier/{pvp_tier_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pvp_tiers_index(self, region, locale): - """ - PvP Tier API - Returns an index of PvP tiers. - """ + """Return an index of Pvp tiers.""" resource = "/data/wow/pvp-tier/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pvp_tier(self, region, locale, pvp_tier_id): - """ - PvP Tier API - Returns a PvP tier by ID. - """ + """Return a Pvp tier by ID.""" resource = f"/data/wow/pvp-tier/{pvp_tier_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -878,69 +695,49 @@ def get_pvp_tier(self, region, locale, pvp_tier_id): # Quest API def get_quests_index(self, region, locale): - """ - Quest API - Returns the parent index for quests. - """ + """Return the parent index for quests.""" resource = "/data/wow/quest/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_quest(self, region, locale, quest_id): - """ - Quest API - Returns a quest by ID. - """ + """Return a quest by ID.""" resource = f"/data/wow/quest/{quest_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_quest_categories_index(self, region, locale): - """ - Quest API - Returns an index of quest categories (such as quests for a - specific class, - profession, or storyline). - """ + """Return an index of quest categories (such as quests for a specific class, profession, or storyline).""" resource = "/data/wow/quest/category/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_quest_category(self, region, locale, quest_category_id): - """ - Quest API - Returns a quest category by ID. - """ + """Return a quest category by ID.""" resource = f"/data/wow/quest/category/{quest_category_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_quest_areas_index(self, region, locale): - """ - Quest API - Returns an index of quest areas. - """ + """Return an index of quest areas.""" resource = "/data/wow/quest/area/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_quest_area(self, region, locale, quest_area_id): - """ - Quest API - Returns a quest area by ID. - """ + """Return a quest area by ID.""" resource = f"/data/wow/quest/area/{quest_area_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_quest_types_index(self, region, locale): - """ - Quest API - Returns an index of quest types (such as PvP quests, raid - quests, or account - quests). - """ + """Return an index of quest types (such as Pvp quests, raid quests, or account quests).""" resource = "/data/wow/quest/type/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_quest_type(self, region, locale, quest_type_id): - """ - Quest API - Returns a quest type by ID. - """ + """Return a quest type by ID.""" resource = f"/data/wow/quest/type/{quest_type_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -948,9 +745,7 @@ def get_quest_type(self, region, locale, quest_type_id): # Realm API def get_realms_index(self, region, locale, is_classic=False): - """ - Realm API - Returns an index of realms. - """ + """Return an index of realms.""" resource = "/data/wow/realm/index" namespace = ( f"dynamic-classic-{region}" if is_classic else f"dynamic-{region}" @@ -959,9 +754,7 @@ def get_realms_index(self, region, locale, is_classic=False): return super().get_resource(resource, region, query_params) def get_realm(self, region, locale, realm_slug, is_classic=False): - """ - Realm API - Returns a single realm by slug or ID. - """ + """Return a single realm by slug or ID.""" resource = f"/data/wow/realm/{realm_slug}" namespace = ( f"dynamic-classic-{region}" if is_classic else f"dynamic-{region}" @@ -972,9 +765,7 @@ def get_realm(self, region, locale, realm_slug, is_classic=False): # Region API def get_regions_index(self, region, locale, is_classic=False): - """ - Region API - Returns an index of regions. - """ + """Return an index of regions.""" resource = "/data/wow/region/index" namespace = ( f"dynamic-classic-{region}" if is_classic else f"dynamic-{region}" @@ -983,9 +774,7 @@ def get_regions_index(self, region, locale, is_classic=False): return super().get_resource(resource, region, query_params) def get_region(self, region, locale, region_id, is_classic=False): - """ - Region API - Returns a region by ID. - """ + """Return a region by ID.""" resource = f"/data/wow/region/{region_id}" namespace = ( f"dynamic-classic-{region}" if is_classic else f"dynamic-{region}" @@ -996,33 +785,25 @@ def get_region(self, region, locale, region_id, is_classic=False): # Reputations API def get_reputation_factions_index(self, region, locale): - """ - Reputations API - Returns an index of reputation factions. - """ + """Return an index of reputation factions.""" resource = "/data/wow/reputation-faction/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_reputation_faction(self, region, locale, reputation_faction_id): - """ - Reputations API - Returns a single reputation faction by ID. - """ + """Return a single reputation faction by ID.""" resource = f"/data/wow/reputation-faction/{reputation_faction_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_reputation_tiers_index(self, region, locale): - """ - Reputations API - Returns an index of reputation tiers. - """ + """Return an index of reputation tiers.""" resource = "/data/wow/reputation-tiers/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_reputation_tier(self, region, locale, reputation_tiers_id): - """ - Reputations API - Returns a single set of reputation tiers by ID. - """ + """Return a single set of reputation tiers by ID.""" resource = f"/data/wow/reputation-tiers/{reputation_tiers_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -1030,17 +811,13 @@ def get_reputation_tier(self, region, locale, reputation_tiers_id): # Spell API def get_spell(self, region, locale, spell_id): - """ - Spell API - Returns a spell by ID. - """ + """Return a spell by ID.""" resource = f"/data/wow/spell/{spell_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_spell_media(self, region, locale, spell_id): - """ - Spell API - Returns media for a spell by ID. - """ + """Return media for a spell by ID.""" resource = f"/data/wow/media/spell/{spell_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -1048,33 +825,25 @@ def get_spell_media(self, region, locale, spell_id): # Talent API def get_talents_index(self, region, locale): - """ - Talent API - Returns an index of talents. - """ + """Return an index of talents.""" resource = "/data/wow/talent/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_talent(self, region, locale, talent_id): - """ - Talent API - Returns a talent by ID. - """ + """Return a talent by ID.""" resource = f"/data/wow/talent/{talent_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pvp_talents_index(self, region, locale): - """ - Talent API - Returns an index of PvP talents. - """ + """Return an index of Pvp talents.""" resource = "/data/wow/pvp-talent/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_pvp_talent(self, region, locale, pvp_talent_id): - """ - Talent API - Returns a PvP talent by ID. - """ + """Return a Pvp talent by ID.""" resource = f"/data/wow/pvp-talent/{pvp_talent_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -1082,27 +851,21 @@ def get_pvp_talent(self, region, locale, pvp_talent_id): # Title API def get_titles_index(self, region, locale): - """ - Title API - Returns an index of titles. - """ + """Return an index of titles.""" resource = "/data/wow/title/index" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_title(self, region, locale, title_id): - """ - Title API - Returns a title by ID. - """ + """Return a title by ID.""" resource = f"/data/wow/title/{title_id}" query_params = {"namespace": f"static-{region}", "locale": locale} return super().get_resource(resource, region, query_params) - # WoW Token API + # Wow Token API def get_token_index(self, region, locale, is_classic=False): - """ - WoW Token API - Returns the WoW Token index. - """ + """Return the Wow Token index.""" resource = "/data/wow/token/index" namespace = ( f"dynamic-classic-{region}" if is_classic else f"dynamic-{region}" diff --git a/blizzardapi/wow/wow_profile_api.py b/blizzardapi/wow/wow_profile_api.py index 795551a..43eb5e9 100644 --- a/blizzardapi/wow/wow_profile_api.py +++ b/blizzardapi/wow/wow_profile_api.py @@ -1,18 +1,23 @@ +"""wow_profile_api.py file.""" from ..api import Api class WowProfileApi(Api): - """All Profile API methods""" + """All Wow Profile API methods. + + Attributes: + client_id: A string client id supplied by Blizzard. + client_secret: A string client secret supplied by Blizzard. + """ def __init__(self, client_id, client_secret): + """Init WowProfileApi.""" super().__init__(client_id, client_secret) # Account Profile API def get_account_profile_summary(self, region, locale, access_token): - """ - Account Profile API - Returns a profile summary for an account. - """ + """Return a profile summary for an account.""" resource = "/profile/user/wow" query_params = { "namespace": f"profile-{region}", @@ -24,10 +29,7 @@ def get_account_profile_summary(self, region, locale, access_token): def get_protected_character_profile_summary( self, region, locale, access_token, realm_id, character_id ): - """ - Account Profile API - Returns a protected profile summary for a - character. - """ + """Return a protected profile summary for a character.""" resource = ( f"/profile/user/wow/protected-character/{realm_id}-{character_id}" ) @@ -39,10 +41,7 @@ def get_protected_character_profile_summary( return super().get_resource(resource, region, query_params) def get_account_collections_index(self, region, locale, access_token): - """ - Account Profile API - Returns an index of collection types for an - account. - """ + """Return an index of collection types for an account.""" resource = "/profile/user/wow/collections" query_params = { "namespace": f"profile-{region}", @@ -54,10 +53,7 @@ def get_account_collections_index(self, region, locale, access_token): def get_account_mounts_collection_summary( self, region, locale, access_token ): - """ - Account Profile API - Returns a summary of the mounts an account has - obtained. - """ + """Return a summary of the mounts an account has obtained.""" resource = "/profile/user/wow/collections/mounts" query_params = { "namespace": f"profile-{region}", @@ -69,10 +65,7 @@ def get_account_mounts_collection_summary( def get_account_pets_collection_summary( self, region, locale, access_token ): - """ - Account Profile API - Returns a summary of the battle pets an account - has obtained. - """ + """Return a summary of the battle pets an account has obtained.""" resource = "/profile/user/wow/collections/pets" query_params = { "namespace": f"profile-{region}", @@ -86,10 +79,7 @@ def get_account_pets_collection_summary( def get_character_achievements_summary( self, region, locale, realm_slug, character_name ): - """ - Character Achievements API - Returns a summary of the achievements a - character has completed. - """ + """Return a summary of the achievements a character has completed.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/achievements" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -97,10 +87,7 @@ def get_character_achievements_summary( def get_character_achievement_statistics( self, region, locale, realm_slug, character_name ): - """ - Character Achievements API - Returns a character's statistics as they - pertain to achievements. - """ + """Return a character's statistics as they pertain to achievements.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/achievements/statistics" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -110,10 +97,7 @@ def get_character_achievement_statistics( def get_character_appearance_summary( self, region, locale, realm_slug, character_name ): - """ - Character Appearance API - Returns a summary of a character's - appearance settings. - """ + """Return a summary of a character's appearance settings.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/appearance" ) @@ -125,10 +109,7 @@ def get_character_appearance_summary( def get_character_collections_index( self, region, locale, realm_slug, character_name ): - """ - Character Collections API - Returns an index of collection types for - a character. - """ + """Return an index of collection types for a character.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/collections" ) @@ -138,10 +119,7 @@ def get_character_collections_index( def get_character_mounts_collection_index( self, region, locale, realm_slug, character_name ): - """ - Character Collections API - Returns a summary of the mounts a character - has obtained. - """ + """Return a summary of the mounts a character has obtained.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/collections/mounts" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -149,10 +127,7 @@ def get_character_mounts_collection_index( def get_character_pets_collection_index( self, region, locale, realm_slug, character_name ): - """ - Character Collections API - Returns a summary of the battle pets a - character has obtained. - """ + """Return a summary of the battle pets a character has obtained.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/collections/pets" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -162,10 +137,7 @@ def get_character_pets_collection_index( def get_character_encounters_summary( self, region, locale, realm_slug, character_name ): - """ - Character Encounters API - Returns a summary of a character's - encounters. - """ + """Return a summary of a character's encounters.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/encounters" ) @@ -175,19 +147,13 @@ def get_character_encounters_summary( def get_character_dungeons( self, region, locale, realm_slug, character_name ): - """ - Character Encounters API - Returns a summary of a character's - completed dungeons. - """ + """Return a summary of a character's completed dungeons.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/encounters/dungeons" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_character_raids(self, region, locale, realm_slug, character_name): - """ - Character Encounters API - Returns a summary of a character's - completed raids. - """ + """Return a summary of a character's completed raids.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/encounters/raids" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -197,10 +163,7 @@ def get_character_raids(self, region, locale, realm_slug, character_name): def get_character_equipment_summary( self, region, locale, realm_slug, character_name ): - """ - Character Equipment API - Returns a summary of the items equipped by a - character. - """ + """Return a summary of the items equipped by a character.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/equipment" ) @@ -212,10 +175,7 @@ def get_character_equipment_summary( def get_character_hunter_pets_summary( self, region, locale, realm_slug, character_name ): - """ - Character Hunter Pets API - If the character is a hunter, returns a - summary of the character's hunter pets. - """ + """If the character is a hunter, returns a summary of the character's hunter pets.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/hunter-pets" ) @@ -227,10 +187,7 @@ def get_character_hunter_pets_summary( def get_character_media_summary( self, region, locale, realm_slug, character_name ): - """ - Character Media API - Returns a summary of the media assets available - for a character (such as an avatar render). - """ + """Return a summary of the media assets available for a character (such as an avatar render).""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/character-media" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -240,10 +197,7 @@ def get_character_media_summary( def get_character_mythic_keystone_profile_index( self, region, locale, realm_slug, character_name ): - """ - Character Mythic Keystone Profile API - Returns the Mythic Keystone - profile index for a character. - """ + """Return the Mythic Keystone profile index for a character.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/mythic-keystone-profile" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -251,10 +205,7 @@ def get_character_mythic_keystone_profile_index( def get_character_mythic_keystone_profile_season_details( self, region, locale, realm_slug, character_name, season_id ): - """ - Character Mythic Keystone Profile API - Returns the Mythic Keystone - season details for a character. - """ + """Return the Mythic Keystone season details for a character.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/mythic-keystone-profile/season/{season_id}" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -264,10 +215,7 @@ def get_character_mythic_keystone_profile_season_details( def get_character_professions_summary( self, region, locale, realm_slug, character_name ): - """ - Character Professions API - Returns a summary of professions for a - character. - """ + """Return a summary of professions for a character.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/professions" ) @@ -279,9 +227,7 @@ def get_character_professions_summary( def get_character_profile_summary( self, region, locale, realm_slug, character_name ): - """ - Character Profile API - Returns a profile summary for a character. - """ + """Return a profile summary for a character.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -289,24 +235,19 @@ def get_character_profile_summary( def get_character_profile_status( self, region, locale, realm_slug, character_name ): - """ - Character Profile API - Returns the status and a unique ID for a - character. - """ + """Return the status and a unique ID for a character.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/status" ) query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) - # Character PvP API + # Character Pvp API def get_character_pvp_bracket_statistics( self, region, locale, realm_slug, character_name, pvp_bracket ): - """ - Character PvP API - Returns the PvP bracket statistics for a character. - """ + """Return the Pvp bracket statistics for a character.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/pvp-bracket/{pvp_bracket}" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -314,9 +255,7 @@ def get_character_pvp_bracket_statistics( def get_character_pvp_summary( self, region, locale, realm_slug, character_name ): - """ - Character PvP API - Returns a PvP summary for a character. - """ + """Return a Pvp summary for a character.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/pvp-summary" ) @@ -326,10 +265,7 @@ def get_character_pvp_summary( # Character Quests API def get_character_quests(self, region, locale, realm_slug, character_name): - """ - Character Quests API - Returns a character's active quests as well as a - link to the character's completed quests. - """ + """Return a character's active quests as well as a link to the character's completed quests.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/quests" ) @@ -339,10 +275,7 @@ def get_character_quests(self, region, locale, realm_slug, character_name): def get_character_completed_quests( self, region, locale, realm_slug, character_name ): - """ - Character Quests API - Returns a list of quests that a character has - completed. - """ + """Return a list of quests that a character has completed.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/quests/completed" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -352,10 +285,7 @@ def get_character_completed_quests( def get_character_reputations_summary( self, region, locale, realm_slug, character_name ): - """ - Character Reputations API - Returns a summary of a character's - reputations. - """ + """Return a summary of a character's reputations.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/reputations" ) @@ -367,10 +297,7 @@ def get_character_reputations_summary( def get_character_specializations_summary( self, region, locale, realm_slug, character_name ): - """ - Character Specializations API - Returns a summary of a character's - specializations. - """ + """Return a summary of a character's specializations.""" resource = f"/profile/wow/character/{realm_slug}/{character_name}/specializations" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) @@ -380,10 +307,7 @@ def get_character_specializations_summary( def get_character_statistics_summary( self, region, locale, realm_slug, character_name ): - """ - Character Statistics API - Returns a statistics summary for a - character. - """ + """Return a statistics summary for a character.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/statistics" ) @@ -395,10 +319,7 @@ def get_character_statistics_summary( def get_character_titles_summary( self, region, locale, realm_slug, character_name ): - """ - Character Titles API - Returns a summary of titles a character has - obtained. - """ + """Return a summary of titles a character has obtained.""" resource = ( f"/profile/wow/character/{realm_slug}/{character_name}/titles" ) @@ -408,33 +329,25 @@ def get_character_titles_summary( # Guild API def get_guild(self, region, locale, realm_slug, name_slug): - """ - Guild API - Returns a single guild by its name and realm. - """ + """Return a single guild by its name and realm.""" resource = f"/data/wow/guild/{realm_slug}/{name_slug}" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_guild_activity(self, region, locale, realm_slug, name_slug): - """ - Guild API - Returns a single guild's activity by name and realm. - """ + """Return a single guild's activity by name and realm.""" resource = f"/data/wow/guild/{realm_slug}/{name_slug}/activity" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_guild_achievements(self, region, locale, realm_slug, name_slug): - """ - Guild API - Returns a single guild's achievements by name and realm. - """ + """Return a single guild's achievements by name and realm.""" resource = f"/data/wow/guild/{realm_slug}/{name_slug}/achievements" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) def get_guild_roster(self, region, locale, realm_slug, name_slug): - """ - Guild API - Returns a single guild's roster by its name and realm. - """ + """Return a single guild's roster by its name and realm.""" resource = f"/data/wow/guild/{realm_slug}/{name_slug}/roster" query_params = {"namespace": f"profile-{region}", "locale": locale} return super().get_resource(resource, region, query_params) diff --git a/requirements.txt b/requirements.txt index 098431f..c7be74d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,9 @@ -pytest==6.0.1 +bandit +black +mypy +pydocstyle +pylint pytest-cov==2.10.1 pytest-mock==3.3.1 -requests==2.24.0 +pytest==6.0.1 +requests==2.24.0 \ No newline at end of file diff --git a/tests/test_battlenet_oauth_api.py b/tests/test_battlenet_oauth_api.py index 5ace215..e8a9e95 100644 --- a/tests/test_battlenet_oauth_api.py +++ b/tests/test_battlenet_oauth_api.py @@ -14,6 +14,5 @@ def test_get_user_info(self, success_response_mock): "access_token": "new_access_token", } success_response_mock.assert_called_with( - "https://us.battle.net/oauth/userinfo", - params=params, + "https://us.battle.net/oauth/userinfo", params=params ) diff --git a/tests/test_diablo3_community_api.py b/tests/test_diablo3_community_api.py index 97fa548..d44491c 100644 --- a/tests/test_diablo3_community_api.py +++ b/tests/test_diablo3_community_api.py @@ -15,8 +15,7 @@ def test_get_act_index(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/d3/data/act", - params=params, + "https://us.api.blizzard.com/d3/data/act", params=params ) def test_get_act(self, success_response_mock): @@ -26,8 +25,7 @@ def test_get_act(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/d3/data/act/1", - params=params, + "https://us.api.blizzard.com/d3/data/act/1", params=params ) # D3 Artisan and Recipe API @@ -80,8 +78,7 @@ def test_get_character_class(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/d3/data/hero/barbarian", - params=params, + "https://us.api.blizzard.com/d3/data/hero/barbarian", params=params ) def test_get_api_skill(self, success_response_mock): @@ -106,8 +103,7 @@ def test_get_item_type_index(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/d3/data/item-type", - params=params, + "https://us.api.blizzard.com/d3/data/item-type", params=params ) def test_get_item_type(self, success_response_mock): diff --git a/tests/test_diablo3_game_data_api.py b/tests/test_diablo3_game_data_api.py index e711c57..4b3a317 100644 --- a/tests/test_diablo3_game_data_api.py +++ b/tests/test_diablo3_game_data_api.py @@ -14,8 +14,7 @@ def test_get_season_index(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/data/d3/season/", - params=params, + "https://us.api.blizzard.com/data/d3/season/", params=params ) def test_get_season(self, success_response_mock): @@ -24,8 +23,7 @@ def test_get_season(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/data/d3/season/1", - params=params, + "https://us.api.blizzard.com/data/d3/season/1", params=params ) def test_get_season_leaderboard(self, success_response_mock): @@ -46,8 +44,7 @@ def test_get_era_index(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/data/d3/era/", - params=params, + "https://us.api.blizzard.com/data/d3/era/", params=params ) def test_get_era(self, success_response_mock): @@ -56,8 +53,7 @@ def test_get_era(self, success_response_mock): "access_token": "access_token", } success_response_mock.assert_called_with( - "https://us.api.blizzard.com/data/d3/era/1", - params=params, + "https://us.api.blizzard.com/data/d3/era/1", params=params ) def test_get_era_leaderboard(self, success_response_mock): diff --git a/tests/test_hearthstone_game_data_api.py b/tests/test_hearthstone_game_data_api.py new file mode 100644 index 0000000..7511850 --- /dev/null +++ b/tests/test_hearthstone_game_data_api.py @@ -0,0 +1,93 @@ +from blizzardapi import BlizzardApi + + +class TestHearthstoneGameDataApi: + def setup(self): + self.api = BlizzardApi("client_id", "client_secret") + self.api.hearthstone.game_data._access_token = "access_token" + + # Cards + + def test_search_cards(self, success_response_mock): + self.api.hearthstone.game_data.search_cards("us", "en_US") + params = { + "locale": "en_US", + "access_token": "access_token", + } + success_response_mock.assert_called_with( + "https://us.api.blizzard.com/hearthstone/cards", params=params + ) + + def test_get_card(self, success_response_mock): + self.api.hearthstone.game_data.get_card( + "us", "en_US", "52119-arch-villain-rafaam" + ) + params = { + "locale": "en_US", + "access_token": "access_token", + "game_mode": "constructed", + } + success_response_mock.assert_called_with( + "https://us.api.blizzard.com/hearthstone/cards/52119-arch-villain-rafaam", + params=params, + ) + + # Card Backs + + def test_search_card_backs(self, success_response_mock): + self.api.hearthstone.game_data.search_card_backs("us", "en_US") + params = { + "locale": "en_US", + "access_token": "access_token", + } + success_response_mock.assert_called_with( + "https://us.api.blizzard.com/hearthstone/cardbacks", params=params + ) + + def test_get_card_back(self, success_response_mock): + self.api.hearthstone.game_data.get_card_back( + "us", "en_US", "155-pizza-stone" + ) + params = { + "locale": "en_US", + "access_token": "access_token", + } + success_response_mock.assert_called_with( + "https://us.api.blizzard.com/hearthstone/cardbacks/155-pizza-stone", + params=params, + ) + + # Decks + + def test_get_deck(self, success_response_mock): + self.api.hearthstone.game_data.get_deck("us", "en_US") + params = { + "locale": "en_US", + "access_token": "access_token", + } + success_response_mock.assert_called_with( + "https://us.api.blizzard.com/hearthstone/deck", params=params + ) + + # Metadata + + def test_get_metadata(self, success_response_mock): + self.api.hearthstone.game_data.get_metadata("us", "en_US") + params = { + "locale": "en_US", + "access_token": "access_token", + } + success_response_mock.assert_called_with( + "https://us.api.blizzard.com/hearthstone/metadata", params=params + ) + + def test_get_metadata_type(self, success_response_mock): + self.api.hearthstone.game_data.get_metadata_type("us", "en_US", "sets") + params = { + "locale": "en_US", + "access_token": "access_token", + } + success_response_mock.assert_called_with( + "https://us.api.blizzard.com/hearthstone/metadata/sets", + params=params, + ) diff --git a/tests/test_wow_classic_game_data_api.py b/tests/test_wow_classic_game_data_api.py index 6477dda..021ac62 100644 --- a/tests/test_wow_classic_game_data_api.py +++ b/tests/test_wow_classic_game_data_api.py @@ -426,7 +426,7 @@ def test_get_region(self, success_response_mock): "https://us.api.blizzard.com/data/wow/region/1", params=params ) - # WoW Token API + # Wow Token API def test_get_tokens_index(self, success_response_mock): self.api.wow.game_data.get_token_index("us", "en_US", is_classic=True) diff --git a/tests/test_wow_game_data_api.py b/tests/test_wow_game_data_api.py index 4cc11f4..3699dac 100644 --- a/tests/test_wow_game_data_api.py +++ b/tests/test_wow_game_data_api.py @@ -998,7 +998,7 @@ def test_get_recipe_media(self, success_response_mock): params=params, ) - # PvP Season API + # Pvp Season API def test_get_pvp_seasons_index(self, success_response_mock): self.api.wow.game_data.get_pvp_seasons_index("us", "en_US") @@ -1059,7 +1059,7 @@ def test_get_pvp_rewards_index(self, success_response_mock): params=params, ) - # PvP Tier API + # Pvp Tier API def test_get_pvp_tier_media(self, success_response_mock): self.api.wow.game_data.get_pvp_tier_media("us", "en_US", 1) @@ -1385,7 +1385,7 @@ def test_get_title(self, success_response_mock): "https://us.api.blizzard.com/data/wow/title/1", params=params ) - # WoW Token API + # Wow Token API def test_get_tokens_index(self, success_response_mock): self.api.wow.game_data.get_token_index("us", "en_US") diff --git a/tests/test_wow_profile_api.py b/tests/test_wow_profile_api.py index f012e78..5b252ce 100644 --- a/tests/test_wow_profile_api.py +++ b/tests/test_wow_profile_api.py @@ -345,7 +345,7 @@ def test_get_character_profile_status(self, success_response_mock): params=params, ) - # Character PvP API + # Character Pvp API def test_get_character_pvp_bracket_statistics(self, success_response_mock): self.api.wow.profile.get_character_pvp_bracket_statistics(