Skip to content

Commit

Permalink
Merge pull request #18 from stas-bool/master
Browse files Browse the repository at this point in the history
add get_historical_stats_for_account endpoint
  • Loading branch information
jgayfer authored Jun 30, 2020
2 parents 68358e9 + 335d289 commit ff3db87
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,22 @@ See [Destiny.HistoricalStats.DestinyHistoricalStatsByPeriod](https://bungie-net.

---

> get_historical_stats_for_account(membership_type, membership_id, groups=[])
This function is a coroutine.

Gets aggregate historical stats organized around each character for a given account.

**Parameters**
- `membership_type` - A valid non-BungieNet membership type, or All. See [BungieMembershipType](https://bungie-net.github.io/multi/schema_BungieMembershipType.html#schema_BungieMembershipType)
- `membership_id` - The full gamertag or PSN id of the player. Spaces and case are ignored.
- `groups` - A list containing the groups of stats to include in the response (see [Destiny.HistoricalStats.Definitions.DestinyStatsGroupType](https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyStatsGroupType.html#schema_Destiny-HistoricalStats-Definitions-DestinyStatsGroupType)).

**Response**
See [Destiny.HistoricalStats.DestinyHistoricalStatsAccountResult](https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-DestinyHistoricalStatsAccountResult.html#schema_Destiny-HistoricalStats-DestinyHistoricalStatsAccountResult)

---

> get_public_milestone_content(milestone_hash)
This function is a coroutine.
Expand Down
16 changes: 16 additions & 0 deletions pydest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,22 @@ async def get_historical_stats(self, membership_type, membership_id, character_i
url = url.format(membership_type, membership_id, character_id, ','.join([str(i) for i in groups]), ','.join([str(i) for i in modes]))
return await self._get_request(url)

async def get_historical_stats_for_account(self, membership_type, membership_id, groups=[]):
"""Gets aggregate historical stats organized around each character for a given account.
Args:
membership_type (int):
A valid non-BungieNet membership type (BungieMembershipType)
membership_id (int):
Destiny membership ID
groups (list - str/int):
A list containing the groups of stats to include in the response
(see Destiny.HistoricalStats.Definitions.DestinyStatsGroupType).
"""
url = DESTINY2_URL + '{}/Account/{}/Stats/?groups={}'
url = url.format(membership_type, membership_id, ','.join([str(i) for i in groups]))
return await self._get_request(url)


async def get_public_milestone_content(self, milestone_hash):
"""Gets custom localized content for the milestone of
Expand Down
13 changes: 12 additions & 1 deletion pydest/test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,15 @@ async def res(self):
destiny = pydest.Pydest(api_key)
r = await destiny.api.get_activity_history(self._membership_type, self._membership_id, 0, 1, None, 0)
await destiny.close()
return r
return r


class TestGetHistoricalStatsForAccount(BaseTestClass):

@pytest.mark.asyncio
@pytest.fixture
async def res(self):
destiny = pydest.Pydest(api_key)
r = await destiny.api.get_historical_stats_for_account(self._membership_type, self._membership_id, [0])
await destiny.close()
return r

0 comments on commit ff3db87

Please sign in to comment.