blizzardapi2 4.0.1__tar.gz → 5.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.github/workflows/python-package.yml +5 -1
  2. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.pre-commit-config.yaml +6 -0
  3. blizzardapi2-5.0.0/.release-it.cjs +55 -0
  4. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/CONTRIBUTING.md +2 -2
  5. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/PKG-INFO +32 -23
  6. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/README.md +31 -22
  7. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/__init__.py +1 -0
  8. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/api.py +3 -6
  9. blizzardapi2-5.0.0/blizzardapi2/battlenet/__init__.py +5 -0
  10. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/battlenet/battlenet_api.py +4 -1
  11. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/battlenet/battlenet_oauth_api.py +1 -1
  12. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/blizzard_api.py +25 -5
  13. blizzardapi2-5.0.0/blizzardapi2/diablo3/__init__.py +4 -0
  14. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/diablo3/diablo3_api.py +12 -4
  15. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/diablo3/diablo3_game_data_api.py +1 -1
  16. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/endpoint.py +19 -2
  17. blizzardapi2-5.0.0/blizzardapi2/hearthstone/__init__.py +4 -0
  18. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/hearthstone/hearthstone_api.py +8 -3
  19. blizzardapi2-5.0.0/blizzardapi2/starcraft2/__init__.py +4 -0
  20. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/starcraft2/starcraft2_api.py +12 -5
  21. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/starcraft2/starcraft2_community_api.py +1 -1
  22. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/starcraft2/starcraft2_game_data_api.py +1 -1
  23. blizzardapi2-5.0.0/blizzardapi2/wow/__init__.py +4 -0
  24. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/wow/wow_api.py +16 -4
  25. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/wow/wow_profile_api.py +1 -1
  26. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2.egg-info/PKG-INFO +32 -23
  27. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2.egg-info/SOURCES.txt +4 -1
  28. blizzardapi2-5.0.0/docs/EXAMPLES.md +76 -0
  29. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/docs/battlenet/README.md +37 -24
  30. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/docs/diablo3/README.md +35 -21
  31. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/docs/hearthstone/README.md +58 -23
  32. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/docs/starcraft2/README.md +78 -42
  33. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/docs/wow/README.md +52 -45
  34. blizzardapi2-5.0.0/examples/custom_session.py +108 -0
  35. blizzardapi2-5.0.0/examples/oauth_server.py +81 -0
  36. blizzardapi2-5.0.0/package-lock.json +2643 -0
  37. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/package.json +3 -3
  38. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/pyproject.toml +2 -1
  39. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/test_base_api.py +1 -1
  40. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/test_battlenet.py +12 -11
  41. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/test_diablo3.py +14 -11
  42. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/test_hearthstone.py +14 -11
  43. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/test_starcraft2.py +14 -9
  44. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/test_wow.py +24 -19
  45. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/uv.lock +4 -4
  46. blizzardapi2-4.0.1/.release-it.json +0 -24
  47. blizzardapi2-4.0.1/blizzardapi2/battlenet/__init__.py +0 -1
  48. blizzardapi2-4.0.1/blizzardapi2/diablo3/__init__.py +0 -1
  49. blizzardapi2-4.0.1/blizzardapi2/hearthstone/__init__.py +0 -1
  50. blizzardapi2-4.0.1/blizzardapi2/starcraft2/__init__.py +0 -1
  51. blizzardapi2-4.0.1/blizzardapi2/wow/__init__.py +0 -1
  52. blizzardapi2-4.0.1/package-lock.json +0 -4407
  53. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  54. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  55. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.github/dependabot.yml +0 -0
  56. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.github/workflows/README.md +0 -0
  57. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.github/workflows/black-check.yml +0 -0
  58. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/.gitignore +0 -0
  59. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/CLAUDE.md +0 -0
  60. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/CODE_OF_CONDUCT.md +0 -0
  61. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/LICENSE +0 -0
  62. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/SECURITY.md +0 -0
  63. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/diablo3/diablo3_community_api.py +0 -0
  64. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/hearthstone/hearthstone_game_data_api.py +0 -0
  65. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/types.py +0 -0
  66. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2/wow/wow_game_data_api.py +0 -0
  67. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2.egg-info/dependency_links.txt +0 -0
  68. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2.egg-info/requires.txt +0 -0
  69. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/blizzardapi2.egg-info/top_level.txt +0 -0
  70. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/docs/pull_request_template.md +0 -0
  71. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/setup.cfg +0 -0
  72. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/__init__.py +0 -0
  73. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/conftest.py +0 -0
  74. {blizzardapi2-4.0.1 → blizzardapi2-5.0.0}/tests/test_types.py +0 -0
