Skip to content

Commit 6b5ffe7

Browse files
authored
Add profile api by Soulofdestiny (#12)
* Fix Typo in variable name "region" * Add Wrapper for Profile API * Add tests
1 parent 70a8ed1 commit 6b5ffe7

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

tests/test_api.py

+32
Original file line numberDiff line numberDiff line change
@@ -574,3 +574,35 @@ def test_get_token(self, response_mock):
574574
params['namespace'] = 'dynamic-us'
575575
response_mock.assert_called_with(
576576
'https://us.api.blizzard.com/data/wow/token/index', params=params)
577+
578+
# ---------------------------------------------------------------------------------------------
579+
# Profile API tests
580+
# ---------------------------------------------------------------------------------------------
581+
582+
# WoW Mythic Keystone Character Profile API
583+
584+
def test_get_character_mythic_keystone_profile(self, response_mock):
585+
self.authorized_api.get_character_mythic_keystone_profile(
586+
'us', 'blackmoore', 'ayanda', 'profile-us')
587+
588+
params = copy.deepcopy(self.params)
589+
params['namespace'] = 'profile-us'
590+
591+
base_url = 'https://us.api.blizzard.com'
592+
response_mock.assert_called_with(
593+
'{0}/profile/wow/character/blackmoore/ayanda/mythic-keystone-profile'.format(base_url),
594+
params=params)
595+
596+
def test_get_character_mythic_keystone_profile_season(self, response_mock):
597+
self.authorized_api.get_character_mythic_keystone_profile_season(
598+
'us', 'blackmoore', 'ayanda', 'profile-us', '1')
599+
600+
params = copy.deepcopy(self.params)
601+
params['namespace'] = 'profile-us'
602+
603+
response_mock.assert_called_with(
604+
'{0}/profile/wow/character/blackmoore/ayanda/mythic-keystone-profile/season/1'.format(
605+
'https://us.api.blizzard.com'
606+
),
607+
params=params
608+
)

wowapi/api.py

+33-2
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,40 @@ def get_region(self, region, namespace, region_id, **filters):
582582

583583
# WoW Token API
584584

585-
def get_token(self, regiom, namespace, **filters):
585+
def get_token(self, region, namespace, **filters):
586586
"""
587587
Game data api - get Wow token
588588
"""
589589
filters['namespace'] = namespace
590-
return self.get_resource('data/wow/token/index', regiom, **filters)
590+
return self.get_resource('data/wow/token/index', region, **filters)
591+
592+
# ---------------------------------------------------------------------------------------------
593+
# Profile API wrappers
594+
# ---------------------------------------------------------------------------------------------
595+
596+
# WoW Mythic Keystone Character Profile API
597+
598+
def get_character_mythic_keystone_profile(self,
599+
region, realm_slug, character_name, namespace,
600+
**filters):
601+
"""
602+
Profile api - get keystone character profile
603+
"""
604+
filters['namespace'] = namespace
605+
return self.get_resource(
606+
'profile/wow/character/{0}/{1}/mythic-keystone-profile',
607+
region, *[realm_slug, character_name], **filters
608+
)
609+
610+
def get_character_mythic_keystone_profile_season(self,
611+
region, realm_slug, character_name, namespace,
612+
season_id,
613+
**filters):
614+
"""
615+
Profile api - get keystone character profile for specific season
616+
"""
617+
filters['namespace'] = namespace
618+
return self.get_resource(
619+
'profile/wow/character/{0}/{1}/mythic-keystone-profile/season/{2}',
620+
region, *[realm_slug, character_name, season_id], **filters
621+
)

0 commit comments

Comments
 (0)