diff --git a/TrackerGG/HTTPClients/__init__.py b/TrackerGG/HTTPClients/__init__.py index 40e14ae..48e1bfe 100644 --- a/TrackerGG/HTTPClients/__init__.py +++ b/TrackerGG/HTTPClients/__init__.py @@ -19,3 +19,5 @@ from .httpclient import ResponseData from .httpclient import Route from .httpclient import get_http_client + +__all__ = ["AbstractHTTPClient", "HTTPClientLibrary", "RequestMethod", "ResponseData", "Route", "get_http_client"] diff --git a/TrackerGG/HTTPClients/abstract_http_client.py b/TrackerGG/HTTPClients/abstract_http_client.py index 864ac53..871f720 100644 --- a/TrackerGG/HTTPClients/abstract_http_client.py +++ b/TrackerGG/HTTPClients/abstract_http_client.py @@ -14,10 +14,12 @@ """ from abc import * -from typing import Optional, Dict +from typing import * from .httpclient import ResponseData, Route +__all__ = ["AbstractHTTPClient"] + class AbstractHTTPClient(metaclass=ABCMeta): def __new__(cls, *args, **kwargs): diff --git a/TrackerGG/HTTPClients/aiohttp_client.py b/TrackerGG/HTTPClients/aiohttp_client.py index 3d50934..3192e07 100644 --- a/TrackerGG/HTTPClients/aiohttp_client.py +++ b/TrackerGG/HTTPClients/aiohttp_client.py @@ -15,13 +15,15 @@ import asyncio import atexit -from typing import ClassVar, Optional, Union, Dict +from typing import * import aiohttp from .abstract_http_client import AbstractHTTPClient from .httpclient import MISSING, ResponseData, Route +__all__ = ["AiohttpHTTPClient"] + class AiohttpHTTPClient(AbstractHTTPClient): USER_AGENT: ClassVar[str] = "Mozilla/5.0" diff --git a/TrackerGG/HTTPClients/httpclient.py b/TrackerGG/HTTPClients/httpclient.py index 70331cf..31e2761 100644 --- a/TrackerGG/HTTPClients/httpclient.py +++ b/TrackerGG/HTTPClients/httpclient.py @@ -15,7 +15,10 @@ import asyncio from enum import Enum, auto -from typing import ClassVar, Optional, Dict, Any +from typing import * + + +__all__ = ["HTTPClientLibrary", "get_http_client", "ResponseData", "Route", "RequestMethod", "MISSING"] class Missing: @@ -30,9 +33,7 @@ class HTTPClientLibrary(Enum): HTTPX = auto() -def get_http_client( - loop: asyncio.AbstractEventLoop, api_key: str, lib: Optional[HTTPClientLibrary] = None -): +def get_http_client(loop: asyncio.AbstractEventLoop, api_key: str, lib: Optional[HTTPClientLibrary] = None): if lib is None: try: import aiohttp diff --git a/TrackerGG/HTTPClients/httpx_client.py b/TrackerGG/HTTPClients/httpx_client.py index e7caad8..24dbeeb 100644 --- a/TrackerGG/HTTPClients/httpx_client.py +++ b/TrackerGG/HTTPClients/httpx_client.py @@ -14,13 +14,15 @@ """ import asyncio -from typing import ClassVar, Optional, Union, Dict +from typing import * import httpx from .abstract_http_client import AbstractHTTPClient from .httpclient import ResponseData, Route +__all__ = ["HttpxHTTPClient"] + class HttpxHTTPClient(AbstractHTTPClient): USER_AGENT: ClassVar[str] = "Mozilla/5.0" diff --git a/TrackerGG/Models/Apex/__init__.py b/TrackerGG/Models/Apex/__init__.py new file mode 100644 index 0000000..15074d9 --- /dev/null +++ b/TrackerGG/Models/Apex/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from .apex_profile import ApexProfile +from .apex_query_data import ApexQueryData +from .apex_segment import ApexSegment +from .apex_stats import ApexStats + +__all__ = ["ApexProfile", "ApexQueryData", "ApexSegment", "ApexStats"] diff --git a/TrackerGG/Models/Apex/apex_profile.py b/TrackerGG/Models/Apex/apex_profile.py new file mode 100644 index 0000000..2a7a036 --- /dev/null +++ b/TrackerGG/Models/Apex/apex_profile.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from TrackerGG.Models.General import PlatformInfo, UserInfo +from .apex_segment import ApexSegment + +__all__ = ["ApexProfile"] + + +class ApexProfile: + def __init__(self, data: Dict[str, Any]): + segments = [] + for seg in data["segments"]: + segments.append(ApexSegment(seg)) + + self.platform_info: PlatformInfo = PlatformInfo(data["platformInfo"]) + self.user_info: UserInfo = UserInfo(data["userInfo"]) + self.segments: List[ApexSegment] = segments + self.expiry_date: str = data["expiryDate"] diff --git a/TrackerGG/Models/Apex/apex_query_data.py b/TrackerGG/Models/Apex/apex_query_data.py new file mode 100644 index 0000000..d6e8e29 --- /dev/null +++ b/TrackerGG/Models/Apex/apex_query_data.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" +from typing import * + +__all__ = ["ApexQueryData"] + + +class ApexQueryData: + def __init__(self, data: Dict[str, Optional[Union[str, int]]]): + self.platform_id: int = int(data["platformId"]) + self.platform_slug: str = data["platformSlug"] + self.platform_user_identifier: str = data["platformUserIdentifier"] + self.platform_user_id: str = data["platformUserId"] + self.platform_user_handle: str = data["platformUserHandle"] + self.avatar_url: Optional[str] = data["avatarUrl"] + self.status: Optional[str] = data["status"] + self.additional_parameters: Optional[str] = data["additionalParameters"] diff --git a/TrackerGG/Models/Apex/apex_segment.py b/TrackerGG/Models/Apex/apex_segment.py new file mode 100644 index 0000000..b4e014c --- /dev/null +++ b/TrackerGG/Models/Apex/apex_segment.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from .apex_stats import ApexStats + +__all__ = ["ApexSegment"] + + +class ApexSegment: + def __init__(self, data: Dict[str, Union[str, dict]]): + self.type: str = data["type"] + self.attributes: dict = data["attributes"] + self.metadata: dict = data["metadata"] + self.expiry_date: str = data["expiryDate"] + self.stats: ApexStats = ApexStats(data["stats"]) diff --git a/TrackerGG/Models/Apex/apex_stats.py b/TrackerGG/Models/Apex/apex_stats.py new file mode 100644 index 0000000..0a6e215 --- /dev/null +++ b/TrackerGG/Models/Apex/apex_stats.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from TrackerGG.Models.General import Stat + +__all__ = ["ApexStats"] + + +class ApexStats: + def __init__(self, data: Dict[str, dict]): + self.level: Optional[Stat] = Stat(data.get("level")) + self.kills: Optional[Stat] = Stat(data.get("kills")) + self.kills_per_match: Optional[Stat] = Stat(data.get("killsPerMatch")) + self.winning_kills: Optional[Stat] = Stat(data.get("winningKills")) + self.kills_as_kill_leader: Optional[Stat] = Stat(data.get("killsAsKillLeader")) + self.damage: Optional[Stat] = Stat(data.get("damage")) + self.matches_played: Optional[Stat] = Stat(data.get("matchesPlayed")) + self.revives: Optional[Stat] = Stat(data.get("revives")) + self.sniper_kills: Optional[Stat] = Stat(data.get("sniperKills")) + self.rank_score: Optional[Stat] = Stat(data.get("rankScore")) + self.arena_rank_score: Optional[Stat] = Stat(data.get("arenaRankScore")) + self.beast_of_the_hunt_kills: Optional[Stat] = Stat(data.get("beastOfTheHuntKills")) + self.grapple_travel_distance: Optional[Stat] = Stat(data.get("grappleTravelDistance")) + self.voices_warnings_heard: Optional[Stat] = Stat(data.get("voicesWarningsHeard")) + self.voices_warnings_heard: Optional[Stat] = Stat(data.get("voicesWarningsHeard")) diff --git a/TrackerGG/Models/CSGO/__init__.py b/TrackerGG/Models/CSGO/__init__.py new file mode 100644 index 0000000..337c359 --- /dev/null +++ b/TrackerGG/Models/CSGO/__init__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from .csgo_map import CSGOMap +from .csgo_map_segment import CSGOMapSegment +from .csgo_map_stats import CSGOMapStats +from .csgo_profile import CSGOProfile +from .csgo_query_data import CSGOQueryData +from .csgo_segment import CSGOSegment +from .csgo_stats import CSGOStats +from .csgo_weapon import CSGOWeapon +from .csgo_weapon_segment import CSGOWeaponSegment +from .csgo_weapon_stats import CSGOWeaponStats + +__all__ = [ + "CSGOMap", + "CSGOMapSegment", + "CSGOMapStats", + "CSGOProfile", + "CSGOQueryData", + "CSGOSegment", + "CSGOStats", + "CSGOWeapon", + "CSGOWeaponSegment", + "CSGOWeaponStats", +] diff --git a/TrackerGG/Models/CSGO/csgo_map.py b/TrackerGG/Models/CSGO/csgo_map.py new file mode 100644 index 0000000..9a59fb2 --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_map.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from .csgo_map_stats import CSGOMapStats + +__all__ = ["CSGOMap"] + + +class CSGOMap: + def __init__(self, data: Dict[str, Union[str, dict]]): + self.attributes: dict = data["attributes"] + self.metadata: dict = data["metadata"] + self.expiry_date: str = data["expiryDate"] + self.stats: CSGOMapStats = CSGOMapStats(data["stats"]) diff --git a/TrackerGG/Models/CSGO/csgo_map_segment.py b/TrackerGG/Models/CSGO/csgo_map_segment.py new file mode 100644 index 0000000..1ab7483 --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_map_segment.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from .csgo_map_stats import CSGOMapStats + +__all__ = ["CSGOMapSegment"] + + +class CSGOMapSegment: + def __init__(self, data: Dict[str, Union[str, dict]]): + self.type: str = data["type"] + self.attributes: dict = data["attributes"] + self.metadata: dict = data["metadata"] + self.expiry_date: str = data["expiryDate"] + self.stats: CSGOMapStats = CSGOMapStats(data["stats"]) diff --git a/TrackerGG/Models/CSGO/csgo_map_stats.py b/TrackerGG/Models/CSGO/csgo_map_stats.py new file mode 100644 index 0000000..51655ef --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_map_stats.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from TrackerGG.Models.General import Stat + +__all__ = ["CSGOMapStats"] + + +class CSGOMapStats: + def __init__(self, data: Dict[str, dict]): + self.rounds: Stat = Stat(data["rounds"]) + self.wins: Stat = Stat(data["wins"]) diff --git a/TrackerGG/Models/CSGO/csgo_profile.py b/TrackerGG/Models/CSGO/csgo_profile.py new file mode 100644 index 0000000..0474d2f --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_profile.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from TrackerGG.Models.General import PlatformInfo, UserInfo +from .csgo_segment import CSGOSegment + +__all__ = ["CSGOProfile"] + + +class CSGOProfile: + def __init__(self, data: Dict[str, Any]): + segments = [] + for seg in data["segments"]: + segments.append(CSGOSegment(seg)) + + self.platform_info: PlatformInfo = PlatformInfo(data["platformInfo"]) + self.user_info: UserInfo = UserInfo(data["userInfo"]) + self.segments: List[CSGOSegment] = segments + self.expiry_date: str = data["expiryDate"] diff --git a/TrackerGG/Models/CSGO/csgo_query_data.py b/TrackerGG/Models/CSGO/csgo_query_data.py new file mode 100644 index 0000000..6410149 --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_query_data.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +__all__ = ["CSGOQueryData"] + + +class CSGOQueryData: + def __init__(self, data: Dict[str, Optional[Union[str, int]]]): + self.platform_id = int(data["platformId"]) + self.platform_user_id: Union[str, int] = data["platformUserId"] + self.platform_user_handle: str = data["platformUserHandle"] + self.platform_user_identifier: Union[str, int] = data["platformUserIdentifier"] + self.avatar_url: str = data["avatarUrl"] + self.additional_parameters: Any = data["additionalParameters"] + self.status: Any = data["status"] diff --git a/TrackerGG/Models/CSGO/csgo_segment.py b/TrackerGG/Models/CSGO/csgo_segment.py new file mode 100644 index 0000000..e4cf462 --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_segment.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from .csgo_stats import CSGOStats + +__all__ = ["CSGOSegment"] + + +class CSGOSegment: + def __init__(self, data: Dict[str, Union[str, dict]]): + self.type: str = data["type"] + self.attributes: dict = data["attributes"] + self.metadata: dict = data["metadata"] + self.expiry_date: str = data["expiryDate"] + self.stats: CSGOStats = CSGOStats(data["stats"]) diff --git a/TrackerGG/Models/CSGO/csgo_stats.py b/TrackerGG/Models/CSGO/csgo_stats.py new file mode 100644 index 0000000..6c7aa86 --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_stats.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from TrackerGG.Models.General import Stat + +__all__ = ["CSGOStats"] + + +class CSGOStats: + def __init__(self, data: Dict[str, dict]): + self.time_played: Stat = Stat(data["timePlayed"]) + self.score: Stat = Stat(data["score"]) + self.kills: Stat = Stat(data["kills"]) + self.deaths: Stat = Stat(data["deaths"]) + self.kd: Stat = Stat(data["kd"]) + self.damage: Stat = Stat(data["damage"]) + self.headshots: Stat = Stat(data["headshots"]) + self.dominations: Stat = Stat(data["dominations"]) + self.shots_fired: Stat = Stat(data["shotsFired"]) + self.shots_hit: Stat = Stat(data["shotsHit"]) + self.shots_accuracy: Stat = Stat(data["shotsAccuracy"]) + self.snipers_killed: Stat = Stat(data["snipersKilled"]) + self.domination_overkills: Stat = Stat(data["dominationOverkills"]) + self.domination_revenges: Stat = Stat(data["dominationRevenges"]) + self.bombs_planted: Stat = Stat(data["bombsPlanted"]) + self.bombs_defused: Stat = Stat(data["bombsDefused"]) + self.money_earned: Stat = Stat(data["moneyEarned"]) + self.hostages_rescued: Stat = Stat(data["hostagesRescued"]) + self.mvp: Stat = Stat(data["mvp"]) + self.wins: Stat = Stat(data["wins"]) + self.ties: Stat = Stat(data["ties"]) + self.matches_played: Stat = Stat(data["matchesPlayed"]) + self.losses: Stat = Stat(data["losses"]) + self.rounds_played: Stat = Stat(data["roundsPlayed"]) + self.rounds_won: Stat = Stat(data["roundsWon"]) + self.wl_percentage: Stat = Stat(data["wlPercentage"]) + self.headshot_pct: Stat = Stat(data["headshotPct"]) diff --git a/TrackerGG/Models/CSGO/csgo_weapon.py b/TrackerGG/Models/CSGO/csgo_weapon.py new file mode 100644 index 0000000..87e15f6 --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_weapon.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from enum import Enum + +__all__ = ["CSGOWeapon"] + + +class CSGOWeapon(Enum): + AK47 = "ak47" + AUG = "aug" + AWP = "awp" + BIZON = "bizon" + DEAGLE = "deagle" + DUALS = "elite" + FAMAS = "famas" + FIVESEVEN = "fiveseven" + G3SG1 = "g3sg1" + GALIL = "galilar" + GLOCK = "glock" + P2000 = "hkp2000" + M249 = "m249" + M4A1 = "m4a1" + MAC10 = "mac10" + MAG7 = "mag7" + MP7 = "mp7" + MP9 = "mp9" + NEGEV = "negev" + NOVA = "nova" + P250 = "p250" + P90 = "p90" + SAWED_OFF = "sawedoff" + SCAR = "scar20" + SG553 = "sg556" + SSG08 = "ssg08" + ZEUS = "taser" + TEC9 = "tec9" + UMP45 = "ump45" + XM1014 = "xm1014" diff --git a/TrackerGG/Models/CSGO/csgo_weapon_segment.py b/TrackerGG/Models/CSGO/csgo_weapon_segment.py new file mode 100644 index 0000000..413d8cd --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_weapon_segment.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from .csgo_weapon_stats import CSGOWeaponStats + +__all__ = ["CSGOWeaponSegment"] + + +class CSGOWeaponSegment: + def __init__(self, data: Dict[str, Union[str, dict]]): + self.type: str = data["type"] + self.attributes: dict = data["attributes"] + self.metadata = data["metadata"] + self.expiry_date: str = data["expiryDate"] + self.stats: CSGOWeaponStats = CSGOWeaponStats(data["stats"]) diff --git a/TrackerGG/Models/CSGO/csgo_weapon_stats.py b/TrackerGG/Models/CSGO/csgo_weapon_stats.py new file mode 100644 index 0000000..9d8c171 --- /dev/null +++ b/TrackerGG/Models/CSGO/csgo_weapon_stats.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +from TrackerGG.Models.General import Stat + +__all__ = ["CSGOWeaponStats"] + + +class CSGOWeaponStats: + def __init__(self, data: Dict[str, dict]): + self.kills: Stat = Stat(data["kills"]) + self.shots_fired: Stat = Stat(data["shotsFired"]) + self.shots_hit: Stat = Stat(data["shotsHit"]) + self.shots_accuracy: Stat = Stat(data["shotsAccuracy"]) diff --git a/TrackerGG/Models/General/__init__.py b/TrackerGG/Models/General/__init__.py new file mode 100644 index 0000000..0d85030 --- /dev/null +++ b/TrackerGG/Models/General/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from .platform import Platform +from .platform_info import PlatformInfo +from .social_account import SocialAccount +from .stat import Stat +from .user_info import UserInfo + +__all__ = ["Stat", "Platform", "PlatformInfo", "SocialAccount", "UserInfo"] diff --git a/TrackerGG/Models/General/platform.py b/TrackerGG/Models/General/platform.py new file mode 100644 index 0000000..f5a542e --- /dev/null +++ b/TrackerGG/Models/General/platform.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from enum import Enum, auto + +__all__ = ["Platform"] + + +class Platform(Enum): + steam = auto() + origin = auto() + xbl = auto() + psn = auto() + uplay = auto() + battlenet = auto() + + @staticmethod + def from_name(raw: str): + raw = raw.lower() + + platform = { + "steam": Platform.steam, + "origin": Platform.origin, + "xbl": Platform.xbl, + "psn": Platform.psn, + "uplay": Platform.uplay, + }.get(raw) + + return platform diff --git a/TrackerGG/Models/platform.py b/TrackerGG/Models/General/platform_info.py similarity index 66% rename from TrackerGG/Models/platform.py rename to TrackerGG/Models/General/platform_info.py index f43e46c..2ceb4b3 100644 --- a/TrackerGG/Models/platform.py +++ b/TrackerGG/Models/General/platform_info.py @@ -16,30 +16,16 @@ """ -from enum import Enum -from typing import Dict, Union, Any +from typing import * +from TrackerGG.Models.General import Platform -class Platform(Enum): - steam = "steam" - origin = "origin" - xbl = "xbl" - psn = "psn" - uplay = "uplay" - battlenet = "battlenet" +__all__ = ["PlatformInfo"] class PlatformInfo: def __init__(self, data: Dict[str, Union[str, int, None]]): - platforms = { - "steam": Platform.steam, - "origin": Platform.origin, - "xbl": Platform.xbl, - "psn": Platform.psn, - "uplay": Platform.uplay, - } - - self.platform_slug: Platform = platforms[data["platformSlug"]] + self.platform_slug: Platform = Platform.from_name(data["platformSlug"]) self.platform_user_id: Union[str, int] = data["platformUserId"] self.platform_user_handle: str = data["platformUserHandle"] self.platform_user_identifier: Union[str, int] = data["platformUserIdentifier"] diff --git a/TrackerGG/Models/General/social_account.py b/TrackerGG/Models/General/social_account.py new file mode 100644 index 0000000..6c3394e --- /dev/null +++ b/TrackerGG/Models/General/social_account.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +""" +Copyright (c) 2023 DevRuby + +MIT License + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +""" + +from typing import * + +__all__ = ["SocialAccount"] + + +class SocialAccount: + def __init__(self, data: Dict[str, Union[str, int, None]]): + self.platform_slug: str = data["platformSlug"] + self.platform_user_id: Union[str, int] = data["platformUserId"] + self.platform_user_handle: str = data["platformUserHandle"] + self.platform_user_identifier: Union[str, int] = data["platformUserIdentifier"] + self.avatar_url: Optional[str] = data.get("avatarUrl") + self.additional_parameters: Any = data["additionalParameters"] diff --git a/TrackerGG/Models/segment.py b/TrackerGG/Models/General/stat.py similarity index 87% rename from TrackerGG/Models/segment.py rename to TrackerGG/Models/General/stat.py index 19b112f..a8ce6b1 100644 --- a/TrackerGG/Models/segment.py +++ b/TrackerGG/Models/General/stat.py @@ -16,7 +16,9 @@ """ -from typing import Dict, Union, Any, Optional +from typing import * + +__all__ = ["Stat"] class Stat: @@ -33,6 +35,3 @@ def __init__(self, data: Dict[str, Union[int, float, str, dict, None]]): self.display_value: str = data["displayValue"] self.display_category: str = data["displayCategory"] self.display_type: str = data["displayType"] - - def __str__(self): - return f"Name : {self.display_name}\nValue : {self.display_value}\nPercentile : {self.percentile}" diff --git a/TrackerGG/Models/user.py b/TrackerGG/Models/General/user_info.py similarity index 72% rename from TrackerGG/Models/user.py rename to TrackerGG/Models/General/user_info.py index a74e126..d7ccc65 100644 --- a/TrackerGG/Models/user.py +++ b/TrackerGG/Models/General/user_info.py @@ -16,17 +16,11 @@ """ -from typing import Dict, Union, Optional, Any, List +from typing import * +from TrackerGG.Models.General import SocialAccount -class SocialAccount: - def __init__(self, data: Dict[str, Union[str, int, None]]): - self.platform_slug: str = data["platformSlug"] - self.platform_user_id: Union[str, int] = data["platformUserId"] - self.platform_user_handle: str = data["platformUserHandle"] - self.platform_user_identifier: Union[str, int] = data["platformUserIdentifier"] - self.avatar_url: Optional[str] = data.get("avatarUrl") - self.additional_parameters: Any = data["additionalParameters"] +__all__ = ["UserInfo"] class UserInfo: diff --git a/TrackerGG/Models/__init__.py b/TrackerGG/Models/__init__.py index 1481da6..61f71ad 100644 --- a/TrackerGG/Models/__init__.py +++ b/TrackerGG/Models/__init__.py @@ -16,13 +16,8 @@ """ -from .csgo import CSGOProfile -from .csgo import CSGOMapSegment -from .csgo import CSGOQueryData -from .csgo import CSGOWeaponSegment -from .csgo import CSGOWeapon +from . import Apex +from . import CSGO +from . import General -from .apex import ApexProfile -from .apex import ApexQueryData - -from .platform import Platform +__all__ = ["CSGO", "General", "Apex"] diff --git a/TrackerGG/Models/apex.py b/TrackerGG/Models/apex.py deleted file mode 100644 index ab159ce..0000000 --- a/TrackerGG/Models/apex.py +++ /dev/null @@ -1,81 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -Copyright (c) 2023 DevRuby - -MIT License - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -""" -from typing import Dict, Any, Union, Optional, List -from .segment import Stat -from .platform import PlatformInfo -from .user import UserInfo - - -class ApexQueryData: - def __init__(self, data: Dict[str, Optional[Union[str, int]]]): - self.platform_id: int = int(data["platformId"]) - self.platform_slug: str = data["platformSlug"] - self.platform_user_identifier: str = data["platformUserIdentifier"] - self.platform_user_id: str = data["platformUserId"] - self.platform_user_handle: str = data["platformUserHandle"] - self.avatar_url: Optional[str] = data["avatarUrl"] - self.status: Optional[str] = data["status"] - self.additional_parameters: Optional[str] = data["additionalParameters"] - - -class ApexStats: - def __init__(self, data: Dict[str, dict]): - self.level: Optional[Stat] = Stat(data.get("level")) - self.kills: Optional[Stat] = Stat(data.get("kills")) - self.kills_per_match: Optional[Stat] = Stat(data.get("killsPerMatch")) - self.winning_kills: Optional[Stat] = Stat(data.get("winningKills")) - self.kills_as_kill_leader: Optional[Stat] = Stat(data.get("killsAsKillLeader")) - self.damage: Optional[Stat] = Stat(data.get("damage")) - self.matches_played: Optional[Stat] = Stat(data.get("matchesPlayed")) - self.revives: Optional[Stat] = Stat(data.get("revives")) - self.sniper_kills: Optional[Stat] = Stat(data.get("sniperKills")) - self.rank_score: Optional[Stat] = Stat(data.get("rankScore")) - self.arena_rank_score: Optional[Stat] = Stat(data.get("arenaRankScore")) - self.beast_of_the_hunt_kills: Optional[Stat] = Stat( - data.get("beastOfTheHuntKills") - ) - self.grapple_travel_distance: Optional[Stat] = Stat( - data.get("grappleTravelDistance") - ) - self.voices_warnings_heard: Optional[Stat] = Stat( - data.get("voicesWarningsHeard") - ) - self.voices_warnings_heard: Optional[Stat] = Stat( - data.get("voicesWarningsHeard") - ) - - -class ApexSegment: - def __init__(self, data: Dict[str, Union[str, dict]]): - self.type: str = data["type"] - self.attributes: dict = data["attributes"] - self.metadata: dict = data["metadata"] - self.expiry_date: str = data["expiryDate"] - self.stats: ApexStats = ApexStats(data["stats"]) - - -class ApexProfile: - def __init__(self, data: Dict[str, Any]): - segments = [] - for seg in data["segments"]: - segments.append(ApexSegment(seg)) - - self.platform_info: PlatformInfo = PlatformInfo(data["platformInfo"]) - self.user_info: UserInfo = UserInfo(data["userInfo"]) - self.segments: List[ApexSegment] = segments - self.expiry_date: str = data["expiryDate"] diff --git a/TrackerGG/Models/csgo.py b/TrackerGG/Models/csgo.py deleted file mode 100644 index 2bc9d2e..0000000 --- a/TrackerGG/Models/csgo.py +++ /dev/null @@ -1,159 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -Copyright (c) 2023 DevRuby - -MIT License - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -""" -from enum import Enum -from typing import Dict, Any, List, Union, Optional - -from .platform import PlatformInfo -from .segment import Stat -from .user import UserInfo - - -class CSGOStats: - def __init__(self, data: Dict[str, dict]): - self.time_played: Stat = Stat(data["timePlayed"]) - self.score: Stat = Stat(data["score"]) - self.kills: Stat = Stat(data["kills"]) - self.deaths: Stat = Stat(data["deaths"]) - self.kd: Stat = Stat(data["kd"]) - self.damage: Stat = Stat(data["damage"]) - self.headshots: Stat = Stat(data["headshots"]) - self.dominations: Stat = Stat(data["dominations"]) - self.shots_fired: Stat = Stat(data["shotsFired"]) - self.shots_hit: Stat = Stat(data["shotsHit"]) - self.shots_accuracy: Stat = Stat(data["shotsAccuracy"]) - self.snipers_killed: Stat = Stat(data["snipersKilled"]) - self.domination_overkills: Stat = Stat(data["dominationOverkills"]) - self.domination_revenges: Stat = Stat(data["dominationRevenges"]) - self.bombs_planted: Stat = Stat(data["bombsPlanted"]) - self.bombs_defused: Stat = Stat(data["bombsDefused"]) - self.money_earned: Stat = Stat(data["moneyEarned"]) - self.hostages_rescued: Stat = Stat(data["hostagesRescued"]) - self.mvp: Stat = Stat(data["mvp"]) - self.wins: Stat = Stat(data["wins"]) - self.ties: Stat = Stat(data["ties"]) - self.matches_played: Stat = Stat(data["matchesPlayed"]) - self.losses: Stat = Stat(data["losses"]) - self.rounds_played: Stat = Stat(data["roundsPlayed"]) - self.rounds_won: Stat = Stat(data["roundsWon"]) - self.wl_percentage: Stat = Stat(data["wlPercentage"]) - self.headshot_pct: Stat = Stat(data["headshotPct"]) - - -class CSGOMapStats: - def __init__(self, data: Dict[str, dict]): - self.rounds: Stat = Stat(data["rounds"]) - self.wins: Stat = Stat(data["wins"]) - - -class CSGOWeaponStats: - def __init__(self, data: Dict[str, dict]): - self.kills: Stat = Stat(data["kills"]) - self.shots_fired: Stat = Stat(data["shotsFired"]) - self.shots_hit: Stat = Stat(data["shotsHit"]) - self.shots_accuracy: Stat = Stat(data["shotsAccuracy"]) - - -class CSGOMapSegment: - def __init__(self, data: Dict[str, Union[str, dict]]): - self.type: str = data["type"] - self.attributes: dict = data["attributes"] - self.metadata: dict = data["metadata"] - self.expiry_date: str = data["expiryDate"] - self.stats: CSGOMapStats = CSGOMapStats(data["stats"]) - - -class CSGOWeaponSegment: - def __init__(self, data: Dict[str, Union[str, dict]]): - self.type: str = data["type"] - self.attributes: dict = data["attributes"] - self.metadata = data["metadata"] - self.expiry_date: str = data["expiryDate"] - self.stats: CSGOWeaponStats = CSGOWeaponStats(data["stats"]) - - -class CSGOSegment: - def __init__(self, data: Dict[str, Union[str, dict]]): - self.type: str = data["type"] - self.attributes: dict = data["attributes"] - self.metadata: dict = data["metadata"] - self.expiry_date: str = data["expiryDate"] - self.stats: CSGOStats = CSGOStats(data["stats"]) - - -class CSGOProfile: - def __init__(self, data: Dict[str, Any]): - segments = [] - for seg in data["segments"]: - segments.append(CSGOSegment(seg)) - - self.platform_info: PlatformInfo = PlatformInfo(data["platformInfo"]) - self.user_info: UserInfo = UserInfo(data["userInfo"]) - self.segments: List[CSGOSegment] = segments - self.expiry_date: str = data["expiryDate"] - - -class CSGOMap: - def __init__(self, data: Dict[str, Union[str, dict]]): - self.attributes: dict = data["attributes"] - self.metadata: dict = data["metadata"] - self.expiry_date: str = data["expiryDate"] - self.stats: CSGOMapStats = CSGOMapStats(data["stats"]) - - -class CSGOQueryData: - def __init__(self, data: Dict[str, Optional[Union[str, int]]]): - self.platform_id = int(data["platformId"]) - self.platform_user_id: Union[str, int] = data["platformUserId"] - self.platform_user_handle: str = data["platformUserHandle"] - self.platform_user_identifier: Union[str, int] = data["platformUserIdentifier"] - self.avatar_url: str = data["avatarUrl"] - self.additional_parameters: Any = data["additionalParameters"] - self.status: Any = data["status"] - - -class CSGOWeapon(Enum): - AK47 = "ak47" - AUG = "aug" - AWP = "awp" - BIZON = "bizon" - DEAGLE = "deagle" - DUALS = "elite" - FAMAS = "famas" - FIVESEVEN = "fiveseven" - G3SG1 = "g3sg1" - GALIL = "galilar" - GLOCK = "glock" - P2000 = "hkp2000" - M249 = "m249" - M4A1 = "m4a1" - MAC10 = "mac10" - MAG7 = "mag7" - MP7 = "mp7" - MP9 = "mp9" - NEGEV = "negev" - NOVA = "nova" - P250 = "p250" - P90 = "p90" - SAWED_OFF = "sawedoff" - SCAR = "scar20" - SG553 = "sg556" - SSG08 = "ssg08" - ZEUS = "taser" - TEC9 = "tec9" - UMP45 = "ump45" - XM1014 = "xm1014" diff --git a/TrackerGG/__init__.py b/TrackerGG/__init__.py index 3eb7248..91a3ad4 100644 --- a/TrackerGG/__init__.py +++ b/TrackerGG/__init__.py @@ -26,32 +26,30 @@ """ -from .Models import Platform -from .Models import CSGOProfile -from .Models import CSGOMapSegment -from .Models import CSGOWeaponSegment -from .Models import CSGOWeapon -from .Models import ApexProfile - -from .client import CSGOClient -from .client import ApexClient - +import TrackerGG.Models from . import utils +from .client import ApexClient +from .client import CSGOClient +__all__ = ["Models", "CSGOClient", "ApexClient", "utils"] count = 0 try: import aiohttp + count += 1 except ImportError: pass try: import httpx + count += 1 except ImportError: pass if count == 0: - raise ImportError("\nAt least one of aiohttp or httpx libraries is required\nTry `pip install aiohttp` or `pip install httpx`") \ No newline at end of file + raise ImportError( + "\nAt least one of aiohttp or httpx libraries is required\nTry `pip install aiohttp` or `pip install httpx`" + ) diff --git a/TrackerGG/client.py b/TrackerGG/client.py index 5173998..dd4922e 100644 --- a/TrackerGG/client.py +++ b/TrackerGG/client.py @@ -18,16 +18,12 @@ import asyncio import json -from typing import List, Union, Optional +from typing import * -from .HTTPClients import * -from .Models import ApexProfile -from .Models import ApexQueryData -from .Models import CSGOMapSegment -from .Models import CSGOProfile -from .Models import CSGOQueryData -from .Models import CSGOWeaponSegment -from .Models import Platform +from TrackerGG.HTTPClients import * +from TrackerGG.Models import * + +__all__ = ["CSGOClient", "ApexClient"] class TrackerClient: @@ -64,7 +60,7 @@ class CSGOClient(TrackerClient): def __init__(self, api_key: str, http_client: Optional[HTTPClientLibrary] = None) -> None: super().__init__(api_key, http_client) - async def get_profile(self, identifier: str) -> CSGOProfile: + async def get_profile(self, identifier: str) -> CSGO.CSGOProfile: """ Returns career stats for an CSGO player. @@ -76,15 +72,13 @@ async def get_profile(self, identifier: str) -> CSGOProfile: Route(RequestMethod.GET, f"/csgo/standard/profile/steam/{identifier}") ) - assert response.status == 200, ( - "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status - ) + assert response.status == 200, "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status json_data: dict = json.loads(response.response_data) - return CSGOProfile(json_data["data"]) + return CSGO.CSGOProfile(json_data["data"]) - async def get_map_segment(self, identifier: str) -> List[CSGOMapSegment]: + async def get_map_segment(self, identifier: str) -> List[CSGO.CSGOMapSegment]: """ Returns the stats of the map for a CSGO player. @@ -99,20 +93,18 @@ async def get_map_segment(self, identifier: str) -> List[CSGOMapSegment]: ) ) - assert response.status == 200, ( - "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status - ) + assert response.status == 200, "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status json_data: dict = json.loads(response.response_data) segments = [] for segment in json_data["data"]: - segments.append(CSGOMapSegment(segment)) + segments.append(CSGO.CSGOMapSegment(segment)) return segments - async def get_weapon_segment(self, identifier: str) -> List[CSGOWeaponSegment]: + async def get_weapon_segment(self, identifier: str) -> List[CSGO.CSGOWeaponSegment]: """ Returns the stats of the weapon for a CSGO player. @@ -127,20 +119,18 @@ async def get_weapon_segment(self, identifier: str) -> List[CSGOWeaponSegment]: ) ) - assert response.status == 200, ( - "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status - ) + assert response.status == 200, "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status json_data: dict = json.loads(response.response_data) segments = [] for segment in json_data["data"]: - segments.append(CSGOWeaponSegment(segment)) + segments.append(CSGO.CSGOWeaponSegment(segment)) return segments - async def search_profile(self, query: str) -> Union[None, List[CSGOQueryData]]: + async def search_profile(self, query: str) -> Union[None, List[CSGO.CSGOQueryData]]: """ Returns search data for a CSGO player using a unique identifier. @@ -156,9 +146,7 @@ async def search_profile(self, query: str) -> Union[None, List[CSGOQueryData]]: ) ) - assert response.status == 200, ( - "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status - ) + assert response.status == 200, "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status json_data: dict = json.loads(response.response_data) @@ -167,7 +155,7 @@ async def search_profile(self, query: str) -> Union[None, List[CSGOQueryData]]: if json_data["data"]: query_data = [] for dat in json_data["data"]: - query_data.append(CSGOQueryData(dat)) + query_data.append(CSGO.CSGOQueryData(dat)) return query_data @@ -176,7 +164,7 @@ class ApexClient(TrackerClient): def __init__(self, api_key: str, http_client: Optional[HTTPClientLibrary] = None) -> None: super().__init__(api_key, http_client) - async def get_profile(self, identifier: str, platform: Platform) -> ApexProfile: + async def get_profile(self, identifier: str, platform: General.Platform) -> Apex.ApexProfile: """ Returns career stats for an Apex player. @@ -192,17 +180,13 @@ async def get_profile(self, identifier: str, platform: Platform) -> ApexProfile: ) ) - assert response.status == 200, ( - "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status - ) + assert response.status == 200, "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status json_data: dict = json.loads(response.response_data) - return ApexProfile(json_data["data"]) + return Apex.ApexProfile(json_data["data"]) - async def search_profile( - self, query: str, platform: Platform - ) -> Union[None, List[ApexQueryData]]: + async def search_profile(self, query: str, platform: General.Platform) -> Union[None, List[Apex.ApexQueryData]]: """ Returns search data for an Apex player using a unique identifier. @@ -219,9 +203,7 @@ async def search_profile( ) ) - assert response.status == 200, ( - "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status - ) + assert response.status == 200, "HTTP Response Status Code is not 200\nStatus Code : %d" % response.status json_data: dict = json.loads(response.response_data) @@ -230,6 +212,6 @@ async def search_profile( if json_data["data"]: query_data = [] for dat in json_data["data"]: - query_data.append(ApexQueryData(dat)) + query_data.append(Apex.ApexQueryData(dat)) return query_data diff --git a/TrackerGG/utils.py b/TrackerGG/utils.py index ba9871d..fb874d0 100644 --- a/TrackerGG/utils.py +++ b/TrackerGG/utils.py @@ -16,15 +16,14 @@ """ -from .Models import CSGOMapSegment -from .Models import CSGOWeaponSegment -from .Models import CSGOWeapon -from typing import List, Union +from typing import * +from TrackerGG.Models import * -def query_map_by_key( - maps: List[CSGOMapSegment], key: str -) -> Union[CSGOMapSegment, int]: +__all__ = ["query_weapon", "query_map_by_key"] + + +def query_map_by_key(maps: List[CSGO.CSGOMapSegment], key: str) -> Union[CSGO.CSGOMapSegment, int]: """ Returns a CSGOMapSegment that matches key. Returns -1 if there is no matching CSGOMapSegment Object. @@ -39,9 +38,7 @@ def query_map_by_key( return -1 -def query_weapon( - weapons: List[CSGOWeaponSegment], key: CSGOWeapon -) -> Union[CSGOWeaponSegment, int]: +def query_weapon(weapons: List[CSGO.CSGOWeaponSegment], key: CSGO.CSGOWeapon) -> Union[CSGO.CSGOWeaponSegment, int]: """ Returns a CSGO weapon segment that matches key. Returns -1 if there is no matching CSGOWeaponSegment Object.