Skip to content

Commit d13c980

Browse files
authored
Merge pull request #9 from dev-ruby/dev
Separate model classes
2 parents 188e76d + b72b70d commit d13c980

33 files changed

+743
-353
lines changed

TrackerGG/HTTPClients/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919
from .httpclient import ResponseData
2020
from .httpclient import Route
2121
from .httpclient import get_http_client
22+
23+
__all__ = ["AbstractHTTPClient", "HTTPClientLibrary", "RequestMethod", "ResponseData", "Route", "get_http_client"]

TrackerGG/HTTPClients/abstract_http_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
"""
1515

1616
from abc import *
17-
from typing import Optional, Dict
17+
from typing import *
1818

1919
from .httpclient import ResponseData, Route
2020

21+
__all__ = ["AbstractHTTPClient"]
22+
2123

2224
class AbstractHTTPClient(metaclass=ABCMeta):
2325
def __new__(cls, *args, **kwargs):

TrackerGG/HTTPClients/aiohttp_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515

1616
import asyncio
1717
import atexit
18-
from typing import ClassVar, Optional, Union, Dict
18+
from typing import *
1919

2020
import aiohttp
2121

2222
from .abstract_http_client import AbstractHTTPClient
2323
from .httpclient import MISSING, ResponseData, Route
2424

25+
__all__ = ["AiohttpHTTPClient"]
26+
2527

2628
class AiohttpHTTPClient(AbstractHTTPClient):
2729
USER_AGENT: ClassVar[str] = "Mozilla/5.0"

TrackerGG/HTTPClients/httpclient.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616
import asyncio
1717
from enum import Enum, auto
18-
from typing import ClassVar, Optional, Dict, Any
18+
from typing import *
19+
20+
21+
__all__ = ["HTTPClientLibrary", "get_http_client", "ResponseData", "Route", "RequestMethod", "MISSING"]
1922

2023

2124
class Missing:
@@ -30,9 +33,7 @@ class HTTPClientLibrary(Enum):
3033
HTTPX = auto()
3134

3235

33-
def get_http_client(
34-
loop: asyncio.AbstractEventLoop, api_key: str, lib: Optional[HTTPClientLibrary] = None
35-
):
36+
def get_http_client(loop: asyncio.AbstractEventLoop, api_key: str, lib: Optional[HTTPClientLibrary] = None):
3637
if lib is None:
3738
try:
3839
import aiohttp

TrackerGG/HTTPClients/httpx_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
"""
1515

1616
import asyncio
17-
from typing import ClassVar, Optional, Union, Dict
17+
from typing import *
1818

1919
import httpx
2020

2121
from .abstract_http_client import AbstractHTTPClient
2222
from .httpclient import ResponseData, Route
2323

24+
__all__ = ["HttpxHTTPClient"]
25+
2426

2527
class HttpxHTTPClient(AbstractHTTPClient):
2628
USER_AGENT: ClassVar[str] = "Mozilla/5.0"

