Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 6e69a96

Browse files
author
Trevor Phillips
authored
Merge pull request #1 from trevorphillips/d3
finalized d3 endpoints
2 parents 0cd9cd6 + 98afbf3 commit 6e69a96

12 files changed

+479
-104
lines changed

.github/workflows/python-package.yml

-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,5 @@ jobs:
3737
run: |
3838
pytest
3939
- name: Codecov Report
40-
env:
41-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4240
run: |
4341
bash <(curl -s https://codecov.io/bash)

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
devinstall:
2+
pip install -r requirements.txt
3+
14
clean:
25
rm -rf dist
36
rm -rf build

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Current supported features include:
77
- Battle.net User
88
- WoW Profile
99
- WoW Game Data
10+
- Diablo 3 Community
1011
- Diablo 3 Game Data
1112

1213
To gain access to Blizzard's API please register [here](https://develop.battle.net/access/) to obtain a client id and client secret.

blizzardapi/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ def _format_oauth_url(self, resource, region):
8282

8383
return url
8484

85-
def get_oauth_resource(self, resource, region, query_params):
85+
def get_oauth_resource(self, resource, region, query_params={}):
8686
url = self._format_oauth_url(resource, region)
8787
return self._request_handler(url, region, query_params)

blizzardapi/battlenet/battlenet_oauth_api.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from urllib import parse
2-
31
from ..api import Api
42

53

@@ -13,7 +11,8 @@ def __init__(self, client_id, client_secret):
1311

1412
def get_user_info(self, region, access_token):
1513
"""
16-
User Authentication - Returns basic information about the user associated with the current bearer token.
14+
User Authentication - Returns basic information about the user
15+
associated with the current bearer token.
1716
"""
1817
resource = "/oauth/userinfo"
1918
query_params = {

blizzardapi/diablo3/diablo3_api.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from .diablo3_community_api import Diablo3CommunityApi
12
from .diablo3_game_data_api import Diablo3GameDataApi
23

34

45
class Diablo3Api:
56
def __init__(self, client_id, client_secret):
7+
self.community = Diablo3CommunityApi(client_id, client_secret)
68
self.game_data = Diablo3GameDataApi(client_id, client_secret)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
from ..api import Api
2+
3+
4+
class Diablo3CommunityApi(Api):
5+
"""All Community API methods"""
6+
7+
def __init__(self, client_id, client_secret):
8+
super().__init__(client_id, client_secret)
9+
10+
# D3 Act API
11+
12+
def get_act_index(self, region, locale):
13+
"""
14+
D3 Act API - Returns an index of acts.
15+
"""
16+
resource = "/d3/data/act"
17+
query_params = {"locale": locale}
18+
return super().get_resource(resource, region, query_params)
19+
20+
def get_act(self, region, locale, act_id):
21+
"""
22+
D3 Act API - Returns a single act by ID.
23+
"""
24+
resource = f"/d3/data/act/{act_id}"
25+
query_params = {"locale": locale}
26+
return super().get_resource(resource, region, query_params)
27+
28+
# D3 Artisan and Recipe API
29+
30+
def get_artisan(self, region, locale, artisan_slug):
31+
"""
32+
D3 Artisan and Recipe API - Returns a single artisan by slug.
33+
"""
34+
resource = f"/d3/data/artisan/{artisan_slug}"
35+
query_params = {"locale": locale}
36+
return super().get_resource(resource, region, query_params)
37+
38+
def get_recipe(self, region, locale, artisan_slug, recipe_slug):
39+
"""
40+
D3 Artisan and Recipe API - Returns a single recipe by slug for the
41+
specified artisan.
42+
"""
43+
resource = f"/d3/data/artisan/{artisan_slug}/recipe/{recipe_slug}"
44+
query_params = {"locale": locale}
45+
return super().get_resource(resource, region, query_params)
46+
47+
# D3 Follower API
48+
49+
def get_follower(self, region, locale, follower_slug):
50+
"""
51+
D3 Follower API - Returns a single follower by slug.
52+
"""
53+
resource = f"/d3/data/follower/{follower_slug}"
54+
query_params = {"locale": locale}
55+
return super().get_resource(resource, region, query_params)
56+
57+
# D3 Character Class and Skill API
58+
59+
def get_character_class(self, region, locale, class_slug):
60+
"""
61+
D3 Character Class and Skill API - Returns a single character class by
62+
slug.
63+
"""
64+
resource = f"/d3/data/hero/{class_slug}"
65+
query_params = {"locale": locale}
66+
return super().get_resource(resource, region, query_params)
67+
68+
def get_api_skill(self, region, locale, class_slug, skill_slug):
69+
"""
70+
D3 Character Class and Skill API - Returns a single skill by slug for a
71+
specific character class.
72+
"""
73+
resource = f"/d3/data/hero/{class_slug}/skill/{skill_slug}"
74+
query_params = {"locale": locale}
75+
return super().get_resource(resource, region, query_params)
76+
77+
# D3 Item Type API
78+
79+
def get_item_type_index(self, region, locale):
80+
"""
81+
D3 Item Type API - Returns an index of item types.
82+
"""
83+
resource = "/d3/data/item-type"
84+
query_params = {"locale": locale}
85+
return super().get_resource(resource, region, query_params)
86+
87+
def get_item_type(self, region, locale, item_type_slug):
88+
"""
89+
D3 Item Type API - Returns a single item type by slug.
90+
"""
91+
resource = f"/d3/data/item-type/{item_type_slug}"
92+
query_params = {"locale": locale}
93+
return super().get_resource(resource, region, query_params)
94+
95+
# D3 Item API
96+
97+
def get_item(self, region, locale, item_slug_id):
98+
"""
99+
D3 Item API - Returns a single item by item slug and ID.
100+
"""
101+
resource = f"/d3/data/item/{item_slug_id}"
102+
query_params = {"locale": locale}
103+
return super().get_resource(resource, region, query_params)
104+
105+
# D3 Profile API
106+
107+
def get_api_account(self, region, locale, account_id):
108+
"""
109+
D3 Profile API - Returns the specified account profile.
110+
"""
111+
resource = f"/d3/profile/{account_id}/"
112+
query_params = {"locale": locale}
113+
return super().get_resource(resource, region, query_params)
114+
115+
def get_api_hero(self, region, locale, account_id, hero_id):
116+
"""
117+
D3 Profile API - Returns a single hero.
118+
"""
119+
resource = f"/d3/profile/{account_id}/hero/{hero_id}"
120+
query_params = {"locale": locale}
121+
return super().get_resource(resource, region, query_params)
122+
123+
def get_api_detailed_hero_items(self, region, locale, account_id, hero_id):
124+
"""
125+
D3 Profile API - Returns a list of items for the specified hero.
126+
"""
127+
resource = f"/d3/profile/{account_id}/hero/{hero_id}/items"
128+
query_params = {"locale": locale}
129+
return super().get_resource(resource, region, query_params)
130+
131+
def get_api_detailed_follower_items(
132+
self, region, locale, account_id, hero_id
133+
):
134+
"""
135+
D3 Profile API - Returns a single item by item slug and ID.
136+
"""
137+
resource = f"/d3/profile/{account_id}/hero/{hero_id}/follower-items"
138+
query_params = {"locale": locale}
139+
return super().get_resource(resource, region, query_params)

0 commit comments

Comments
 (0)