Skip to content
This repository was archived by the owner on Jan 12, 2021. It is now read-only.

Commit f1f3fde

Browse files
committed
Account importing now works
1 parent 7cd3a33 commit f1f3fde

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

HoH/D3API.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ class D3API:
1212
endpoint = None
1313
username = None
1414
id = None
15-
region_id = None
1615
region = None
1716

18-
api_key = 'uevsvyrvw5qw6tksskk8r7em73ghbjck'
17+
api_key = 'kk'
1918
locale = 'fr_FR'
2019

21-
def __init__(self, region, region_id, username, id):
22-
self.endpoint = 'https://{}.api.battle.net/d3/'.format(region)
20+
def __init__(self, region, username, id):
21+
self.endpoint = 'https://{}.api.battle.net/d3/'.format(region.slug)
2322

2423
self.region = region
2524
self.username = username
2625
self.id = id
27-
self.region_id = region_id
2826

2927
def _call(self, endpoint):
3028
endpoint = endpoint + '?locale={}&apikey={}'.format(self.locale, self.api_key)
@@ -66,16 +64,16 @@ def import_profile(self):
6664

6765
db.session.add(account)
6866

69-
for hero in response:
70-
hero_class = Hero.query.filter(slug=hero.get('class')).first()
67+
for hero in response['heroes']:
68+
hero_class = HeroClass.query.filter_by(slug = hero['class']).first()
7169

7270
hero = Hero(
73-
hero.id,
74-
hero.name,
75-
hero.gender,
76-
True if response.lastHeroPlayed == hero.id else False,
77-
True if hero.seasonal == 1 else False,
78-
True if hero.hardcore == 1 else False,
71+
hero['id'],
72+
hero['name'],
73+
hero['gender'],
74+
True if response['lastHeroPlayed'] == hero['id'] else False,
75+
True if hero['seasonal'] == 1 else False,
76+
True if hero['hardcore'] == 1 else False,
7977
account,
8078
hero_class
8179
)

HoH/models/Account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ def __init__(self, battlenet_id, username, region, last_updated=None):
2020
def __repr__(self):
2121
return '<Account> #{} : {}'.format(self.id, self.username)
2222

23-
def already_exists( battlenet_id, username, account_region_id):
23+
def already_exists(battlenet_id, username, account_region_id):
2424
return Account.query.filter_by(battlenet_id = battlenet_id, username = username, account_region_id = account_region_id).count() > 0

HoH/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def import_account():
2929
return jsonify(result)
3030

3131
try:
32-
d3api = D3API(account_region.slug, account_region_id, username, battlenet_id)
32+
d3api = D3API(account_region, username, battlenet_id)
3333

3434
d3api.import_profile()
3535

HoH/storage/db.sqlite

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)