@@ -40,6 +40,9 @@ jobs:
40
40
  uv venv
41
41
  uv pip install -e ".[dev]"
42
42
 
43
+ - name: Lint with ruff
44
+ run: uv run ruff check .
45
+
43
46
  - name: Run tests
44
47
  run: uv run pytest tests/ -v
45
48
 
@@ -57,6 +60,7 @@ jobs:
57
60
  uses: actions/checkout@v4
58
61
  with:
59
62
  fetch-depth: 0
63
+ token: ${{ secrets.RELEASE_TOKEN }}
60
64
 
61
65
  - name: Configure Git
62
66
  run: |
@@ -83,7 +87,7 @@ jobs:
83
87
  - name: Run release script
84
88
  id: bump
85
89
  env:
86
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90
+ GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
87
91
  run: |
88
92
  npx release-it --ci || {
89
93
  echo "release-it failed, creating GitHub release manually..."
@@ -1,4 +1,10 @@
1
1
  repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.15.12
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+
2
8
  - repo: https://github.com/psf/black
3
9
  rev: 26.3.1
4
10
  hooks:
@@ -0,0 +1,55 @@
1
+ // release-it config. JS instead of JSON so we can express a custom whatBump
2
+ // that suppresses noise releases (chore, ci, docs, style, test, refactor, build).
3
+ // Without this override, release-it falls back to a patch bump whenever there
4
+ // are any commits since the last tag — which is how v4.0.1 shipped from a
5
+ // chore-only PR.
6
+
7
+ const RELEASABLE_TYPES = new Set(["feat", "fix", "perf"]);
8
+
9
+ function whatBump(commits) {
10
+ let bump = null;
11
+
12
+ for (const commit of commits) {
13
+ const isBreaking =
14
+ (commit.notes || []).some((n) => /BREAKING/.test(n.title || "")) ||
15
+ / !$| !:|^[a-z]+!:/.test(commit.header || "");
16
+
17
+ if (isBreaking) {
18
+ return { level: 0, reason: "BREAKING CHANGE" }; // major
19
+ }
20
+
21
+ if (commit.type === "feat" && bump !== 1) {
22
+ bump = 1; // minor
23
+ } else if (RELEASABLE_TYPES.has(commit.type) && bump === null) {
24
+ bump = 2; // patch
25
+ }
26
+ }
27
+
28
+ // null = no release. release-it skips the bump/tag/publish chain.
29
+ return bump === null ? null : { level: bump };
30
+ }
31
+
32
+ module.exports = {
33
+ git: {
34
+ commitMessage: "chore: release v${version} [skip ci]",
35
+ tagName: "v${version}",
36
+ },
37
+ github: {
38
+ release: true,
39
+ releaseName: "Release v${version}",
40
+ },
41
+ npm: {
42
+ publish: false,
43
+ },
44
+ hooks: {
45
+ "after:bump": [
46
+ "sed -i 's/^version = \".*\"/version = \"${version}\"/' pyproject.toml",
47
+ ],
48
+ },
49
+ plugins: {
50
+ "@release-it/conventional-changelog": {
51
+ preset: "conventionalcommits",
52
+ whatBump,
53
+ },
54
+ },
55
+ };
@@ -42,7 +42,7 @@ The project uses several tools to maintain code quality:
42
42
 
43
43
  - **Black**: Code formatting
44
44
  - **isort**: Import sorting
45
- - **flake8**: Linting
45
+ - **ruff**: Linting
46
46
 
47
47
  ### Manual Formatting
48
48
 
@@ -56,7 +56,7 @@ black .
56
56
  isort .
57
57
 
58
58
  # Check linting
59
- flake8 .
59
+ ruff check .
60
60
  ```
61
61
 
62
62
  ## GitHub Workflows
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blizzardapi2
3
- Version: 4.0.1
3
+ Version: 5.0.0
4
4
  Summary: A Python wrapper for Blizzard API
5
5
  Author-email: lostcol0ny <c098os0k@4wrd.cc>
6
6
  License-Expression: MIT
@@ -75,28 +75,28 @@ Python (3.11+)
75
75
  **Basic Usage**
76
76
 
77
77
  ```python
78
- from blizzardapi2 import BlizzardApi
78
+ from blizzardapi2 import BlizzardApi, Region, Locale
79
79
 
80
80
  api_client = BlizzardApi("client_id", "client_secret")
81
81
 
82
82
  # Public API endpoint (uses automatic client credentials token)
83
83
  categories_index = api_client.wow.game_data.get_achievement_categories_index(
84
- "us", # region
85
- "en_US" # locale
84
+ region=Region.US,
85
+ locale=Locale.EN_US,
86
86
  )
87
87
 
88
88
  # Protected API endpoint (requires user OAuth token)
89
89
  summary = api_client.wow.profile.get_account_profile_summary(
90
- "us",
91
- "en_US",
92
- "user_access_token" # OAuth token from authorization code flow
90
+ "user_access_token", # OAuth token from authorization code flow
91
+ region=Region.US,
92
+ locale=Locale.EN_US,
93
93
  )
94
94
 
95
95
  # WoW Classic endpoint
96
96
  connected_realms_index = api_client.wow.game_data.get_connected_realms_index(
97
- "us",
98
- "en_US",
99
- is_classic=True
97
+ region=Region.US,
98
+ locale=Locale.EN_US,
99
+ is_classic=True,
100
100
  )
101
101
  ```
102
102
 
@@ -105,15 +105,21 @@ connected_realms_index = api_client.wow.game_data.get_connected_realms_index(
105
105
  The library automatically manages client credentials tokens for public endpoints:
106
106
 
107
107
  ```python
108
- from blizzardapi2 import BlizzardApi
108
+ from blizzardapi2 import BlizzardApi, Region, Locale
109
109
 
110
110
  api_client = BlizzardApi("client_id", "client_secret")
111
111
 
112
112
  # First call: library automatically fetches and caches a client credentials token
113
- realms = api_client.wow.game_data.get_realms_index("us", "en_US")
113
+ realms = api_client.wow.game_data.get_realms_index(
114
+ region=Region.US,
115
+ locale=Locale.EN_US,
116
+ )
114
117
 
115
118
  # Subsequent calls: library reuses the cached token
116
- achievements = api_client.wow.game_data.get_achievements_index("us", "en_US")
119
+ achievements = api_client.wow.game_data.get_achievements_index(
120
+ region=Region.US,
121
+ locale=Locale.EN_US,
122
+ )
117
123
 
118
124
  # When token expires: library automatically refreshes it
119
125
  # You don't need to manage tokens manually!
@@ -128,16 +134,19 @@ You can pass in a `client_id` and `client_secret` and use almost any endpoint ex
128
134
  2. Sends it via `Authorization: Bearer <token>` header
129
135
  3. Keeps tokens out of URL query strings
130
136
 
131
- Here is the list of endpoints, specified by Blizzard, that require an OAuth token:
132
-
133
- ```
134
- GET /oauth/userinfo
135
- GET /profile/user/wow
136
- GET /profile/user/wow/protected-character/{realm-id}-{character-id}
137
- GET /profile/user/wow/collections
138
- GET /profile/user/wow/collections/pets
139
- GET /profile/user/wow/collections/mounts
140
- ```
137
+ Here is the list of endpoints, and related API methods, that require an OAuth authorization code token:
138
+
139
+ | Resource path | API call |
140
+ | ------------- | -------- |
141
+ | /userinfo | `.battlenet.oauth.get_user_info(access_token)` |
142
+ | /profile/user/wow | `.wow.profile.get_account_profile_summary(access_token)` |
143
+ | /profile/user/wow/protected-character/{realm-id}-{character-id} | `.wow.profile.get_protected_character_profile_summary(access_token, realm_id, character_id)` |
144
+ | /profile/user/wow/collections | `.wow.profile.get_account_collections_index(access_token)` |
145
+ | /profile/user/wow/collections/heirlooms | `.wow.profile.get_account_heirlooms_collection_summary(access_token)` |
146
+ | /profile/user/wow/collections/mounts | `.wow.profile.get_account_mounts_collection_summary(access_token)` |
147
+ | /profile/user/wow/collections/pets | `.wow.profile.get_account_pets_collection_summary(access_token)` |
148
+ | /profile/user/wow/collections/toys | `.wow.profile.get_account_toys_collection_summary(access_token)` |
149
+ | /profile/user/wow/collections/transmogs | `.wow.profile.get_account_transmog_collection_summary(access_token)` |
141
150
 
142
151
  **Note:** For these protected endpoints, you must implement the OAuth authorization code flow in your application to obtain a user access token. The library does not handle the OAuth flow itself - it only accepts and uses the token you provide.
143
152
 
@@ -49,28 +49,28 @@ Python (3.11+)
49
49
  **Basic Usage**
50
50
 
51
51
  ```python
52
- from blizzardapi2 import BlizzardApi
52
+ from blizzardapi2 import BlizzardApi, Region, Locale
53
53
 
54
54
  api_client = BlizzardApi("client_id", "client_secret")
55
55
 
56
56
  # Public API endpoint (uses automatic client credentials token)
57
57
  categories_index = api_client.wow.game_data.get_achievement_categories_index(
58
- "us", # region
59
- "en_US" # locale
58
+ region=Region.US,
59
+ locale=Locale.EN_US,
60
60
  )
61
61
 
62
62
  # Protected API endpoint (requires user OAuth token)
63
63
  summary = api_client.wow.profile.get_account_profile_summary(
64
- "us",
65
- "en_US",
66
- "user_access_token" # OAuth token from authorization code flow
64
+ "user_access_token", # OAuth token from authorization code flow
65
+ region=Region.US,
66
+ locale=Locale.EN_US,
67
67
  )
68
68
 
69
69
  # WoW Classic endpoint
70
70
  connected_realms_index = api_client.wow.game_data.get_connected_realms_index(
71
- "us",
72
- "en_US",
73
- is_classic=True
71
+ region=Region.US,
72
+ locale=Locale.EN_US,
73
+ is_classic=True,
74
74
  )
75
75
  ```
76
76
 
@@ -79,15 +79,21 @@ connected_realms_index = api_client.wow.game_data.get_connected_realms_index(
79
79
  The library automatically manages client credentials tokens for public endpoints:
80
80
 
81
81
  ```python
82
- from blizzardapi2 import BlizzardApi
82
+ from blizzardapi2 import BlizzardApi, Region, Locale
83
83
 
84
84
  api_client = BlizzardApi("client_id", "client_secret")
85
85
 
86
86
  # First call: library automatically fetches and caches a client credentials token
87
- realms = api_client.wow.game_data.get_realms_index("us", "en_US")
87
+ realms = api_client.wow.game_data.get_realms_index(
88
+ region=Region.US,
89
+ locale=Locale.EN_US,
90
+ )
88
91
 
89
92
  # Subsequent calls: library reuses the cached token
90
- achievements = api_client.wow.game_data.get_achievements_index("us", "en_US")
93
+ achievements = api_client.wow.game_data.get_achievements_index(
94
+ region=Region.US,
95
+ locale=Locale.EN_US,
96
+ )
91
97
 
92
98
  # When token expires: library automatically refreshes it
93
99
  # You don't need to manage tokens manually!
@@ -102,16 +108,19 @@ You can pass in a `client_id` and `client_secret` and use almost any endpoint ex
102
108
  2. Sends it via `Authorization: Bearer <token>` header
103
109
  3. Keeps tokens out of URL query strings
104
110
 
105
- Here is the list of endpoints, specified by Blizzard, that require an OAuth token:
106
-
107
- ```
108
- GET /oauth/userinfo
109
- GET /profile/user/wow
110
- GET /profile/user/wow/protected-character/{realm-id}-{character-id}
111
- GET /profile/user/wow/collections
112
- GET /profile/user/wow/collections/pets
113
- GET /profile/user/wow/collections/mounts
114
- ```
111
+ Here is the list of endpoints, and related API methods, that require an OAuth authorization code token:
112
+
113
+ | Resource path | API call |
114
+ | ------------- | -------- |
115
+ | /userinfo | `.battlenet.oauth.get_user_info(access_token)` |
116
+ | /profile/user/wow | `.wow.profile.get_account_profile_summary(access_token)` |
117
+ | /profile/user/wow/protected-character/{realm-id}-{character-id} | `.wow.profile.get_protected_character_profile_summary(access_token, realm_id, character_id)` |
118
+ | /profile/user/wow/collections | `.wow.profile.get_account_collections_index(access_token)` |
119
+ | /profile/user/wow/collections/heirlooms | `.wow.profile.get_account_heirlooms_collection_summary(access_token)` |
120
+ | /profile/user/wow/collections/mounts | `.wow.profile.get_account_mounts_collection_summary(access_token)` |
121
+ | /profile/user/wow/collections/pets | `.wow.profile.get_account_pets_collection_summary(access_token)` |
122
+ | /profile/user/wow/collections/toys | `.wow.profile.get_account_toys_collection_summary(access_token)` |
123
+ | /profile/user/wow/collections/transmogs | `.wow.profile.get_account_transmog_collection_summary(access_token)` |
115
124
 
116
125
  **Note:** For these protected endpoints, you must implement the OAuth authorization code flow in your application to obtain a user access token. The library does not handle the OAuth flow itself - it only accepts and uses the token you provide.
117
126
 
@@ -3,3 +3,4 @@
3
3
  from requests.exceptions import * # noqa
4
4
 
5
5
  from .blizzard_api import BlizzardApi # noqa
6
+ from .types import Locale, Region # noqa
@@ -3,8 +3,6 @@
3
3
  from datetime import UTC, datetime, timedelta
4
4
  from typing import Any, Optional
5
5
 
6
- import requests
7
-
8
6
  from .endpoint import ApiEndpoint
9
7
  from .types import Locale, OptionalLocale, OptionalRegion, Region
10
8
 
@@ -38,7 +36,6 @@ class BaseApi(ApiEndpoint):
38
36
  def extend_endpoint(self) -> None:
39
37
  self._access_token: Optional[str] = None
40
38
  self._token_expires_at: Optional[datetime] = None
41
- self._session = requests.Session()
42
39
 
43
40
  def _is_token_expired(self) -> bool:
44
41
  """Check if the token is expiring within the refresh buffer window."""
@@ -56,7 +53,7 @@ class BaseApi(ApiEndpoint):
56
53
  The token response from the API.
57
54
  """
58
55
  url = self._build_oauth_url("/oauth/token", region)
59
- response = self._session.post(
56
+ response = self.session.post(
60
57
  url,
61
58
  params={"grant_type": "client_credentials"},
62
59
  auth=(self.client_id, self._client_secret),
@@ -137,7 +134,7 @@ class BaseApi(ApiEndpoint):
137
134
  token = self._access_token
138
135
 
139
136
  # Make the request
140
- response = self._session.get(
137
+ response = self.session.get(
141
138
  url,
142
139
  params=params,
143
140
  headers={"Authorization": f"Bearer {token}"},
@@ -148,7 +145,7 @@ class BaseApi(ApiEndpoint):
148
145
  if response.status_code == 401 and not user_token:
149
146
  # Token might have expired, refresh and retry
150
147
  self._get_client_token(region)
151
- response = self._session.get(
148
+ response = self.session.get(
152
149
  url,
153
150
  params=params,
154
151
  headers={"Authorization": f"Bearer {self._access_token}"},
@@ -0,0 +1,5 @@
1
+ """__init__.py file."""
2
+
3
+ from ..types import Locale, Region # noqa
4
+ from .battlenet_api import BattlenetApi # noqa
5
+ from .battlenet_oauth_api import BattlenetOAuthApi # noqa
@@ -11,9 +11,12 @@ class BattlenetApi(ApiEndpoint):
11
11
  client_id (str): A string client id supplied by Blizzard.
12
12
  client_secret (str): A string client secret supplied by Blizzard.
13
13
  region (Region, optional): Default region to use for requests.
14
+ session (requests.Session, optional): A default session to use for requests.
14
15
  oauth (BattlenetOAuthApi): An instance of the BattlenetOAuthApi class for accessing OAuth endpoints.
15
16
  """
16
17
 
17
18
  def extend_endpoint(self) -> None:
18
19
  """Init BattlenetApi."""
19
- self.oauth = BattlenetOAuthApi(self.client_id, self.client_secret, self.region)
20
+ self.oauth = BattlenetOAuthApi(
21
+ self.client_id, self.client_secret, region=self.region, session=self.session
22
+ )
@@ -38,7 +38,7 @@ class BattlenetOAuthApi(BaseApi):
38
38
  requests.HTTPError: If the API request fails (raised via
39
39
  ``response.raise_for_status()`` in ``BaseApi._make_request``).
40
40
  """
41
- resource = "/oauth/userinfo"
41
+ resource = "/userinfo"
42
42
  query_params = {
43
43
  "access_token": access_token,
44
44
  }
@@ -29,14 +29,34 @@ class BlizzardApi(ApiEndpoint):
29
29
  """
30
30
 
31
31
  def extend_endpoint(self) -> None:
32
- self.wow = WowApi(self.client_id, self.client_secret, self.region, self.locale)
32
+ self.wow = WowApi(
33
+ self.client_id,
34
+ self.client_secret,
35
+ region=self.region,
36
+ locale=self.locale,
37
+ session=self.session,
38
+ )
33
39
  self.diablo3 = Diablo3Api(
34
- self.client_id, self.client_secret, self.region, self.locale
40
+ self.client_id,
41
+ self.client_secret,
42
+ region=self.region,
43
+ locale=self.locale,
44
+ session=self.session,
35
45
  )
36
46
  self.hearthstone = HearthstoneApi(
37
- self.client_id, self.client_secret, self.region, self.locale
47
+ self.client_id,
48
+ self.client_secret,
49
+ region=self.region,
50
+ locale=self.locale,
51
+ session=self.session,
38
52
  )
39
53
  self.starcraft2 = Starcraft2Api(
40
- self.client_id, self.client_secret, self.region, self.locale
54
+ self.client_id,
55
+ self.client_secret,
56
+ region=self.region,
57
+ locale=self.locale,
58
+ session=self.session,
59
+ )
60
+ self.battlenet = BattlenetApi(
61
+ self.client_id, self.client_secret, region=self.region, session=self.session
41
62
  )
42
- self.battlenet = BattlenetApi(self.client_id, self.client_secret, self.region)
@@ -0,0 +1,4 @@
1
+ """__init__.py file."""
2
+
3
+ from ..types import Locale, Region # noqa
4
+ from .diablo3_api import Diablo3Api # noqa
@@ -4,8 +4,7 @@ This module provides access to the Diablo III API endpoints,
4
4
  including game data and community information.
5
5
  """
6
6
 
7
- from blizzardapi2.endpoint import ApiEndpoint
8
-
7
+ from ..endpoint import ApiEndpoint
9
8
  from .diablo3_community_api import Diablo3CommunityApi
10
9
  from .diablo3_game_data_api import Diablo3GameDataApi
11
10
 
@@ -18,14 +17,23 @@ class Diablo3Api(ApiEndpoint):
18
17
  the Diablo3CommunityApi and Diablo3GameDataApi components.
19
18
 
20
19
  Attributes:
20
+ client_id: A string client id supplied by Blizzard.
21
+ client_secret: A string client secret supplied by Blizzard.
22
+ region (Region, optional): A default region to use for requests.
23
+ locale (Locale, optional): A default locale to use for community requests.
24
+ session (requests.Session, optional): A default session to use for requests.
21
25
  community: The community API client.
22
26
  game_data: The game data API client.
23
27
  """
24
28
 
25
29
  def extend_endpoint(self) -> None:
26
30
  self.community = Diablo3CommunityApi(
27
- self.client_id, self.client_secret, self.region, self.locale
31
+ self.client_id,
32
+ self.client_secret,
33
+ region=self.region,
34
+ locale=self.locale,
35
+ session=self.session,
28
36
  )
29
37
  self.game_data = Diablo3GameDataApi(
30
- self.client_id, self.client_secret, self.region
38
+ self.client_id, self.client_secret, region=self.region, session=self.session
31
39
  )
@@ -1,4 +1,4 @@
1
- from typing import Any, Optional
1
+ from typing import Any
2
2
 
3
3
  from ..api import BaseApi
4
4
  from ..types import OptionalRegion
@@ -1,5 +1,9 @@
1
1
  """endpoint.py file."""
2
2
 
3
+ from typing import Optional
4
+
5
+ import requests
6
+
3
7
  from .types import OptionalLocale, OptionalRegion
4
8
 
5
9
 
@@ -13,16 +17,19 @@ class ApiEndpoint:
13
17
  Attributes:
14
18
  client_id (str): The Blizzard API client ID.
15
19
  client_secret (str): The Blizzard API client secret.
16
- region (Region or str, optional): A default region to use for requests.
17
- locale (Locale or str, optional): A default locale to use for requests.
20
+ region (Region, optional): A default region to use for requests.
21
+ locale (Locale, optional): A default locale to use for requests.
22
+ session (requests.Session, optional): A session object for making HTTP requests.
18
23
  """
19
24
 
20
25
  def __init__(
21
26
  self,
22
27
  client_id: str,
23
28
  client_secret: str,
29
+ *,
24
30
  region: OptionalRegion = None,
25
31
  locale: OptionalLocale = None,
32
+ session: Optional[requests.Session] = None,
26
33
  ) -> None:
27
34
  """Initialize the API endpoint.
28
35
 
@@ -35,6 +42,7 @@ class ApiEndpoint:
35
42
  self._client_secret = client_secret
36
43
  self._region = region
37
44
  self._locale = locale
45
+ self._session = session if session is not None else requests.Session()
38
46
  self.extend_endpoint()
39
47
 
40
48
  def extend_endpoint(self) -> None:
@@ -79,3 +87,12 @@ class ApiEndpoint:
79
87
  OptionalLocale: the default locale used for queries or None if no default was provided
80
88
  """
81
89
  return self._locale
90
+
91
+ @property
92
+ def session(self) -> requests.Session:
93
+ """Get the HTTP session
94
+
95
+ Returns:
96
+ requests.Session: The session object for making HTTP requests
97
+ """
98
+ return self._session
@@ -0,0 +1,4 @@
1
+ """__init__.py file."""
2
+
3
+ from ..types import Locale, Region # noqa
4
+ from .hearthstone_api import HearthstoneApi # noqa
@@ -26,13 +26,18 @@ class HearthstoneApi(ApiEndpoint):
26
26
  Attributes:
27
27
  client_id: The Blizzard API client ID.
28
28
  client_secret: The Blizzard API client secret.
29
- region: Default region to use for requests.
30
- locale: Default locale to use for requests.
29
+ region (Region, optional): A default region to use for requests.
30
+ locale (Locale, optional): A default locale to use for community requests.
31
+ session (requests.Session, optional): A default session to use for requests.
31
32
  game_data: The Hearthstone game-data API client.
32
33
  """
33
34
 
34
35
  def extend_endpoint(self) -> None:
35
36
  """Add the Hearthstone game-data endpoint."""
36
37
  self.game_data = HearthstoneGameDataApi(
37
- self.client_id, self.client_secret, self.region, self.locale
38
+ self.client_id,
39
+ self.client_secret,
40
+ region=self.region,
41
+ locale=self.locale,
42
+ session=self.session,
38
43
  )
@@ -0,0 +1,4 @@
1
+ """__init__.py file."""
2
+
3
+ from ..types import Locale, Region # noqa
4
+ from .starcraft2_api import Starcraft2Api # noqa
@@ -1,11 +1,13 @@
1
- from typing import Optional
1
+ """StarCraft2 API client.
2
+
3
+ This module provides access to the StarCraft2 API endpoints,
4
+ including game data and community information.
5
+ """
2
6
 
3
7
  from ..endpoint import ApiEndpoint
4
8
  from .starcraft2_community_api import Starcraft2CommunityApi
5
9
  from .starcraft2_game_data_api import Starcraft2GameDataApi
6
10
 
7
- """starcraft2_api.py file."""
8
-
9
11
 
10
12
  class Starcraft2Api(ApiEndpoint):
11
13
  """Starcraft2 API class.
@@ -15,6 +17,7 @@ class Starcraft2Api(ApiEndpoint):
15
17
  client_secret: A string client secret supplied by Blizzard.
16
18
  region (Region, optional): A default region to use for requests.
17
19
  locale (Locale, optional): A default locale to use for community requests.
20
+ session (requests.Session, optional): A default session to use for requests.
18
21
  community: An instance of ``Starcraft2CommunityApi`` for accessing community services.
19
22
  game_data: An instance of ``Starcraft2GameDataApi`` for accessing game data services.
20
23
  """
@@ -22,8 +25,12 @@ class Starcraft2Api(ApiEndpoint):
22
25
  def extend_endpoint(self) -> None:
23
26
  """Init Starcraft2."""
24
27
  self.community: Starcraft2CommunityApi = Starcraft2CommunityApi(
25
- self.client_id, self.client_secret, self.region, self.locale
28
+ self.client_id,
29
+ self.client_secret,
30
+ region=self.region,
31
+ locale=self.locale,
32
+ session=self.session,
26
33
  )
27
34
  self.game_data: Starcraft2GameDataApi = Starcraft2GameDataApi(
28
- self.client_id, self.client_secret, self.region
35
+ self.client_id, self.client_secret, region=self.region, session=self.session
29
36
  )
@@ -3,7 +3,7 @@
3
3
  from typing import Any
4
4
 
5
5
  from ..api import LocaleApi
6
- from ..types import OptionalLocale, OptionalRegion, Region
6
+ from ..types import OptionalLocale, OptionalRegion
7
7
 
8
8
 
9
9
  class Starcraft2CommunityApi(LocaleApi):
@@ -1,6 +1,6 @@
1
1
  """starcraft2_game_data_api.py file."""
2
2
 
3
- from typing import Any, Optional
3
+ from typing import Any
4
4
 
5
5
  from ..api import BaseApi
6
6
  from ..types import OptionalRegion
@@ -0,0 +1,4 @@
1
+ """__init__.py file."""
2
+
3
+ from ..types import Locale, Region # noqa
4
+ from .wow_api import WowApi # noqa