diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-03-16 21:34:38 +0100 |
|---|---|---|
| committer | Kashif Memon <iamkashifmemon@gmail.com> | 2017-03-16 15:24:00 -0600 |
| commit | 9a4f0be81079c6d37f24b9183bc6d296369d55f6 (patch) | |
| tree | cca0a44fb7d1673d8a01a64b942bc730aa9d9713 | |
| parent | 6ec993bdc3bb37360dc4a1165f6a054224d7abd5 (diff) | |
| download | python-gamelocker-9a4f0be81079c6d37f24b9183bc6d296369d55f6.tar.gz python-gamelocker-9a4f0be81079c6d37f24b9183bc6d296369d55f6.zip | |
Example added for Telemetry.
Signed-off-by: Kashif Memon <iamkashifmemon@gmail.com>
| -rw-r--r-- | examples/telemetry-access.py | 31 | ||||
| -rw-r--r-- | gamelocker/datatypes.py | 13 | ||||
| -rw-r--r-- | tests/gamelocker_test.py | 5 |
3 files changed, 49 insertions, 0 deletions
diff --git a/examples/telemetry-access.py b/examples/telemetry-access.py new file mode 100644 index 0000000..166c8e9 --- /dev/null +++ b/examples/telemetry-access.py @@ -0,0 +1,31 @@ +#!/usrz/bin/python + +# +#How to access Telemetry using python - gamelocker# +# +import gamelocker +vgApiKey = '' +api = gamelocker.Gamelocker(vgApiKey).Vainglory() + + +# Get telemetry URL for a particular match played by IGN. +def getTelemetryInfo(IGN): + try: + matches = api.matches({ + "sort": "-createdAt", + "filter[playerNames]": IGN, + "filter[createdAt-start]": "2017-03-10T00:00:00Z", + "page[limit]": "1" + }) + + if (matches == False): + print("No Matches found") + else : + match = matches[0] + print('Time Played: ', match.createdAt) + print('GameMode: ', match.gameMode) + print(match.assets[0].name, match.assets[0].url) + except: + print("Invalid Name") + +getTelemetryInfo("IGN")
\ No newline at end of file diff --git a/gamelocker/datatypes.py b/gamelocker/datatypes.py index b1e83cf..afa0aad 100644 --- a/gamelocker/datatypes.py +++ b/gamelocker/datatypes.py @@ -38,6 +38,18 @@ def rel(typ, key): return attr(typ, key, True) +class Asset(DataMessage): + type_name = "asset" + key_id = attr(str, "id") + + url = attr(str, "URL") + content_type = attr(str, "contentType") + created_at = attr(str, "createdAt") + description = attr(str, "description") + filename = attr(str, "filename") + name = attr(str, "name") + + class Player(DataMessage): type_name = "player" key_id = attr(str, "id") @@ -85,6 +97,7 @@ class Match(DataMessage): stats = attr(dict, "stats") rosters = rel(Roster, "rosters") + assets = rel(Asset, "assets") def modulemap(): diff --git a/tests/gamelocker_test.py b/tests/gamelocker_test.py index c7a27a9..f94216f 100644 --- a/tests/gamelocker_test.py +++ b/tests/gamelocker_test.py @@ -41,6 +41,11 @@ class TestGamelocker: assert isinstance(matches[0], gamelocker.datatypes.Match) assert matches[0].duration > 0 + def test_asset(self, api): + match = api.match(elid="f73274b2-0a7f-11e7-a28f-0206eb3a2f5b", + region="eu") + assert isinstance(match.assets[0].url, str) + def test_region(self, api): assert len(api.matches(region="na", params={ |
