Skip to content

Commit

Permalink
Merge pull request #14 from hamlowl/feature/get_activity_history
Browse files Browse the repository at this point in the history
Added endpoint GetActivityHistory
  • Loading branch information
jgayfer authored Oct 28, 2019
2 parents c217308 + 9fd01ad commit 9c3c034
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,33 @@ This function is a coroutine.
This function retreives additional information for a milestone from the destiny2 Manifest.

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

---


> get_activity_history(membership_type, membership_id, character_id, count=1, mode=None, page=0)
This function is a coroutine.

Gets activity history stats for indicated character.

**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.
- `character_id` - ID of the character.
- `count` - Number of rows to return.
- `mode` - The game mode to include in the response (see [Destiny.HistoricalStats.Definitions.DestinyActivityModeType](https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType.html#schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType)).
- `page` - Page number to return, starting with 0.

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

---

For additional information on how the API endpoints function, refer to the [official documentation](https://bungie-net.github.io/multi/index.html).

---

## Running Tests

There is a series of integration tests that can be run to verify that Pydest is working as intended. These tests will hit all supported Destiny 2 endpoints with well formed requests, and verify that a valid response is received. The main reason reason that these tests would fail, is if the Bungie.net servers are down, or the endpoints themselves have changed.
Expand Down
25 changes: 25 additions & 0 deletions pydest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,28 @@ async def get_milestone_definitions(self, milestone_hash):
# /Manifest/DestinyMilestoneDefinition/{milestoneHash}
url = DESTINY2_URL + 'Manifest/DestinyMilestoneDefinition/{}'.format(milestone_hash)
return await self._get_request(url)

async def get_activity_history(self, membership_type, membership_id, character_id, count=1, mode=None, page=0):
"""Gets activity history stats for indicated character
Args:
membership_type (int):
A valid non-BungieNet membership type
membership_id (int):
The Destiny membershipId of the user to retrieve
character_id (int) [optional]:
The id of the character to retrieve stats for. If not provided, stats for all
characters will be retrieved.
count (int):
Number of rows to return
mode (int):
A filter for the activity mode to be returned. None returns all activities.
(see Destiny.HistoricalStats.Definitions.DestinyActivityModeType for valid values.)
page (int):
Page number to return, starting with 0
returns json(dict)
"""
# /{membershipType}/Account/{destinyMembershipId}/Character/{characterId}/Stats/Activities/
url = DESTINY2_URL + '{}/Account/{}/Character/{}/Stats/Activities/?mode={}&count={}&page={}'.format(membership_type, membership_id, character_id, mode, count, page)
return await self._get_request(url)
9 changes: 9 additions & 0 deletions pydest/test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,12 @@ async def res(self):
await destiny.close()
return r

class TestGetActivityHistory(BaseTestClass):

@pytest.mark.asyncio
@pytest.fixture
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

0 comments on commit 9c3c034

Please sign in to comment.