TrackerGG/Models/Apex/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Copyright (c) 2023 DevRuby
5+
6+
MIT License
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
10+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
14+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
15+
OTHER DEALINGS IN THE SOFTWARE.
16+
17+
"""
18+
19+
from .apex_profile import ApexProfile
20+
from .apex_query_data import ApexQueryData
21+
from .apex_segment import ApexSegment
22+
from .apex_stats import ApexStats
23+
24+
__all__ = ["ApexProfile", "ApexQueryData", "ApexSegment", "ApexStats"]

TrackerGG/Models/Apex/apex_profile.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Copyright (c) 2023 DevRuby
5+
6+
MIT License
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
10+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
14+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
15+
OTHER DEALINGS IN THE SOFTWARE.
16+
17+
"""
18+
19+
from typing import *
20+
21+
from TrackerGG.Models.General import PlatformInfo, UserInfo
22+
from .apex_segment import ApexSegment
23+
24+
__all__ = ["ApexProfile"]
25+
26+
27+
class ApexProfile:
28+
def __init__(self, data: Dict[str, Any]):
29+
segments = []
30+
for seg in data["segments"]:
31+
segments.append(ApexSegment(seg))
32+
33+
self.platform_info: PlatformInfo = PlatformInfo(data["platformInfo"])
34+
self.user_info: UserInfo = UserInfo(data["userInfo"])
35+
self.segments: List[ApexSegment] = segments
36+
self.expiry_date: str = data["expiryDate"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Copyright (c) 2023 DevRuby
5+
6+
MIT License
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
10+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
14+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
15+
OTHER DEALINGS IN THE SOFTWARE.
16+
17+
"""
18+
from typing import *
19+
20+
__all__ = ["ApexQueryData"]
21+
22+
23+
class ApexQueryData:
24+
def __init__(self, data: Dict[str, Optional[Union[str, int]]]):
25+
self.platform_id: int = int(data["platformId"])
26+
self.platform_slug: str = data["platformSlug"]
27+
self.platform_user_identifier: str = data["platformUserIdentifier"]
28+
self.platform_user_id: str = data["platformUserId"]
29+
self.platform_user_handle: str = data["platformUserHandle"]
30+
self.avatar_url: Optional[str] = data["avatarUrl"]
31+
self.status: Optional[str] = data["status"]
32+
self.additional_parameters: Optional[str] = data["additionalParameters"]

TrackerGG/Models/Apex/apex_segment.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Copyright (c) 2023 DevRuby
5+
6+
MIT License
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
10+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
14+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
15+
OTHER DEALINGS IN THE SOFTWARE.
16+
17+
"""
18+
19+
from typing import *
20+
21+
from .apex_stats import ApexStats
22+
23+
__all__ = ["ApexSegment"]
24+
25+
26+
class ApexSegment:
27+
def __init__(self, data: Dict[str, Union[str, dict]]):
28+
self.type: str = data["type"]
29+
self.attributes: dict = data["attributes"]
30+
self.metadata: dict = data["metadata"]
31+
self.expiry_date: str = data["expiryDate"]
32+
self.stats: ApexStats = ApexStats(data["stats"])

TrackerGG/Models/Apex/apex_stats.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Copyright (c) 2023 DevRuby
5+
6+
MIT License
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
10+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
14+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
15+
OTHER DEALINGS IN THE SOFTWARE.
16+
17+
"""
18+
19+
from typing import *
20+
21+
from TrackerGG.Models.General import Stat
22+
23+
__all__ = ["ApexStats"]
24+
25+
26+
class ApexStats:
27+
def __init__(self, data: Dict[str, dict]):
28+
self.level: Optional[Stat] = Stat(data.get("level"))
29+
self.kills: Optional[Stat] = Stat(data.get("kills"))
30+
self.kills_per_match: Optional[Stat] = Stat(data.get("killsPerMatch"))
31+
self.winning_kills: Optional[Stat] = Stat(data.get("winningKills"))
32+
self.kills_as_kill_leader: Optional[Stat] = Stat(data.get("killsAsKillLeader"))
33+
self.damage: Optional[Stat] = Stat(data.get("damage"))
34+
self.matches_played: Optional[Stat] = Stat(data.get("matchesPlayed"))
35+
self.revives: Optional[Stat] = Stat(data.get("revives"))
36+
self.sniper_kills: Optional[Stat] = Stat(data.get("sniperKills"))
37+
self.rank_score: Optional[Stat] = Stat(data.get("rankScore"))
38+
self.arena_rank_score: Optional[Stat] = Stat(data.get("arenaRankScore"))
39+
self.beast_of_the_hunt_kills: Optional[Stat] = Stat(data.get("beastOfTheHuntKills"))
40+
self.grapple_travel_distance: Optional[Stat] = Stat(data.get("grappleTravelDistance"))
41+
self.voices_warnings_heard: Optional[Stat] = Stat(data.get("voicesWarningsHeard"))
42+
self.voices_warnings_heard: Optional[Stat] = Stat(data.get("voicesWarningsHeard"))

0 commit comments

Comments
 (0)