-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dev-ruby/dev
Change Major API Sets
- Loading branch information
Showing
12 changed files
with
363 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright (c) 2021 DevRuby | ||
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 | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
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. | ||
""" | ||
|
||
__version__ = "1.0" | ||
__author__ = "DevRuby" | ||
__license__ = "MIT License" | ||
__copyright__ = "(c) 2021 DevRuby" | ||
from .csgo import CSGOProfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- 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, List | ||
|
||
from .platform import PlatformInfo | ||
from .segment import Segment | ||
from .user import UserInfo | ||
|
||
|
||
class CSGOProfile: | ||
def __init__(self, data: Dict[str, Any]): | ||
segments = [] | ||
for seg in data["segments"]: | ||
segments.append(Segment(seg)) | ||
|
||
self.platform_info: PlatformInfo = PlatformInfo(data["platformInfo"]) | ||
self.user_info: UserInfo = UserInfo(data["userInfo"]) | ||
self.segments: List[Segment] = segments | ||
self.expiry_date: str = data["expiryDate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- 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, Union, Any | ||
|
||
|
||
class Platform(Enum): | ||
steam = "steam" | ||
origin = "origin" | ||
xbl = "xbl" | ||
psn = "psn" | ||
uplay = "uplay" | ||
|
||
|
||
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_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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- 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 List, Dict, Union, Any | ||
|
||
|
||
class Stat: | ||
def __init__(self, data: Dict[str, Union[int, float, str, None, dict]]): | ||
self.rank: int = data["rank"] | ||
self.percentile: float = data["percentile"] | ||
self.display_name: str = data["displayName"] | ||
self.display_category: str = data["displayCategory"] | ||
self.category: Union[None, str] = data["category"] | ||
self.description: str = data["description"] | ||
self.metadata: Union[None, dict[str, Any]] = data["metadata"] | ||
self.value: int = data["value"] | ||
self.display_value: str = data["displayValue"] | ||
self.display_type: str = data["displayType"] | ||
|
||
def __str__(self): | ||
return f"Name : {self.display_name}\nValue : {self.display_value}\nPercentile : {self.percentile}" | ||
|
||
|
||
class Segment: | ||
def __init__(self, data: Dict[str, Union[str, int, dict]]): | ||
stats = [] | ||
for stat in data["stats"].keys(): | ||
stats.append(Stat(data["stats"][stat])) | ||
|
||
self.type: str = data["type"] | ||
self.attributes: dict = data["attributes"] | ||
self.metadata: dict = data["metadata"] | ||
self.expiry_date: str = data["expiryDate"] | ||
self.stats: List[Stat] = stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- 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, Union, Optional, Any, List | ||
|
||
|
||
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: str = data["avatarUrl"] | ||
self.additional_parameters: Any = data["additionalParameters"] | ||
|
||
|
||
class UserInfo: | ||
def __init__(self, data: Dict[str, Union[str, int, bool, list, None]]): | ||
social_accounts = [] | ||
if data["socialAccounts"]: | ||
for social_account in data["socialAccounts"]: | ||
social_accounts.append(SocialAccount(social_account)) | ||
|
||
self.user_id: Optional[int] = data["userId"] | ||
self.is_premium: bool = data["isPremium"] | ||
self.is_verified: bool = data["isVerified"] | ||
self.is_influencer: bool = data["isInfluencer"] | ||
self.is_partner: bool = data["isPartner"] | ||
self.country_code: Union[str, None] = data["countryCode"] | ||
self.custom_avatar_url: Optional[str] = data["customAvatarUrl"] | ||
self.custom_hero_url: Optional[str] = data["customHeroUrl"] | ||
self.social_accounts: List[SocialAccount] = social_accounts | ||
self.page_views: int = data["pageviews"] | ||
self.custom_avatar_url: Any = data["isSuspicious"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright (c) 2021 DevRuby | ||
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 | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
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 .exceptions import ApiError | ||
from .exceptions import UserError | ||
from .models import Client | ||
from .models import CsgoStatData | ||
from .models import CsgoProfileData | ||
from .models import CsgoStats | ||
from .models import PlatformInfo | ||
from .models import Platform | ||
from .info import __version__ | ||
from .info import __author__ | ||
from .info import __license__ | ||
from .info import __copyright__ | ||
from .Models import CSGOProfile | ||
from .client import CSGOClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- 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. | ||
""" | ||
|
||
import asyncio | ||
import json | ||
|
||
from .Models import CSGOProfile | ||
from .httpclient import HTTPClient | ||
from .httpclient import RequestMethod | ||
from .httpclient import ResponseData | ||
from .httpclient import Route | ||
|
||
|
||
class CSGOClient: | ||
api_key: str | ||
loop: asyncio.AbstractEventLoop | ||
http_client: HTTPClient | ||
|
||
def __init__(self, api_key: str) -> None: | ||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) | ||
self.loop = asyncio.get_event_loop() | ||
self.api_key = api_key | ||
self.http_client = HTTPClient(self.loop, self.api_key) | ||
|
||
async def get_profile(self, identifier: str): | ||
response: ResponseData = await self.http_client.request( | ||
Route(RequestMethod.GET, f"/csgo/standard/profile/steam/{identifier}") | ||
) | ||
|
||
assert response.status == 200, "HTTP Response Status Code is not 200" | ||
|
||
json_data: dict = json.loads(response.response_data) | ||
|
||
return CSGOProfile(json_data["data"]) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.