diff --git a/.env b/.env new file mode 100644 index 0000000..4d94bed --- /dev/null +++ b/.env @@ -0,0 +1 @@ +LOG_LEVEL=DEBUG \ No newline at end of file diff --git a/BEATLEADER.md b/BEATLEADER.md deleted file mode 100644 index 664e2c6..0000000 --- a/BEATLEADER.md +++ /dev/null @@ -1,78 +0,0 @@ -# BeatLeaderAPI Python Wrapper - -This Python class provides a convenient wrapper for interacting with the BeatLeader API, specifically for retrieving player scores and song data for the game Beat Saber. - -## Features - -- Fetch player scores and song data from the BeatLeader API -- Local caching of API responses to reduce API calls and improve performance -- Automatic pagination handling to retrieve all available data -- Configurable cache expiration -- Methods to retrieve both full and minimal song data - -## Usage - -### Basic Usage - -```python -from saberlist.beatleaderAPI import BeatLeaderAPI - -# Initialize the API wrapper -api = BeatLeaderAPI(cache_expiry_days=1) - -# Fetch player scores -player_id = '76561199407393962' -scores = api.get_player_scores(player_id) - -# Get full song data -songs = api.get_player_songs(player_id) - -# Get minimal song data -minimal_songs = api.get_player_songs_minimal(player_id) -``` - -### Caching - -The class uses a local cache to store API responses. By default, the cache is located at: - -- `~/.cache/saberlist/` on Unix-like systems (if `~/.cache/` exists) -- `./.cache/` in the current working directory (as a fallback) - -You can control cache behavior: - -```python -# Set cache expiry (in days) -api = BeatLeaderAPI(cache_expiry_days=7) - -# Force a fresh API call (ignore cache) -fresh_scores = api.get_player_scores(player_id, use_cache=False) - -# Clear cache for a specific player -api.clear_cache(player_id) - -# Clear all cache -api.clear_cache() - -# Get the current cache directory -cache_dir = api.get_cache_dir() -``` - -### Pagination - -The `get_player_scores` method automatically handles pagination to retrieve all available scores. You can control this behavior: - -```python -# Set a custom page size (default is 100) -scores = api.get_player_scores(player_id, page_size=50) - -# Limit the number of pages fetched -scores = api.get_player_scores(player_id, max_pages=5) -``` - -## Methods - -- `get_player_scores(player_id, use_cache=True, page_size=100, max_pages=None)`: Retrieves all scores for a player. -- `get_player_songs(player_id, page=1, count=100, use_cache=True)`: Retrieves full song data for all unique songs a player has played. -- `get_player_songs_minimal(player_id, page=1, count=100, use_cache=True)`: Retrieves minimal song data (id, name, author, mapper, hash, bpm, duration) for all unique songs a player has played. -- `clear_cache(player_id=None)`: Clears the cache for a specific player or all cached data. -- `get_cache_dir()`: Returns the path to the current cache directory. diff --git a/docs/OLDREADME.md b/docs/OLDREADME.md deleted file mode 100644 index 79a4302..0000000 --- a/docs/OLDREADME.md +++ /dev/null @@ -1,80 +0,0 @@ -# playlist helper - -This is the old readme that explains the scoresaber functions. - -## Usage - -```sh -pipx install pleb-saberlist -player_scores_by_stars -leaderboard_songs_by_stars -``` - -### Examples - -```sh -leaderboard_songs_by_stars -Enter the minimum starlevel to include on the playlist (Default: 6.0): 6.2 -Enter the maximum starlevel to include on the playlist (Default: 6.3): -Enter the filename for the playlist (Default: SS Leaderboard 6.2★): -2024-07-09 16:06:13 DEBUG: Using selector: EpollSelector -2024-07-09 16:06:13 INFO: Fetching page 1/-1 of leaderboards -2024-07-09 16:06:13 INFO: Got 14 songs from leaderboard page 1 -2024-07-09 16:06:13 INFO: Fetching page 2/3 of leaderboards -2024-07-09 16:06:14 INFO: Got 14 songs from leaderboard page 2 -2024-07-09 16:06:14 INFO: Fetching page 3/3 of leaderboards -2024-07-09 16:06:14 INFO: Got 3 songs from leaderboard page 3 -2024-07-09 16:06:14 INFO: Playlist written to SS Leaderboard 6.2★.bplist -``` - -Player songs by stars: - -```sh -player_scores_by_stars -2024-07-09 16:07:04 DEBUG: Using selector: EpollSelector -Enter the playerid (Default: 76561199407393962): -Enter the minimum starlevel to include on the playlist (Default: 5): -Enter the maximum starlevel to include on the playlist (Default: 6.0): 5.5 -Enter the filename for the playlist (Default: Replay SS 5.0★): -2024-07-09 16:07:14 INFO: Fetching page 1/-1 of player scores -2024-07-09 16:07:15 INFO: Got 100 scores from page 1 -... -2024-07-09 16:07:19 INFO: Fetching page 8/9 of player scores -2024-07-09 16:07:20 INFO: Got 96 scores from page 8 -2024-07-09 16:07:20 INFO: Playlist written to Replay SS 5.0★.bplist - -``` - -## Development - -Clone the repo and install dependencies into a local virtual environment: - -```bash -pip install --upgrade pip -pip install --editable . -``` - -## Resources - -* [Beatleader API](https://beatleader.xyz/developer) -* [ScoreSaber API](https://docs.scoresaber.com/) - -## Tips - -Count results - -```shell -jq '.songs | length' < playlist.bplist -``` - -Avoid printing covers in console. - -```shell -jq 'del(.image)' < playlist.bplist -``` - -Find the most common mappers the player has played: - -```shell -jq -r '.songs[].levelAuthorName' *.bplist | sort | uniq -c | sort -rn | head -n 10 -``` diff --git a/docs/PlaylistBuilder.md b/docs/PlaylistBuilder.md new file mode 100644 index 0000000..acd50d8 --- /dev/null +++ b/docs/PlaylistBuilder.md @@ -0,0 +1,157 @@ +# PlaylistBuilder Class - Quick Reference + +## Overview + +The **PlaylistBuilder** class is a Python utility designed to create customized playlists efficiently. It manages cover images, tracks usage history to prevent duplication, and structures playlist data in a standardized JSON format. Ideal for applications requiring organized and visually appealing playlists, `PlaylistBuilder` simplifies the playlist creation process. + +## Key Data Structures + +### Difficulty +Represents the difficulty level of a song. + +- **Attributes:** + - `name` (str): Difficulty name (e.g., "normal", "hard"). + - `characteristic` (str): Mode or characteristic (e.g., "Standard"). + +### Song +Encapsulates song details within a playlist. + +- **Attributes:** + - `hash` (str): Unique identifier for the song. + - `difficulties` (List[Difficulty]): Available difficulty levels. + - `key` (Optional[str]): Optional key identifier. + - `levelId` (Optional[str]): Optional custom level ID. + - `songName` (Optional[str]): Optional name of the song. + +### CustomData +Holds additional metadata for the playlist. + +- **Attributes:** + - `syncURL` (Optional[str]) + - `owner` (Optional[str]) + - `id` (Optional[str]) + - `hash` (Optional[str]) + - `shared` (Optional[bool]) + +### Playlist +Represents the complete playlist structure. + +- **Attributes:** + - `playlistTitle` (str): Title of the playlist. + - `songs` (List[Song]): List of songs included. + - `playlistAuthor` (Optional[str]): Author of the playlist. + - `image` (Optional[str]): Base64-encoded cover image. + - `coverImage` (Optional[str]): File path to the cover image. + - `description` (Optional[str]): Description of the playlist. + - `allowDuplicates` (Optional[bool]): Flag to allow duplicate songs. + - `customData` (Optional[CustomData]): Additional metadata. + +## PlaylistBuilder Class + +### Initialization + +```python +def __init__(self, covers_dir="./covers", history_file="./playlist_history.json", output_dir=None): +``` + +- **Parameters:** + - `covers_dir` (str): Directory containing cover images. + - `history_file` (str): Path to the JSON file tracking used covers. + - `output_dir` (Optional[str]): Directory to save generated playlists. Defaults to current working directory. + +- **Behavior:** + - Ensures the covers directory exists. + - Loads or initializes the history of used covers. + +### Methods + +#### `create_playlist` + +Generates a playlist based on provided song data. + +```python +def create_playlist(self, playlist_data: List[Dict], playlist_title: str = "playlist", playlist_author: str = "SaberList Tool") -> str: +``` + +- **Parameters:** + - `playlist_data` (List[Dict]): List of song dictionaries. + - `playlist_title` (str): Title of the playlist. + - `playlist_author` (str): Author of the playlist. + +- **Returns:** + - `str`: File path to the created playlist. + +- **Behavior:** + - Converts song dictionaries to `Song` instances. + - Selects a random unused cover image. + - Encodes the cover image to Base64. + - Constructs a `Playlist` instance. + - Saves the playlist as a `.bplist` JSON file. + - Updates the history of used covers. + +## Usage Example + +```python +from src.saberlist.PlaylistBuilder import PlaylistBuilder + +# Initialize PlaylistBuilder +builder = PlaylistBuilder( + covers_dir="./covers", + history_file="./playlist_history.json", + output_dir="./playlists" +) + +# Define song data +sample_song = { + "hash": "7c9e0a7c523395c7ef9d79006b9d42dc6ab8b44a", + "key": "2a44e", + "levelId": "custom_level_7c9e0a7c523395c7ef9d79006b9d42dc6ab8b44a", + "songName": "Gleodream", + "difficulties": [ + { + "name": "normal", + "characteristic": "Standard" + } + ] +} + +# Create the playlist +playlist_path = builder.create_playlist( + playlist_data=[sample_song], + playlist_title="Chill Vibes", + playlist_author="Alice Smith" +) + +print(f"Playlist created at: {playlist_path}") +``` + +## Handling Cover Images + +- **Adding Covers:** Place `.jpg` images in the `covers_dir`. The `PlaylistBuilder` selects an unused cover for each playlist. +- **Preventing Duplicates:** The `history_file` tracks used covers to avoid repetition until all covers are utilized. +- **Resetting History:** Delete or modify `playlist_history.json` to reset cover usage history. + +## File Structures + +### Playlist File (`.bplist`) + +- **Format:** JSON +- **Contents:** + - Playlist metadata (title, author, description). + - List of songs with details. + - Base64-encoded cover image. + - Path to the cover image file. + +### History File (`playlist_history.json`) + +- **Format:** JSON +- **Contents:** + - `used_covers`: Array of filenames that have been used as covers. + +## Additional Information + +- **Logging:** The class logs important actions, such as creating directories and handling missing covers. +- **Extensibility:** Easily extendable to support more image formats or additional metadata fields. +- **Dependencies:** Utilizes Python's standard libraries (`os`, `json`, `random`, etc.) and `dataclasses` for structured data. + +--- \ No newline at end of file diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..f381043 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,75 @@ +# API Libraries + +Libraries were generated using [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) for interacting with various REST APIs: + +```sh +nix-shell -p ruff --run "openapi-python-client generate --path archive/scoresaber.com.swagger.json" +nix-shell -p ruff --run "openapi-python-client generate --path archive/beatleader.xyz.swagger.json" +``` + +To convert beatsaver, we had to convert it from openapi 2.0 to 3.0: + +```sh +npm set prefix ~/.npm-global +export PATH=$HOME/.npm-global/bin:$PATH +npm install -g swagger2openapi +swagger2openapi --patch archive/beatsaver.com.swagger.json > archive/beatsaver.com.swagger_openapi3.json +``` + +Then we had to run some python code to fix up the mapping after the conversion: + +```python +import json + +# Load the OpenAPI spec +with open('archive/beatsaver.com.swagger_openapi3.json', 'r') as f: + spec = json.load(f) + +# Fix tags in the main spec +if 'tags' in spec: + spec['tags'] = [tag['name'] if isinstance(tag, dict) else tag for tag in spec['tags']] + +# Fix tags in each path +for path in spec['paths'].values(): + for method in path.values(): + if 'tags' in method: + method['tags'] = [tag['name'] if isinstance(tag, dict) else tag for tag in method['tags']] + +# Save the fixed spec +with open('archive/beatsaver.com.swagger_openapi3_fixed.json', 'w') as f: + json.dump(spec, f, indent=2) +``` + +And we ran this one too: + +```python +import json + +# Load the OpenAPI spec +with open('archive/beatsaver.com.swagger_openapi3_fixed.json', 'r') as f: + spec = json.load(f) + +# Fix tags in the main spec +if 'tags' in spec: + spec['tags'] = [tag['name'] if isinstance(tag, dict) else tag for tag in spec['tags']] + +# Fix tags and content types in each path +for path in spec['paths'].values(): + for method in path.values(): + if 'tags' in method: + method['tags'] = [tag['name'] if isinstance(tag, dict) else tag for tag in method['tags']] + if 'responses' in method: + for response in method['responses'].values(): + if 'content' in response: + if '*/*' in response['content']: + content = response['content']['*/*'] + response['content'] = {'application/json': content} + +# Save the fixed spec +with open('archive/beatsaver.com.swagger_openapi3_fixed2.json', 'w') as f: + json.dump(spec, f, indent=2) +``` + +```sh +nix-shell -p ruff --run "openapi-python-client generate --path archive/beatsaver.com.swagger_openapi3_fixed2.json" +``` diff --git a/docs/capture.md b/docs/capture.md new file mode 100644 index 0000000..a56adf0 --- /dev/null +++ b/docs/capture.md @@ -0,0 +1,226 @@ +# Notes + +Sample bplist (playlist file) for [PlaylistManager](https://github.com/rithik-b/PlaylistManager): + +```json +{ + "playlistTitle": "My Enhanced Playlist", + "playlistAuthor": "SaberList Tool", + "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==", + "coverImage": "https://example.com/playlist-cover.jpg", + "description": "This is an enhanced version of my playlist with additional fields.", + "allowDuplicates": false, + "songs": [ + { + "hash": "7c9e0a7c523395c7ef9d79006b9d42dc6ab8b44a", + "key": "2a44e", + "levelId": "custom_level_7c9e0a7c523395c7ef9d79006b9d42dc6ab8b44a", + "songName": "Gleodream", + "difficulties": [ + { + "name": "normal", + "characteristic": "Standard" + } + ] + }, + { + "hash": "18ef469f44b0fa93327f9d193d10bdfe7401e5a0", + "key": "1b3f7", + "levelId": "custom_level_18ef469f44b0fa93327f9d193d10bdfe7401e5a0", + "songName": "Dual Fractal", + "difficulties": [ + { + "name": "expert", + "characteristic": "Standard" + } + ] + }, + { + "hash": "a51425319d892986a4867388153bce45b3c28483", + "key": "3c8d9", + "levelId": "custom_level_a51425319d892986a4867388153bce45b3c28483", + "songName": "Shake The Ground", + "difficulties": [ + { + "name": "expert", + "characteristic": "Standard" + } + ] + } + ], + "customData": { + "syncURL": "https://api.beatleader.xyz/playlist/guid/fc1000d77d0f4ed19611043367248ee0", + "owner": "76561199407393962", + "id": "80650", + "hash": "279a9c66ed021b8ef75ff9db848b28ad6c48d3c770bd26f1a586e8d489c728b3", + "shared": false + } +} +``` + +Sample Scoresaber score: + +```python +data = { + 'metadata': {'itemsPerPage': 100, 'page': 10, 'total': 961}, + 'playerScores': [{ + 'leaderboard': { + 'coverImage': 'https://cdn.scoresaber.com/covers/09F8BEE6908E3A9CD724B3DB3162A5C381ECB156.png', + 'createdDate': '2020-12-04T12:52:24.000Z', + 'dailyPlays': 7, + 'difficulties': None, + 'difficulty': { + 'difficulty': 9, + 'difficultyRaw': '_ExpertPlus_SoloStandard', + 'gameMode': 'SoloStandard', + 'leaderboardId': 311333 + }, + 'id': 311333, + 'levelAuthorName': 'FatBeanzoop & ExUnReal', + 'loved': False, + 'lovedDate': None, + 'maxPP': -1, + 'maxScore': 1476715, + 'playerScore': None, + 'plays': 13701, + 'positiveModifiers': False, + 'qualified': False, + 'qualifiedDate': '2020-12-05T18:16:56.000Z', + 'ranked': True, + 'rankedDate': '2020-12-20T17:15:39.000Z', + 'songAuthorName': 'Pegboard Nerds', + 'songHash': '09F8BEE6908E3A9CD724B3DB3162A5C381ECB156', + 'songName': 'Purple People Eater', + 'songSubName': '', + 'stars': 7.05 + }, + 'score': { + 'badCuts': 4, + 'baseScore': 1362341, + 'deviceControllerLeft': 'Touch', + 'deviceControllerRight': 'Touch', + 'deviceHmd': 'Vive', + 'fullCombo': False, + 'hasReplay': False, + 'hmd': 0, + 'id': 85113198, + 'leaderboardPlayerInfo': None, + 'maxCombo': 741, + 'missedNotes': 4, + 'modifiedScore': 1362341, + 'modifiers': '', + 'multiplier': 1, + 'pp': 261.6251, + 'rank': 2711, + 'timeSet': '2024-09-28T22:02:02.000Z', + 'weight': 0.04670344831503159 + } + }] +} +``` + +Sample BeatLeader score: + +```python +scores = [{ + 'accLeft': 110.32343, + 'accPP': 366.7179, + 'accRight': 110.67913, + 'accuracy': 0.95488137, + 'badCuts': 1, + 'baseScore': 1090317, + 'bombCuts': 1, + 'bonusPp': 63.974487, + 'controller': 64, + 'country': 'NL', + 'fcAccuracy': 0.95854264, + 'fcPp': 510.75574, + 'fullCombo': False, + 'hmd': 64, + 'id': 2800090, + 'lastTryTime': 0, + 'leaderboard': {'difficulty': {'accRating': 10.151069, + 'bombs': 666, + 'difficultyName': 'ExpertPlus', + 'duration': 227, + 'featureTags': 0, + 'id': 115, + 'maxScore': 1141835, + 'mode': 1, + 'modeName': 'Standard', + 'modifierValues': {'da': 0, + 'ez': -0.4, + 'fs': 0.22, + 'gn': 0.08, + 'hd': 0.05, + 'modifierId': 3203, + 'na': -0.3, + 'nb': -0.2, + 'nf': -1, + 'no': -0.2, + 'ohp': 0, + 'op': -0.5, + 'pm': 0, + 'sa': 0, + 'sc': 0, + 'sf': 0.5, + 'smc': 0.07, + 'ss': -0.3}, + 'modifiersRating': {'bfsAccRating': 10.946411, + 'bfsPassRating': 6.827801, + 'bfsPredictedAcc': 0.97209585, + 'bfsStars': 9.858454, + 'bfsTechRating': 6.3452663, + 'bsfAccRating': 11.91756, + 'bsfPassRating': 9.088728, + 'bsfPredictedAcc': 0.96791214, + 'bsfStars': 11.616207, + 'bsfTechRating': 6.8890166, + 'fsAccRating': 11.0798855, + 'fsPassRating': 6.8595705, + 'fsPredictedAcc': 0.9715599, + 'fsStars': 9.968003, + 'fsTechRating': 6.22683, + 'id': 6456, + 'sfAccRating': 12.244068, + 'sfPassRating': 9.434687, + 'sfPredictedAcc': 0.9660631, + 'sfStars': 12.006947, + 'sfTechRating': 6.655377, + 'ssAccRating': 9.436057, + 'ssPassRating': 4.4481916, + 'ssPredictedAcc': 0.97730374, + 'ssStars': 7.6588736, + 'ssTechRating': 5.366563}, + 'njs': 19, + 'nominatedTime': 0, + 'notes': 1249, + 'nps': 5.66, + 'passRating': 5.48632, + 'predictedAcc': 0.9749072, + 'qualifiedTime': 0, + 'rankedTime': 0, + 'requirements': 0, + 'speedTags': 0, + 'stars': 8.681121, + 'status': 3, + 'styleTags': 0, + 'techRating': 6.0219316, + 'type': 2, + 'value': 9, + 'walls': 666}, + 'id': '138da91', + 'song': {'author': 'Desmeon', + 'bpm': 174, + 'collaboratorIds': None, + 'coverImage': 'https://eu.cdn.beatsaver.com/bdf85d5d575a992139eff968a8348b3e6f03eefe.jpg', + 'duration': 227, + 'fullCoverImage': 'https://cdn.assets.beatleader.xyz/songcover-138da-cover.png', + 'hash': 'bdf85d5d575a992139eff968a8348b3e6f03eefe', + 'id': '138da', + 'mapper': 'CyanSnow', + 'mapperId': 4235138, + 'name': 'Hellcat', + 'subName': ''}}, +}] +``` diff --git a/docs/prompts/01-new.md b/docs/prompts/01-new.md new file mode 100644 index 0000000..06af731 --- /dev/null +++ b/docs/prompts/01-new.md @@ -0,0 +1,392 @@ +# Python coding + +We used openapi-python-client to generate client libraries for the scoresaber api. It's in clients/scoresaber in our python project: + +``` +treegit +. +├── docs +│   ├── api.md +│   ├── capture.md +│   └── PlaylistBuilder.md +├── src +│   ├── clients +│   │   ├── beatleader +│   │   │   ├── api +│   │   │   │   ├── beast_saber +│   │   │   │   │   ├── beast_saber_get_all.py +│   │   │   │   │   ├── beast_saber_nominate.py +│   │   │   │   │   └── __init__.py +│   │   │   │   ├── clan +│   │   │   │   │   ├── clan_get_all.py +│   │   │   │   │   ├── clan_get_clan_by_id.py +│   │   │   │   │   ├── clan_get_clan.py +│   │   │   │   │   ├── clan_get_clan_with_maps_by_id.py +│   │   │   │   │   ├── clan_get_clan_with_maps.py +│   │   │   │   │   ├── clan_get_history.py +│   │   │   │   │   ├── clan_global_map.py +│   │   │   │   │   └── __init__.py +│   │   │   │   ├── leaderboard +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   ├── leaderboard_get_all.py +│   │   │   │   │   ├── leaderboard_get_clan_rankings.py +│   │   │   │   │   ├── leaderboard_get.py +│   │   │   │   │   └── leaderboard_get_scoregraph.py +│   │   │   │   ├── modifiers +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   └── modifiers_get_modifiers.py +│   │   │   │   ├── patreon +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   └── patreon_refresh_my_patreon.py +│   │   │   │   ├── player +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   ├── player_get_beat_saver.py +│   │   │   │   │   ├── player_get_discord.py +│   │   │   │   │   ├── player_get_followers_info.py +│   │   │   │   │   ├── player_get_followers.py +│   │   │   │   │   ├── player_get_founded_clan.py +│   │   │   │   │   ├── player_get_participating_events.py +│   │   │   │   │   ├── player_get_patreon.py +│   │   │   │   │   ├── player_get_players.py +│   │   │   │   │   ├── player_get.py +│   │   │   │   │   └── player_get_ranked_maps.py +│   │   │   │   ├── player_scores +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   ├── player_scores_acc_graph.py +│   │   │   │   │   ├── player_scores_get_compact_history.py +│   │   │   │   │   ├── player_scores_get_compact_scores.py +│   │   │   │   │   ├── player_scores_get_history.py +│   │   │   │   │   ├── player_scores_get_pinned_scores.py +│   │   │   │   │   ├── player_scores_get_scores.py +│   │   │   │   │   └── player_scores_get_score_value.py +│   │   │   │   ├── song +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   └── song_get_all.py +│   │   │   │   └── __init__.py +│   │   │   ├── models +│   │   │   │   ├── __pycache__ +│   │   │   │   ├── achievement_description.py +│   │   │   │   ├── achievement_level.py +│   │   │   │   ├── achievement.py +│   │   │   │   ├── badge.py +│   │   │   │   ├── ban.py +│   │   │   │   ├── beasties_nomination.py +│   │   │   │   ├── besties_nomination_response.py +│   │   │   │   ├── clan_bigger_response.py +│   │   │   │   ├── clan_global_map_point.py +│   │   │   │   ├── clan_global_map.py +│   │   │   │   ├── clan_map_connection.py +│   │   │   │   ├── clan_maps_sort_by.py +│   │   │   │   ├── clan_point.py +│   │   │   │   ├── clan.py +│   │   │   │   ├── clan_ranking_response_clan_response_full_response_with_metadata_and_container.py +│   │   │   │   ├── clan_ranking_response.py +│   │   │   │   ├── clan_response_full.py +│   │   │   │   ├── clan_response_full_response_with_metadata.py +│   │   │   │   ├── clan_response.py +│   │   │   │   ├── clan_sort_by.py +│   │   │   │   ├── compact_leaderboard.py +│   │   │   │   ├── compact_leaderboard_response.py +│   │   │   │   ├── compact_score.py +│   │   │   │   ├── compact_score_response.py +│   │   │   │   ├── compact_score_response_response_with_metadata.py +│   │   │   │   ├── compact_song_response.py +│   │   │   │   ├── controller_enum.py +│   │   │   │   ├── criteria_commentary.py +│   │   │   │   ├── difficulty_description.py +│   │   │   │   ├── difficulty_response.py +│   │   │   │   ├── difficulty_status.py +│   │   │   │   ├── event_player.py +│   │   │   │   ├── event_ranking.py +│   │   │   │   ├── external_status.py +│   │   │   │   ├── featured_playlist.py +│   │   │   │   ├── featured_playlist_response.py +│   │   │   │   ├── follower_type.py +│   │   │   │   ├── global_map_history.py +│   │   │   │   ├── history_compact_response.py +│   │   │   │   ├── hmd.py +│   │   │   │   ├── info_to_highlight.py +│   │   │   │   ├── __init__.py +│   │   │   │   ├── leaderboard_change.py +│   │   │   │   ├── leaderboard_clan_ranking_response.py +│   │   │   │   ├── leaderboard_contexts.py +│   │   │   │   ├── leaderboard_group_entry.py +│   │   │   │   ├── leaderboard_info_response.py +│   │   │   │   ├── leaderboard_info_response_response_with_metadata.py +│   │   │   │   ├── leaderboard.py +│   │   │   │   ├── leaderboard_response.py +│   │   │   │   ├── leaderboard_sort_by.py +│   │   │   │   ├── legacy_modifiers.py +│   │   │   │   ├── link_response.py +│   │   │   │   ├── map_diff_response.py +│   │   │   │   ├── map_info_response.py +│   │   │   │   ├── map_info_response_response_with_metadata.py +│   │   │   │   ├── mapper.py +│   │   │   │   ├── mapper_response.py +│   │   │   │   ├── map_quality.py +│   │   │   │   ├── map_sort_by.py +│   │   │   │   ├── maps_type.py +│   │   │   │   ├── metadata.py +│   │   │   │   ├── modifiers_map.py +│   │   │   │   ├── modifiers_rating.py +│   │   │   │   ├── my_type.py +│   │   │   │   ├── operation.py +│   │   │   │   ├── order.py +│   │   │   │   ├── participating_event_response.py +│   │   │   │   ├── patreon_features.py +│   │   │   │   ├── player_change.py +│   │   │   │   ├── player_context_extension.py +│   │   │   │   ├── player_follower.py +│   │   │   │   ├── player_followers_info_response.py +│   │   │   │   ├── player.py +│   │   │   │   ├── player_response_clan_response_full_response_with_metadata_and_container.py +│   │   │   │   ├── player_response_full.py +│   │   │   │   ├── player_response.py +│   │   │   │   ├── player_response_with_stats.py +│   │   │   │   ├── player_response_with_stats_response_with_metadata.py +│   │   │   │   ├── player_score_stats_history.py +│   │   │   │   ├── player_score_stats.py +│   │   │   │   ├── player_search.py +│   │   │   │   ├── player_social.py +│   │   │   │   ├── player_sort_by.py +│   │   │   │   ├── pp_type.py +│   │   │   │   ├── profile_settings.py +│   │   │   │   ├── qualification_change.py +│   │   │   │   ├── qualification_commentary.py +│   │   │   │   ├── qualification_vote.py +│   │   │   │   ├── ranked_mapper_response.py +│   │   │   │   ├── ranked_map.py +│   │   │   │   ├── rank_qualification.py +│   │   │   │   ├── rank_update_change.py +│   │   │   │   ├── rank_update.py +│   │   │   │   ├── rank_voting.py +│   │   │   │   ├── replay_offsets.py +│   │   │   │   ├── requirements.py +│   │   │   │   ├── score_filter_status.py +│   │   │   │   ├── score_graph_entry.py +│   │   │   │   ├── score_improvement.py +│   │   │   │   ├── score_metadata.py +│   │   │   │   ├── score_response.py +│   │   │   │   ├── score_response_with_acc.py +│   │   │   │   ├── score_response_with_my_score.py +│   │   │   │   ├── score_response_with_my_score_response_with_metadata.py +│   │   │   │   ├── scores_sort_by.py +│   │   │   │   ├── song.py +│   │   │   │   ├── song_response.py +│   │   │   │   ├── song_status.py +│   │   │   │   ├── type.py +│   │   │   │   └── voter_feedback.py +│   │   │   ├── __pycache__ +│   │   │   ├── client.py +│   │   │   ├── errors.py +│   │   │   ├── __init__.py +│   │   │   ├── py.typed +│   │   │   └── types.py +│   │   ├── beatsaver +│   │   │   ├── api +│   │   │   │   ├── maps +│   │   │   │   │   ├── get_maps_collaborations_id.py +│   │   │   │   │   ├── get_maps_hash_hash.py +│   │   │   │   │   ├── get_maps_id_id.py +│   │   │   │   │   ├── get_maps_ids_ids.py +│   │   │   │   │   ├── get_maps_latest.py +│   │   │   │   │   ├── get_maps_plays_page.py +│   │   │   │   │   ├── get_maps_uploader_id_page.py +│   │   │   │   │   └── __init__.py +│   │   │   │   ├── playlists +│   │   │   │   │   ├── get_playlists_id_id_page.py +│   │   │   │   │   ├── get_playlists_latest.py +│   │   │   │   │   ├── get_playlists_search_page.py +│   │   │   │   │   ├── get_playlists_user_user_id_page.py +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   └── post_playlists_id_id_batch.py +│   │   │   │   ├── search +│   │   │   │   │   ├── get_search_text_page.py +│   │   │   │   │   └── __init__.py +│   │   │   │   ├── users +│   │   │   │   │   ├── get_users_id_id.py +│   │   │   │   │   ├── get_users_ids_ids.py +│   │   │   │   │   ├── get_users_name_name.py +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   └── post_users_verify.py +│   │   │   │   ├── vote +│   │   │   │   │   ├── get_vote.py +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   └── post_vote.py +│   │   │   │   └── __init__.py +│   │   │   ├── models +│   │   │   │   ├── __pycache__ +│   │   │   │   ├── action_response.py +│   │   │   │   ├── auth_request.py +│   │   │   │   ├── get_maps_latest_sort.py +│   │   │   │   ├── get_playlists_latest_sort.py +│   │   │   │   ├── get_playlists_search_page_sort_order.py +│   │   │   │   ├── get_search_text_page_leaderboard.py +│   │   │   │   ├── get_search_text_page_sort_order.py +│   │   │   │   ├── __init__.py +│   │   │   │   ├── map_detail_declared_ai.py +│   │   │   │   ├── map_detail_metadata.py +│   │   │   │   ├── map_detail.py +│   │   │   │   ├── map_detail_tags_item.py +│   │   │   │   ├── map_detail_with_order.py +│   │   │   │   ├── map_difficulty_characteristic.py +│   │   │   │   ├── map_difficulty_difficulty.py +│   │   │   │   ├── map_difficulty.py +│   │   │   │   ├── map_parity_summary.py +│   │   │   │   ├── map_stats.py +│   │   │   │   ├── map_stats_sentiment.py +│   │   │   │   ├── map_testplay.py +│   │   │   │   ├── map_version.py +│   │   │   │   ├── map_version_state.py +│   │   │   │   ├── playlist_batch_request.py +│   │   │   │   ├── playlist_full.py +│   │   │   │   ├── playlist_full_type.py +│   │   │   │   ├── playlist_page.py +│   │   │   │   ├── playlist_search_response.py +│   │   │   │   ├── playlist_stats.py +│   │   │   │   ├── search_response.py +│   │   │   │   ├── user_detail_patreon.py +│   │   │   │   ├── user_detail.py +│   │   │   │   ├── user_detail_type.py +│   │   │   │   ├── user_diff_stats.py +│   │   │   │   ├── user_follow_data.py +│   │   │   │   ├── user_stats.py +│   │   │   │   ├── vote_request.py +│   │   │   │   └── vote_summary.py +│   │   │   ├── __pycache__ +│   │   │   ├── client.py +│   │   │   ├── errors.py +│   │   │   ├── __init__.py +│   │   │   ├── py.typed +│   │   │   └── types.py +│   │   ├── __pycache__ +│   │   ├── scoresaber +│   │   │   ├── api +│   │   │   │   ├── leaderboards +│   │   │   │   │   ├── get_api_leaderboard_by_hash_hash_info.py +│   │   │   │   │   ├── get_api_leaderboard_by_hash_hash_scores.py +│   │   │   │   │   ├── get_api_leaderboard_by_id_leaderboard_id_info.py +│   │   │   │   │   ├── get_api_leaderboard_by_id_leaderboard_id_scores.py +│   │   │   │   │   ├── get_api_leaderboard_get_difficulties_hash.py +│   │   │   │   │   ├── get_api_leaderboards.py +│   │   │   │   │   └── __init__.py +│   │   │   │   ├── nomination_assessment_team +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   ├── post_api_ranking_request_action_nat_deny.py +│   │   │   │   │   ├── post_api_ranking_request_action_nat_qualify.py +│   │   │   │   │   └── post_api_ranking_request_action_nat_replace.py +│   │   │   │   ├── players +│   │   │   │   │   ├── get_api_player_player_id_basic.py +│   │   │   │   │   ├── get_api_player_player_id_full.py +│   │   │   │   │   ├── get_api_player_player_id_scores.py +│   │   │   │   │   ├── get_api_players_count.py +│   │   │   │   │   ├── get_api_players.py +│   │   │   │   │   └── __init__.py +│   │   │   │   ├── public_ranking +│   │   │   │   │   ├── get_api_ranking_request_by_id_leaderboard_id.py +│   │   │   │   │   ├── get_api_ranking_request_request_id.py +│   │   │   │   │   ├── get_api_ranking_requests_below_top.py +│   │   │   │   │   ├── get_api_ranking_requests_top.py +│   │   │   │   │   └── __init__.py +│   │   │   │   ├── quality_assurance_team +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   ├── post_api_ranking_request_action_qat_comment.py +│   │   │   │   │   └── post_api_ranking_request_action_qat_vote.py +│   │   │   │   ├── ranking_team +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   ├── post_api_ranking_request_action_rt_comment.py +│   │   │   │   │   ├── post_api_ranking_request_action_rt_create.py +│   │   │   │   │   └── post_api_ranking_request_action_rt_vote.py +│   │   │   │   ├── website_auth +│   │   │   │   │   ├── get_api_auth_get_token.py +│   │   │   │   │   ├── get_api_auth_logout.py +│   │   │   │   │   ├── __init__.py +│   │   │   │   │   └── post_api_auth_check_token.py +│   │   │   │   ├── website_user +│   │   │   │   │   ├── get_api_user_me.py +│   │   │   │   │   ├── get_api_user_player_id_refresh.py +│   │   │   │   │   ├── get_api_user_quest_key.py +│   │   │   │   │   └── __init__.py +│   │   │   │   └── __init__.py +│   │   │   ├── models +│   │   │   │   ├── __pycache__ +│   │   │   │   ├── badge.py +│   │   │   │   ├── check_token_body.py +│   │   │   │   ├── comment.py +│   │   │   │   ├── difficulty.py +│   │   │   │   ├── get_api_player_player_id_scores_sort.py +│   │   │   │   ├── i_get_token_response.py +│   │   │   │   ├── __init__.py +│   │   │   │   ├── leaderboard_info_collection.py +│   │   │   │   ├── leaderboard_info.py +│   │   │   │   ├── leaderboard_player.py +│   │   │   │   ├── metadata.py +│   │   │   │   ├── nat_deny_body.py +│   │   │   │   ├── nat_qualify_body.py +│   │   │   │   ├── nat_replace_body.py +│   │   │   │   ├── player_badges_type_1.py +│   │   │   │   ├── player_collection.py +│   │   │   │   ├── player.py +│   │   │   │   ├── player_score_collection.py +│   │   │   │   ├── player_score.py +│   │   │   │   ├── qat_comment_body.py +│   │   │   │   ├── qat_vote_body.py +│   │   │   │   ├── ranking_difficulty.py +│   │   │   │   ├── rank_request_information.py +│   │   │   │   ├── rank_request_listing.py +│   │   │   │   ├── rt_comment_body.py +│   │   │   │   ├── rt_create_body.py +│   │   │   │   ├── rt_vote_body.py +│   │   │   │   ├── score_collection.py +│   │   │   │   ├── score.py +│   │   │   │   ├── score_saber_error.py +│   │   │   │   ├── score_stats.py +│   │   │   │   ├── user_data.py +│   │   │   │   └── vote_group.py +│   │   │   ├── __pycache__ +│   │   │   ├── client.py +│   │   │   ├── errors.py +│   │   │   ├── __init__.py +│   │   │   ├── py.typed +│   │   │   └── types.py +│   │   └── __init__.py +│   ├── pleb_saberlist.egg-info +│   │   ├── dependency_links.txt +│   │   ├── entry_points.txt +│   │   ├── PKG-INFO +│   │   ├── requires.txt +│   │   ├── SOURCES.txt +│   │   └── top_level.txt +│   ├── saberlist +│   │   ├── __pycache__ +│   │   ├── beatleader.py +│   │   ├── __init__.py +│   │   ├── PlaylistBuilder.py +│   │   └── scoresaber.py +│   └── saberlist.egg-info +│   ├── dependency_links.txt +│   ├── entry_points.txt +│   ├── PKG-INFO +│   ├── requires.txt +│   ├── SOURCES.txt +│   └── top_level.txt +├── temp_covers +├── tests +│   ├── archive +│   │   ├── __pycache__ +│   │   └── saberlist +│   │   ├── __pycache__ +│   │   └── playlist_builder.py +│   ├── assets +│   │   └── sample_cover.jpg +│   ├── __pycache__ +│   └── playlist_builder.py +├── convert-comyfui-outupt.sh +├── LICENSE +├── pyproject.toml +└── README.md + +53 directories, 328 files +``` + +We are trying to learn how to use the scoresaber client in `clients/scoresaber` that we generated using openapi-python-client. diff --git a/docs/prompts/02-sample-usage.md b/docs/prompts/02-sample-usage.md new file mode 100644 index 0000000..d292c2d --- /dev/null +++ b/docs/prompts/02-sample-usage.md @@ -0,0 +1,41 @@ +We have some sample usage of this library here: + + +``` +In [40]: client = ScoreSaberClient(base_url="https://scoresaber.com") + ...: + ...: player_id = '76561199407393962' + ...: + ...: player_score_collection: PlayerScoreCollection = get_api_player_player_id_scores.sync( + ...: client=client, + ...: player_id=player_id, + ...: # page=1, + ...: # limit=50, + ...: # sort='recent' + ...: ) + ...: +2024-09-30 09:30:49 DEBUG: load_ssl_context verify=True cert=None trust_env=True http2=False +2024-09-30 09:30:49 DEBUG: load_verify_locations cafile='/home/blee/ops/beatsaber/playlist-tool/.venv/lib/python3.11/site-packages/certifi/cacert.pem' +2024-09-30 09:30:49 DEBUG: connect_tcp.started host='scoresaber.com' port=443 local_address=None timeout=None socket_options=None +2024-09-30 09:30:49 DEBUG: connect_tcp.complete return_value= +2024-09-30 09:30:49 DEBUG: start_tls.started ssl_context= server_hostname='scoresaber.com' timeout=None +2024-09-30 09:30:49 DEBUG: start_tls.complete return_value= +2024-09-30 09:30:49 DEBUG: send_request_headers.started request= +2024-09-30 09:30:49 DEBUG: send_request_headers.complete +2024-09-30 09:30:49 DEBUG: send_request_body.started request= +2024-09-30 09:30:49 DEBUG: send_request_body.complete +2024-09-30 09:30:49 DEBUG: receive_response_headers.started request= +2024-09-30 09:30:49 DEBUG: receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Mon, 30 Sep 2024 16:30:49 GMT'), (b'Content-Type', b'application/json; charset=utf-8'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'Content-Security-Policy', b"default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests"), (b'Cross-Origin-Embedder-Policy', b'require-corp'), (b'Cross-Origin-Opener-Policy', b'same-origin'), (b'Cross-Origin-Resource-Policy', b'same-origin'), (b'Origin-Agent-Cluster', b'?1'), (b'Referrer-Policy', b'no-referrer'), (b'Strict-Transport-Security', b'max-age=15552000; includeSubDomains'), (b'X-Content-Type-Options', b'nosniff'), (b'X-DNS-Prefetch-Control', b'off'), (b'X-Download-Options', b'noopen'), (b'X-Frame-Options', b'SAMEORIGIN'), (b'X-Permitted-Cross-Domain-Policies', b'none'), (b'X-XSS-Protection', b'0'), (b'X-RateLimit-Limit', b'400'), (b'X-RateLimit-Remaining', b'399'), (b'X-RateLimit-Reset', b'1727713862'), (b'ETag', b'W/"3369-agcCR95tngk5ACxBE2z3E87S8IM"'), (b'CF-Cache-Status', b'DYNAMIC'), (b'Report-To', b'{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=3WgwWJyhnP7LHZaTLYLst9jpVmzOj5bhgASSmRqf97BJDejCgVN2K%2BD1XI79HkY4TAXyQVzNxgYWid9iMXy2lmS0q6QVpYZKakJZhoPOj1GEKQeV22VgLUfKXsgPbxK2aQ%3D%3D"}],"group":"cf-nel","max_age":604800}'), (b'NEL', b'{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'), (b'Server', b'cloudflare'), (b'CF-RAY', b'8cb59986999b0cbb-LAX'), (b'Content-Encoding', b'gzip')]) +2024-09-30 09:30:49 INFO: HTTP Request: GET https://scoresaber.com/api/player/76561199407393962/scores "HTTP/1.1 200 OK" +2024-09-30 09:30:49 DEBUG: receive_response_body.started request= +2024-09-30 09:30:49 DEBUG: receive_response_body.complete +2024-09-30 09:30:49 DEBUG: response_closed.started +2024-09-30 09:30:49 DEBUG: response_closed.complete + +2024-09-30 09:30:49 DEBUG: Using selector: EpollSelector +In [41]: player_score_collection +Out[41]: PlayerScoreCollection(player_scores=[PlayerScore(score=Score(id=84950667, rank=104, base_score=1099231, modified_score=1099231, pp=341.7099, weight=1, modifiers='', multiplier=1, bad_cuts=0, missed_notes=2, max_combo=775, full_combo=False, hmd=0, has_replay=True, time_set=datetime.datetime(2024, 9, 5, 1, 8, 57, tzinfo=tzutc()), device_hmd='Vive', device_controller_left='Touch', device_controller_right='Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=617336, song_hash='CEE98A6F3D644468E231D385CA609F804977583A', song_name='Unlimited Hyperlink', song_sub_name='', song_author_name='Kobaryo', level_author_name='Timbo', difficulty=Difficulty(leaderboard_id=617336, difficulty=5, game_mode='SoloStandard', difficulty_raw='_Hard_SoloStandard'), max_score=1165755, created_date=datetime.datetime(2024, 7, 20, 0, 17, 12, tzinfo=tzutc()), ranked_date=datetime.datetime(2024, 9, 2, 17, 38, 15, tzinfo=tzutc()), qualified_date=datetime.datetime(2024, 8, 4, 7, 39, 33, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=8.46, positive_modifiers=False, plays=357, daily_plays=10, cover_image='https://cdn.scoresaber.com/covers/CEE98A6F3D644468E231D385CA609F804977583A.png', player_score=None, difficulties=[], additional_properties={})), PlayerScore(score=Score(id=84877397, rank=556, base_score=1440841, modified_score=1440841, pp=313.5614, weight=0.965, modifiers='', multiplier=1, bad_cuts=1, missed_notes=1, max_combo=979, full_combo=False, hmd=0, has_replay=False, time_set=datetime.datetime(2024, 9, 3, 0, 40, 42, tzinfo=tzutc()), device_hmd='Vive', device_controller_left='Touch', device_controller_right='Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=292442, song_hash='5EEA46E777960913951ED9D0257404CC3A1BE305', song_name='Memecore', song_sub_name='', song_author_name='HiTECH NINJA', level_author_name='FatBeanzoop', difficulty=Difficulty(leaderboard_id=292442, difficulty=7, game_mode='SoloStandard', difficulty_raw='_Expert_SoloStandard'), max_score=1541115, created_date=datetime.datetime(2020, 9, 10, 3, 12, 50, tzinfo=tzutc()), ranked_date=datetime.datetime(2020, 9, 15, 9, 27, 51, tzinfo=tzutc()), qualified_date=datetime.datetime(2020, 9, 10, 16, 7, 16, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=8.07, positive_modifiers=False, plays=5560, daily_plays=4, cover_image='https://cdn.scoresaber.com/covers/5EEA46E777960913951ED9D0257404CC3A1BE305.png', player_score=None, difficulties=[], additional_properties={})), PlayerScore(score=Score(id=83361463, rank=132, base_score=1363346, modified_score=1363346, pp=306.9723, weight=0.931225, modifiers='', multiplier=1, bad_cuts=0, missed_notes=0, max_combo=1572, full_combo=True, hmd=0, has_replay=True, time_set=datetime.datetime(2024, 8, 15, 23, 10, 29, tzinfo=tzutc()), device_hmd='Vive', device_controller_left='Touch', device_controller_right='Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=299718, song_hash='A51425319D892986A4867388153BCE45B3C28483', song_name='Shake The Ground', song_sub_name='(feat. Sullivan King & Jonah Kay)', song_author_name='Kill The Noise & SNAILS', level_author_name='Checkthepan', difficulty=Difficulty(leaderboard_id=299718, difficulty=7, game_mode='SoloStandard', difficulty_raw='_Expert_SoloStandard'), max_score=1438995, created_date=datetime.datetime(2020, 10, 9, 0, 26, 9, tzinfo=tzutc()), ranked_date=datetime.datetime(2020, 10, 16, 15, 28, 19, tzinfo=tzutc()), qualified_date=datetime.datetime(2020, 10, 11, 16, 10, 9, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=7.4, positive_modifiers=False, plays=3317, daily_plays=1, cover_image='https://cdn.scoresaber.com/covers/A51425319D892986A4867388153BCE45B3C28483.png', player_score=None, difficulties=[], additional_properties={})), PlayerScore(score=Score(id=83135043, rank=512, base_score=884286, modified_score=884286, pp=302.4246, weight=0.8986321249999999, modifiers='', multiplier=1, bad_cuts=0, missed_notes=2, max_combo=797, full_combo=False, hmd=0, has_replay=True, time_set=datetime.datetime(2024, 5, 1, 22, 58, 43, tzinfo=tzutc()), device_hmd='Quest 2', device_controller_left='Quest 2 Touch', device_controller_right='Quest 2 Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=320372, song_hash='62128DFDD39DB6A2CC380C254031A9D4367B87A1', song_name='Nibelungen', song_sub_name='', song_author_name='Gram', level_author_name='ComplexFrequency', difficulty=Difficulty(leaderboard_id=320372, difficulty=5, game_mode='SoloStandard', difficulty_raw='_Hard_SoloStandard'), max_score=937595, created_date=datetime.datetime(2021, 1, 11, 2, 21, 1, tzinfo=tzutc()), ranked_date=datetime.datetime(2021, 1, 22, 5, 8, 50, tzinfo=tzutc()), qualified_date=datetime.datetime(2021, 1, 11, 2, 57, 56, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=7.48, positive_modifiers=False, plays=5915, daily_plays=4, cover_image='https://cdn.scoresaber.com/covers/62128DFDD39DB6A2CC380C254031A9D4367B87A1.png', player_score=None, difficulties=[], additional_properties={})), PlayerScore(score=Score(id=82951813, rank=225, base_score=1063732, modified_score=1063732, pp=299.8663, weight=0.8671800006249999, modifiers='', multiplier=1, bad_cuts=0, missed_notes=0, max_combo=1228, full_combo=True, hmd=0, has_replay=True, time_set=datetime.datetime(2024, 9, 17, 21, 0, 28, tzinfo=tzutc()), device_hmd='Vive', device_controller_left='Touch', device_controller_right='Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=290861, song_hash='2E6CB362F31D00EE9F2B9C8640CFD94BBFB8377F', song_name='Astronomia', song_sub_name='(Camellia Remix)', song_author_name='Vicetone and Tony Igy', level_author_name='That_Narwhal', difficulty=Difficulty(leaderboard_id=290861, difficulty=7, game_mode='SoloStandard', difficulty_raw='_Expert_SoloStandard'), max_score=1122515, created_date=datetime.datetime(2020, 9, 3, 4, 19, 55, tzinfo=tzutc()), ranked_date=datetime.datetime(2020, 9, 8, 12, 35, 3, tzinfo=tzutc()), qualified_date=datetime.datetime(2020, 9, 3, 13, 24, 17, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=7.22, positive_modifiers=False, plays=5830, daily_plays=3, cover_image='https://cdn.scoresaber.com/covers/2E6CB362F31D00EE9F2B9C8640CFD94BBFB8377F.png', player_score=None, difficulties=[], additional_properties={})), PlayerScore(score=Score(id=82951898, rank=284, base_score=1190738, modified_score=1190738, pp=299.2155, weight=0.8368287006031249, modifiers='', multiplier=1, bad_cuts=1, missed_notes=2, max_combo=900, full_combo=False, hmd=0, has_replay=True, time_set=datetime.datetime(2024, 4, 12, 22, 25, 4, tzinfo=tzutc()), device_hmd='Quest 2', device_controller_left='Quest 2 Touch', device_controller_right='Quest 2 Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=198670, song_hash='9E6DEB75CA74B96497BC5EF0BB5B98EE5C0B7E69', song_name='Twisted Drop Party', song_sub_name='', song_author_name='t+pazolite & Getty', level_author_name='Depito & ExUnReal', difficulty=Difficulty(leaderboard_id=198670, difficulty=7, game_mode='SoloStandard', difficulty_raw='_Expert_SoloStandard'), max_score=1267875, created_date=datetime.datetime(2020, 1, 21, 17, 27, 38, tzinfo=tzutc()), ranked_date=datetime.datetime(2020, 4, 9, 18, 0, 31, tzinfo=tzutc()), qualified_date=datetime.datetime(2020, 4, 5, 0, 59, 34, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=7.57, positive_modifiers=False, plays=3988, daily_plays=1, cover_image='https://cdn.scoresaber.com/covers/9E6DEB75CA74B96497BC5EF0BB5B98EE5C0B7E69.png', player_score=None, difficulties=[], additional_properties={})), PlayerScore(score=Score(id=84617098, rank=268, base_score=695542, modified_score=695542, pp=298.7397, weight=0.8075396960820155, modifiers='', multiplier=1, bad_cuts=0, missed_notes=0, max_combo=816, full_combo=True, hmd=0, has_replay=True, time_set=datetime.datetime(2024, 8, 16, 23, 28, 18, tzinfo=tzutc()), device_hmd='Vive', device_controller_left='Touch', device_controller_right='Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=597749, song_hash='61FD5B17CBA13ABE1E76591121E1AC7FE8A5F425', song_name='ANALYS', song_sub_name='', song_author_name='HAYAKO', level_author_name='RetrX', difficulty=Difficulty(leaderboard_id=597749, difficulty=7, game_mode='SoloStandard', difficulty_raw='_Expert_SoloStandard'), max_score=743475, created_date=datetime.datetime(2024, 3, 2, 5, 38, 26, tzinfo=tzutc()), ranked_date=datetime.datetime(2024, 3, 18, 3, 3, 12, tzinfo=tzutc()), qualified_date=datetime.datetime(2024, 3, 4, 19, 50, 44, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=7.67, positive_modifiers=False, plays=1253, daily_plays=3, cover_image='https://cdn.scoresaber.com/covers/61FD5B17CBA13ABE1E76591121E1AC7FE8A5F425.png', player_score=None, difficulties=[], additional_properties={})), PlayerScore(score=Score(id=83669721, rank=1373, base_score=1687417, modified_score=1687417, pp=298.7396, weight=0.7792758067191449, modifiers='', multiplier=1, bad_cuts=0, missed_notes=4, max_combo=764, full_combo=False, hmd=0, has_replay=False, time_set=datetime.datetime(2024, 9, 6, 21, 32, 52, tzinfo=tzutc()), device_hmd='Vive', device_controller_left='Touch', device_controller_right='Touch', leaderboard_player_info=None), leaderboard=LeaderboardInfo(id=368474, song_hash='9E3CD9B0C5559167E31E6894C14E391AEA937991', song_name='KillerToy', song_sub_name='', song_author_name='Camellia', level_author_name='Jabob', difficulty=Difficulty(leaderboard_id=368474, difficulty=7, game_mode='SoloStandard', difficulty_raw='_Expert_SoloStandard'), max_score=1818955, created_date=datetime.datetime(2021, 7, 14, 17, 31, 30, tzinfo=tzutc()), ranked_date=datetime.datetime(2021, 9, 19, 16, 56, 7, tzinfo=tzutc()), qualified_date=datetime.datetime(2021, 9, 10, 18, 53, 58, tzinfo=tzutc()), loved_date=None, ranked=True, qualified=False, loved=False, max_pp=-1, stars=7.91, positive_modifiers=False, plays=6698, daily_plays=8, cover_image='https://cdn.scoresaber.com/covers/9E3CD9B0C5559167E31E6894C14E391AEA937991.png', player_score=None, difficulties=[], additional_properties={}))], metadata=Metadata(total=961, page=1, items_per_page=8)) + +2024-09-30 09:31:03 DEBUG: Using selector: EpollSelector +``` + diff --git a/pyproject.toml b/pyproject.toml index 6f7bfbd..b5d819e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pleb-saberlist" -version = "0.1.0" +version = "0.2.0" description = "Beat Saber playlist tool" readme = "README.md" authors = [{ name = "blee", email = "git@blee.tube" }] @@ -14,6 +14,7 @@ dependencies = [ 'build>=1.2.1', 'requests>=2.31.0', 'pytest>=8.1.1', + 'python-dotenv>=1.0.1', 'PyScoreSaber>=1.0.10', 'beatsaver>=1.0.1' ] @@ -37,7 +38,8 @@ Homepage = "https://git.satstack.dev/blee/beatsaber-playlist-tool" #player_scores_by_stars = "saberlist.scoresaber:replay_ranked" #replay_all_by_acc = "saberlist.scoresaber:replay_all_by_acc" #leaderboard_songs_by_stars = "saberlist.scoresaber:leaderboard_songs" -saberlist_replay_bl = "saberlist.beatleader:saberlist_replay_bl" +#saberlist_replay_bl = "saberlist.beatleader:saberlist_replay_bl" +settle_old_scores_ss = "saberlist.make:create_playlist" [tool.pytest.ini_options] pythonpath = ["src"] \ No newline at end of file diff --git a/src/clients/__init__.py b/src/clients/__init__.py new file mode 100644 index 0000000..f5e94e3 --- /dev/null +++ b/src/clients/__init__.py @@ -0,0 +1,35 @@ +""" +from .beatleader.client import Client as BeatLeaderClient +from .beatleader.models import ( + Player as BeatLeaderPlayer, + Leaderboard as BeatLeaderLeaderboard, +) + +from .beatsaver.client import Client as BeatSaverClient +from .beatsaver.models import ( + MapDetail as BeatSaverMapDetail, + UserDetail as BeatSaverUserDetail, + SearchResponse as BeatSaverSearchResponse, +) +""" +from .scoresaber.client import Client as ScoreSaberClient +from .scoresaber.models import ( + Player as ScoreSaberPlayer, + Score as ScoreSaberScore, + LeaderboardInfo as ScoreSaberLeaderboardInfo, +) + +__all__ = [ +# "BeatLeaderClient", +# "BeatLeaderPlayer", +# "BeatLeaderScore", +# "BeatLeaderLeaderboard", +# "BeatSaverClient", +# "BeatSaverMapDetail", +# "BeatSaverUserDetail", +# "BeatSaverSearchResponse", + "ScoreSaberClient", + "ScoreSaberPlayer", + "ScoreSaberScore", + "ScoreSaberLeaderboardInfo", +] \ No newline at end of file diff --git a/src/clients/beatleader/__init__.py b/src/clients/beatleader/__init__.py new file mode 100644 index 0000000..49ef706 --- /dev/null +++ b/src/clients/beatleader/__init__.py @@ -0,0 +1,8 @@ +"""A client library for accessing BeatLeader API. Get various Beat Saber information.""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/src/clients/beatleader/api/__init__.py b/src/clients/beatleader/api/__init__.py new file mode 100644 index 0000000..81f9fa2 --- /dev/null +++ b/src/clients/beatleader/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/src/clients/beatleader/api/beast_saber/__init__.py b/src/clients/beatleader/api/beast_saber/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/beast_saber/beast_saber_get_all.py b/src/clients/beatleader/api/beast_saber/beast_saber_get_all.py new file mode 100644 index 0000000..6d48fa8 --- /dev/null +++ b/src/clients/beatleader/api/beast_saber/beast_saber_get_all.py @@ -0,0 +1,177 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.beasties_nomination import BeastiesNomination +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + leaderboard_id: Union[Unset, str] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["leaderboardId"] = leaderboard_id + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/beasties/nominations", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["BeastiesNomination"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.text + for response_200_item_data in _response_200: + response_200_item = BeastiesNomination.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = cast(Any, None) + return response_401 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["BeastiesNomination"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, +) -> Response[Union[Any, List["BeastiesNomination"]]]: + """Retrieve a list of nominations for particular leaderboard + + Authenticated player Beasties nominations. + + Args: + leaderboard_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['BeastiesNomination']]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, List["BeastiesNomination"]]]: + """Retrieve a list of nominations for particular leaderboard + + Authenticated player Beasties nominations. + + Args: + leaderboard_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['BeastiesNomination']] + """ + + return sync_detailed( + client=client, + leaderboard_id=leaderboard_id, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, +) -> Response[Union[Any, List["BeastiesNomination"]]]: + """Retrieve a list of nominations for particular leaderboard + + Authenticated player Beasties nominations. + + Args: + leaderboard_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['BeastiesNomination']]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, List["BeastiesNomination"]]]: + """Retrieve a list of nominations for particular leaderboard + + Authenticated player Beasties nominations. + + Args: + leaderboard_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['BeastiesNomination']] + """ + + return ( + await asyncio_detailed( + client=client, + leaderboard_id=leaderboard_id, + ) + ).parsed diff --git a/src/clients/beatleader/api/beast_saber/beast_saber_nominate.py b/src/clients/beatleader/api/beast_saber/beast_saber_nominate.py new file mode 100644 index 0000000..82ef575 --- /dev/null +++ b/src/clients/beatleader/api/beast_saber/beast_saber_nominate.py @@ -0,0 +1,187 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.besties_nomination_response import BestiesNominationResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + leaderboard_id: Union[Unset, str] = UNSET, + category: Union[Unset, str] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["leaderboardId"] = leaderboard_id + + params["category"] = category + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/beasties/nominate", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, BestiesNominationResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = BestiesNominationResponse.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = cast(Any, None) + return response_401 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, BestiesNominationResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, + category: Union[Unset, str] = UNSET, +) -> Response[Union[Any, BestiesNominationResponse]]: + """Nominate a map for Besties Awards + + Nominates provided leaderboard map for mapping awards in selected category + + Args: + leaderboard_id (Union[Unset, str]): + category (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, BestiesNominationResponse]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + category=category, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, + category: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, BestiesNominationResponse]]: + """Nominate a map for Besties Awards + + Nominates provided leaderboard map for mapping awards in selected category + + Args: + leaderboard_id (Union[Unset, str]): + category (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, BestiesNominationResponse] + """ + + return sync_detailed( + client=client, + leaderboard_id=leaderboard_id, + category=category, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, + category: Union[Unset, str] = UNSET, +) -> Response[Union[Any, BestiesNominationResponse]]: + """Nominate a map for Besties Awards + + Nominates provided leaderboard map for mapping awards in selected category + + Args: + leaderboard_id (Union[Unset, str]): + category (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, BestiesNominationResponse]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + category=category, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + leaderboard_id: Union[Unset, str] = UNSET, + category: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, BestiesNominationResponse]]: + """Nominate a map for Besties Awards + + Nominates provided leaderboard map for mapping awards in selected category + + Args: + leaderboard_id (Union[Unset, str]): + category (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, BestiesNominationResponse] + """ + + return ( + await asyncio_detailed( + client=client, + leaderboard_id=leaderboard_id, + category=category, + ) + ).parsed diff --git a/src/clients/beatleader/api/clan/__init__.py b/src/clients/beatleader/api/clan/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/clan/clan_get_all.py b/src/clients/beatleader/api/clan/clan_get_all.py new file mode 100644 index 0000000..6064092 --- /dev/null +++ b/src/clients/beatleader/api/clan/clan_get_all.py @@ -0,0 +1,265 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.clan_response_full_response_with_metadata import ClanResponseFullResponseWithMetadata +from ...models.clan_sort_by import ClanSortBy +from ...models.order import Order +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort: Union[Unset, ClanSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + sort_by: Union[Unset, ClanSortBy] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort: Union[Unset, str] = UNSET + if not isinstance(sort, Unset): + json_sort = sort.value + + params["sort"] = json_sort + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["search"] = search + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/clans", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ClanResponseFullResponseWithMetadata]]: + if response.status_code == HTTPStatus.OK: + response_200 = ClanResponseFullResponseWithMetadata.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ClanResponseFullResponseWithMetadata]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort: Union[Unset, ClanSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + sort_by: Union[Unset, ClanSortBy] = UNSET, +) -> Response[Union[Any, ClanResponseFullResponseWithMetadata]]: + """Retrieve a list of clans + + Fetches a paginated and optionally filtered list of clans (group of players). Filters include + sorting by performance points, search, name, rank, and more. + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort (Union[Unset, ClanSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + sort_by (Union[Unset, ClanSortBy]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanResponseFullResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + page=page, + count=count, + sort=sort, + order=order, + search=search, + sort_by=sort_by, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort: Union[Unset, ClanSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + sort_by: Union[Unset, ClanSortBy] = UNSET, +) -> Optional[Union[Any, ClanResponseFullResponseWithMetadata]]: + """Retrieve a list of clans + + Fetches a paginated and optionally filtered list of clans (group of players). Filters include + sorting by performance points, search, name, rank, and more. + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort (Union[Unset, ClanSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + sort_by (Union[Unset, ClanSortBy]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanResponseFullResponseWithMetadata] + """ + + return sync_detailed( + client=client, + page=page, + count=count, + sort=sort, + order=order, + search=search, + sort_by=sort_by, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort: Union[Unset, ClanSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + sort_by: Union[Unset, ClanSortBy] = UNSET, +) -> Response[Union[Any, ClanResponseFullResponseWithMetadata]]: + """Retrieve a list of clans + + Fetches a paginated and optionally filtered list of clans (group of players). Filters include + sorting by performance points, search, name, rank, and more. + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort (Union[Unset, ClanSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + sort_by (Union[Unset, ClanSortBy]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanResponseFullResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + page=page, + count=count, + sort=sort, + order=order, + search=search, + sort_by=sort_by, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort: Union[Unset, ClanSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + sort_by: Union[Unset, ClanSortBy] = UNSET, +) -> Optional[Union[Any, ClanResponseFullResponseWithMetadata]]: + """Retrieve a list of clans + + Fetches a paginated and optionally filtered list of clans (group of players). Filters include + sorting by performance points, search, name, rank, and more. + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort (Union[Unset, ClanSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + sort_by (Union[Unset, ClanSortBy]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanResponseFullResponseWithMetadata] + """ + + return ( + await asyncio_detailed( + client=client, + page=page, + count=count, + sort=sort, + order=order, + search=search, + sort_by=sort_by, + ) + ).parsed diff --git a/src/clients/beatleader/api/clan/clan_get_clan.py b/src/clients/beatleader/api/clan/clan_get_clan.py new file mode 100644 index 0000000..08be5cf --- /dev/null +++ b/src/clients/beatleader/api/clan/clan_get_clan.py @@ -0,0 +1,254 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.order import Order +from ...models.player_response_clan_response_full_response_with_metadata_and_container import ( + PlayerResponseClanResponseFullResponseWithMetadataAndContainer, +) +from ...models.player_sort_by import PlayerSortBy +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + tag: str, + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["primary"] = primary + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/clan/{tag}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerResponseClanResponseFullResponseWithMetadataAndContainer.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by tag + + Fetches details of a specific clan identified by its tag. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + tag=tag, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Optional[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by tag + + Fetches details of a specific clan identified by its tag. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return sync_detailed( + tag=tag, + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ).parsed + + +async def asyncio_detailed( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by tag + + Fetches details of a specific clan identified by its tag. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + tag=tag, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Optional[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by tag + + Fetches details of a specific clan identified by its tag. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return ( + await asyncio_detailed( + tag=tag, + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ) + ).parsed diff --git a/src/clients/beatleader/api/clan/clan_get_clan_by_id.py b/src/clients/beatleader/api/clan/clan_get_clan_by_id.py new file mode 100644 index 0000000..ae1b7a7 --- /dev/null +++ b/src/clients/beatleader/api/clan/clan_get_clan_by_id.py @@ -0,0 +1,254 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.order import Order +from ...models.player_response_clan_response_full_response_with_metadata_and_container import ( + PlayerResponseClanResponseFullResponseWithMetadataAndContainer, +) +from ...models.player_sort_by import PlayerSortBy +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: int, + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["primary"] = primary + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/clan/id/{id}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerResponseClanResponseFullResponseWithMetadataAndContainer.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by ID + + Fetches details of a specific clan identified by its ID. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Optional[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by ID + + Fetches details of a specific clan identified by its ID. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return sync_detailed( + id=id, + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by ID + + Fetches details of a specific clan identified by its ID. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + primary: Union[Unset, bool] = False, +) -> Optional[Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve details of a specific clan by ID + + Fetches details of a specific clan identified by its ID. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, PlayerSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + primary (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + primary=primary, + ) + ).parsed diff --git a/src/clients/beatleader/api/clan/clan_get_clan_with_maps.py b/src/clients/beatleader/api/clan/clan_get_clan_with_maps.py new file mode 100644 index 0000000..46cec89 --- /dev/null +++ b/src/clients/beatleader/api/clan/clan_get_clan_with_maps.py @@ -0,0 +1,263 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.clan_maps_sort_by import ClanMapsSortBy +from ...models.clan_ranking_response_clan_response_full_response_with_metadata_and_container import ( + ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer, +) +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.order import Order +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + tag: str, + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/clan/{tag}/maps", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + if response.status_code == HTTPStatus.OK: + response_200 = ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by tag + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its tag, with optional sorting and filtering. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + tag=tag, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Optional[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by tag + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its tag, with optional sorting and filtering. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return sync_detailed( + tag=tag, + client=client, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ).parsed + + +async def asyncio_detailed( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by tag + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its tag, with optional sorting and filtering. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + tag=tag, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + tag: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Optional[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by tag + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its tag, with optional sorting and filtering. + + Args: + tag (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return ( + await asyncio_detailed( + tag=tag, + client=client, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ) + ).parsed diff --git a/src/clients/beatleader/api/clan/clan_get_clan_with_maps_by_id.py b/src/clients/beatleader/api/clan/clan_get_clan_with_maps_by_id.py new file mode 100644 index 0000000..f130b8b --- /dev/null +++ b/src/clients/beatleader/api/clan/clan_get_clan_with_maps_by_id.py @@ -0,0 +1,263 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.clan_maps_sort_by import ClanMapsSortBy +from ...models.clan_ranking_response_clan_response_full_response_with_metadata_and_container import ( + ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer, +) +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.order import Order +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: int, + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/clan/id/{id}/maps", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + if response.status_code == HTTPStatus.OK: + response_200 = ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by ID + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its ID, with optional sorting and filtering. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Optional[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by ID + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its ID, with optional sorting and filtering. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return sync_detailed( + id=id, + client=client, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by ID + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its ID, with optional sorting and filtering. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, ClanMapsSortBy] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + order: Union[Unset, Order] = UNSET, +) -> Optional[Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer]]: + """Retrieve clan maps by ID + + Fetches ranked maps(maps that can be captured on the global map) for where players of clan made + scores identified by its ID, with optional sorting and filtering. + + Args: + id (int): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, ClanMapsSortBy]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + page=page, + count=count, + sort_by=sort_by, + leaderboard_context=leaderboard_context, + order=order, + ) + ).parsed diff --git a/src/clients/beatleader/api/clan/clan_get_history.py b/src/clients/beatleader/api/clan/clan_get_history.py new file mode 100644 index 0000000..5b9ef3d --- /dev/null +++ b/src/clients/beatleader/api/clan/clan_get_history.py @@ -0,0 +1,190 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.global_map_history import GlobalMapHistory +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: int, + *, + count: Union[Unset, int] = 50, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["count"] = count + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/clan/{id}/history", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["GlobalMapHistory"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.text + for response_200_item_data in _response_200: + response_200_item = GlobalMapHistory.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["GlobalMapHistory"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + count: Union[Unset, int] = 50, +) -> Response[Union[Any, List["GlobalMapHistory"]]]: + """Retrieve clan's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (int): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['GlobalMapHistory']]] + """ + + kwargs = _get_kwargs( + id=id, + count=count, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: Union[AuthenticatedClient, Client], + count: Union[Unset, int] = 50, +) -> Optional[Union[Any, List["GlobalMapHistory"]]]: + """Retrieve clan's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (int): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['GlobalMapHistory']] + """ + + return sync_detailed( + id=id, + client=client, + count=count, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + count: Union[Unset, int] = 50, +) -> Response[Union[Any, List["GlobalMapHistory"]]]: + """Retrieve clan's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (int): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['GlobalMapHistory']]] + """ + + kwargs = _get_kwargs( + id=id, + count=count, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + *, + client: Union[AuthenticatedClient, Client], + count: Union[Unset, int] = 50, +) -> Optional[Union[Any, List["GlobalMapHistory"]]]: + """Retrieve clan's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (int): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['GlobalMapHistory']] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + count=count, + ) + ).parsed diff --git a/src/clients/beatleader/api/clan/clan_global_map.py b/src/clients/beatleader/api/clan/clan_global_map.py new file mode 100644 index 0000000..7e4e813 --- /dev/null +++ b/src/clients/beatleader/api/clan/clan_global_map.py @@ -0,0 +1,137 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.clan_global_map import ClanGlobalMap +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/clans/globalmap", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ClanGlobalMap]]: + if response.status_code == HTTPStatus.OK: + response_200 = ClanGlobalMap.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ClanGlobalMap]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, ClanGlobalMap]]: + """Retrieve the global clan map + + Fetches a global map showing clan captured maps and rankings. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanGlobalMap]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, ClanGlobalMap]]: + """Retrieve the global clan map + + Fetches a global map showing clan captured maps and rankings. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanGlobalMap] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, ClanGlobalMap]]: + """Retrieve the global clan map + + Fetches a global map showing clan captured maps and rankings. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanGlobalMap]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, ClanGlobalMap]]: + """Retrieve the global clan map + + Fetches a global map showing clan captured maps and rankings. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanGlobalMap] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/leaderboard/__init__.py b/src/clients/beatleader/api/leaderboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/leaderboard/leaderboard_get.py b/src/clients/beatleader/api/leaderboard/leaderboard_get.py new file mode 100644 index 0000000..ba81af0 --- /dev/null +++ b/src/clients/beatleader/api/leaderboard/leaderboard_get.py @@ -0,0 +1,386 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.leaderboard_response import LeaderboardResponse +from ...models.leaderboard_sort_by import LeaderboardSortBy +from ...models.order import Order +from ...models.score_filter_status import ScoreFilterStatus +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, LeaderboardSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + modifiers: Union[Unset, str] = UNSET, + friends: Union[Unset, bool] = False, + voters: Union[Unset, bool] = False, + clan_tag: Union[Unset, str] = UNSET, + prediction: Union[Unset, bool] = False, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + json_score_status: Union[Unset, str] = UNSET + if not isinstance(score_status, Unset): + json_score_status = score_status.value + + params["scoreStatus"] = json_score_status + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + params["countries"] = countries + + params["search"] = search + + params["modifiers"] = modifiers + + params["friends"] = friends + + params["voters"] = voters + + params["clanTag"] = clan_tag + + params["prediction"] = prediction + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/leaderboard/{id}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, LeaderboardResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = LeaderboardResponse.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, LeaderboardResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, LeaderboardSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + modifiers: Union[Unset, str] = UNSET, + friends: Union[Unset, bool] = False, + voters: Union[Unset, bool] = False, + clan_tag: Union[Unset, str] = UNSET, + prediction: Union[Unset, bool] = False, +) -> Response[Union[Any, LeaderboardResponse]]: + """Retrieve leaderboard details + + Fetches details of a leaderboard identified by its ID, with optional sorting and filtering for + scores. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, LeaderboardSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + countries (Union[Unset, str]): + search (Union[Unset, str]): + modifiers (Union[Unset, str]): + friends (Union[Unset, bool]): Default: False. + voters (Union[Unset, bool]): Default: False. + clan_tag (Union[Unset, str]): + prediction (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardResponse]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + sort_by=sort_by, + order=order, + score_status=score_status, + leaderboard_context=leaderboard_context, + countries=countries, + search=search, + modifiers=modifiers, + friends=friends, + voters=voters, + clan_tag=clan_tag, + prediction=prediction, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, LeaderboardSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + modifiers: Union[Unset, str] = UNSET, + friends: Union[Unset, bool] = False, + voters: Union[Unset, bool] = False, + clan_tag: Union[Unset, str] = UNSET, + prediction: Union[Unset, bool] = False, +) -> Optional[Union[Any, LeaderboardResponse]]: + """Retrieve leaderboard details + + Fetches details of a leaderboard identified by its ID, with optional sorting and filtering for + scores. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, LeaderboardSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + countries (Union[Unset, str]): + search (Union[Unset, str]): + modifiers (Union[Unset, str]): + friends (Union[Unset, bool]): Default: False. + voters (Union[Unset, bool]): Default: False. + clan_tag (Union[Unset, str]): + prediction (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardResponse] + """ + + return sync_detailed( + id=id, + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + score_status=score_status, + leaderboard_context=leaderboard_context, + countries=countries, + search=search, + modifiers=modifiers, + friends=friends, + voters=voters, + clan_tag=clan_tag, + prediction=prediction, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, LeaderboardSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + modifiers: Union[Unset, str] = UNSET, + friends: Union[Unset, bool] = False, + voters: Union[Unset, bool] = False, + clan_tag: Union[Unset, str] = UNSET, + prediction: Union[Unset, bool] = False, +) -> Response[Union[Any, LeaderboardResponse]]: + """Retrieve leaderboard details + + Fetches details of a leaderboard identified by its ID, with optional sorting and filtering for + scores. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, LeaderboardSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + countries (Union[Unset, str]): + search (Union[Unset, str]): + modifiers (Union[Unset, str]): + friends (Union[Unset, bool]): Default: False. + voters (Union[Unset, bool]): Default: False. + clan_tag (Union[Unset, str]): + prediction (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardResponse]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + sort_by=sort_by, + order=order, + score_status=score_status, + leaderboard_context=leaderboard_context, + countries=countries, + search=search, + modifiers=modifiers, + friends=friends, + voters=voters, + clan_tag=clan_tag, + prediction=prediction, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, LeaderboardSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + modifiers: Union[Unset, str] = UNSET, + friends: Union[Unset, bool] = False, + voters: Union[Unset, bool] = False, + clan_tag: Union[Unset, str] = UNSET, + prediction: Union[Unset, bool] = False, +) -> Optional[Union[Any, LeaderboardResponse]]: + """Retrieve leaderboard details + + Fetches details of a leaderboard identified by its ID, with optional sorting and filtering for + scores. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, LeaderboardSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + countries (Union[Unset, str]): + search (Union[Unset, str]): + modifiers (Union[Unset, str]): + friends (Union[Unset, bool]): Default: False. + voters (Union[Unset, bool]): Default: False. + clan_tag (Union[Unset, str]): + prediction (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardResponse] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + score_status=score_status, + leaderboard_context=leaderboard_context, + countries=countries, + search=search, + modifiers=modifiers, + friends=friends, + voters=voters, + clan_tag=clan_tag, + prediction=prediction, + ) + ).parsed diff --git a/src/clients/beatleader/api/leaderboard/leaderboard_get_all.py b/src/clients/beatleader/api/leaderboard/leaderboard_get_all.py new file mode 100644 index 0000000..90a0f5e --- /dev/null +++ b/src/clients/beatleader/api/leaderboard/leaderboard_get_all.py @@ -0,0 +1,603 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.leaderboard_info_response_response_with_metadata import LeaderboardInfoResponseResponseWithMetadata +from ...models.map_sort_by import MapSortBy +from ...models.my_type import MyType +from ...models.operation import Operation +from ...models.order import Order +from ...models.requirements import Requirements +from ...models.song_status import SongStatus +from ...models.type import Type +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["search"] = search + + json_type: Union[Unset, str] = UNSET + if not isinstance(type, Unset): + json_type = type.value + + params["type"] = json_type + + params["mode"] = mode + + params["difficulty"] = difficulty + + params["mapType"] = map_type + + json_all_types: Union[Unset, str] = UNSET + if not isinstance(all_types, Unset): + json_all_types = all_types.value + + params["allTypes"] = json_all_types + + json_map_requirements: Union[Unset, str] = UNSET + if not isinstance(map_requirements, Unset): + json_map_requirements = map_requirements.value + + params["mapRequirements"] = json_map_requirements + + json_all_requirements: Union[Unset, str] = UNSET + if not isinstance(all_requirements, Unset): + json_all_requirements = all_requirements.value + + params["allRequirements"] = json_all_requirements + + json_song_status: Union[Unset, str] = UNSET + if not isinstance(song_status, Unset): + json_song_status = song_status.value + + params["songStatus"] = json_song_status + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + json_mytype: Union[Unset, str] = UNSET + if not isinstance(mytype, Unset): + json_mytype = mytype.value + + params["mytype"] = json_mytype + + params["stars_from"] = stars_from + + params["stars_to"] = stars_to + + params["accrating_from"] = accrating_from + + params["accrating_to"] = accrating_to + + params["passrating_from"] = passrating_from + + params["passrating_to"] = passrating_to + + params["techrating_from"] = techrating_from + + params["techrating_to"] = techrating_to + + params["date_from"] = date_from + + params["date_to"] = date_to + + params["mappers"] = mappers + + params["overrideCurrentId"] = override_current_id + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/leaderboards", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, LeaderboardInfoResponseResponseWithMetadata]]: + if response.status_code == HTTPStatus.OK: + response_200 = LeaderboardInfoResponseResponseWithMetadata.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, LeaderboardInfoResponseResponseWithMetadata]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Response[Union[Any, LeaderboardInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfoResponseResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, LeaderboardInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfoResponseResponseWithMetadata] + """ + + return sync_detailed( + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Response[Union[Any, LeaderboardInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfoResponseResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, LeaderboardInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfoResponseResponseWithMetadata] + """ + + return ( + await asyncio_detailed( + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ) + ).parsed diff --git a/src/clients/beatleader/api/leaderboard/leaderboard_get_clan_rankings.py b/src/clients/beatleader/api/leaderboard/leaderboard_get_clan_rankings.py new file mode 100644 index 0000000..3e3f5d3 --- /dev/null +++ b/src/clients/beatleader/api/leaderboard/leaderboard_get_clan_rankings.py @@ -0,0 +1,197 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_clan_ranking_response import LeaderboardClanRankingResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/leaderboard/clanRankings/{id}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, LeaderboardClanRankingResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = LeaderboardClanRankingResponse.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, LeaderboardClanRankingResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, +) -> Response[Union[Any, LeaderboardClanRankingResponse]]: + """Retrieve clan rankings for a leaderboard + + Fetches clan rankings for a leaderboard identified by its ID. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardClanRankingResponse]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, +) -> Optional[Union[Any, LeaderboardClanRankingResponse]]: + """Retrieve clan rankings for a leaderboard + + Fetches clan rankings for a leaderboard identified by its ID. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardClanRankingResponse] + """ + + return sync_detailed( + id=id, + client=client, + page=page, + count=count, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, +) -> Response[Union[Any, LeaderboardClanRankingResponse]]: + """Retrieve clan rankings for a leaderboard + + Fetches clan rankings for a leaderboard identified by its ID. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardClanRankingResponse]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, +) -> Optional[Union[Any, LeaderboardClanRankingResponse]]: + """Retrieve clan rankings for a leaderboard + + Fetches clan rankings for a leaderboard identified by its ID. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardClanRankingResponse] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + page=page, + count=count, + ) + ).parsed diff --git a/src/clients/beatleader/api/leaderboard/leaderboard_get_scoregraph.py b/src/clients/beatleader/api/leaderboard/leaderboard_get_scoregraph.py new file mode 100644 index 0000000..8e4e8f6 --- /dev/null +++ b/src/clients/beatleader/api/leaderboard/leaderboard_get_scoregraph.py @@ -0,0 +1,170 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.score_graph_entry import ScoreGraphEntry +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/leaderboard/{id}/scoregraph", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["ScoreGraphEntry"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.text + for response_200_item_data in _response_200: + response_200_item = ScoreGraphEntry.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["ScoreGraphEntry"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, List["ScoreGraphEntry"]]]: + """Retrieve scores graph for a leaderboard + + Fetches the scores graph for a leaderboard identified by its ID. Compact endpoint to use in the + leaderboard data visualizations. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['ScoreGraphEntry']]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, List["ScoreGraphEntry"]]]: + """Retrieve scores graph for a leaderboard + + Fetches the scores graph for a leaderboard identified by its ID. Compact endpoint to use in the + leaderboard data visualizations. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['ScoreGraphEntry']] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, List["ScoreGraphEntry"]]]: + """Retrieve scores graph for a leaderboard + + Fetches the scores graph for a leaderboard identified by its ID. Compact endpoint to use in the + leaderboard data visualizations. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['ScoreGraphEntry']]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, List["ScoreGraphEntry"]]]: + """Retrieve scores graph for a leaderboard + + Fetches the scores graph for a leaderboard identified by its ID. Compact endpoint to use in the + leaderboard data visualizations. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['ScoreGraphEntry']] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/modifiers/__init__.py b/src/clients/beatleader/api/modifiers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/modifiers/modifiers_get_modifiers.py b/src/clients/beatleader/api/modifiers/modifiers_get_modifiers.py new file mode 100644 index 0000000..e3b9492 --- /dev/null +++ b/src/clients/beatleader/api/modifiers/modifiers_get_modifiers.py @@ -0,0 +1,138 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.legacy_modifiers import LegacyModifiers +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/modifiers", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[LegacyModifiers]: + if response.status_code == HTTPStatus.OK: + response_200 = LegacyModifiers.from_dict(response.text) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[LegacyModifiers]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[LegacyModifiers]: + """Retrieve Legacy Modifiers + + Provides a list of Beat Saber modifiers and their associated score multiplier values. This is legacy + support, for the recent values please use `modifierValues` and `modifierRatings` on leaderboards. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[LegacyModifiers] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[LegacyModifiers]: + """Retrieve Legacy Modifiers + + Provides a list of Beat Saber modifiers and their associated score multiplier values. This is legacy + support, for the recent values please use `modifierValues` and `modifierRatings` on leaderboards. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + LegacyModifiers + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[LegacyModifiers]: + """Retrieve Legacy Modifiers + + Provides a list of Beat Saber modifiers and their associated score multiplier values. This is legacy + support, for the recent values please use `modifierValues` and `modifierRatings` on leaderboards. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[LegacyModifiers] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[LegacyModifiers]: + """Retrieve Legacy Modifiers + + Provides a list of Beat Saber modifiers and their associated score multiplier values. This is legacy + support, for the recent values please use `modifierValues` and `modifierRatings` on leaderboards. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + LegacyModifiers + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/patreon/__init__.py b/src/clients/beatleader/api/patreon/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/patreon/patreon_refresh_my_patreon.py b/src/clients/beatleader/api/patreon/patreon_refresh_my_patreon.py new file mode 100644 index 0000000..aca6c6a --- /dev/null +++ b/src/clients/beatleader/api/patreon/patreon_refresh_my_patreon.py @@ -0,0 +1,89 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/refreshmypatreon", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.UNAUTHORIZED: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Refresh Patreon Link + + Refreshes the Patreon link for the current user, updating their Patreon tier and roles based on the + latest information. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Refresh Patreon Link + + Refreshes the Patreon link for the current user, updating their Patreon tier and roles based on the + latest information. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/beatleader/api/player/__init__.py b/src/clients/beatleader/api/player/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/player/player_get.py b/src/clients/beatleader/api/player/player_get.py new file mode 100644 index 0000000..d738d04 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get.py @@ -0,0 +1,217 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.player_response_full import PlayerResponseFull +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + stats: Union[Unset, bool] = True, + keep_original_id: Union[Unset, bool] = False, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["stats"] = stats + + params["keepOriginalId"] = keep_original_id + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerResponseFull]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerResponseFull.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerResponseFull]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + stats: Union[Unset, bool] = True, + keep_original_id: Union[Unset, bool] = False, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player profile + + Retrieves a Beat Saber profile data for a specific player ID. + + Args: + id (str): + stats (Union[Unset, bool]): Default: True. + keep_original_id (Union[Unset, bool]): Default: False. + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + stats=stats, + keep_original_id=keep_original_id, + leaderboard_context=leaderboard_context, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + stats: Union[Unset, bool] = True, + keep_original_id: Union[Unset, bool] = False, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player profile + + Retrieves a Beat Saber profile data for a specific player ID. + + Args: + id (str): + stats (Union[Unset, bool]): Default: True. + keep_original_id (Union[Unset, bool]): Default: False. + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return sync_detailed( + id=id, + client=client, + stats=stats, + keep_original_id=keep_original_id, + leaderboard_context=leaderboard_context, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + stats: Union[Unset, bool] = True, + keep_original_id: Union[Unset, bool] = False, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player profile + + Retrieves a Beat Saber profile data for a specific player ID. + + Args: + id (str): + stats (Union[Unset, bool]): Default: True. + keep_original_id (Union[Unset, bool]): Default: False. + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + stats=stats, + keep_original_id=keep_original_id, + leaderboard_context=leaderboard_context, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + stats: Union[Unset, bool] = True, + keep_original_id: Union[Unset, bool] = False, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player profile + + Retrieves a Beat Saber profile data for a specific player ID. + + Args: + id (str): + stats (Union[Unset, bool]): Default: True. + keep_original_id (Union[Unset, bool]): Default: False. + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + stats=stats, + keep_original_id=keep_original_id, + leaderboard_context=leaderboard_context, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_beat_saver.py b/src/clients/beatleader/api/player/player_get_beat_saver.py new file mode 100644 index 0000000..09c9bbd --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_beat_saver.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.player_response_full import PlayerResponseFull +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/beatsaver/{id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerResponseFull]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerResponseFull.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerResponseFull]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player with BeatSaver + + Retrieves a BeatLeader profile data with linked BeatSaver profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player with BeatSaver + + Retrieves a BeatLeader profile data with linked BeatSaver profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player with BeatSaver + + Retrieves a BeatLeader profile data with linked BeatSaver profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player with BeatSaver + + Retrieves a BeatLeader profile data with linked BeatSaver profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_discord.py b/src/clients/beatleader/api/player/player_get_discord.py new file mode 100644 index 0000000..ede90e3 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_discord.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.player_response_full import PlayerResponseFull +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/discord/{id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerResponseFull]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerResponseFull.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerResponseFull]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player with Discord + + Retrieves a BeatLeader profile data with linked Discord profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player with Discord + + Retrieves a BeatLeader profile data with linked Discord profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player with Discord + + Retrieves a BeatLeader profile data with linked Discord profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player with Discord + + Retrieves a BeatLeader profile data with linked Discord profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_followers.py b/src/clients/beatleader/api/player/player_get_followers.py new file mode 100644 index 0000000..e516a19 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_followers.py @@ -0,0 +1,222 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.follower_type import FollowerType +from ...models.player_follower import PlayerFollower +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + type: Union[Unset, FollowerType] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_type: Union[Unset, str] = UNSET + if not isinstance(type, Unset): + json_type = type.value + + params["type"] = json_type + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/followers", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["PlayerFollower"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.text + for response_200_item_data in _response_200: + response_200_item = PlayerFollower.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["PlayerFollower"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + type: Union[Unset, FollowerType] = UNSET, +) -> Response[Union[Any, List["PlayerFollower"]]]: + """Get player's full follower list + + Retrieves a full list of player' followers and players this player follow. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + type (Union[Unset, FollowerType]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['PlayerFollower']]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + type=type, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + type: Union[Unset, FollowerType] = UNSET, +) -> Optional[Union[Any, List["PlayerFollower"]]]: + """Get player's full follower list + + Retrieves a full list of player' followers and players this player follow. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + type (Union[Unset, FollowerType]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['PlayerFollower']] + """ + + return sync_detailed( + id=id, + client=client, + page=page, + count=count, + type=type, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + type: Union[Unset, FollowerType] = UNSET, +) -> Response[Union[Any, List["PlayerFollower"]]]: + """Get player's full follower list + + Retrieves a full list of player' followers and players this player follow. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + type (Union[Unset, FollowerType]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['PlayerFollower']]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + count=count, + type=type, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + type: Union[Unset, FollowerType] = UNSET, +) -> Optional[Union[Any, List["PlayerFollower"]]]: + """Get player's full follower list + + Retrieves a full list of player' followers and players this player follow. + + Args: + id (str): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + type (Union[Unset, FollowerType]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['PlayerFollower']] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + page=page, + count=count, + type=type, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_followers_info.py b/src/clients/beatleader/api/player/player_get_followers_info.py new file mode 100644 index 0000000..c229887 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_followers_info.py @@ -0,0 +1,165 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.player_followers_info_response import PlayerFollowersInfoResponse +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/followersInfo", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerFollowersInfoResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerFollowersInfoResponse.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerFollowersInfoResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerFollowersInfoResponse]]: + """Get player' followers and players they follow + + Retrieves an info about player' followers such as count and 3 closest followers. Also 3 most + followed players this player follows + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerFollowersInfoResponse]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerFollowersInfoResponse]]: + """Get player' followers and players they follow + + Retrieves an info about player' followers such as count and 3 closest followers. Also 3 most + followed players this player follows + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerFollowersInfoResponse] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerFollowersInfoResponse]]: + """Get player' followers and players they follow + + Retrieves an info about player' followers such as count and 3 closest followers. Also 3 most + followed players this player follows + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerFollowersInfoResponse]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerFollowersInfoResponse]]: + """Get player' followers and players they follow + + Retrieves an info about player' followers such as count and 3 closest followers. Also 3 most + followed players this player follows + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerFollowersInfoResponse] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_founded_clan.py b/src/clients/beatleader/api/player/player_get_founded_clan.py new file mode 100644 index 0000000..f8e3fba --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_founded_clan.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.clan_bigger_response import ClanBiggerResponse +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/foundedClan", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ClanBiggerResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = ClanBiggerResponse.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ClanBiggerResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, ClanBiggerResponse]]: + """Get info about the clan this player founded + + Retrieves an information about the clan this player created and manage. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanBiggerResponse]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, ClanBiggerResponse]]: + """Get info about the clan this player founded + + Retrieves an information about the clan this player created and manage. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanBiggerResponse] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, ClanBiggerResponse]]: + """Get info about the clan this player founded + + Retrieves an information about the clan this player created and manage. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ClanBiggerResponse]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, ClanBiggerResponse]]: + """Get info about the clan this player founded + + Retrieves an information about the clan this player created and manage. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ClanBiggerResponse] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_participating_events.py b/src/clients/beatleader/api/player/player_get_participating_events.py new file mode 100644 index 0000000..55eef86 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_participating_events.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.participating_event_response import ParticipatingEventResponse +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/eventsparticipating", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ParticipatingEventResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = ParticipatingEventResponse.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ParticipatingEventResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, ParticipatingEventResponse]]: + """Get events where player participated + + Retrieves a chronological list of events player with such ID took part of. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ParticipatingEventResponse]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, ParticipatingEventResponse]]: + """Get events where player participated + + Retrieves a chronological list of events player with such ID took part of. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ParticipatingEventResponse] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, ParticipatingEventResponse]]: + """Get events where player participated + + Retrieves a chronological list of events player with such ID took part of. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ParticipatingEventResponse]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, ParticipatingEventResponse]]: + """Get events where player participated + + Retrieves a chronological list of events player with such ID took part of. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ParticipatingEventResponse] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_patreon.py b/src/clients/beatleader/api/player/player_get_patreon.py new file mode 100644 index 0000000..41d3a95 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_patreon.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.player_response_full import PlayerResponseFull +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/patreon/{id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerResponseFull]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerResponseFull.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerResponseFull]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player with Patreon + + Retrieves a BeatLeader profile data with linked Patreon profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player with Patreon + + Retrieves a BeatLeader profile data with linked Patreon profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlayerResponseFull]]: + """Get player with Patreon + + Retrieves a BeatLeader profile data with linked Patreon profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseFull]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlayerResponseFull]]: + """Get player with Patreon + + Retrieves a BeatLeader profile data with linked Patreon profile. + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseFull] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_players.py b/src/clients/beatleader/api/player/player_get_players.py new file mode 100644 index 0000000..674ca89 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_players.py @@ -0,0 +1,441 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.maps_type import MapsType +from ...models.order import Order +from ...models.player_response_with_stats_response_with_metadata import PlayerResponseWithStatsResponseWithMetadata +from ...models.player_sort_by import PlayerSortBy +from ...models.pp_type import PpType +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + sort_by: Union[Unset, PlayerSortBy] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 50, + search: Union[Unset, str] = "", + order: Union[Unset, Order] = UNSET, + countries: Union[Unset, str] = "", + maps_type: Union[Unset, MapsType] = UNSET, + pp_type: Union[Unset, PpType] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + friends: Union[Unset, bool] = False, + pp_range: Union[Unset, str] = UNSET, + score_range: Union[Unset, str] = UNSET, + platform: Union[Unset, str] = UNSET, + role: Union[Unset, str] = UNSET, + hmd: Union[Unset, str] = UNSET, + activity_period: Union[Unset, int] = UNSET, + banned: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + params["page"] = page + + params["count"] = count + + params["search"] = search + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["countries"] = countries + + json_maps_type: Union[Unset, str] = UNSET + if not isinstance(maps_type, Unset): + json_maps_type = maps_type.value + + params["mapsType"] = json_maps_type + + json_pp_type: Union[Unset, str] = UNSET + if not isinstance(pp_type, Unset): + json_pp_type = pp_type.value + + params["ppType"] = json_pp_type + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + params["friends"] = friends + + params["pp_range"] = pp_range + + params["score_range"] = score_range + + params["platform"] = platform + + params["role"] = role + + params["hmd"] = hmd + + params["activityPeriod"] = activity_period + + params["banned"] = banned + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/players", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerResponseWithStatsResponseWithMetadata]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerResponseWithStatsResponseWithMetadata.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerResponseWithStatsResponseWithMetadata]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, PlayerSortBy] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 50, + search: Union[Unset, str] = "", + order: Union[Unset, Order] = UNSET, + countries: Union[Unset, str] = "", + maps_type: Union[Unset, MapsType] = UNSET, + pp_type: Union[Unset, PpType] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + friends: Union[Unset, bool] = False, + pp_range: Union[Unset, str] = UNSET, + score_range: Union[Unset, str] = UNSET, + platform: Union[Unset, str] = UNSET, + role: Union[Unset, str] = UNSET, + hmd: Union[Unset, str] = UNSET, + activity_period: Union[Unset, int] = UNSET, + banned: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, PlayerResponseWithStatsResponseWithMetadata]]: + """Retrieve a list of players (ranking) + + Fetches a paginated and optionally filtered list of players. Filters include sorting by performance + points, search, country, maps type, platform, and more. + + Args: + sort_by (Union[Unset, PlayerSortBy]): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 50. + search (Union[Unset, str]): Default: ''. + order (Union[Unset, Order]): Represents the order in which values will be sorted. + countries (Union[Unset, str]): Default: ''. + maps_type (Union[Unset, MapsType]): + pp_type (Union[Unset, PpType]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + friends (Union[Unset, bool]): Default: False. + pp_range (Union[Unset, str]): + score_range (Union[Unset, str]): + platform (Union[Unset, str]): + role (Union[Unset, str]): + hmd (Union[Unset, str]): + activity_period (Union[Unset, int]): + banned (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseWithStatsResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + sort_by=sort_by, + page=page, + count=count, + search=search, + order=order, + countries=countries, + maps_type=maps_type, + pp_type=pp_type, + leaderboard_context=leaderboard_context, + friends=friends, + pp_range=pp_range, + score_range=score_range, + platform=platform, + role=role, + hmd=hmd, + activity_period=activity_period, + banned=banned, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, PlayerSortBy] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 50, + search: Union[Unset, str] = "", + order: Union[Unset, Order] = UNSET, + countries: Union[Unset, str] = "", + maps_type: Union[Unset, MapsType] = UNSET, + pp_type: Union[Unset, PpType] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + friends: Union[Unset, bool] = False, + pp_range: Union[Unset, str] = UNSET, + score_range: Union[Unset, str] = UNSET, + platform: Union[Unset, str] = UNSET, + role: Union[Unset, str] = UNSET, + hmd: Union[Unset, str] = UNSET, + activity_period: Union[Unset, int] = UNSET, + banned: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, PlayerResponseWithStatsResponseWithMetadata]]: + """Retrieve a list of players (ranking) + + Fetches a paginated and optionally filtered list of players. Filters include sorting by performance + points, search, country, maps type, platform, and more. + + Args: + sort_by (Union[Unset, PlayerSortBy]): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 50. + search (Union[Unset, str]): Default: ''. + order (Union[Unset, Order]): Represents the order in which values will be sorted. + countries (Union[Unset, str]): Default: ''. + maps_type (Union[Unset, MapsType]): + pp_type (Union[Unset, PpType]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + friends (Union[Unset, bool]): Default: False. + pp_range (Union[Unset, str]): + score_range (Union[Unset, str]): + platform (Union[Unset, str]): + role (Union[Unset, str]): + hmd (Union[Unset, str]): + activity_period (Union[Unset, int]): + banned (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseWithStatsResponseWithMetadata] + """ + + return sync_detailed( + client=client, + sort_by=sort_by, + page=page, + count=count, + search=search, + order=order, + countries=countries, + maps_type=maps_type, + pp_type=pp_type, + leaderboard_context=leaderboard_context, + friends=friends, + pp_range=pp_range, + score_range=score_range, + platform=platform, + role=role, + hmd=hmd, + activity_period=activity_period, + banned=banned, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, PlayerSortBy] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 50, + search: Union[Unset, str] = "", + order: Union[Unset, Order] = UNSET, + countries: Union[Unset, str] = "", + maps_type: Union[Unset, MapsType] = UNSET, + pp_type: Union[Unset, PpType] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + friends: Union[Unset, bool] = False, + pp_range: Union[Unset, str] = UNSET, + score_range: Union[Unset, str] = UNSET, + platform: Union[Unset, str] = UNSET, + role: Union[Unset, str] = UNSET, + hmd: Union[Unset, str] = UNSET, + activity_period: Union[Unset, int] = UNSET, + banned: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, PlayerResponseWithStatsResponseWithMetadata]]: + """Retrieve a list of players (ranking) + + Fetches a paginated and optionally filtered list of players. Filters include sorting by performance + points, search, country, maps type, platform, and more. + + Args: + sort_by (Union[Unset, PlayerSortBy]): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 50. + search (Union[Unset, str]): Default: ''. + order (Union[Unset, Order]): Represents the order in which values will be sorted. + countries (Union[Unset, str]): Default: ''. + maps_type (Union[Unset, MapsType]): + pp_type (Union[Unset, PpType]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + friends (Union[Unset, bool]): Default: False. + pp_range (Union[Unset, str]): + score_range (Union[Unset, str]): + platform (Union[Unset, str]): + role (Union[Unset, str]): + hmd (Union[Unset, str]): + activity_period (Union[Unset, int]): + banned (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerResponseWithStatsResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + sort_by=sort_by, + page=page, + count=count, + search=search, + order=order, + countries=countries, + maps_type=maps_type, + pp_type=pp_type, + leaderboard_context=leaderboard_context, + friends=friends, + pp_range=pp_range, + score_range=score_range, + platform=platform, + role=role, + hmd=hmd, + activity_period=activity_period, + banned=banned, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, PlayerSortBy] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 50, + search: Union[Unset, str] = "", + order: Union[Unset, Order] = UNSET, + countries: Union[Unset, str] = "", + maps_type: Union[Unset, MapsType] = UNSET, + pp_type: Union[Unset, PpType] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + friends: Union[Unset, bool] = False, + pp_range: Union[Unset, str] = UNSET, + score_range: Union[Unset, str] = UNSET, + platform: Union[Unset, str] = UNSET, + role: Union[Unset, str] = UNSET, + hmd: Union[Unset, str] = UNSET, + activity_period: Union[Unset, int] = UNSET, + banned: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, PlayerResponseWithStatsResponseWithMetadata]]: + """Retrieve a list of players (ranking) + + Fetches a paginated and optionally filtered list of players. Filters include sorting by performance + points, search, country, maps type, platform, and more. + + Args: + sort_by (Union[Unset, PlayerSortBy]): + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 50. + search (Union[Unset, str]): Default: ''. + order (Union[Unset, Order]): Represents the order in which values will be sorted. + countries (Union[Unset, str]): Default: ''. + maps_type (Union[Unset, MapsType]): + pp_type (Union[Unset, PpType]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + friends (Union[Unset, bool]): Default: False. + pp_range (Union[Unset, str]): + score_range (Union[Unset, str]): + platform (Union[Unset, str]): + role (Union[Unset, str]): + hmd (Union[Unset, str]): + activity_period (Union[Unset, int]): + banned (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerResponseWithStatsResponseWithMetadata] + """ + + return ( + await asyncio_detailed( + client=client, + sort_by=sort_by, + page=page, + count=count, + search=search, + order=order, + countries=countries, + maps_type=maps_type, + pp_type=pp_type, + leaderboard_context=leaderboard_context, + friends=friends, + pp_range=pp_range, + score_range=score_range, + platform=platform, + role=role, + hmd=hmd, + activity_period=activity_period, + banned=banned, + ) + ).parsed diff --git a/src/clients/beatleader/api/player/player_get_ranked_maps.py b/src/clients/beatleader/api/player/player_get_ranked_maps.py new file mode 100644 index 0000000..4f32186 --- /dev/null +++ b/src/clients/beatleader/api/player/player_get_ranked_maps.py @@ -0,0 +1,182 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.ranked_mapper_response import RankedMapperResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: int, + *, + sort_by: Union[Unset, str] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["sortBy"] = sort_by + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/rankedMaps", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, RankedMapperResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = RankedMapperResponse.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, RankedMapperResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, str] = UNSET, +) -> Response[Union[Any, RankedMapperResponse]]: + """Get ranked maps this player mapped + + Retrieves a list of maps this player created that later became ranked and give PP now. + + Args: + id (int): + sort_by (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, RankedMapperResponse]] + """ + + kwargs = _get_kwargs( + id=id, + sort_by=sort_by, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, RankedMapperResponse]]: + """Get ranked maps this player mapped + + Retrieves a list of maps this player created that later became ranked and give PP now. + + Args: + id (int): + sort_by (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, RankedMapperResponse] + """ + + return sync_detailed( + id=id, + client=client, + sort_by=sort_by, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, str] = UNSET, +) -> Response[Union[Any, RankedMapperResponse]]: + """Get ranked maps this player mapped + + Retrieves a list of maps this player created that later became ranked and give PP now. + + Args: + id (int): + sort_by (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, RankedMapperResponse]] + """ + + kwargs = _get_kwargs( + id=id, + sort_by=sort_by, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, RankedMapperResponse]]: + """Get ranked maps this player mapped + + Retrieves a list of maps this player created that later became ranked and give PP now. + + Args: + id (int): + sort_by (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, RankedMapperResponse] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + sort_by=sort_by, + ) + ).parsed diff --git a/src/clients/beatleader/api/player_scores/__init__.py b/src/clients/beatleader/api/player_scores/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/player_scores/player_scores_acc_graph.py b/src/clients/beatleader/api/player_scores/player_scores_acc_graph.py new file mode 100644 index 0000000..c72ca59 --- /dev/null +++ b/src/clients/beatleader/api/player_scores/player_scores_acc_graph.py @@ -0,0 +1,139 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + type: Union[Unset, str] = "acc", + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + no_unranked_stars: Union[Unset, bool] = False, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["type"] = type + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + params["no_unranked_stars"] = no_unranked_stars + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/accgraph", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.NOT_FOUND: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + type: Union[Unset, str] = "acc", + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + no_unranked_stars: Union[Unset, bool] = False, +) -> Response[Any]: + """Retrieve player's accuracy graph + + Usefull to visualise player's performance relative to map's complexity + + Args: + id (str): + type (Union[Unset, str]): Default: 'acc'. + leaderboard_context (Union[Unset, LeaderboardContexts]): + no_unranked_stars (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + type=type, + leaderboard_context=leaderboard_context, + no_unranked_stars=no_unranked_stars, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + type: Union[Unset, str] = "acc", + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + no_unranked_stars: Union[Unset, bool] = False, +) -> Response[Any]: + """Retrieve player's accuracy graph + + Usefull to visualise player's performance relative to map's complexity + + Args: + id (str): + type (Union[Unset, str]): Default: 'acc'. + leaderboard_context (Union[Unset, LeaderboardContexts]): + no_unranked_stars (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + type=type, + leaderboard_context=leaderboard_context, + no_unranked_stars=no_unranked_stars, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/beatleader/api/player_scores/player_scores_get_compact_history.py b/src/clients/beatleader/api/player_scores/player_scores_get_compact_history.py new file mode 100644 index 0000000..45cad7a --- /dev/null +++ b/src/clients/beatleader/api/player_scores/player_scores_get_compact_history.py @@ -0,0 +1,210 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.history_compact_response import HistoryCompactResponse +from ...models.leaderboard_contexts import LeaderboardContexts +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + params["count"] = count + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/history/compact", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["HistoryCompactResponse"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.text + for response_200_item_data in _response_200: + response_200_item = HistoryCompactResponse.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["HistoryCompactResponse"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Response[Union[Any, List["HistoryCompactResponse"]]]: + """Retrieve player's statistic history in a compact form + + Fetches a list of player's performance metrics subset. Use the main history endpoint for a full. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['HistoryCompactResponse']]] + """ + + kwargs = _get_kwargs( + id=id, + leaderboard_context=leaderboard_context, + count=count, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Optional[Union[Any, List["HistoryCompactResponse"]]]: + """Retrieve player's statistic history in a compact form + + Fetches a list of player's performance metrics subset. Use the main history endpoint for a full. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['HistoryCompactResponse']] + """ + + return sync_detailed( + id=id, + client=client, + leaderboard_context=leaderboard_context, + count=count, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Response[Union[Any, List["HistoryCompactResponse"]]]: + """Retrieve player's statistic history in a compact form + + Fetches a list of player's performance metrics subset. Use the main history endpoint for a full. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['HistoryCompactResponse']]] + """ + + kwargs = _get_kwargs( + id=id, + leaderboard_context=leaderboard_context, + count=count, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Optional[Union[Any, List["HistoryCompactResponse"]]]: + """Retrieve player's statistic history in a compact form + + Fetches a list of player's performance metrics subset. Use the main history endpoint for a full. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['HistoryCompactResponse']] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + leaderboard_context=leaderboard_context, + count=count, + ) + ).parsed diff --git a/src/clients/beatleader/api/player_scores/player_scores_get_compact_scores.py b/src/clients/beatleader/api/player_scores/player_scores_get_compact_scores.py new file mode 100644 index 0000000..5ed4627 --- /dev/null +++ b/src/clients/beatleader/api/player_scores/player_scores_get_compact_scores.py @@ -0,0 +1,459 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.compact_score_response_response_with_metadata import CompactScoreResponseResponseWithMetadata +from ...models.difficulty_status import DifficultyStatus +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.order import Order +from ...models.requirements import Requirements +from ...models.score_filter_status import ScoreFilterStatus +from ...models.scores_sort_by import ScoresSortBy +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["page"] = page + + params["count"] = count + + params["search"] = search + + params["diff"] = diff + + params["mode"] = mode + + json_requirements: Union[Unset, str] = UNSET + if not isinstance(requirements, Unset): + json_requirements = requirements.value + + params["requirements"] = json_requirements + + json_score_status: Union[Unset, str] = UNSET + if not isinstance(score_status, Unset): + json_score_status = score_status.value + + params["scoreStatus"] = json_score_status + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + json_type: Union[Unset, str] = UNSET + if not isinstance(type, Unset): + json_type = type.value + + params["type"] = json_type + + params["modifiers"] = modifiers + + params["stars_from"] = stars_from + + params["stars_to"] = stars_to + + params["time_from"] = time_from + + params["time_to"] = time_to + + params["eventId"] = event_id + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/scores/compact", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, CompactScoreResponseResponseWithMetadata]]: + if response.status_code == HTTPStatus.OK: + response_200 = CompactScoreResponseResponseWithMetadata.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, CompactScoreResponseResponseWithMetadata]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Response[Union[Any, CompactScoreResponseResponseWithMetadata]]: + """Retrieve player's scores in a compact form + + Fetches a paginated list of scores for a specified player ID. Returns less info to save bandwith or + processing time + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, CompactScoreResponseResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + id=id, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Optional[Union[Any, CompactScoreResponseResponseWithMetadata]]: + """Retrieve player's scores in a compact form + + Fetches a paginated list of scores for a specified player ID. Returns less info to save bandwith or + processing time + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, CompactScoreResponseResponseWithMetadata] + """ + + return sync_detailed( + id=id, + client=client, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Response[Union[Any, CompactScoreResponseResponseWithMetadata]]: + """Retrieve player's scores in a compact form + + Fetches a paginated list of scores for a specified player ID. Returns less info to save bandwith or + processing time + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, CompactScoreResponseResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + id=id, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Optional[Union[Any, CompactScoreResponseResponseWithMetadata]]: + """Retrieve player's scores in a compact form + + Fetches a paginated list of scores for a specified player ID. Returns less info to save bandwith or + processing time + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, CompactScoreResponseResponseWithMetadata] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ) + ).parsed diff --git a/src/clients/beatleader/api/player_scores/player_scores_get_history.py b/src/clients/beatleader/api/player_scores/player_scores_get_history.py new file mode 100644 index 0000000..0b578fe --- /dev/null +++ b/src/clients/beatleader/api/player_scores/player_scores_get_history.py @@ -0,0 +1,210 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.player_score_stats_history import PlayerScoreStatsHistory +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + params["count"] = count + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/history", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["PlayerScoreStatsHistory"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.text + for response_200_item_data in _response_200: + response_200_item = PlayerScoreStatsHistory.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["PlayerScoreStatsHistory"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Response[Union[Any, List["PlayerScoreStatsHistory"]]]: + """Retrieve player's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['PlayerScoreStatsHistory']]] + """ + + kwargs = _get_kwargs( + id=id, + leaderboard_context=leaderboard_context, + count=count, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Optional[Union[Any, List["PlayerScoreStatsHistory"]]]: + """Retrieve player's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['PlayerScoreStatsHistory']] + """ + + return sync_detailed( + id=id, + client=client, + leaderboard_context=leaderboard_context, + count=count, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Response[Union[Any, List["PlayerScoreStatsHistory"]]]: + """Retrieve player's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['PlayerScoreStatsHistory']]] + """ + + kwargs = _get_kwargs( + id=id, + leaderboard_context=leaderboard_context, + count=count, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + count: Union[Unset, int] = 50, +) -> Optional[Union[Any, List["PlayerScoreStatsHistory"]]]: + """Retrieve player's statistic history + + Fetches a list of player's performance metrics and various stats saved daily + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + count (Union[Unset, int]): Default: 50. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['PlayerScoreStatsHistory']] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + leaderboard_context=leaderboard_context, + count=count, + ) + ).parsed diff --git a/src/clients/beatleader/api/player_scores/player_scores_get_pinned_scores.py b/src/clients/beatleader/api/player_scores/player_scores_get_pinned_scores.py new file mode 100644 index 0000000..0763df0 --- /dev/null +++ b/src/clients/beatleader/api/player_scores/player_scores_get_pinned_scores.py @@ -0,0 +1,195 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.score_response_with_my_score import ScoreResponseWithMyScore +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/pinnedScores", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["ScoreResponseWithMyScore"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.text + for response_200_item_data in _response_200: + response_200_item = ScoreResponseWithMyScore.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["ScoreResponseWithMyScore"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Response[Union[Any, List["ScoreResponseWithMyScore"]]]: + """Retrieve player's pinned scores + + Fetches a paginated list of scores pinned by player for their ID. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['ScoreResponseWithMyScore']]] + """ + + kwargs = _get_kwargs( + id=id, + leaderboard_context=leaderboard_context, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Optional[Union[Any, List["ScoreResponseWithMyScore"]]]: + """Retrieve player's pinned scores + + Fetches a paginated list of scores pinned by player for their ID. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['ScoreResponseWithMyScore']] + """ + + return sync_detailed( + id=id, + client=client, + leaderboard_context=leaderboard_context, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Response[Union[Any, List["ScoreResponseWithMyScore"]]]: + """Retrieve player's pinned scores + + Fetches a paginated list of scores pinned by player for their ID. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['ScoreResponseWithMyScore']]] + """ + + kwargs = _get_kwargs( + id=id, + leaderboard_context=leaderboard_context, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, +) -> Optional[Union[Any, List["ScoreResponseWithMyScore"]]]: + """Retrieve player's pinned scores + + Fetches a paginated list of scores pinned by player for their ID. + + Args: + id (str): + leaderboard_context (Union[Unset, LeaderboardContexts]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['ScoreResponseWithMyScore']] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + leaderboard_context=leaderboard_context, + ) + ).parsed diff --git a/src/clients/beatleader/api/player_scores/player_scores_get_score_value.py b/src/clients/beatleader/api/player_scores/player_scores_get_score_value.py new file mode 100644 index 0000000..9d6b852 --- /dev/null +++ b/src/clients/beatleader/api/player_scores/player_scores_get_score_value.py @@ -0,0 +1,201 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + id: str, + hash_: str, + difficulty: str, + mode: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/scorevalue/{hash_}/{difficulty}/{mode}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, int]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(int, response.text) + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, int]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + hash_: str, + difficulty: str, + mode: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, int]]: + """Retrieve player's score for a specific map + + Fetches a score made by a Player with ID for a map specified by Hash and difficulty + + Args: + id (str): + hash_ (str): + difficulty (str): + mode (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, int]] + """ + + kwargs = _get_kwargs( + id=id, + hash_=hash_, + difficulty=difficulty, + mode=mode, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + hash_: str, + difficulty: str, + mode: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, int]]: + """Retrieve player's score for a specific map + + Fetches a score made by a Player with ID for a map specified by Hash and difficulty + + Args: + id (str): + hash_ (str): + difficulty (str): + mode (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, int] + """ + + return sync_detailed( + id=id, + hash_=hash_, + difficulty=difficulty, + mode=mode, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + hash_: str, + difficulty: str, + mode: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, int]]: + """Retrieve player's score for a specific map + + Fetches a score made by a Player with ID for a map specified by Hash and difficulty + + Args: + id (str): + hash_ (str): + difficulty (str): + mode (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, int]] + """ + + kwargs = _get_kwargs( + id=id, + hash_=hash_, + difficulty=difficulty, + mode=mode, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + hash_: str, + difficulty: str, + mode: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, int]]: + """Retrieve player's score for a specific map + + Fetches a score made by a Player with ID for a map specified by Hash and difficulty + + Args: + id (str): + hash_ (str): + difficulty (str): + mode (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, int] + """ + + return ( + await asyncio_detailed( + id=id, + hash_=hash_, + difficulty=difficulty, + mode=mode, + client=client, + ) + ).parsed diff --git a/src/clients/beatleader/api/player_scores/player_scores_get_scores.py b/src/clients/beatleader/api/player_scores/player_scores_get_scores.py new file mode 100644 index 0000000..8609209 --- /dev/null +++ b/src/clients/beatleader/api/player_scores/player_scores_get_scores.py @@ -0,0 +1,459 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.difficulty_status import DifficultyStatus +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.order import Order +from ...models.requirements import Requirements +from ...models.score_filter_status import ScoreFilterStatus +from ...models.score_response_with_my_score_response_with_metadata import ScoreResponseWithMyScoreResponseWithMetadata +from ...models.scores_sort_by import ScoresSortBy +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["page"] = page + + params["count"] = count + + params["search"] = search + + params["diff"] = diff + + params["mode"] = mode + + json_requirements: Union[Unset, str] = UNSET + if not isinstance(requirements, Unset): + json_requirements = requirements.value + + params["requirements"] = json_requirements + + json_score_status: Union[Unset, str] = UNSET + if not isinstance(score_status, Unset): + json_score_status = score_status.value + + params["scoreStatus"] = json_score_status + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + json_type: Union[Unset, str] = UNSET + if not isinstance(type, Unset): + json_type = type.value + + params["type"] = json_type + + params["modifiers"] = modifiers + + params["stars_from"] = stars_from + + params["stars_to"] = stars_to + + params["time_from"] = time_from + + params["time_to"] = time_to + + params["eventId"] = event_id + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/player/{id}/scores", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]]: + if response.status_code == HTTPStatus.OK: + response_200 = ScoreResponseWithMyScoreResponseWithMetadata.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Response[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]]: + """Retrieve player's scores + + Fetches a paginated list of scores for a specified player ID. Allows filtering by various criteria + like date, difficulty, mode, and more. + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + id=id, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Optional[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]]: + """Retrieve player's scores + + Fetches a paginated list of scores for a specified player ID. Allows filtering by various criteria + like date, difficulty, mode, and more. + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ScoreResponseWithMyScoreResponseWithMetadata] + """ + + return sync_detailed( + id=id, + client=client, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Response[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]]: + """Retrieve player's scores + + Fetches a paginated list of scores for a specified player ID. Allows filtering by various criteria + like date, difficulty, mode, and more. + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + id=id, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], + sort_by: Union[Unset, ScoresSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 8, + search: Union[Unset, str] = UNSET, + diff: Union[Unset, str] = UNSET, + mode: Union[Unset, str] = UNSET, + requirements: Union[Unset, Requirements] = UNSET, + score_status: Union[Unset, ScoreFilterStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + type: Union[Unset, DifficultyStatus] = UNSET, + modifiers: Union[Unset, str] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + time_from: Union[Unset, int] = UNSET, + time_to: Union[Unset, int] = UNSET, + event_id: Union[Unset, int] = UNSET, +) -> Optional[Union[Any, ScoreResponseWithMyScoreResponseWithMetadata]]: + """Retrieve player's scores + + Fetches a paginated list of scores for a specified player ID. Allows filtering by various criteria + like date, difficulty, mode, and more. + + Args: + id (str): + sort_by (Union[Unset, ScoresSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 8. + search (Union[Unset, str]): + diff (Union[Unset, str]): + mode (Union[Unset, str]): + requirements (Union[Unset, Requirements]): + score_status (Union[Unset, ScoreFilterStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + type (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifiers (Union[Unset, str]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + time_from (Union[Unset, int]): + time_to (Union[Unset, int]): + event_id (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ScoreResponseWithMyScoreResponseWithMetadata] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + sort_by=sort_by, + order=order, + page=page, + count=count, + search=search, + diff=diff, + mode=mode, + requirements=requirements, + score_status=score_status, + leaderboard_context=leaderboard_context, + type=type, + modifiers=modifiers, + stars_from=stars_from, + stars_to=stars_to, + time_from=time_from, + time_to=time_to, + event_id=event_id, + ) + ).parsed diff --git a/src/clients/beatleader/api/song/__init__.py b/src/clients/beatleader/api/song/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatleader/api/song/song_get_all.py b/src/clients/beatleader/api/song/song_get_all.py new file mode 100644 index 0000000..ccb4b2e --- /dev/null +++ b/src/clients/beatleader/api/song/song_get_all.py @@ -0,0 +1,603 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_contexts import LeaderboardContexts +from ...models.map_info_response_response_with_metadata import MapInfoResponseResponseWithMetadata +from ...models.map_sort_by import MapSortBy +from ...models.my_type import MyType +from ...models.operation import Operation +from ...models.order import Order +from ...models.requirements import Requirements +from ...models.song_status import SongStatus +from ...models.type import Type +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["page"] = page + + params["count"] = count + + json_sort_by: Union[Unset, str] = UNSET + if not isinstance(sort_by, Unset): + json_sort_by = sort_by.value + + params["sortBy"] = json_sort_by + + json_order: Union[Unset, str] = UNSET + if not isinstance(order, Unset): + json_order = order.value + + params["order"] = json_order + + params["search"] = search + + json_type: Union[Unset, str] = UNSET + if not isinstance(type, Unset): + json_type = type.value + + params["type"] = json_type + + params["mode"] = mode + + params["difficulty"] = difficulty + + params["mapType"] = map_type + + json_all_types: Union[Unset, str] = UNSET + if not isinstance(all_types, Unset): + json_all_types = all_types.value + + params["allTypes"] = json_all_types + + json_map_requirements: Union[Unset, str] = UNSET + if not isinstance(map_requirements, Unset): + json_map_requirements = map_requirements.value + + params["mapRequirements"] = json_map_requirements + + json_all_requirements: Union[Unset, str] = UNSET + if not isinstance(all_requirements, Unset): + json_all_requirements = all_requirements.value + + params["allRequirements"] = json_all_requirements + + json_song_status: Union[Unset, str] = UNSET + if not isinstance(song_status, Unset): + json_song_status = song_status.value + + params["songStatus"] = json_song_status + + json_leaderboard_context: Union[Unset, str] = UNSET + if not isinstance(leaderboard_context, Unset): + json_leaderboard_context = leaderboard_context.value + + params["leaderboardContext"] = json_leaderboard_context + + json_mytype: Union[Unset, str] = UNSET + if not isinstance(mytype, Unset): + json_mytype = mytype.value + + params["mytype"] = json_mytype + + params["stars_from"] = stars_from + + params["stars_to"] = stars_to + + params["accrating_from"] = accrating_from + + params["accrating_to"] = accrating_to + + params["passrating_from"] = passrating_from + + params["passrating_to"] = passrating_to + + params["techrating_from"] = techrating_from + + params["techrating_to"] = techrating_to + + params["date_from"] = date_from + + params["date_to"] = date_to + + params["mappers"] = mappers + + params["overrideCurrentId"] = override_current_id + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/maps", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, MapInfoResponseResponseWithMetadata]]: + if response.status_code == HTTPStatus.OK: + response_200 = MapInfoResponseResponseWithMetadata.from_dict(response.text) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, MapInfoResponseResponseWithMetadata]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Response[Union[Any, MapInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapInfoResponseResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, MapInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapInfoResponseResponseWithMetadata] + """ + + return sync_detailed( + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Response[Union[Any, MapInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapInfoResponseResponseWithMetadata]] + """ + + kwargs = _get_kwargs( + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + page: Union[Unset, int] = 1, + count: Union[Unset, int] = 10, + sort_by: Union[Unset, MapSortBy] = UNSET, + order: Union[Unset, Order] = UNSET, + search: Union[Unset, str] = UNSET, + type: Union[Unset, Type] = UNSET, + mode: Union[Unset, str] = UNSET, + difficulty: Union[Unset, str] = UNSET, + map_type: Union[Unset, int] = UNSET, + all_types: Union[Unset, Operation] = UNSET, + map_requirements: Union[Unset, Requirements] = UNSET, + all_requirements: Union[Unset, Operation] = UNSET, + song_status: Union[Unset, SongStatus] = UNSET, + leaderboard_context: Union[Unset, LeaderboardContexts] = UNSET, + mytype: Union[Unset, MyType] = UNSET, + stars_from: Union[Unset, float] = UNSET, + stars_to: Union[Unset, float] = UNSET, + accrating_from: Union[Unset, float] = UNSET, + accrating_to: Union[Unset, float] = UNSET, + passrating_from: Union[Unset, float] = UNSET, + passrating_to: Union[Unset, float] = UNSET, + techrating_from: Union[Unset, float] = UNSET, + techrating_to: Union[Unset, float] = UNSET, + date_from: Union[Unset, int] = UNSET, + date_to: Union[Unset, int] = UNSET, + mappers: Union[Unset, str] = UNSET, + override_current_id: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, MapInfoResponseResponseWithMetadata]]: + """Retrieve a list of leaderboards (maps) + + Fetches a paginated and optionally filtered list of leaderboards (Beat Saber maps). + + Args: + page (Union[Unset, int]): Default: 1. + count (Union[Unset, int]): Default: 10. + sort_by (Union[Unset, MapSortBy]): + order (Union[Unset, Order]): Represents the order in which values will be sorted. + search (Union[Unset, str]): + type (Union[Unset, Type]): + mode (Union[Unset, str]): + difficulty (Union[Unset, str]): + map_type (Union[Unset, int]): + all_types (Union[Unset, Operation]): + map_requirements (Union[Unset, Requirements]): + all_requirements (Union[Unset, Operation]): + song_status (Union[Unset, SongStatus]): + leaderboard_context (Union[Unset, LeaderboardContexts]): + mytype (Union[Unset, MyType]): + stars_from (Union[Unset, float]): + stars_to (Union[Unset, float]): + accrating_from (Union[Unset, float]): + accrating_to (Union[Unset, float]): + passrating_from (Union[Unset, float]): + passrating_to (Union[Unset, float]): + techrating_from (Union[Unset, float]): + techrating_to (Union[Unset, float]): + date_from (Union[Unset, int]): + date_to (Union[Unset, int]): + mappers (Union[Unset, str]): + override_current_id (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapInfoResponseResponseWithMetadata] + """ + + return ( + await asyncio_detailed( + client=client, + page=page, + count=count, + sort_by=sort_by, + order=order, + search=search, + type=type, + mode=mode, + difficulty=difficulty, + map_type=map_type, + all_types=all_types, + map_requirements=map_requirements, + all_requirements=all_requirements, + song_status=song_status, + leaderboard_context=leaderboard_context, + mytype=mytype, + stars_from=stars_from, + stars_to=stars_to, + accrating_from=accrating_from, + accrating_to=accrating_to, + passrating_from=passrating_from, + passrating_to=passrating_to, + techrating_from=techrating_from, + techrating_to=techrating_to, + date_from=date_from, + date_to=date_to, + mappers=mappers, + override_current_id=override_current_id, + ) + ).parsed diff --git a/src/clients/beatleader/client.py b/src/clients/beatleader/client.py new file mode 100644 index 0000000..63a2493 --- /dev/null +++ b/src/clients/beatleader/client.py @@ -0,0 +1,268 @@ +import ssl +from typing import Any, Dict, Optional, Union + +import httpx +from attrs import define, evolve, field + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + def with_headers(self, headers: Dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: Dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/src/clients/beatleader/errors.py b/src/clients/beatleader/errors.py new file mode 100644 index 0000000..5f92e76 --- /dev/null +++ b/src/clients/beatleader/errors.py @@ -0,0 +1,16 @@ +"""Contains shared errors types that can be raised from API functions""" + + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + + +__all__ = ["UnexpectedStatus"] diff --git a/src/clients/beatleader/models/__init__.py b/src/clients/beatleader/models/__init__.py new file mode 100644 index 0000000..4568a63 --- /dev/null +++ b/src/clients/beatleader/models/__init__.py @@ -0,0 +1,229 @@ +"""Contains all the data models used in inputs/outputs""" + +from .achievement import Achievement +from .achievement_description import AchievementDescription +from .achievement_level import AchievementLevel +from .badge import Badge +from .ban import Ban +from .beasties_nomination import BeastiesNomination +from .besties_nomination_response import BestiesNominationResponse +from .clan import Clan +from .clan_bigger_response import ClanBiggerResponse +from .clan_global_map import ClanGlobalMap +from .clan_global_map_point import ClanGlobalMapPoint +from .clan_map_connection import ClanMapConnection +from .clan_maps_sort_by import ClanMapsSortBy +from .clan_point import ClanPoint +from .clan_ranking_response import ClanRankingResponse +from .clan_ranking_response_clan_response_full_response_with_metadata_and_container import ( + ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer, +) +from .clan_response import ClanResponse +from .clan_response_full import ClanResponseFull +from .clan_response_full_response_with_metadata import ClanResponseFullResponseWithMetadata +from .clan_sort_by import ClanSortBy +from .compact_leaderboard import CompactLeaderboard +from .compact_leaderboard_response import CompactLeaderboardResponse +from .compact_score import CompactScore +from .compact_score_response import CompactScoreResponse +from .compact_score_response_response_with_metadata import CompactScoreResponseResponseWithMetadata +from .compact_song_response import CompactSongResponse +from .controller_enum import ControllerEnum +from .criteria_commentary import CriteriaCommentary +from .difficulty_description import DifficultyDescription +from .difficulty_response import DifficultyResponse +from .difficulty_status import DifficultyStatus +from .event_player import EventPlayer +from .event_ranking import EventRanking +from .external_status import ExternalStatus +from .featured_playlist import FeaturedPlaylist +from .featured_playlist_response import FeaturedPlaylistResponse +from .follower_type import FollowerType +from .global_map_history import GlobalMapHistory +from .history_compact_response import HistoryCompactResponse +from .hmd import HMD +from .info_to_highlight import InfoToHighlight +from .leaderboard import Leaderboard +from .leaderboard_change import LeaderboardChange +from .leaderboard_clan_ranking_response import LeaderboardClanRankingResponse +from .leaderboard_contexts import LeaderboardContexts +from .leaderboard_group_entry import LeaderboardGroupEntry +from .leaderboard_info_response import LeaderboardInfoResponse +from .leaderboard_info_response_response_with_metadata import LeaderboardInfoResponseResponseWithMetadata +from .leaderboard_response import LeaderboardResponse +from .leaderboard_sort_by import LeaderboardSortBy +from .legacy_modifiers import LegacyModifiers +from .link_response import LinkResponse +from .map_diff_response import MapDiffResponse +from .map_info_response import MapInfoResponse +from .map_info_response_response_with_metadata import MapInfoResponseResponseWithMetadata +from .map_quality import MapQuality +from .map_sort_by import MapSortBy +from .mapper import Mapper +from .mapper_response import MapperResponse +from .maps_type import MapsType +from .metadata import Metadata +from .modifiers_map import ModifiersMap +from .modifiers_rating import ModifiersRating +from .my_type import MyType +from .operation import Operation +from .order import Order +from .participating_event_response import ParticipatingEventResponse +from .patreon_features import PatreonFeatures +from .player import Player +from .player_change import PlayerChange +from .player_context_extension import PlayerContextExtension +from .player_follower import PlayerFollower +from .player_followers_info_response import PlayerFollowersInfoResponse +from .player_response import PlayerResponse +from .player_response_clan_response_full_response_with_metadata_and_container import ( + PlayerResponseClanResponseFullResponseWithMetadataAndContainer, +) +from .player_response_full import PlayerResponseFull +from .player_response_with_stats import PlayerResponseWithStats +from .player_response_with_stats_response_with_metadata import PlayerResponseWithStatsResponseWithMetadata +from .player_score_stats import PlayerScoreStats +from .player_score_stats_history import PlayerScoreStatsHistory +from .player_search import PlayerSearch +from .player_social import PlayerSocial +from .player_sort_by import PlayerSortBy +from .pp_type import PpType +from .profile_settings import ProfileSettings +from .qualification_change import QualificationChange +from .qualification_commentary import QualificationCommentary +from .qualification_vote import QualificationVote +from .rank_qualification import RankQualification +from .rank_update import RankUpdate +from .rank_update_change import RankUpdateChange +from .rank_voting import RankVoting +from .ranked_map import RankedMap +from .ranked_mapper_response import RankedMapperResponse +from .replay_offsets import ReplayOffsets +from .requirements import Requirements +from .score_filter_status import ScoreFilterStatus +from .score_graph_entry import ScoreGraphEntry +from .score_improvement import ScoreImprovement +from .score_metadata import ScoreMetadata +from .score_response import ScoreResponse +from .score_response_with_acc import ScoreResponseWithAcc +from .score_response_with_my_score import ScoreResponseWithMyScore +from .score_response_with_my_score_response_with_metadata import ScoreResponseWithMyScoreResponseWithMetadata +from .scores_sort_by import ScoresSortBy +from .song import Song +from .song_response import SongResponse +from .song_status import SongStatus +from .type import Type +from .voter_feedback import VoterFeedback + +__all__ = ( + "Achievement", + "AchievementDescription", + "AchievementLevel", + "Badge", + "Ban", + "BeastiesNomination", + "BestiesNominationResponse", + "Clan", + "ClanBiggerResponse", + "ClanGlobalMap", + "ClanGlobalMapPoint", + "ClanMapConnection", + "ClanMapsSortBy", + "ClanPoint", + "ClanRankingResponse", + "ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer", + "ClanResponse", + "ClanResponseFull", + "ClanResponseFullResponseWithMetadata", + "ClanSortBy", + "CompactLeaderboard", + "CompactLeaderboardResponse", + "CompactScore", + "CompactScoreResponse", + "CompactScoreResponseResponseWithMetadata", + "CompactSongResponse", + "ControllerEnum", + "CriteriaCommentary", + "DifficultyDescription", + "DifficultyResponse", + "DifficultyStatus", + "EventPlayer", + "EventRanking", + "ExternalStatus", + "FeaturedPlaylist", + "FeaturedPlaylistResponse", + "FollowerType", + "GlobalMapHistory", + "HistoryCompactResponse", + "HMD", + "InfoToHighlight", + "Leaderboard", + "LeaderboardChange", + "LeaderboardClanRankingResponse", + "LeaderboardContexts", + "LeaderboardGroupEntry", + "LeaderboardInfoResponse", + "LeaderboardInfoResponseResponseWithMetadata", + "LeaderboardResponse", + "LeaderboardSortBy", + "LegacyModifiers", + "LinkResponse", + "MapDiffResponse", + "MapInfoResponse", + "MapInfoResponseResponseWithMetadata", + "Mapper", + "MapperResponse", + "MapQuality", + "MapSortBy", + "MapsType", + "Metadata", + "ModifiersMap", + "ModifiersRating", + "MyType", + "Operation", + "Order", + "ParticipatingEventResponse", + "PatreonFeatures", + "Player", + "PlayerChange", + "PlayerContextExtension", + "PlayerFollower", + "PlayerFollowersInfoResponse", + "PlayerResponse", + "PlayerResponseClanResponseFullResponseWithMetadataAndContainer", + "PlayerResponseFull", + "PlayerResponseWithStats", + "PlayerResponseWithStatsResponseWithMetadata", + "PlayerScoreStats", + "PlayerScoreStatsHistory", + "PlayerSearch", + "PlayerSocial", + "PlayerSortBy", + "PpType", + "ProfileSettings", + "QualificationChange", + "QualificationCommentary", + "QualificationVote", + "RankedMap", + "RankedMapperResponse", + "RankQualification", + "RankUpdate", + "RankUpdateChange", + "RankVoting", + "ReplayOffsets", + "Requirements", + "ScoreFilterStatus", + "ScoreGraphEntry", + "ScoreImprovement", + "ScoreMetadata", + "ScoreResponse", + "ScoreResponseWithAcc", + "ScoreResponseWithMyScore", + "ScoreResponseWithMyScoreResponseWithMetadata", + "ScoresSortBy", + "Song", + "SongResponse", + "SongStatus", + "Type", + "VoterFeedback", +) diff --git a/src/clients/beatleader/models/achievement.py b/src/clients/beatleader/models/achievement.py new file mode 100644 index 0000000..b7988d9 --- /dev/null +++ b/src/clients/beatleader/models/achievement.py @@ -0,0 +1,125 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.achievement_description import AchievementDescription + from ..models.achievement_level import AchievementLevel + + +T = TypeVar("T", bound="Achievement") + + +@_attrs_define +class Achievement: + """ + Attributes: + id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + achievement_description_id (Union[Unset, int]): + achievement_description (Union[Unset, AchievementDescription]): + level (Union[Unset, AchievementLevel]): + timeset (Union[Unset, int]): + count (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + achievement_description_id: Union[Unset, int] = UNSET + achievement_description: Union[Unset, "AchievementDescription"] = UNSET + level: Union[Unset, "AchievementLevel"] = UNSET + timeset: Union[Unset, int] = UNSET + count: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + achievement_description_id = self.achievement_description_id + + achievement_description: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.achievement_description, Unset): + achievement_description = self.achievement_description.to_dict() + + level: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.level, Unset): + level = self.level.to_dict() + + timeset = self.timeset + + count = self.count + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if achievement_description_id is not UNSET: + field_dict["achievementDescriptionId"] = achievement_description_id + if achievement_description is not UNSET: + field_dict["achievementDescription"] = achievement_description + if level is not UNSET: + field_dict["level"] = level + if timeset is not UNSET: + field_dict["timeset"] = timeset + if count is not UNSET: + field_dict["count"] = count + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.achievement_description import AchievementDescription + from ..models.achievement_level import AchievementLevel + + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + achievement_description_id = d.pop("achievementDescriptionId", UNSET) + + _achievement_description = d.pop("achievementDescription", UNSET) + achievement_description: Union[Unset, AchievementDescription] + if isinstance(_achievement_description, Unset): + achievement_description = UNSET + else: + achievement_description = AchievementDescription.from_dict(_achievement_description) + + _level = d.pop("level", UNSET) + level: Union[Unset, AchievementLevel] + if isinstance(_level, Unset): + level = UNSET + else: + level = AchievementLevel.from_dict(_level) + + timeset = d.pop("timeset", UNSET) + + count = d.pop("count", UNSET) + + achievement = cls( + id=id, + player_id=player_id, + achievement_description_id=achievement_description_id, + achievement_description=achievement_description, + level=level, + timeset=timeset, + count=count, + ) + + return achievement diff --git a/src/clients/beatleader/models/achievement_description.py b/src/clients/beatleader/models/achievement_description.py new file mode 100644 index 0000000..c0f0941 --- /dev/null +++ b/src/clients/beatleader/models/achievement_description.py @@ -0,0 +1,143 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.achievement_level import AchievementLevel + + +T = TypeVar("T", bound="AchievementDescription") + + +@_attrs_define +class AchievementDescription: + """ + Attributes: + id (Union[Unset, int]): + name (Union[None, Unset, str]): + description (Union[None, Unset, str]): + link (Union[None, Unset, str]): + levels (Union[List['AchievementLevel'], None, Unset]): + """ + + id: Union[Unset, int] = UNSET + name: Union[None, Unset, str] = UNSET + description: Union[None, Unset, str] = UNSET + link: Union[None, Unset, str] = UNSET + levels: Union[List["AchievementLevel"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + link: Union[None, Unset, str] + if isinstance(self.link, Unset): + link = UNSET + else: + link = self.link + + levels: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.levels, Unset): + levels = UNSET + elif isinstance(self.levels, list): + levels = [] + for levels_type_0_item_data in self.levels: + levels_type_0_item = levels_type_0_item_data.to_dict() + levels.append(levels_type_0_item) + + else: + levels = self.levels + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if description is not UNSET: + field_dict["description"] = description + if link is not UNSET: + field_dict["link"] = link + if levels is not UNSET: + field_dict["levels"] = levels + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.achievement_level import AchievementLevel + + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + link = _parse_link(d.pop("link", UNSET)) + + def _parse_levels(data: object) -> Union[List["AchievementLevel"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + levels_type_0 = [] + _levels_type_0 = data + for levels_type_0_item_data in _levels_type_0: + levels_type_0_item = AchievementLevel.from_dict(levels_type_0_item_data) + + levels_type_0.append(levels_type_0_item) + + return levels_type_0 + except: # noqa: E722 + pass + return cast(Union[List["AchievementLevel"], None, Unset], data) + + levels = _parse_levels(d.pop("levels", UNSET)) + + achievement_description = cls( + id=id, + name=name, + description=description, + link=link, + levels=levels, + ) + + return achievement_description diff --git a/src/clients/beatleader/models/achievement_level.py b/src/clients/beatleader/models/achievement_level.py new file mode 100644 index 0000000..1a5066d --- /dev/null +++ b/src/clients/beatleader/models/achievement_level.py @@ -0,0 +1,196 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AchievementLevel") + + +@_attrs_define +class AchievementLevel: + """ + Attributes: + id (Union[Unset, int]): + image (Union[None, Unset, str]): + small_image (Union[None, Unset, str]): + name (Union[None, Unset, str]): + description (Union[None, Unset, str]): + detailed_description (Union[None, Unset, str]): + color (Union[None, Unset, str]): + value (Union[None, Unset, float]): + level (Union[Unset, int]): + achievement_description_id (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + image: Union[None, Unset, str] = UNSET + small_image: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + description: Union[None, Unset, str] = UNSET + detailed_description: Union[None, Unset, str] = UNSET + color: Union[None, Unset, str] = UNSET + value: Union[None, Unset, float] = UNSET + level: Union[Unset, int] = UNSET + achievement_description_id: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + image: Union[None, Unset, str] + if isinstance(self.image, Unset): + image = UNSET + else: + image = self.image + + small_image: Union[None, Unset, str] + if isinstance(self.small_image, Unset): + small_image = UNSET + else: + small_image = self.small_image + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + detailed_description: Union[None, Unset, str] + if isinstance(self.detailed_description, Unset): + detailed_description = UNSET + else: + detailed_description = self.detailed_description + + color: Union[None, Unset, str] + if isinstance(self.color, Unset): + color = UNSET + else: + color = self.color + + value: Union[None, Unset, float] + if isinstance(self.value, Unset): + value = UNSET + else: + value = self.value + + level = self.level + + achievement_description_id = self.achievement_description_id + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if image is not UNSET: + field_dict["image"] = image + if small_image is not UNSET: + field_dict["smallImage"] = small_image + if name is not UNSET: + field_dict["name"] = name + if description is not UNSET: + field_dict["description"] = description + if detailed_description is not UNSET: + field_dict["detailedDescription"] = detailed_description + if color is not UNSET: + field_dict["color"] = color + if value is not UNSET: + field_dict["value"] = value + if level is not UNSET: + field_dict["level"] = level + if achievement_description_id is not UNSET: + field_dict["achievementDescriptionId"] = achievement_description_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + image = _parse_image(d.pop("image", UNSET)) + + def _parse_small_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + small_image = _parse_small_image(d.pop("smallImage", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_detailed_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + detailed_description = _parse_detailed_description(d.pop("detailedDescription", UNSET)) + + def _parse_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + color = _parse_color(d.pop("color", UNSET)) + + def _parse_value(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + value = _parse_value(d.pop("value", UNSET)) + + level = d.pop("level", UNSET) + + achievement_description_id = d.pop("achievementDescriptionId", UNSET) + + achievement_level = cls( + id=id, + image=image, + small_image=small_image, + name=name, + description=description, + detailed_description=detailed_description, + color=color, + value=value, + level=level, + achievement_description_id=achievement_description_id, + ) + + return achievement_level diff --git a/src/clients/beatleader/models/badge.py b/src/clients/beatleader/models/badge.py new file mode 100644 index 0000000..7398c6b --- /dev/null +++ b/src/clients/beatleader/models/badge.py @@ -0,0 +1,116 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Badge") + + +@_attrs_define +class Badge: + """ + Attributes: + id (Union[Unset, int]): + description (Union[None, Unset, str]): + image (Union[None, Unset, str]): + link (Union[None, Unset, str]): + timeset (Union[Unset, int]): + hidden (Union[Unset, bool]): + """ + + id: Union[Unset, int] = UNSET + description: Union[None, Unset, str] = UNSET + image: Union[None, Unset, str] = UNSET + link: Union[None, Unset, str] = UNSET + timeset: Union[Unset, int] = UNSET + hidden: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + image: Union[None, Unset, str] + if isinstance(self.image, Unset): + image = UNSET + else: + image = self.image + + link: Union[None, Unset, str] + if isinstance(self.link, Unset): + link = UNSET + else: + link = self.link + + timeset = self.timeset + + hidden = self.hidden + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if description is not UNSET: + field_dict["description"] = description + if image is not UNSET: + field_dict["image"] = image + if link is not UNSET: + field_dict["link"] = link + if timeset is not UNSET: + field_dict["timeset"] = timeset + if hidden is not UNSET: + field_dict["hidden"] = hidden + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + image = _parse_image(d.pop("image", UNSET)) + + def _parse_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + link = _parse_link(d.pop("link", UNSET)) + + timeset = d.pop("timeset", UNSET) + + hidden = d.pop("hidden", UNSET) + + badge = cls( + id=id, + description=description, + image=image, + link=link, + timeset=timeset, + hidden=hidden, + ) + + return badge diff --git a/src/clients/beatleader/models/ban.py b/src/clients/beatleader/models/ban.py new file mode 100644 index 0000000..8e28923 --- /dev/null +++ b/src/clients/beatleader/models/ban.py @@ -0,0 +1,116 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Ban") + + +@_attrs_define +class Ban: + """ + Attributes: + id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + banned_by (Union[None, Unset, str]): + ban_reason (Union[None, Unset, str]): + timeset (Union[Unset, int]): + duration (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + banned_by: Union[None, Unset, str] = UNSET + ban_reason: Union[None, Unset, str] = UNSET + timeset: Union[Unset, int] = UNSET + duration: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + banned_by: Union[None, Unset, str] + if isinstance(self.banned_by, Unset): + banned_by = UNSET + else: + banned_by = self.banned_by + + ban_reason: Union[None, Unset, str] + if isinstance(self.ban_reason, Unset): + ban_reason = UNSET + else: + ban_reason = self.ban_reason + + timeset = self.timeset + + duration = self.duration + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if banned_by is not UNSET: + field_dict["bannedBy"] = banned_by + if ban_reason is not UNSET: + field_dict["banReason"] = ban_reason + if timeset is not UNSET: + field_dict["timeset"] = timeset + if duration is not UNSET: + field_dict["duration"] = duration + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + def _parse_banned_by(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + banned_by = _parse_banned_by(d.pop("bannedBy", UNSET)) + + def _parse_ban_reason(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + ban_reason = _parse_ban_reason(d.pop("banReason", UNSET)) + + timeset = d.pop("timeset", UNSET) + + duration = d.pop("duration", UNSET) + + ban = cls( + id=id, + player_id=player_id, + banned_by=banned_by, + ban_reason=ban_reason, + timeset=timeset, + duration=duration, + ) + + return ban diff --git a/src/clients/beatleader/models/beasties_nomination.py b/src/clients/beatleader/models/beasties_nomination.py new file mode 100644 index 0000000..385d444 --- /dev/null +++ b/src/clients/beatleader/models/beasties_nomination.py @@ -0,0 +1,107 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BeastiesNomination") + + +@_attrs_define +class BeastiesNomination: + """ + Attributes: + id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + leaderboard_id (Union[None, Unset, str]): + category (Union[None, Unset, str]): + timepost (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + leaderboard_id: Union[None, Unset, str] = UNSET + category: Union[None, Unset, str] = UNSET + timepost: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + leaderboard_id: Union[None, Unset, str] + if isinstance(self.leaderboard_id, Unset): + leaderboard_id = UNSET + else: + leaderboard_id = self.leaderboard_id + + category: Union[None, Unset, str] + if isinstance(self.category, Unset): + category = UNSET + else: + category = self.category + + timepost = self.timepost + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if leaderboard_id is not UNSET: + field_dict["leaderboardId"] = leaderboard_id + if category is not UNSET: + field_dict["category"] = category + if timepost is not UNSET: + field_dict["timepost"] = timepost + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + def _parse_leaderboard_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leaderboard_id = _parse_leaderboard_id(d.pop("leaderboardId", UNSET)) + + def _parse_category(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + category = _parse_category(d.pop("category", UNSET)) + + timepost = d.pop("timepost", UNSET) + + beasties_nomination = cls( + id=id, + player_id=player_id, + leaderboard_id=leaderboard_id, + category=category, + timepost=timepost, + ) + + return beasties_nomination diff --git a/src/clients/beatleader/models/besties_nomination_response.py b/src/clients/beatleader/models/besties_nomination_response.py new file mode 100644 index 0000000..98087e6 --- /dev/null +++ b/src/clients/beatleader/models/besties_nomination_response.py @@ -0,0 +1,50 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BestiesNominationResponse") + + +@_attrs_define +class BestiesNominationResponse: + """ + Attributes: + message (Union[None, Unset, str]): + """ + + message: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + message: Union[None, Unset, str] + if isinstance(self.message, Unset): + message = UNSET + else: + message = self.message + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if message is not UNSET: + field_dict["message"] = message + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_message(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + message = _parse_message(d.pop("message", UNSET)) + + besties_nomination_response = cls( + message=message, + ) + + return besties_nomination_response diff --git a/src/clients/beatleader/models/clan.py b/src/clients/beatleader/models/clan.py new file mode 100644 index 0000000..6afd736 --- /dev/null +++ b/src/clients/beatleader/models/clan.py @@ -0,0 +1,354 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.featured_playlist import FeaturedPlaylist + from ..models.leaderboard import Leaderboard + + +T = TypeVar("T", bound="Clan") + + +@_attrs_define +class Clan: + """ + Attributes: + id (Union[Unset, int]): + name (Union[None, Unset, str]): + color (Union[None, Unset, str]): + icon (Union[None, Unset, str]): + tag (Union[None, Unset, str]): + leader_id (Union[None, Unset, str]): + description (Union[None, Unset, str]): + bio (Union[None, Unset, str]): + rich_bio_timeset (Union[Unset, int]): + players_count (Union[Unset, int]): + pp (Union[Unset, float]): + rank (Union[Unset, int]): + average_rank (Union[Unset, float]): + average_accuracy (Union[Unset, float]): + featured_playlists (Union[List['FeaturedPlaylist'], None, Unset]): + ranked_pool_percent_captured (Union[Unset, float]): + capture_leaderboards_count (Union[Unset, int]): + captured_leaderboards (Union[List['Leaderboard'], None, Unset]): + global_map_x (Union[Unset, float]): + global_map_y (Union[Unset, float]): + """ + + id: Union[Unset, int] = UNSET + name: Union[None, Unset, str] = UNSET + color: Union[None, Unset, str] = UNSET + icon: Union[None, Unset, str] = UNSET + tag: Union[None, Unset, str] = UNSET + leader_id: Union[None, Unset, str] = UNSET + description: Union[None, Unset, str] = UNSET + bio: Union[None, Unset, str] = UNSET + rich_bio_timeset: Union[Unset, int] = UNSET + players_count: Union[Unset, int] = UNSET + pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + average_rank: Union[Unset, float] = UNSET + average_accuracy: Union[Unset, float] = UNSET + featured_playlists: Union[List["FeaturedPlaylist"], None, Unset] = UNSET + ranked_pool_percent_captured: Union[Unset, float] = UNSET + capture_leaderboards_count: Union[Unset, int] = UNSET + captured_leaderboards: Union[List["Leaderboard"], None, Unset] = UNSET + global_map_x: Union[Unset, float] = UNSET + global_map_y: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + color: Union[None, Unset, str] + if isinstance(self.color, Unset): + color = UNSET + else: + color = self.color + + icon: Union[None, Unset, str] + if isinstance(self.icon, Unset): + icon = UNSET + else: + icon = self.icon + + tag: Union[None, Unset, str] + if isinstance(self.tag, Unset): + tag = UNSET + else: + tag = self.tag + + leader_id: Union[None, Unset, str] + if isinstance(self.leader_id, Unset): + leader_id = UNSET + else: + leader_id = self.leader_id + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + bio: Union[None, Unset, str] + if isinstance(self.bio, Unset): + bio = UNSET + else: + bio = self.bio + + rich_bio_timeset = self.rich_bio_timeset + + players_count = self.players_count + + pp = self.pp + + rank = self.rank + + average_rank = self.average_rank + + average_accuracy = self.average_accuracy + + featured_playlists: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.featured_playlists, Unset): + featured_playlists = UNSET + elif isinstance(self.featured_playlists, list): + featured_playlists = [] + for featured_playlists_type_0_item_data in self.featured_playlists: + featured_playlists_type_0_item = featured_playlists_type_0_item_data.to_dict() + featured_playlists.append(featured_playlists_type_0_item) + + else: + featured_playlists = self.featured_playlists + + ranked_pool_percent_captured = self.ranked_pool_percent_captured + + capture_leaderboards_count = self.capture_leaderboards_count + + captured_leaderboards: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.captured_leaderboards, Unset): + captured_leaderboards = UNSET + elif isinstance(self.captured_leaderboards, list): + captured_leaderboards = [] + for captured_leaderboards_type_0_item_data in self.captured_leaderboards: + captured_leaderboards_type_0_item = captured_leaderboards_type_0_item_data.to_dict() + captured_leaderboards.append(captured_leaderboards_type_0_item) + + else: + captured_leaderboards = self.captured_leaderboards + + global_map_x = self.global_map_x + + global_map_y = self.global_map_y + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if color is not UNSET: + field_dict["color"] = color + if icon is not UNSET: + field_dict["icon"] = icon + if tag is not UNSET: + field_dict["tag"] = tag + if leader_id is not UNSET: + field_dict["leaderID"] = leader_id + if description is not UNSET: + field_dict["description"] = description + if bio is not UNSET: + field_dict["bio"] = bio + if rich_bio_timeset is not UNSET: + field_dict["richBioTimeset"] = rich_bio_timeset + if players_count is not UNSET: + field_dict["playersCount"] = players_count + if pp is not UNSET: + field_dict["pp"] = pp + if rank is not UNSET: + field_dict["rank"] = rank + if average_rank is not UNSET: + field_dict["averageRank"] = average_rank + if average_accuracy is not UNSET: + field_dict["averageAccuracy"] = average_accuracy + if featured_playlists is not UNSET: + field_dict["featuredPlaylists"] = featured_playlists + if ranked_pool_percent_captured is not UNSET: + field_dict["rankedPoolPercentCaptured"] = ranked_pool_percent_captured + if capture_leaderboards_count is not UNSET: + field_dict["captureLeaderboardsCount"] = capture_leaderboards_count + if captured_leaderboards is not UNSET: + field_dict["capturedLeaderboards"] = captured_leaderboards + if global_map_x is not UNSET: + field_dict["globalMapX"] = global_map_x + if global_map_y is not UNSET: + field_dict["globalMapY"] = global_map_y + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.featured_playlist import FeaturedPlaylist + from ..models.leaderboard import Leaderboard + + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + color = _parse_color(d.pop("color", UNSET)) + + def _parse_icon(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + icon = _parse_icon(d.pop("icon", UNSET)) + + def _parse_tag(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + tag = _parse_tag(d.pop("tag", UNSET)) + + def _parse_leader_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leader_id = _parse_leader_id(d.pop("leaderID", UNSET)) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_bio(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + bio = _parse_bio(d.pop("bio", UNSET)) + + rich_bio_timeset = d.pop("richBioTimeset", UNSET) + + players_count = d.pop("playersCount", UNSET) + + pp = d.pop("pp", UNSET) + + rank = d.pop("rank", UNSET) + + average_rank = d.pop("averageRank", UNSET) + + average_accuracy = d.pop("averageAccuracy", UNSET) + + def _parse_featured_playlists(data: object) -> Union[List["FeaturedPlaylist"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + featured_playlists_type_0 = [] + _featured_playlists_type_0 = data + for featured_playlists_type_0_item_data in _featured_playlists_type_0: + featured_playlists_type_0_item = FeaturedPlaylist.from_dict(featured_playlists_type_0_item_data) + + featured_playlists_type_0.append(featured_playlists_type_0_item) + + return featured_playlists_type_0 + except: # noqa: E722 + pass + return cast(Union[List["FeaturedPlaylist"], None, Unset], data) + + featured_playlists = _parse_featured_playlists(d.pop("featuredPlaylists", UNSET)) + + ranked_pool_percent_captured = d.pop("rankedPoolPercentCaptured", UNSET) + + capture_leaderboards_count = d.pop("captureLeaderboardsCount", UNSET) + + def _parse_captured_leaderboards(data: object) -> Union[List["Leaderboard"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + captured_leaderboards_type_0 = [] + _captured_leaderboards_type_0 = data + for captured_leaderboards_type_0_item_data in _captured_leaderboards_type_0: + captured_leaderboards_type_0_item = Leaderboard.from_dict(captured_leaderboards_type_0_item_data) + + captured_leaderboards_type_0.append(captured_leaderboards_type_0_item) + + return captured_leaderboards_type_0 + except: # noqa: E722 + pass + return cast(Union[List["Leaderboard"], None, Unset], data) + + captured_leaderboards = _parse_captured_leaderboards(d.pop("capturedLeaderboards", UNSET)) + + global_map_x = d.pop("globalMapX", UNSET) + + global_map_y = d.pop("globalMapY", UNSET) + + clan = cls( + id=id, + name=name, + color=color, + icon=icon, + tag=tag, + leader_id=leader_id, + description=description, + bio=bio, + rich_bio_timeset=rich_bio_timeset, + players_count=players_count, + pp=pp, + rank=rank, + average_rank=average_rank, + average_accuracy=average_accuracy, + featured_playlists=featured_playlists, + ranked_pool_percent_captured=ranked_pool_percent_captured, + capture_leaderboards_count=capture_leaderboards_count, + captured_leaderboards=captured_leaderboards, + global_map_x=global_map_x, + global_map_y=global_map_y, + ) + + return clan diff --git a/src/clients/beatleader/models/clan_bigger_response.py b/src/clients/beatleader/models/clan_bigger_response.py new file mode 100644 index 0000000..b91c459 --- /dev/null +++ b/src/clients/beatleader/models/clan_bigger_response.py @@ -0,0 +1,145 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ClanBiggerResponse") + + +@_attrs_define +class ClanBiggerResponse: + """ + Attributes: + id (Union[Unset, int]): + tag (Union[None, Unset, str]): + color (Union[None, Unset, str]): + name (Union[None, Unset, str]): + icon (Union[None, Unset, str]): + ranked_pool_percent_captured (Union[Unset, float]): + players_count (Union[Unset, int]): + joined (Union[Unset, bool]): + """ + + id: Union[Unset, int] = UNSET + tag: Union[None, Unset, str] = UNSET + color: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + icon: Union[None, Unset, str] = UNSET + ranked_pool_percent_captured: Union[Unset, float] = UNSET + players_count: Union[Unset, int] = UNSET + joined: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + tag: Union[None, Unset, str] + if isinstance(self.tag, Unset): + tag = UNSET + else: + tag = self.tag + + color: Union[None, Unset, str] + if isinstance(self.color, Unset): + color = UNSET + else: + color = self.color + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + icon: Union[None, Unset, str] + if isinstance(self.icon, Unset): + icon = UNSET + else: + icon = self.icon + + ranked_pool_percent_captured = self.ranked_pool_percent_captured + + players_count = self.players_count + + joined = self.joined + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if tag is not UNSET: + field_dict["tag"] = tag + if color is not UNSET: + field_dict["color"] = color + if name is not UNSET: + field_dict["name"] = name + if icon is not UNSET: + field_dict["icon"] = icon + if ranked_pool_percent_captured is not UNSET: + field_dict["rankedPoolPercentCaptured"] = ranked_pool_percent_captured + if players_count is not UNSET: + field_dict["playersCount"] = players_count + if joined is not UNSET: + field_dict["joined"] = joined + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_tag(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + tag = _parse_tag(d.pop("tag", UNSET)) + + def _parse_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + color = _parse_color(d.pop("color", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_icon(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + icon = _parse_icon(d.pop("icon", UNSET)) + + ranked_pool_percent_captured = d.pop("rankedPoolPercentCaptured", UNSET) + + players_count = d.pop("playersCount", UNSET) + + joined = d.pop("joined", UNSET) + + clan_bigger_response = cls( + id=id, + tag=tag, + color=color, + name=name, + icon=icon, + ranked_pool_percent_captured=ranked_pool_percent_captured, + players_count=players_count, + joined=joined, + ) + + return clan_bigger_response diff --git a/src/clients/beatleader/models/clan_global_map.py b/src/clients/beatleader/models/clan_global_map.py new file mode 100644 index 0000000..ea6995e --- /dev/null +++ b/src/clients/beatleader/models/clan_global_map.py @@ -0,0 +1,116 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_global_map_point import ClanGlobalMapPoint + from ..models.clan_point import ClanPoint + + +T = TypeVar("T", bound="ClanGlobalMap") + + +@_attrs_define +class ClanGlobalMap: + """ + Attributes: + points (Union[List['ClanGlobalMapPoint'], None, Unset]): + clans (Union[List['ClanPoint'], None, Unset]): + """ + + points: Union[List["ClanGlobalMapPoint"], None, Unset] = UNSET + clans: Union[List["ClanPoint"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + points: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.points, Unset): + points = UNSET + elif isinstance(self.points, list): + points = [] + for points_type_0_item_data in self.points: + points_type_0_item = points_type_0_item_data.to_dict() + points.append(points_type_0_item) + + else: + points = self.points + + clans: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.clans, Unset): + clans = UNSET + elif isinstance(self.clans, list): + clans = [] + for clans_type_0_item_data in self.clans: + clans_type_0_item = clans_type_0_item_data.to_dict() + clans.append(clans_type_0_item) + + else: + clans = self.clans + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if points is not UNSET: + field_dict["points"] = points + if clans is not UNSET: + field_dict["clans"] = clans + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_global_map_point import ClanGlobalMapPoint + from ..models.clan_point import ClanPoint + + d = src_dict.copy() + + def _parse_points(data: object) -> Union[List["ClanGlobalMapPoint"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + points_type_0 = [] + _points_type_0 = data + for points_type_0_item_data in _points_type_0: + points_type_0_item = ClanGlobalMapPoint.from_dict(points_type_0_item_data) + + points_type_0.append(points_type_0_item) + + return points_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanGlobalMapPoint"], None, Unset], data) + + points = _parse_points(d.pop("points", UNSET)) + + def _parse_clans(data: object) -> Union[List["ClanPoint"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + clans_type_0 = [] + _clans_type_0 = data + for clans_type_0_item_data in _clans_type_0: + clans_type_0_item = ClanPoint.from_dict(clans_type_0_item_data) + + clans_type_0.append(clans_type_0_item) + + return clans_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanPoint"], None, Unset], data) + + clans = _parse_clans(d.pop("clans", UNSET)) + + clan_global_map = cls( + points=points, + clans=clans, + ) + + return clan_global_map diff --git a/src/clients/beatleader/models/clan_global_map_point.py b/src/clients/beatleader/models/clan_global_map_point.py new file mode 100644 index 0000000..8fd6787 --- /dev/null +++ b/src/clients/beatleader/models/clan_global_map_point.py @@ -0,0 +1,144 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_map_connection import ClanMapConnection + + +T = TypeVar("T", bound="ClanGlobalMapPoint") + + +@_attrs_define +class ClanGlobalMapPoint: + """ + Attributes: + leaderboard_id (Union[None, Unset, str]): + cover_image (Union[None, Unset, str]): + stars (Union[None, Unset, float]): + tie (Union[Unset, bool]): + clans (Union[List['ClanMapConnection'], None, Unset]): + """ + + leaderboard_id: Union[None, Unset, str] = UNSET + cover_image: Union[None, Unset, str] = UNSET + stars: Union[None, Unset, float] = UNSET + tie: Union[Unset, bool] = UNSET + clans: Union[List["ClanMapConnection"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + leaderboard_id: Union[None, Unset, str] + if isinstance(self.leaderboard_id, Unset): + leaderboard_id = UNSET + else: + leaderboard_id = self.leaderboard_id + + cover_image: Union[None, Unset, str] + if isinstance(self.cover_image, Unset): + cover_image = UNSET + else: + cover_image = self.cover_image + + stars: Union[None, Unset, float] + if isinstance(self.stars, Unset): + stars = UNSET + else: + stars = self.stars + + tie = self.tie + + clans: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.clans, Unset): + clans = UNSET + elif isinstance(self.clans, list): + clans = [] + for clans_type_0_item_data in self.clans: + clans_type_0_item = clans_type_0_item_data.to_dict() + clans.append(clans_type_0_item) + + else: + clans = self.clans + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if leaderboard_id is not UNSET: + field_dict["leaderboardId"] = leaderboard_id + if cover_image is not UNSET: + field_dict["coverImage"] = cover_image + if stars is not UNSET: + field_dict["stars"] = stars + if tie is not UNSET: + field_dict["tie"] = tie + if clans is not UNSET: + field_dict["clans"] = clans + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_map_connection import ClanMapConnection + + d = src_dict.copy() + + def _parse_leaderboard_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leaderboard_id = _parse_leaderboard_id(d.pop("leaderboardId", UNSET)) + + def _parse_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover_image = _parse_cover_image(d.pop("coverImage", UNSET)) + + def _parse_stars(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + stars = _parse_stars(d.pop("stars", UNSET)) + + tie = d.pop("tie", UNSET) + + def _parse_clans(data: object) -> Union[List["ClanMapConnection"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + clans_type_0 = [] + _clans_type_0 = data + for clans_type_0_item_data in _clans_type_0: + clans_type_0_item = ClanMapConnection.from_dict(clans_type_0_item_data) + + clans_type_0.append(clans_type_0_item) + + return clans_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanMapConnection"], None, Unset], data) + + clans = _parse_clans(d.pop("clans", UNSET)) + + clan_global_map_point = cls( + leaderboard_id=leaderboard_id, + cover_image=cover_image, + stars=stars, + tie=tie, + clans=clans, + ) + + return clan_global_map_point diff --git a/src/clients/beatleader/models/clan_map_connection.py b/src/clients/beatleader/models/clan_map_connection.py new file mode 100644 index 0000000..48115bf --- /dev/null +++ b/src/clients/beatleader/models/clan_map_connection.py @@ -0,0 +1,59 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ClanMapConnection") + + +@_attrs_define +class ClanMapConnection: + """ + Attributes: + id (Union[None, Unset, int]): + pp (Union[Unset, float]): + """ + + id: Union[None, Unset, int] = UNSET + pp: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, int] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + pp = self.pp + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if pp is not UNSET: + field_dict["pp"] = pp + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + id = _parse_id(d.pop("id", UNSET)) + + pp = d.pop("pp", UNSET) + + clan_map_connection = cls( + id=id, + pp=pp, + ) + + return clan_map_connection diff --git a/src/clients/beatleader/models/clan_maps_sort_by.py b/src/clients/beatleader/models/clan_maps_sort_by.py new file mode 100644 index 0000000..62e1d67 --- /dev/null +++ b/src/clients/beatleader/models/clan_maps_sort_by.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class ClanMapsSortBy(str, Enum): + ACC = "acc" + DATE = "date" + PP = "pp" + RANK = "rank" + TOCONQUER = "toconquer" + TOHOLD = "tohold" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/clan_point.py b/src/clients/beatleader/models/clan_point.py new file mode 100644 index 0000000..41ecfb2 --- /dev/null +++ b/src/clients/beatleader/models/clan_point.py @@ -0,0 +1,96 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ClanPoint") + + +@_attrs_define +class ClanPoint: + """ + Attributes: + id (Union[Unset, int]): + tag (Union[None, Unset, str]): + color (Union[None, Unset, str]): + x (Union[Unset, float]): + y (Union[Unset, float]): + """ + + id: Union[Unset, int] = UNSET + tag: Union[None, Unset, str] = UNSET + color: Union[None, Unset, str] = UNSET + x: Union[Unset, float] = UNSET + y: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + tag: Union[None, Unset, str] + if isinstance(self.tag, Unset): + tag = UNSET + else: + tag = self.tag + + color: Union[None, Unset, str] + if isinstance(self.color, Unset): + color = UNSET + else: + color = self.color + + x = self.x + + y = self.y + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if tag is not UNSET: + field_dict["tag"] = tag + if color is not UNSET: + field_dict["color"] = color + if x is not UNSET: + field_dict["x"] = x + if y is not UNSET: + field_dict["y"] = y + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_tag(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + tag = _parse_tag(d.pop("tag", UNSET)) + + def _parse_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + color = _parse_color(d.pop("color", UNSET)) + + x = d.pop("x", UNSET) + + y = d.pop("y", UNSET) + + clan_point = cls( + id=id, + tag=tag, + color=color, + x=x, + y=y, + ) + + return clan_point diff --git a/src/clients/beatleader/models/clan_ranking_response.py b/src/clients/beatleader/models/clan_ranking_response.py new file mode 100644 index 0000000..5a3174f --- /dev/null +++ b/src/clients/beatleader/models/clan_ranking_response.py @@ -0,0 +1,220 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response_full import ClanResponseFull + from ..models.leaderboard_response import LeaderboardResponse + from ..models.score_response import ScoreResponse + from ..models.score_response_with_acc import ScoreResponseWithAcc + + +T = TypeVar("T", bound="ClanRankingResponse") + + +@_attrs_define +class ClanRankingResponse: + """ + Attributes: + id (Union[Unset, int]): + clan (Union[Unset, ClanResponseFull]): + last_update_time (Union[Unset, int]): + average_rank (Union[Unset, float]): + rank (Union[Unset, int]): + pp (Union[Unset, float]): + average_accuracy (Union[Unset, float]): + total_score (Union[Unset, float]): + leaderboard_id (Union[None, Unset, str]): + leaderboard (Union[Unset, LeaderboardResponse]): + associated_scores (Union[List['ScoreResponse'], None, Unset]): + associated_scores_count (Union[Unset, int]): + my_score (Union[Unset, ScoreResponseWithAcc]): + """ + + id: Union[Unset, int] = UNSET + clan: Union[Unset, "ClanResponseFull"] = UNSET + last_update_time: Union[Unset, int] = UNSET + average_rank: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + pp: Union[Unset, float] = UNSET + average_accuracy: Union[Unset, float] = UNSET + total_score: Union[Unset, float] = UNSET + leaderboard_id: Union[None, Unset, str] = UNSET + leaderboard: Union[Unset, "LeaderboardResponse"] = UNSET + associated_scores: Union[List["ScoreResponse"], None, Unset] = UNSET + associated_scores_count: Union[Unset, int] = UNSET + my_score: Union[Unset, "ScoreResponseWithAcc"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + clan: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.clan, Unset): + clan = self.clan.to_dict() + + last_update_time = self.last_update_time + + average_rank = self.average_rank + + rank = self.rank + + pp = self.pp + + average_accuracy = self.average_accuracy + + total_score = self.total_score + + leaderboard_id: Union[None, Unset, str] + if isinstance(self.leaderboard_id, Unset): + leaderboard_id = UNSET + else: + leaderboard_id = self.leaderboard_id + + leaderboard: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.leaderboard, Unset): + leaderboard = self.leaderboard.to_dict() + + associated_scores: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.associated_scores, Unset): + associated_scores = UNSET + elif isinstance(self.associated_scores, list): + associated_scores = [] + for associated_scores_type_0_item_data in self.associated_scores: + associated_scores_type_0_item = associated_scores_type_0_item_data.to_dict() + associated_scores.append(associated_scores_type_0_item) + + else: + associated_scores = self.associated_scores + + associated_scores_count = self.associated_scores_count + + my_score: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.my_score, Unset): + my_score = self.my_score.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if clan is not UNSET: + field_dict["clan"] = clan + if last_update_time is not UNSET: + field_dict["lastUpdateTime"] = last_update_time + if average_rank is not UNSET: + field_dict["averageRank"] = average_rank + if rank is not UNSET: + field_dict["rank"] = rank + if pp is not UNSET: + field_dict["pp"] = pp + if average_accuracy is not UNSET: + field_dict["averageAccuracy"] = average_accuracy + if total_score is not UNSET: + field_dict["totalScore"] = total_score + if leaderboard_id is not UNSET: + field_dict["leaderboardId"] = leaderboard_id + if leaderboard is not UNSET: + field_dict["leaderboard"] = leaderboard + if associated_scores is not UNSET: + field_dict["associatedScores"] = associated_scores + if associated_scores_count is not UNSET: + field_dict["associatedScoresCount"] = associated_scores_count + if my_score is not UNSET: + field_dict["myScore"] = my_score + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response_full import ClanResponseFull + from ..models.leaderboard_response import LeaderboardResponse + from ..models.score_response import ScoreResponse + from ..models.score_response_with_acc import ScoreResponseWithAcc + + d = src_dict.copy() + id = d.pop("id", UNSET) + + _clan = d.pop("clan", UNSET) + clan: Union[Unset, ClanResponseFull] + if isinstance(_clan, Unset): + clan = UNSET + else: + clan = ClanResponseFull.from_dict(_clan) + + last_update_time = d.pop("lastUpdateTime", UNSET) + + average_rank = d.pop("averageRank", UNSET) + + rank = d.pop("rank", UNSET) + + pp = d.pop("pp", UNSET) + + average_accuracy = d.pop("averageAccuracy", UNSET) + + total_score = d.pop("totalScore", UNSET) + + def _parse_leaderboard_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leaderboard_id = _parse_leaderboard_id(d.pop("leaderboardId", UNSET)) + + _leaderboard = d.pop("leaderboard", UNSET) + leaderboard: Union[Unset, LeaderboardResponse] + if isinstance(_leaderboard, Unset): + leaderboard = UNSET + else: + leaderboard = LeaderboardResponse.from_dict(_leaderboard) + + def _parse_associated_scores(data: object) -> Union[List["ScoreResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + associated_scores_type_0 = [] + _associated_scores_type_0 = data + for associated_scores_type_0_item_data in _associated_scores_type_0: + associated_scores_type_0_item = ScoreResponse.from_dict(associated_scores_type_0_item_data) + + associated_scores_type_0.append(associated_scores_type_0_item) + + return associated_scores_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ScoreResponse"], None, Unset], data) + + associated_scores = _parse_associated_scores(d.pop("associatedScores", UNSET)) + + associated_scores_count = d.pop("associatedScoresCount", UNSET) + + _my_score = d.pop("myScore", UNSET) + my_score: Union[Unset, ScoreResponseWithAcc] + if isinstance(_my_score, Unset): + my_score = UNSET + else: + my_score = ScoreResponseWithAcc.from_dict(_my_score) + + clan_ranking_response = cls( + id=id, + clan=clan, + last_update_time=last_update_time, + average_rank=average_rank, + rank=rank, + pp=pp, + average_accuracy=average_accuracy, + total_score=total_score, + leaderboard_id=leaderboard_id, + leaderboard=leaderboard, + associated_scores=associated_scores, + associated_scores_count=associated_scores_count, + my_score=my_score, + ) + + return clan_ranking_response diff --git a/src/clients/beatleader/models/clan_ranking_response_clan_response_full_response_with_metadata_and_container.py b/src/clients/beatleader/models/clan_ranking_response_clan_response_full_response_with_metadata_and_container.py new file mode 100644 index 0000000..3b8db91 --- /dev/null +++ b/src/clients/beatleader/models/clan_ranking_response_clan_response_full_response_with_metadata_and_container.py @@ -0,0 +1,110 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_ranking_response import ClanRankingResponse + from ..models.clan_response_full import ClanResponseFull + from ..models.metadata import Metadata + + +T = TypeVar("T", bound="ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer") + + +@_attrs_define +class ClanRankingResponseClanResponseFullResponseWithMetadataAndContainer: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['ClanRankingResponse'], None, Unset]): + container (Union[Unset, ClanResponseFull]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["ClanRankingResponse"], None, Unset] = UNSET + container: Union[Unset, "ClanResponseFull"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + container: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.container, Unset): + container = self.container.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + if container is not UNSET: + field_dict["container"] = container + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_ranking_response import ClanRankingResponse + from ..models.clan_response_full import ClanResponseFull + from ..models.metadata import Metadata + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["ClanRankingResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = ClanRankingResponse.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanRankingResponse"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + _container = d.pop("container", UNSET) + container: Union[Unset, ClanResponseFull] + if isinstance(_container, Unset): + container = UNSET + else: + container = ClanResponseFull.from_dict(_container) + + clan_ranking_response_clan_response_full_response_with_metadata_and_container = cls( + metadata=metadata, + data=data, + container=container, + ) + + return clan_ranking_response_clan_response_full_response_with_metadata_and_container diff --git a/src/clients/beatleader/models/clan_response.py b/src/clients/beatleader/models/clan_response.py new file mode 100644 index 0000000..7d5ede2 --- /dev/null +++ b/src/clients/beatleader/models/clan_response.py @@ -0,0 +1,98 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ClanResponse") + + +@_attrs_define +class ClanResponse: + """ + Attributes: + id (Union[Unset, int]): + tag (Union[None, Unset, str]): + color (Union[None, Unset, str]): + name (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + tag: Union[None, Unset, str] = UNSET + color: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + tag: Union[None, Unset, str] + if isinstance(self.tag, Unset): + tag = UNSET + else: + tag = self.tag + + color: Union[None, Unset, str] + if isinstance(self.color, Unset): + color = UNSET + else: + color = self.color + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if tag is not UNSET: + field_dict["tag"] = tag + if color is not UNSET: + field_dict["color"] = color + if name is not UNSET: + field_dict["name"] = name + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_tag(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + tag = _parse_tag(d.pop("tag", UNSET)) + + def _parse_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + color = _parse_color(d.pop("color", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + clan_response = cls( + id=id, + tag=tag, + color=color, + name=name, + ) + + return clan_response diff --git a/src/clients/beatleader/models/clan_response_full.py b/src/clients/beatleader/models/clan_response_full.py new file mode 100644 index 0000000..a3c1b98 --- /dev/null +++ b/src/clients/beatleader/models/clan_response_full.py @@ -0,0 +1,357 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.featured_playlist_response import FeaturedPlaylistResponse + + +T = TypeVar("T", bound="ClanResponseFull") + + +@_attrs_define +class ClanResponseFull: + """ + Attributes: + id (Union[Unset, int]): + name (Union[None, Unset, str]): + color (Union[None, Unset, str]): + icon (Union[None, Unset, str]): + tag (Union[None, Unset, str]): + leader_id (Union[None, Unset, str]): + description (Union[None, Unset, str]): + bio (Union[None, Unset, str]): + rich_bio_timeset (Union[Unset, int]): + discord_invite (Union[None, Unset, str]): + players_count (Union[Unset, int]): + pp (Union[Unset, float]): + rank (Union[Unset, int]): + average_rank (Union[Unset, float]): + average_accuracy (Union[Unset, float]): + ranked_pool_percent_captured (Union[Unset, float]): + capture_leaderboards_count (Union[Unset, int]): + player_changes_callback (Union[None, Unset, str]): + clan_ranking_discord_hook (Union[None, Unset, str]): + featured_playlists (Union[List['FeaturedPlaylistResponse'], None, Unset]): + """ + + id: Union[Unset, int] = UNSET + name: Union[None, Unset, str] = UNSET + color: Union[None, Unset, str] = UNSET + icon: Union[None, Unset, str] = UNSET + tag: Union[None, Unset, str] = UNSET + leader_id: Union[None, Unset, str] = UNSET + description: Union[None, Unset, str] = UNSET + bio: Union[None, Unset, str] = UNSET + rich_bio_timeset: Union[Unset, int] = UNSET + discord_invite: Union[None, Unset, str] = UNSET + players_count: Union[Unset, int] = UNSET + pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + average_rank: Union[Unset, float] = UNSET + average_accuracy: Union[Unset, float] = UNSET + ranked_pool_percent_captured: Union[Unset, float] = UNSET + capture_leaderboards_count: Union[Unset, int] = UNSET + player_changes_callback: Union[None, Unset, str] = UNSET + clan_ranking_discord_hook: Union[None, Unset, str] = UNSET + featured_playlists: Union[List["FeaturedPlaylistResponse"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + color: Union[None, Unset, str] + if isinstance(self.color, Unset): + color = UNSET + else: + color = self.color + + icon: Union[None, Unset, str] + if isinstance(self.icon, Unset): + icon = UNSET + else: + icon = self.icon + + tag: Union[None, Unset, str] + if isinstance(self.tag, Unset): + tag = UNSET + else: + tag = self.tag + + leader_id: Union[None, Unset, str] + if isinstance(self.leader_id, Unset): + leader_id = UNSET + else: + leader_id = self.leader_id + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + bio: Union[None, Unset, str] + if isinstance(self.bio, Unset): + bio = UNSET + else: + bio = self.bio + + rich_bio_timeset = self.rich_bio_timeset + + discord_invite: Union[None, Unset, str] + if isinstance(self.discord_invite, Unset): + discord_invite = UNSET + else: + discord_invite = self.discord_invite + + players_count = self.players_count + + pp = self.pp + + rank = self.rank + + average_rank = self.average_rank + + average_accuracy = self.average_accuracy + + ranked_pool_percent_captured = self.ranked_pool_percent_captured + + capture_leaderboards_count = self.capture_leaderboards_count + + player_changes_callback: Union[None, Unset, str] + if isinstance(self.player_changes_callback, Unset): + player_changes_callback = UNSET + else: + player_changes_callback = self.player_changes_callback + + clan_ranking_discord_hook: Union[None, Unset, str] + if isinstance(self.clan_ranking_discord_hook, Unset): + clan_ranking_discord_hook = UNSET + else: + clan_ranking_discord_hook = self.clan_ranking_discord_hook + + featured_playlists: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.featured_playlists, Unset): + featured_playlists = UNSET + elif isinstance(self.featured_playlists, list): + featured_playlists = [] + for featured_playlists_type_0_item_data in self.featured_playlists: + featured_playlists_type_0_item = featured_playlists_type_0_item_data.to_dict() + featured_playlists.append(featured_playlists_type_0_item) + + else: + featured_playlists = self.featured_playlists + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if color is not UNSET: + field_dict["color"] = color + if icon is not UNSET: + field_dict["icon"] = icon + if tag is not UNSET: + field_dict["tag"] = tag + if leader_id is not UNSET: + field_dict["leaderID"] = leader_id + if description is not UNSET: + field_dict["description"] = description + if bio is not UNSET: + field_dict["bio"] = bio + if rich_bio_timeset is not UNSET: + field_dict["richBioTimeset"] = rich_bio_timeset + if discord_invite is not UNSET: + field_dict["discordInvite"] = discord_invite + if players_count is not UNSET: + field_dict["playersCount"] = players_count + if pp is not UNSET: + field_dict["pp"] = pp + if rank is not UNSET: + field_dict["rank"] = rank + if average_rank is not UNSET: + field_dict["averageRank"] = average_rank + if average_accuracy is not UNSET: + field_dict["averageAccuracy"] = average_accuracy + if ranked_pool_percent_captured is not UNSET: + field_dict["rankedPoolPercentCaptured"] = ranked_pool_percent_captured + if capture_leaderboards_count is not UNSET: + field_dict["captureLeaderboardsCount"] = capture_leaderboards_count + if player_changes_callback is not UNSET: + field_dict["playerChangesCallback"] = player_changes_callback + if clan_ranking_discord_hook is not UNSET: + field_dict["clanRankingDiscordHook"] = clan_ranking_discord_hook + if featured_playlists is not UNSET: + field_dict["featuredPlaylists"] = featured_playlists + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.featured_playlist_response import FeaturedPlaylistResponse + + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + color = _parse_color(d.pop("color", UNSET)) + + def _parse_icon(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + icon = _parse_icon(d.pop("icon", UNSET)) + + def _parse_tag(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + tag = _parse_tag(d.pop("tag", UNSET)) + + def _parse_leader_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leader_id = _parse_leader_id(d.pop("leaderID", UNSET)) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_bio(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + bio = _parse_bio(d.pop("bio", UNSET)) + + rich_bio_timeset = d.pop("richBioTimeset", UNSET) + + def _parse_discord_invite(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + discord_invite = _parse_discord_invite(d.pop("discordInvite", UNSET)) + + players_count = d.pop("playersCount", UNSET) + + pp = d.pop("pp", UNSET) + + rank = d.pop("rank", UNSET) + + average_rank = d.pop("averageRank", UNSET) + + average_accuracy = d.pop("averageAccuracy", UNSET) + + ranked_pool_percent_captured = d.pop("rankedPoolPercentCaptured", UNSET) + + capture_leaderboards_count = d.pop("captureLeaderboardsCount", UNSET) + + def _parse_player_changes_callback(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_changes_callback = _parse_player_changes_callback(d.pop("playerChangesCallback", UNSET)) + + def _parse_clan_ranking_discord_hook(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + clan_ranking_discord_hook = _parse_clan_ranking_discord_hook(d.pop("clanRankingDiscordHook", UNSET)) + + def _parse_featured_playlists(data: object) -> Union[List["FeaturedPlaylistResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + featured_playlists_type_0 = [] + _featured_playlists_type_0 = data + for featured_playlists_type_0_item_data in _featured_playlists_type_0: + featured_playlists_type_0_item = FeaturedPlaylistResponse.from_dict( + featured_playlists_type_0_item_data + ) + + featured_playlists_type_0.append(featured_playlists_type_0_item) + + return featured_playlists_type_0 + except: # noqa: E722 + pass + return cast(Union[List["FeaturedPlaylistResponse"], None, Unset], data) + + featured_playlists = _parse_featured_playlists(d.pop("featuredPlaylists", UNSET)) + + clan_response_full = cls( + id=id, + name=name, + color=color, + icon=icon, + tag=tag, + leader_id=leader_id, + description=description, + bio=bio, + rich_bio_timeset=rich_bio_timeset, + discord_invite=discord_invite, + players_count=players_count, + pp=pp, + rank=rank, + average_rank=average_rank, + average_accuracy=average_accuracy, + ranked_pool_percent_captured=ranked_pool_percent_captured, + capture_leaderboards_count=capture_leaderboards_count, + player_changes_callback=player_changes_callback, + clan_ranking_discord_hook=clan_ranking_discord_hook, + featured_playlists=featured_playlists, + ) + + return clan_response_full diff --git a/src/clients/beatleader/models/clan_response_full_response_with_metadata.py b/src/clients/beatleader/models/clan_response_full_response_with_metadata.py new file mode 100644 index 0000000..7a37e43 --- /dev/null +++ b/src/clients/beatleader/models/clan_response_full_response_with_metadata.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response_full import ClanResponseFull + from ..models.metadata import Metadata + + +T = TypeVar("T", bound="ClanResponseFullResponseWithMetadata") + + +@_attrs_define +class ClanResponseFullResponseWithMetadata: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['ClanResponseFull'], None, Unset]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["ClanResponseFull"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response_full import ClanResponseFull + from ..models.metadata import Metadata + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["ClanResponseFull"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = ClanResponseFull.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanResponseFull"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + clan_response_full_response_with_metadata = cls( + metadata=metadata, + data=data, + ) + + return clan_response_full_response_with_metadata diff --git a/src/clients/beatleader/models/clan_sort_by.py b/src/clients/beatleader/models/clan_sort_by.py new file mode 100644 index 0000000..e26381c --- /dev/null +++ b/src/clients/beatleader/models/clan_sort_by.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class ClanSortBy(str, Enum): + ACC = "acc" + CAPTURES = "captures" + COUNT = "count" + NAME = "name" + PP = "pp" + RANK = "rank" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/compact_leaderboard.py b/src/clients/beatleader/models/compact_leaderboard.py new file mode 100644 index 0000000..ae52008 --- /dev/null +++ b/src/clients/beatleader/models/compact_leaderboard.py @@ -0,0 +1,99 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="CompactLeaderboard") + + +@_attrs_define +class CompactLeaderboard: + """ + Attributes: + id (Union[None, Unset, str]): + song_hash (Union[None, Unset, str]): + mode_name (Union[None, Unset, str]): + difficulty (Union[Unset, int]): + """ + + id: Union[None, Unset, str] = UNSET + song_hash: Union[None, Unset, str] = UNSET + mode_name: Union[None, Unset, str] = UNSET + difficulty: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + song_hash: Union[None, Unset, str] + if isinstance(self.song_hash, Unset): + song_hash = UNSET + else: + song_hash = self.song_hash + + mode_name: Union[None, Unset, str] + if isinstance(self.mode_name, Unset): + mode_name = UNSET + else: + mode_name = self.mode_name + + difficulty = self.difficulty + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if song_hash is not UNSET: + field_dict["songHash"] = song_hash + if mode_name is not UNSET: + field_dict["modeName"] = mode_name + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_song_hash(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + song_hash = _parse_song_hash(d.pop("songHash", UNSET)) + + def _parse_mode_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mode_name = _parse_mode_name(d.pop("modeName", UNSET)) + + difficulty = d.pop("difficulty", UNSET) + + compact_leaderboard = cls( + id=id, + song_hash=song_hash, + mode_name=mode_name, + difficulty=difficulty, + ) + + return compact_leaderboard diff --git a/src/clients/beatleader/models/compact_leaderboard_response.py b/src/clients/beatleader/models/compact_leaderboard_response.py new file mode 100644 index 0000000..39dc078 --- /dev/null +++ b/src/clients/beatleader/models/compact_leaderboard_response.py @@ -0,0 +1,90 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.compact_song_response import CompactSongResponse + from ..models.difficulty_response import DifficultyResponse + + +T = TypeVar("T", bound="CompactLeaderboardResponse") + + +@_attrs_define +class CompactLeaderboardResponse: + """ + Attributes: + id (Union[None, Unset, str]): + song (Union[Unset, CompactSongResponse]): + difficulty (Union[Unset, DifficultyResponse]): + """ + + id: Union[None, Unset, str] = UNSET + song: Union[Unset, "CompactSongResponse"] = UNSET + difficulty: Union[Unset, "DifficultyResponse"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + song: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.song, Unset): + song = self.song.to_dict() + + difficulty: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.difficulty, Unset): + difficulty = self.difficulty.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if song is not UNSET: + field_dict["song"] = song + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.compact_song_response import CompactSongResponse + from ..models.difficulty_response import DifficultyResponse + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + _song = d.pop("song", UNSET) + song: Union[Unset, CompactSongResponse] + if isinstance(_song, Unset): + song = UNSET + else: + song = CompactSongResponse.from_dict(_song) + + _difficulty = d.pop("difficulty", UNSET) + difficulty: Union[Unset, DifficultyResponse] + if isinstance(_difficulty, Unset): + difficulty = UNSET + else: + difficulty = DifficultyResponse.from_dict(_difficulty) + + compact_leaderboard_response = cls( + id=id, + song=song, + difficulty=difficulty, + ) + + return compact_leaderboard_response diff --git a/src/clients/beatleader/models/compact_score.py b/src/clients/beatleader/models/compact_score.py new file mode 100644 index 0000000..58b9555 --- /dev/null +++ b/src/clients/beatleader/models/compact_score.py @@ -0,0 +1,196 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.controller_enum import ControllerEnum +from ..models.hmd import HMD +from ..types import UNSET, Unset + +T = TypeVar("T", bound="CompactScore") + + +@_attrs_define +class CompactScore: + """ + Attributes: + id (Union[None, Unset, int]): + base_score (Union[Unset, int]): + modified_score (Union[Unset, int]): + modifiers (Union[None, Unset, str]): + full_combo (Union[Unset, bool]): + max_combo (Union[Unset, int]): + missed_notes (Union[Unset, int]): + bad_cuts (Union[Unset, int]): + hmd (Union[Unset, HMD]): + controller (Union[Unset, ControllerEnum]): + accuracy (Union[Unset, float]): + pp (Union[None, Unset, float]): + epoch_time (Union[Unset, int]): + """ + + id: Union[None, Unset, int] = UNSET + base_score: Union[Unset, int] = UNSET + modified_score: Union[Unset, int] = UNSET + modifiers: Union[None, Unset, str] = UNSET + full_combo: Union[Unset, bool] = UNSET + max_combo: Union[Unset, int] = UNSET + missed_notes: Union[Unset, int] = UNSET + bad_cuts: Union[Unset, int] = UNSET + hmd: Union[Unset, HMD] = UNSET + controller: Union[Unset, ControllerEnum] = UNSET + accuracy: Union[Unset, float] = UNSET + pp: Union[None, Unset, float] = UNSET + epoch_time: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, int] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + base_score = self.base_score + + modified_score = self.modified_score + + modifiers: Union[None, Unset, str] + if isinstance(self.modifiers, Unset): + modifiers = UNSET + else: + modifiers = self.modifiers + + full_combo = self.full_combo + + max_combo = self.max_combo + + missed_notes = self.missed_notes + + bad_cuts = self.bad_cuts + + hmd: Union[Unset, str] = UNSET + if not isinstance(self.hmd, Unset): + hmd = self.hmd.value + + controller: Union[Unset, str] = UNSET + if not isinstance(self.controller, Unset): + controller = self.controller.value + + accuracy = self.accuracy + + pp: Union[None, Unset, float] + if isinstance(self.pp, Unset): + pp = UNSET + else: + pp = self.pp + + epoch_time = self.epoch_time + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if base_score is not UNSET: + field_dict["baseScore"] = base_score + if modified_score is not UNSET: + field_dict["modifiedScore"] = modified_score + if modifiers is not UNSET: + field_dict["modifiers"] = modifiers + if full_combo is not UNSET: + field_dict["fullCombo"] = full_combo + if max_combo is not UNSET: + field_dict["maxCombo"] = max_combo + if missed_notes is not UNSET: + field_dict["missedNotes"] = missed_notes + if bad_cuts is not UNSET: + field_dict["badCuts"] = bad_cuts + if hmd is not UNSET: + field_dict["hmd"] = hmd + if controller is not UNSET: + field_dict["controller"] = controller + if accuracy is not UNSET: + field_dict["accuracy"] = accuracy + if pp is not UNSET: + field_dict["pp"] = pp + if epoch_time is not UNSET: + field_dict["epochTime"] = epoch_time + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + id = _parse_id(d.pop("id", UNSET)) + + base_score = d.pop("baseScore", UNSET) + + modified_score = d.pop("modifiedScore", UNSET) + + def _parse_modifiers(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + modifiers = _parse_modifiers(d.pop("modifiers", UNSET)) + + full_combo = d.pop("fullCombo", UNSET) + + max_combo = d.pop("maxCombo", UNSET) + + missed_notes = d.pop("missedNotes", UNSET) + + bad_cuts = d.pop("badCuts", UNSET) + + _hmd = d.pop("hmd", UNSET) + hmd: Union[Unset, HMD] + if isinstance(_hmd, Unset): + hmd = UNSET + else: + hmd = HMD(_hmd) + + _controller = d.pop("controller", UNSET) + controller: Union[Unset, ControllerEnum] + if isinstance(_controller, Unset): + controller = UNSET + else: + controller = ControllerEnum(_controller) + + accuracy = d.pop("accuracy", UNSET) + + def _parse_pp(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + pp = _parse_pp(d.pop("pp", UNSET)) + + epoch_time = d.pop("epochTime", UNSET) + + compact_score = cls( + id=id, + base_score=base_score, + modified_score=modified_score, + modifiers=modifiers, + full_combo=full_combo, + max_combo=max_combo, + missed_notes=missed_notes, + bad_cuts=bad_cuts, + hmd=hmd, + controller=controller, + accuracy=accuracy, + pp=pp, + epoch_time=epoch_time, + ) + + return compact_score diff --git a/src/clients/beatleader/models/compact_score_response.py b/src/clients/beatleader/models/compact_score_response.py new file mode 100644 index 0000000..2ff67ed --- /dev/null +++ b/src/clients/beatleader/models/compact_score_response.py @@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.compact_leaderboard import CompactLeaderboard + from ..models.compact_score import CompactScore + + +T = TypeVar("T", bound="CompactScoreResponse") + + +@_attrs_define +class CompactScoreResponse: + """ + Attributes: + score (Union[Unset, CompactScore]): + leaderboard (Union[Unset, CompactLeaderboard]): + """ + + score: Union[Unset, "CompactScore"] = UNSET + leaderboard: Union[Unset, "CompactLeaderboard"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + score: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score, Unset): + score = self.score.to_dict() + + leaderboard: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.leaderboard, Unset): + leaderboard = self.leaderboard.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if score is not UNSET: + field_dict["score"] = score + if leaderboard is not UNSET: + field_dict["leaderboard"] = leaderboard + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.compact_leaderboard import CompactLeaderboard + from ..models.compact_score import CompactScore + + d = src_dict.copy() + _score = d.pop("score", UNSET) + score: Union[Unset, CompactScore] + if isinstance(_score, Unset): + score = UNSET + else: + score = CompactScore.from_dict(_score) + + _leaderboard = d.pop("leaderboard", UNSET) + leaderboard: Union[Unset, CompactLeaderboard] + if isinstance(_leaderboard, Unset): + leaderboard = UNSET + else: + leaderboard = CompactLeaderboard.from_dict(_leaderboard) + + compact_score_response = cls( + score=score, + leaderboard=leaderboard, + ) + + return compact_score_response diff --git a/src/clients/beatleader/models/compact_score_response_response_with_metadata.py b/src/clients/beatleader/models/compact_score_response_response_with_metadata.py new file mode 100644 index 0000000..a5937f2 --- /dev/null +++ b/src/clients/beatleader/models/compact_score_response_response_with_metadata.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.compact_score_response import CompactScoreResponse + from ..models.metadata import Metadata + + +T = TypeVar("T", bound="CompactScoreResponseResponseWithMetadata") + + +@_attrs_define +class CompactScoreResponseResponseWithMetadata: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['CompactScoreResponse'], None, Unset]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["CompactScoreResponse"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.compact_score_response import CompactScoreResponse + from ..models.metadata import Metadata + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["CompactScoreResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = CompactScoreResponse.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["CompactScoreResponse"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + compact_score_response_response_with_metadata = cls( + metadata=metadata, + data=data, + ) + + return compact_score_response_response_with_metadata diff --git a/src/clients/beatleader/models/compact_song_response.py b/src/clients/beatleader/models/compact_song_response.py new file mode 100644 index 0000000..21c84b2 --- /dev/null +++ b/src/clients/beatleader/models/compact_song_response.py @@ -0,0 +1,237 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="CompactSongResponse") + + +@_attrs_define +class CompactSongResponse: + """ + Attributes: + id (Union[None, Unset, str]): + hash_ (Union[None, Unset, str]): + name (Union[None, Unset, str]): + sub_name (Union[None, Unset, str]): + author (Union[None, Unset, str]): + mapper (Union[None, Unset, str]): + mapper_id (Union[Unset, int]): + collaborator_ids (Union[None, Unset, str]): + cover_image (Union[None, Unset, str]): + bpm (Union[Unset, float]): + duration (Union[Unset, float]): + full_cover_image (Union[None, Unset, str]): + """ + + id: Union[None, Unset, str] = UNSET + hash_: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + sub_name: Union[None, Unset, str] = UNSET + author: Union[None, Unset, str] = UNSET + mapper: Union[None, Unset, str] = UNSET + mapper_id: Union[Unset, int] = UNSET + collaborator_ids: Union[None, Unset, str] = UNSET + cover_image: Union[None, Unset, str] = UNSET + bpm: Union[Unset, float] = UNSET + duration: Union[Unset, float] = UNSET + full_cover_image: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + hash_: Union[None, Unset, str] + if isinstance(self.hash_, Unset): + hash_ = UNSET + else: + hash_ = self.hash_ + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + sub_name: Union[None, Unset, str] + if isinstance(self.sub_name, Unset): + sub_name = UNSET + else: + sub_name = self.sub_name + + author: Union[None, Unset, str] + if isinstance(self.author, Unset): + author = UNSET + else: + author = self.author + + mapper: Union[None, Unset, str] + if isinstance(self.mapper, Unset): + mapper = UNSET + else: + mapper = self.mapper + + mapper_id = self.mapper_id + + collaborator_ids: Union[None, Unset, str] + if isinstance(self.collaborator_ids, Unset): + collaborator_ids = UNSET + else: + collaborator_ids = self.collaborator_ids + + cover_image: Union[None, Unset, str] + if isinstance(self.cover_image, Unset): + cover_image = UNSET + else: + cover_image = self.cover_image + + bpm = self.bpm + + duration = self.duration + + full_cover_image: Union[None, Unset, str] + if isinstance(self.full_cover_image, Unset): + full_cover_image = UNSET + else: + full_cover_image = self.full_cover_image + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if name is not UNSET: + field_dict["name"] = name + if sub_name is not UNSET: + field_dict["subName"] = sub_name + if author is not UNSET: + field_dict["author"] = author + if mapper is not UNSET: + field_dict["mapper"] = mapper + if mapper_id is not UNSET: + field_dict["mapperId"] = mapper_id + if collaborator_ids is not UNSET: + field_dict["collaboratorIds"] = collaborator_ids + if cover_image is not UNSET: + field_dict["coverImage"] = cover_image + if bpm is not UNSET: + field_dict["bpm"] = bpm + if duration is not UNSET: + field_dict["duration"] = duration + if full_cover_image is not UNSET: + field_dict["fullCoverImage"] = full_cover_image + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_hash_(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + hash_ = _parse_hash_(d.pop("hash", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_sub_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + sub_name = _parse_sub_name(d.pop("subName", UNSET)) + + def _parse_author(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + author = _parse_author(d.pop("author", UNSET)) + + def _parse_mapper(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mapper = _parse_mapper(d.pop("mapper", UNSET)) + + mapper_id = d.pop("mapperId", UNSET) + + def _parse_collaborator_ids(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + collaborator_ids = _parse_collaborator_ids(d.pop("collaboratorIds", UNSET)) + + def _parse_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover_image = _parse_cover_image(d.pop("coverImage", UNSET)) + + bpm = d.pop("bpm", UNSET) + + duration = d.pop("duration", UNSET) + + def _parse_full_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + full_cover_image = _parse_full_cover_image(d.pop("fullCoverImage", UNSET)) + + compact_song_response = cls( + id=id, + hash_=hash_, + name=name, + sub_name=sub_name, + author=author, + mapper=mapper, + mapper_id=mapper_id, + collaborator_ids=collaborator_ids, + cover_image=cover_image, + bpm=bpm, + duration=duration, + full_cover_image=full_cover_image, + ) + + return compact_song_response diff --git a/src/clients/beatleader/models/controller_enum.py b/src/clients/beatleader/models/controller_enum.py new file mode 100644 index 0000000..1a7fe0e --- /dev/null +++ b/src/clients/beatleader/models/controller_enum.py @@ -0,0 +1,42 @@ +from enum import Enum + + +class ControllerEnum(str, Enum): + CONTACTGLOVE = "contactglove" + CRY = "cry" + DISCO = "disco" + E4 = "e4" + ETEE = "etee" + GAMEPAD = "gamepad" + HANDS = "hands" + HPMOTION = "hpMotion" + HUAWEI = "huawei" + JOYCON = "joycon" + KNUCKLES = "knuckles" + MIRAMAR = "miramar" + NOLO = "nolo" + OCULUSTOUCH = "oculustouch" + OCULUSTOUCH2 = "oculustouch2" + ODYSSEY = "odyssey" + PICONEO2 = "picoNeo2" + PICONEO3 = "picoNeo3" + PICOPHOENIX = "picophoenix" + PIMAX = "pimax" + POLARIS = "polaris" + QUEST2 = "quest2" + QUEST3 = "quest3" + QUESTPRO = "questPro" + STEAMDECK = "steamdeck" + TUNDRA = "tundra" + UNKNOWN = "unknown" + VIVE = "vive" + VIVECOSMOS = "viveCosmos" + VIVEPRO = "vivePro" + VIVEPRO2 = "vivePro2" + VIVETRACKER = "viveTracker" + VIVETRACKER2 = "viveTracker2" + VIVETRACKER3 = "viveTracker3" + WMR = "wmr" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/criteria_commentary.py b/src/clients/beatleader/models/criteria_commentary.py new file mode 100644 index 0000000..673b761 --- /dev/null +++ b/src/clients/beatleader/models/criteria_commentary.py @@ -0,0 +1,156 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="CriteriaCommentary") + + +@_attrs_define +class CriteriaCommentary: + """ + Attributes: + id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + timeset (Union[Unset, int]): + value (Union[None, Unset, str]): + edit_timeset (Union[None, Unset, int]): + edited (Union[Unset, bool]): + rank_qualification_id (Union[None, Unset, int]): + discord_message_id (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + timeset: Union[Unset, int] = UNSET + value: Union[None, Unset, str] = UNSET + edit_timeset: Union[None, Unset, int] = UNSET + edited: Union[Unset, bool] = UNSET + rank_qualification_id: Union[None, Unset, int] = UNSET + discord_message_id: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + timeset = self.timeset + + value: Union[None, Unset, str] + if isinstance(self.value, Unset): + value = UNSET + else: + value = self.value + + edit_timeset: Union[None, Unset, int] + if isinstance(self.edit_timeset, Unset): + edit_timeset = UNSET + else: + edit_timeset = self.edit_timeset + + edited = self.edited + + rank_qualification_id: Union[None, Unset, int] + if isinstance(self.rank_qualification_id, Unset): + rank_qualification_id = UNSET + else: + rank_qualification_id = self.rank_qualification_id + + discord_message_id: Union[None, Unset, str] + if isinstance(self.discord_message_id, Unset): + discord_message_id = UNSET + else: + discord_message_id = self.discord_message_id + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if value is not UNSET: + field_dict["value"] = value + if edit_timeset is not UNSET: + field_dict["editTimeset"] = edit_timeset + if edited is not UNSET: + field_dict["edited"] = edited + if rank_qualification_id is not UNSET: + field_dict["rankQualificationId"] = rank_qualification_id + if discord_message_id is not UNSET: + field_dict["discordMessageId"] = discord_message_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + timeset = d.pop("timeset", UNSET) + + def _parse_value(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + value = _parse_value(d.pop("value", UNSET)) + + def _parse_edit_timeset(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + edit_timeset = _parse_edit_timeset(d.pop("editTimeset", UNSET)) + + edited = d.pop("edited", UNSET) + + def _parse_rank_qualification_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + rank_qualification_id = _parse_rank_qualification_id(d.pop("rankQualificationId", UNSET)) + + def _parse_discord_message_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + discord_message_id = _parse_discord_message_id(d.pop("discordMessageId", UNSET)) + + criteria_commentary = cls( + id=id, + player_id=player_id, + timeset=timeset, + value=value, + edit_timeset=edit_timeset, + edited=edited, + rank_qualification_id=rank_qualification_id, + discord_message_id=discord_message_id, + ) + + return criteria_commentary diff --git a/src/clients/beatleader/models/difficulty_description.py b/src/clients/beatleader/models/difficulty_description.py new file mode 100644 index 0000000..84b8149 --- /dev/null +++ b/src/clients/beatleader/models/difficulty_description.py @@ -0,0 +1,414 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.difficulty_status import DifficultyStatus +from ..models.requirements import Requirements +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + + +T = TypeVar("T", bound="DifficultyDescription") + + +@_attrs_define +class DifficultyDescription: + """ + Attributes: + id (Union[Unset, int]): + value (Union[Unset, int]): + mode (Union[Unset, int]): + difficulty_name (Union[None, Unset, str]): + mode_name (Union[None, Unset, str]): + status (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifier_values (Union[Unset, ModifiersMap]): + modifiers_rating (Union[Unset, ModifiersRating]): + nominated_time (Union[Unset, int]): + qualified_time (Union[Unset, int]): + ranked_time (Union[Unset, int]): + speed_tags (Union[Unset, int]): + style_tags (Union[Unset, int]): + feature_tags (Union[Unset, int]): + stars (Union[None, Unset, float]): + predicted_acc (Union[None, Unset, float]): + pass_rating (Union[None, Unset, float]): + acc_rating (Union[None, Unset, float]): + tech_rating (Union[None, Unset, float]): + type (Union[Unset, int]): + njs (Union[Unset, float]): + nps (Union[Unset, float]): + notes (Union[Unset, int]): + chains (Union[Unset, int]): + sliders (Union[Unset, int]): + bombs (Union[Unset, int]): + walls (Union[Unset, int]): + max_score (Union[Unset, int]): + duration (Union[Unset, float]): + requirements (Union[Unset, Requirements]): + """ + + id: Union[Unset, int] = UNSET + value: Union[Unset, int] = UNSET + mode: Union[Unset, int] = UNSET + difficulty_name: Union[None, Unset, str] = UNSET + mode_name: Union[None, Unset, str] = UNSET + status: Union[Unset, DifficultyStatus] = UNSET + modifier_values: Union[Unset, "ModifiersMap"] = UNSET + modifiers_rating: Union[Unset, "ModifiersRating"] = UNSET + nominated_time: Union[Unset, int] = UNSET + qualified_time: Union[Unset, int] = UNSET + ranked_time: Union[Unset, int] = UNSET + speed_tags: Union[Unset, int] = UNSET + style_tags: Union[Unset, int] = UNSET + feature_tags: Union[Unset, int] = UNSET + stars: Union[None, Unset, float] = UNSET + predicted_acc: Union[None, Unset, float] = UNSET + pass_rating: Union[None, Unset, float] = UNSET + acc_rating: Union[None, Unset, float] = UNSET + tech_rating: Union[None, Unset, float] = UNSET + type: Union[Unset, int] = UNSET + njs: Union[Unset, float] = UNSET + nps: Union[Unset, float] = UNSET + notes: Union[Unset, int] = UNSET + chains: Union[Unset, int] = UNSET + sliders: Union[Unset, int] = UNSET + bombs: Union[Unset, int] = UNSET + walls: Union[Unset, int] = UNSET + max_score: Union[Unset, int] = UNSET + duration: Union[Unset, float] = UNSET + requirements: Union[Unset, Requirements] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + value = self.value + + mode = self.mode + + difficulty_name: Union[None, Unset, str] + if isinstance(self.difficulty_name, Unset): + difficulty_name = UNSET + else: + difficulty_name = self.difficulty_name + + mode_name: Union[None, Unset, str] + if isinstance(self.mode_name, Unset): + mode_name = UNSET + else: + mode_name = self.mode_name + + status: Union[Unset, str] = UNSET + if not isinstance(self.status, Unset): + status = self.status.value + + modifier_values: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifier_values, Unset): + modifier_values = self.modifier_values.to_dict() + + modifiers_rating: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifiers_rating, Unset): + modifiers_rating = self.modifiers_rating.to_dict() + + nominated_time = self.nominated_time + + qualified_time = self.qualified_time + + ranked_time = self.ranked_time + + speed_tags = self.speed_tags + + style_tags = self.style_tags + + feature_tags = self.feature_tags + + stars: Union[None, Unset, float] + if isinstance(self.stars, Unset): + stars = UNSET + else: + stars = self.stars + + predicted_acc: Union[None, Unset, float] + if isinstance(self.predicted_acc, Unset): + predicted_acc = UNSET + else: + predicted_acc = self.predicted_acc + + pass_rating: Union[None, Unset, float] + if isinstance(self.pass_rating, Unset): + pass_rating = UNSET + else: + pass_rating = self.pass_rating + + acc_rating: Union[None, Unset, float] + if isinstance(self.acc_rating, Unset): + acc_rating = UNSET + else: + acc_rating = self.acc_rating + + tech_rating: Union[None, Unset, float] + if isinstance(self.tech_rating, Unset): + tech_rating = UNSET + else: + tech_rating = self.tech_rating + + type = self.type + + njs = self.njs + + nps = self.nps + + notes = self.notes + + chains = self.chains + + sliders = self.sliders + + bombs = self.bombs + + walls = self.walls + + max_score = self.max_score + + duration = self.duration + + requirements: Union[Unset, str] = UNSET + if not isinstance(self.requirements, Unset): + requirements = self.requirements.value + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if value is not UNSET: + field_dict["value"] = value + if mode is not UNSET: + field_dict["mode"] = mode + if difficulty_name is not UNSET: + field_dict["difficultyName"] = difficulty_name + if mode_name is not UNSET: + field_dict["modeName"] = mode_name + if status is not UNSET: + field_dict["status"] = status + if modifier_values is not UNSET: + field_dict["modifierValues"] = modifier_values + if modifiers_rating is not UNSET: + field_dict["modifiersRating"] = modifiers_rating + if nominated_time is not UNSET: + field_dict["nominatedTime"] = nominated_time + if qualified_time is not UNSET: + field_dict["qualifiedTime"] = qualified_time + if ranked_time is not UNSET: + field_dict["rankedTime"] = ranked_time + if speed_tags is not UNSET: + field_dict["speedTags"] = speed_tags + if style_tags is not UNSET: + field_dict["styleTags"] = style_tags + if feature_tags is not UNSET: + field_dict["featureTags"] = feature_tags + if stars is not UNSET: + field_dict["stars"] = stars + if predicted_acc is not UNSET: + field_dict["predictedAcc"] = predicted_acc + if pass_rating is not UNSET: + field_dict["passRating"] = pass_rating + if acc_rating is not UNSET: + field_dict["accRating"] = acc_rating + if tech_rating is not UNSET: + field_dict["techRating"] = tech_rating + if type is not UNSET: + field_dict["type"] = type + if njs is not UNSET: + field_dict["njs"] = njs + if nps is not UNSET: + field_dict["nps"] = nps + if notes is not UNSET: + field_dict["notes"] = notes + if chains is not UNSET: + field_dict["chains"] = chains + if sliders is not UNSET: + field_dict["sliders"] = sliders + if bombs is not UNSET: + field_dict["bombs"] = bombs + if walls is not UNSET: + field_dict["walls"] = walls + if max_score is not UNSET: + field_dict["maxScore"] = max_score + if duration is not UNSET: + field_dict["duration"] = duration + if requirements is not UNSET: + field_dict["requirements"] = requirements + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + + d = src_dict.copy() + id = d.pop("id", UNSET) + + value = d.pop("value", UNSET) + + mode = d.pop("mode", UNSET) + + def _parse_difficulty_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + difficulty_name = _parse_difficulty_name(d.pop("difficultyName", UNSET)) + + def _parse_mode_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mode_name = _parse_mode_name(d.pop("modeName", UNSET)) + + _status = d.pop("status", UNSET) + status: Union[Unset, DifficultyStatus] + if isinstance(_status, Unset): + status = UNSET + else: + status = DifficultyStatus(_status) + + _modifier_values = d.pop("modifierValues", UNSET) + modifier_values: Union[Unset, ModifiersMap] + if isinstance(_modifier_values, Unset): + modifier_values = UNSET + else: + modifier_values = ModifiersMap.from_dict(_modifier_values) + + _modifiers_rating = d.pop("modifiersRating", UNSET) + modifiers_rating: Union[Unset, ModifiersRating] + if isinstance(_modifiers_rating, Unset): + modifiers_rating = UNSET + else: + modifiers_rating = ModifiersRating.from_dict(_modifiers_rating) + + nominated_time = d.pop("nominatedTime", UNSET) + + qualified_time = d.pop("qualifiedTime", UNSET) + + ranked_time = d.pop("rankedTime", UNSET) + + speed_tags = d.pop("speedTags", UNSET) + + style_tags = d.pop("styleTags", UNSET) + + feature_tags = d.pop("featureTags", UNSET) + + def _parse_stars(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + stars = _parse_stars(d.pop("stars", UNSET)) + + def _parse_predicted_acc(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + predicted_acc = _parse_predicted_acc(d.pop("predictedAcc", UNSET)) + + def _parse_pass_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + pass_rating = _parse_pass_rating(d.pop("passRating", UNSET)) + + def _parse_acc_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + acc_rating = _parse_acc_rating(d.pop("accRating", UNSET)) + + def _parse_tech_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + tech_rating = _parse_tech_rating(d.pop("techRating", UNSET)) + + type = d.pop("type", UNSET) + + njs = d.pop("njs", UNSET) + + nps = d.pop("nps", UNSET) + + notes = d.pop("notes", UNSET) + + chains = d.pop("chains", UNSET) + + sliders = d.pop("sliders", UNSET) + + bombs = d.pop("bombs", UNSET) + + walls = d.pop("walls", UNSET) + + max_score = d.pop("maxScore", UNSET) + + duration = d.pop("duration", UNSET) + + _requirements = d.pop("requirements", UNSET) + requirements: Union[Unset, Requirements] + if isinstance(_requirements, Unset): + requirements = UNSET + else: + requirements = Requirements(_requirements) + + difficulty_description = cls( + id=id, + value=value, + mode=mode, + difficulty_name=difficulty_name, + mode_name=mode_name, + status=status, + modifier_values=modifier_values, + modifiers_rating=modifiers_rating, + nominated_time=nominated_time, + qualified_time=qualified_time, + ranked_time=ranked_time, + speed_tags=speed_tags, + style_tags=style_tags, + feature_tags=feature_tags, + stars=stars, + predicted_acc=predicted_acc, + pass_rating=pass_rating, + acc_rating=acc_rating, + tech_rating=tech_rating, + type=type, + njs=njs, + nps=nps, + notes=notes, + chains=chains, + sliders=sliders, + bombs=bombs, + walls=walls, + max_score=max_score, + duration=duration, + requirements=requirements, + ) + + return difficulty_description diff --git a/src/clients/beatleader/models/difficulty_response.py b/src/clients/beatleader/models/difficulty_response.py new file mode 100644 index 0000000..c283ff6 --- /dev/null +++ b/src/clients/beatleader/models/difficulty_response.py @@ -0,0 +1,396 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.difficulty_status import DifficultyStatus +from ..models.requirements import Requirements +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + + +T = TypeVar("T", bound="DifficultyResponse") + + +@_attrs_define +class DifficultyResponse: + """ + Attributes: + id (Union[Unset, int]): + value (Union[Unset, int]): + mode (Union[Unset, int]): + difficulty_name (Union[None, Unset, str]): + mode_name (Union[None, Unset, str]): + status (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifier_values (Union[Unset, ModifiersMap]): + modifiers_rating (Union[Unset, ModifiersRating]): + nominated_time (Union[Unset, int]): + qualified_time (Union[Unset, int]): + ranked_time (Union[Unset, int]): + speed_tags (Union[Unset, int]): + style_tags (Union[Unset, int]): + feature_tags (Union[Unset, int]): + stars (Union[None, Unset, float]): + predicted_acc (Union[None, Unset, float]): + pass_rating (Union[None, Unset, float]): + acc_rating (Union[None, Unset, float]): + tech_rating (Union[None, Unset, float]): + type (Union[Unset, int]): + njs (Union[Unset, float]): + nps (Union[Unset, float]): + notes (Union[Unset, int]): + bombs (Union[Unset, int]): + walls (Union[Unset, int]): + max_score (Union[Unset, int]): + duration (Union[Unset, float]): + requirements (Union[Unset, Requirements]): + """ + + id: Union[Unset, int] = UNSET + value: Union[Unset, int] = UNSET + mode: Union[Unset, int] = UNSET + difficulty_name: Union[None, Unset, str] = UNSET + mode_name: Union[None, Unset, str] = UNSET + status: Union[Unset, DifficultyStatus] = UNSET + modifier_values: Union[Unset, "ModifiersMap"] = UNSET + modifiers_rating: Union[Unset, "ModifiersRating"] = UNSET + nominated_time: Union[Unset, int] = UNSET + qualified_time: Union[Unset, int] = UNSET + ranked_time: Union[Unset, int] = UNSET + speed_tags: Union[Unset, int] = UNSET + style_tags: Union[Unset, int] = UNSET + feature_tags: Union[Unset, int] = UNSET + stars: Union[None, Unset, float] = UNSET + predicted_acc: Union[None, Unset, float] = UNSET + pass_rating: Union[None, Unset, float] = UNSET + acc_rating: Union[None, Unset, float] = UNSET + tech_rating: Union[None, Unset, float] = UNSET + type: Union[Unset, int] = UNSET + njs: Union[Unset, float] = UNSET + nps: Union[Unset, float] = UNSET + notes: Union[Unset, int] = UNSET + bombs: Union[Unset, int] = UNSET + walls: Union[Unset, int] = UNSET + max_score: Union[Unset, int] = UNSET + duration: Union[Unset, float] = UNSET + requirements: Union[Unset, Requirements] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + value = self.value + + mode = self.mode + + difficulty_name: Union[None, Unset, str] + if isinstance(self.difficulty_name, Unset): + difficulty_name = UNSET + else: + difficulty_name = self.difficulty_name + + mode_name: Union[None, Unset, str] + if isinstance(self.mode_name, Unset): + mode_name = UNSET + else: + mode_name = self.mode_name + + status: Union[Unset, str] = UNSET + if not isinstance(self.status, Unset): + status = self.status.value + + modifier_values: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifier_values, Unset): + modifier_values = self.modifier_values.to_dict() + + modifiers_rating: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifiers_rating, Unset): + modifiers_rating = self.modifiers_rating.to_dict() + + nominated_time = self.nominated_time + + qualified_time = self.qualified_time + + ranked_time = self.ranked_time + + speed_tags = self.speed_tags + + style_tags = self.style_tags + + feature_tags = self.feature_tags + + stars: Union[None, Unset, float] + if isinstance(self.stars, Unset): + stars = UNSET + else: + stars = self.stars + + predicted_acc: Union[None, Unset, float] + if isinstance(self.predicted_acc, Unset): + predicted_acc = UNSET + else: + predicted_acc = self.predicted_acc + + pass_rating: Union[None, Unset, float] + if isinstance(self.pass_rating, Unset): + pass_rating = UNSET + else: + pass_rating = self.pass_rating + + acc_rating: Union[None, Unset, float] + if isinstance(self.acc_rating, Unset): + acc_rating = UNSET + else: + acc_rating = self.acc_rating + + tech_rating: Union[None, Unset, float] + if isinstance(self.tech_rating, Unset): + tech_rating = UNSET + else: + tech_rating = self.tech_rating + + type = self.type + + njs = self.njs + + nps = self.nps + + notes = self.notes + + bombs = self.bombs + + walls = self.walls + + max_score = self.max_score + + duration = self.duration + + requirements: Union[Unset, str] = UNSET + if not isinstance(self.requirements, Unset): + requirements = self.requirements.value + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if value is not UNSET: + field_dict["value"] = value + if mode is not UNSET: + field_dict["mode"] = mode + if difficulty_name is not UNSET: + field_dict["difficultyName"] = difficulty_name + if mode_name is not UNSET: + field_dict["modeName"] = mode_name + if status is not UNSET: + field_dict["status"] = status + if modifier_values is not UNSET: + field_dict["modifierValues"] = modifier_values + if modifiers_rating is not UNSET: + field_dict["modifiersRating"] = modifiers_rating + if nominated_time is not UNSET: + field_dict["nominatedTime"] = nominated_time + if qualified_time is not UNSET: + field_dict["qualifiedTime"] = qualified_time + if ranked_time is not UNSET: + field_dict["rankedTime"] = ranked_time + if speed_tags is not UNSET: + field_dict["speedTags"] = speed_tags + if style_tags is not UNSET: + field_dict["styleTags"] = style_tags + if feature_tags is not UNSET: + field_dict["featureTags"] = feature_tags + if stars is not UNSET: + field_dict["stars"] = stars + if predicted_acc is not UNSET: + field_dict["predictedAcc"] = predicted_acc + if pass_rating is not UNSET: + field_dict["passRating"] = pass_rating + if acc_rating is not UNSET: + field_dict["accRating"] = acc_rating + if tech_rating is not UNSET: + field_dict["techRating"] = tech_rating + if type is not UNSET: + field_dict["type"] = type + if njs is not UNSET: + field_dict["njs"] = njs + if nps is not UNSET: + field_dict["nps"] = nps + if notes is not UNSET: + field_dict["notes"] = notes + if bombs is not UNSET: + field_dict["bombs"] = bombs + if walls is not UNSET: + field_dict["walls"] = walls + if max_score is not UNSET: + field_dict["maxScore"] = max_score + if duration is not UNSET: + field_dict["duration"] = duration + if requirements is not UNSET: + field_dict["requirements"] = requirements + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + + d = src_dict.copy() + id = d.pop("id", UNSET) + + value = d.pop("value", UNSET) + + mode = d.pop("mode", UNSET) + + def _parse_difficulty_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + difficulty_name = _parse_difficulty_name(d.pop("difficultyName", UNSET)) + + def _parse_mode_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mode_name = _parse_mode_name(d.pop("modeName", UNSET)) + + _status = d.pop("status", UNSET) + status: Union[Unset, DifficultyStatus] + if isinstance(_status, Unset): + status = UNSET + else: + status = DifficultyStatus(_status) + + _modifier_values = d.pop("modifierValues", UNSET) + modifier_values: Union[Unset, ModifiersMap] + if isinstance(_modifier_values, Unset): + modifier_values = UNSET + else: + modifier_values = ModifiersMap.from_dict(_modifier_values) + + _modifiers_rating = d.pop("modifiersRating", UNSET) + modifiers_rating: Union[Unset, ModifiersRating] + if isinstance(_modifiers_rating, Unset): + modifiers_rating = UNSET + else: + modifiers_rating = ModifiersRating.from_dict(_modifiers_rating) + + nominated_time = d.pop("nominatedTime", UNSET) + + qualified_time = d.pop("qualifiedTime", UNSET) + + ranked_time = d.pop("rankedTime", UNSET) + + speed_tags = d.pop("speedTags", UNSET) + + style_tags = d.pop("styleTags", UNSET) + + feature_tags = d.pop("featureTags", UNSET) + + def _parse_stars(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + stars = _parse_stars(d.pop("stars", UNSET)) + + def _parse_predicted_acc(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + predicted_acc = _parse_predicted_acc(d.pop("predictedAcc", UNSET)) + + def _parse_pass_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + pass_rating = _parse_pass_rating(d.pop("passRating", UNSET)) + + def _parse_acc_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + acc_rating = _parse_acc_rating(d.pop("accRating", UNSET)) + + def _parse_tech_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + tech_rating = _parse_tech_rating(d.pop("techRating", UNSET)) + + type = d.pop("type", UNSET) + + njs = d.pop("njs", UNSET) + + nps = d.pop("nps", UNSET) + + notes = d.pop("notes", UNSET) + + bombs = d.pop("bombs", UNSET) + + walls = d.pop("walls", UNSET) + + max_score = d.pop("maxScore", UNSET) + + duration = d.pop("duration", UNSET) + + _requirements = d.pop("requirements", UNSET) + requirements: Union[Unset, Requirements] + if isinstance(_requirements, Unset): + requirements = UNSET + else: + requirements = Requirements(_requirements) + + difficulty_response = cls( + id=id, + value=value, + mode=mode, + difficulty_name=difficulty_name, + mode_name=mode_name, + status=status, + modifier_values=modifier_values, + modifiers_rating=modifiers_rating, + nominated_time=nominated_time, + qualified_time=qualified_time, + ranked_time=ranked_time, + speed_tags=speed_tags, + style_tags=style_tags, + feature_tags=feature_tags, + stars=stars, + predicted_acc=predicted_acc, + pass_rating=pass_rating, + acc_rating=acc_rating, + tech_rating=tech_rating, + type=type, + njs=njs, + nps=nps, + notes=notes, + bombs=bombs, + walls=walls, + max_score=max_score, + duration=duration, + requirements=requirements, + ) + + return difficulty_response diff --git a/src/clients/beatleader/models/difficulty_status.py b/src/clients/beatleader/models/difficulty_status.py new file mode 100644 index 0000000..9de2dd1 --- /dev/null +++ b/src/clients/beatleader/models/difficulty_status.py @@ -0,0 +1,15 @@ +from enum import Enum + + +class DifficultyStatus(str, Enum): + INEVENT = "inevent" + NOMINATED = "nominated" + OST = "oST" + OUTDATED = "outdated" + QUALIFIED = "qualified" + RANKED = "ranked" + UNRANKABLE = "unrankable" + UNRANKED = "unranked" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/event_player.py b/src/clients/beatleader/models/event_player.py new file mode 100644 index 0000000..1f44997 --- /dev/null +++ b/src/clients/beatleader/models/event_player.py @@ -0,0 +1,187 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.event_ranking import EventRanking + + +T = TypeVar("T", bound="EventPlayer") + + +@_attrs_define +class EventPlayer: + """ + Attributes: + id (Union[Unset, int]): + event_ranking_id (Union[None, Unset, int]): + event (Union[Unset, EventRanking]): + event_name (Union[None, Unset, str]): + player_name (Union[None, Unset, str]): + player_id (Union[None, Unset, str]): + country (Union[None, Unset, str]): + rank (Union[Unset, int]): + country_rank (Union[Unset, int]): + pp (Union[Unset, float]): + """ + + id: Union[Unset, int] = UNSET + event_ranking_id: Union[None, Unset, int] = UNSET + event: Union[Unset, "EventRanking"] = UNSET + event_name: Union[None, Unset, str] = UNSET + player_name: Union[None, Unset, str] = UNSET + player_id: Union[None, Unset, str] = UNSET + country: Union[None, Unset, str] = UNSET + rank: Union[Unset, int] = UNSET + country_rank: Union[Unset, int] = UNSET + pp: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + event_ranking_id: Union[None, Unset, int] + if isinstance(self.event_ranking_id, Unset): + event_ranking_id = UNSET + else: + event_ranking_id = self.event_ranking_id + + event: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.event, Unset): + event = self.event.to_dict() + + event_name: Union[None, Unset, str] + if isinstance(self.event_name, Unset): + event_name = UNSET + else: + event_name = self.event_name + + player_name: Union[None, Unset, str] + if isinstance(self.player_name, Unset): + player_name = UNSET + else: + player_name = self.player_name + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + rank = self.rank + + country_rank = self.country_rank + + pp = self.pp + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if event_ranking_id is not UNSET: + field_dict["eventRankingId"] = event_ranking_id + if event is not UNSET: + field_dict["event"] = event + if event_name is not UNSET: + field_dict["eventName"] = event_name + if player_name is not UNSET: + field_dict["playerName"] = player_name + if player_id is not UNSET: + field_dict["playerId"] = player_id + if country is not UNSET: + field_dict["country"] = country + if rank is not UNSET: + field_dict["rank"] = rank + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if pp is not UNSET: + field_dict["pp"] = pp + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.event_ranking import EventRanking + + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_event_ranking_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + event_ranking_id = _parse_event_ranking_id(d.pop("eventRankingId", UNSET)) + + _event = d.pop("event", UNSET) + event: Union[Unset, EventRanking] + if isinstance(_event, Unset): + event = UNSET + else: + event = EventRanking.from_dict(_event) + + def _parse_event_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + event_name = _parse_event_name(d.pop("eventName", UNSET)) + + def _parse_player_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_name = _parse_player_name(d.pop("playerName", UNSET)) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + rank = d.pop("rank", UNSET) + + country_rank = d.pop("countryRank", UNSET) + + pp = d.pop("pp", UNSET) + + event_player = cls( + id=id, + event_ranking_id=event_ranking_id, + event=event, + event_name=event_name, + player_name=player_name, + player_id=player_id, + country=country, + rank=rank, + country_rank=country_rank, + pp=pp, + ) + + return event_player diff --git a/src/clients/beatleader/models/event_ranking.py b/src/clients/beatleader/models/event_ranking.py new file mode 100644 index 0000000..a7d9565 --- /dev/null +++ b/src/clients/beatleader/models/event_ranking.py @@ -0,0 +1,96 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="EventRanking") + + +@_attrs_define +class EventRanking: + """ + Attributes: + id (Union[Unset, int]): + name (Union[None, Unset, str]): + end_date (Union[Unset, int]): + playlist_id (Union[Unset, int]): + image (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + name: Union[None, Unset, str] = UNSET + end_date: Union[Unset, int] = UNSET + playlist_id: Union[Unset, int] = UNSET + image: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + end_date = self.end_date + + playlist_id = self.playlist_id + + image: Union[None, Unset, str] + if isinstance(self.image, Unset): + image = UNSET + else: + image = self.image + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if end_date is not UNSET: + field_dict["endDate"] = end_date + if playlist_id is not UNSET: + field_dict["playlistId"] = playlist_id + if image is not UNSET: + field_dict["image"] = image + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + end_date = d.pop("endDate", UNSET) + + playlist_id = d.pop("playlistId", UNSET) + + def _parse_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + image = _parse_image(d.pop("image", UNSET)) + + event_ranking = cls( + id=id, + name=name, + end_date=end_date, + playlist_id=playlist_id, + image=image, + ) + + return event_ranking diff --git a/src/clients/beatleader/models/external_status.py b/src/clients/beatleader/models/external_status.py new file mode 100644 index 0000000..06520d6 --- /dev/null +++ b/src/clients/beatleader/models/external_status.py @@ -0,0 +1,164 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.song_status import SongStatus +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ExternalStatus") + + +@_attrs_define +class ExternalStatus: + """ + Attributes: + id (Union[Unset, int]): + status (Union[Unset, SongStatus]): + timeset (Union[Unset, int]): + link (Union[None, Unset, str]): + responsible (Union[None, Unset, str]): + details (Union[None, Unset, str]): + title (Union[None, Unset, str]): + title_color (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + status: Union[Unset, SongStatus] = UNSET + timeset: Union[Unset, int] = UNSET + link: Union[None, Unset, str] = UNSET + responsible: Union[None, Unset, str] = UNSET + details: Union[None, Unset, str] = UNSET + title: Union[None, Unset, str] = UNSET + title_color: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + status: Union[Unset, str] = UNSET + if not isinstance(self.status, Unset): + status = self.status.value + + timeset = self.timeset + + link: Union[None, Unset, str] + if isinstance(self.link, Unset): + link = UNSET + else: + link = self.link + + responsible: Union[None, Unset, str] + if isinstance(self.responsible, Unset): + responsible = UNSET + else: + responsible = self.responsible + + details: Union[None, Unset, str] + if isinstance(self.details, Unset): + details = UNSET + else: + details = self.details + + title: Union[None, Unset, str] + if isinstance(self.title, Unset): + title = UNSET + else: + title = self.title + + title_color: Union[None, Unset, str] + if isinstance(self.title_color, Unset): + title_color = UNSET + else: + title_color = self.title_color + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if status is not UNSET: + field_dict["status"] = status + if timeset is not UNSET: + field_dict["timeset"] = timeset + if link is not UNSET: + field_dict["link"] = link + if responsible is not UNSET: + field_dict["responsible"] = responsible + if details is not UNSET: + field_dict["details"] = details + if title is not UNSET: + field_dict["title"] = title + if title_color is not UNSET: + field_dict["titleColor"] = title_color + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + _status = d.pop("status", UNSET) + status: Union[Unset, SongStatus] + if isinstance(_status, Unset): + status = UNSET + else: + status = SongStatus(_status) + + timeset = d.pop("timeset", UNSET) + + def _parse_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + link = _parse_link(d.pop("link", UNSET)) + + def _parse_responsible(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + responsible = _parse_responsible(d.pop("responsible", UNSET)) + + def _parse_details(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + details = _parse_details(d.pop("details", UNSET)) + + def _parse_title(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + title = _parse_title(d.pop("title", UNSET)) + + def _parse_title_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + title_color = _parse_title_color(d.pop("titleColor", UNSET)) + + external_status = cls( + id=id, + status=status, + timeset=timeset, + link=link, + responsible=responsible, + details=details, + title=title, + title_color=title_color, + ) + + return external_status diff --git a/src/clients/beatleader/models/featured_playlist.py b/src/clients/beatleader/models/featured_playlist.py new file mode 100644 index 0000000..112d725 --- /dev/null +++ b/src/clients/beatleader/models/featured_playlist.py @@ -0,0 +1,178 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="FeaturedPlaylist") + + +@_attrs_define +class FeaturedPlaylist: + """ + Attributes: + id (Union[Unset, int]): + playlist_link (Union[None, Unset, str]): + cover (Union[None, Unset, str]): + title (Union[None, Unset, str]): + description (Union[None, Unset, str]): + owner (Union[None, Unset, str]): + owner_cover (Union[None, Unset, str]): + owner_link (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + playlist_link: Union[None, Unset, str] = UNSET + cover: Union[None, Unset, str] = UNSET + title: Union[None, Unset, str] = UNSET + description: Union[None, Unset, str] = UNSET + owner: Union[None, Unset, str] = UNSET + owner_cover: Union[None, Unset, str] = UNSET + owner_link: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + playlist_link: Union[None, Unset, str] + if isinstance(self.playlist_link, Unset): + playlist_link = UNSET + else: + playlist_link = self.playlist_link + + cover: Union[None, Unset, str] + if isinstance(self.cover, Unset): + cover = UNSET + else: + cover = self.cover + + title: Union[None, Unset, str] + if isinstance(self.title, Unset): + title = UNSET + else: + title = self.title + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + owner: Union[None, Unset, str] + if isinstance(self.owner, Unset): + owner = UNSET + else: + owner = self.owner + + owner_cover: Union[None, Unset, str] + if isinstance(self.owner_cover, Unset): + owner_cover = UNSET + else: + owner_cover = self.owner_cover + + owner_link: Union[None, Unset, str] + if isinstance(self.owner_link, Unset): + owner_link = UNSET + else: + owner_link = self.owner_link + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if playlist_link is not UNSET: + field_dict["playlistLink"] = playlist_link + if cover is not UNSET: + field_dict["cover"] = cover + if title is not UNSET: + field_dict["title"] = title + if description is not UNSET: + field_dict["description"] = description + if owner is not UNSET: + field_dict["owner"] = owner + if owner_cover is not UNSET: + field_dict["ownerCover"] = owner_cover + if owner_link is not UNSET: + field_dict["ownerLink"] = owner_link + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_playlist_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + playlist_link = _parse_playlist_link(d.pop("playlistLink", UNSET)) + + def _parse_cover(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover = _parse_cover(d.pop("cover", UNSET)) + + def _parse_title(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + title = _parse_title(d.pop("title", UNSET)) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_owner(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + owner = _parse_owner(d.pop("owner", UNSET)) + + def _parse_owner_cover(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + owner_cover = _parse_owner_cover(d.pop("ownerCover", UNSET)) + + def _parse_owner_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + owner_link = _parse_owner_link(d.pop("ownerLink", UNSET)) + + featured_playlist = cls( + id=id, + playlist_link=playlist_link, + cover=cover, + title=title, + description=description, + owner=owner, + owner_cover=owner_cover, + owner_link=owner_link, + ) + + return featured_playlist diff --git a/src/clients/beatleader/models/featured_playlist_response.py b/src/clients/beatleader/models/featured_playlist_response.py new file mode 100644 index 0000000..02b0960 --- /dev/null +++ b/src/clients/beatleader/models/featured_playlist_response.py @@ -0,0 +1,178 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="FeaturedPlaylistResponse") + + +@_attrs_define +class FeaturedPlaylistResponse: + """ + Attributes: + id (Union[Unset, int]): + playlist_link (Union[None, Unset, str]): + cover (Union[None, Unset, str]): + title (Union[None, Unset, str]): + description (Union[None, Unset, str]): + owner (Union[None, Unset, str]): + owner_cover (Union[None, Unset, str]): + owner_link (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + playlist_link: Union[None, Unset, str] = UNSET + cover: Union[None, Unset, str] = UNSET + title: Union[None, Unset, str] = UNSET + description: Union[None, Unset, str] = UNSET + owner: Union[None, Unset, str] = UNSET + owner_cover: Union[None, Unset, str] = UNSET + owner_link: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + playlist_link: Union[None, Unset, str] + if isinstance(self.playlist_link, Unset): + playlist_link = UNSET + else: + playlist_link = self.playlist_link + + cover: Union[None, Unset, str] + if isinstance(self.cover, Unset): + cover = UNSET + else: + cover = self.cover + + title: Union[None, Unset, str] + if isinstance(self.title, Unset): + title = UNSET + else: + title = self.title + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + owner: Union[None, Unset, str] + if isinstance(self.owner, Unset): + owner = UNSET + else: + owner = self.owner + + owner_cover: Union[None, Unset, str] + if isinstance(self.owner_cover, Unset): + owner_cover = UNSET + else: + owner_cover = self.owner_cover + + owner_link: Union[None, Unset, str] + if isinstance(self.owner_link, Unset): + owner_link = UNSET + else: + owner_link = self.owner_link + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if playlist_link is not UNSET: + field_dict["playlistLink"] = playlist_link + if cover is not UNSET: + field_dict["cover"] = cover + if title is not UNSET: + field_dict["title"] = title + if description is not UNSET: + field_dict["description"] = description + if owner is not UNSET: + field_dict["owner"] = owner + if owner_cover is not UNSET: + field_dict["ownerCover"] = owner_cover + if owner_link is not UNSET: + field_dict["ownerLink"] = owner_link + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_playlist_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + playlist_link = _parse_playlist_link(d.pop("playlistLink", UNSET)) + + def _parse_cover(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover = _parse_cover(d.pop("cover", UNSET)) + + def _parse_title(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + title = _parse_title(d.pop("title", UNSET)) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_owner(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + owner = _parse_owner(d.pop("owner", UNSET)) + + def _parse_owner_cover(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + owner_cover = _parse_owner_cover(d.pop("ownerCover", UNSET)) + + def _parse_owner_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + owner_link = _parse_owner_link(d.pop("ownerLink", UNSET)) + + featured_playlist_response = cls( + id=id, + playlist_link=playlist_link, + cover=cover, + title=title, + description=description, + owner=owner, + owner_cover=owner_cover, + owner_link=owner_link, + ) + + return featured_playlist_response diff --git a/src/clients/beatleader/models/follower_type.py b/src/clients/beatleader/models/follower_type.py new file mode 100644 index 0000000..5cbf0cf --- /dev/null +++ b/src/clients/beatleader/models/follower_type.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class FollowerType(str, Enum): + FOLLOWERS = "followers" + FOLLOWING = "following" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/global_map_history.py b/src/clients/beatleader/models/global_map_history.py new file mode 100644 index 0000000..383a0d3 --- /dev/null +++ b/src/clients/beatleader/models/global_map_history.py @@ -0,0 +1,141 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan import Clan + + +T = TypeVar("T", bound="GlobalMapHistory") + + +@_attrs_define +class GlobalMapHistory: + """ + Attributes: + id (Union[Unset, int]): + timestamp (Union[Unset, int]): + clan_id (Union[Unset, int]): + clan (Union[Unset, Clan]): + global_map_captured (Union[Unset, float]): + players_count (Union[Unset, int]): + pp (Union[Unset, float]): + rank (Union[Unset, int]): + average_rank (Union[Unset, float]): + average_accuracy (Union[Unset, float]): + capture_leaderboards_count (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + timestamp: Union[Unset, int] = UNSET + clan_id: Union[Unset, int] = UNSET + clan: Union[Unset, "Clan"] = UNSET + global_map_captured: Union[Unset, float] = UNSET + players_count: Union[Unset, int] = UNSET + pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + average_rank: Union[Unset, float] = UNSET + average_accuracy: Union[Unset, float] = UNSET + capture_leaderboards_count: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timestamp = self.timestamp + + clan_id = self.clan_id + + clan: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.clan, Unset): + clan = self.clan.to_dict() + + global_map_captured = self.global_map_captured + + players_count = self.players_count + + pp = self.pp + + rank = self.rank + + average_rank = self.average_rank + + average_accuracy = self.average_accuracy + + capture_leaderboards_count = self.capture_leaderboards_count + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timestamp is not UNSET: + field_dict["timestamp"] = timestamp + if clan_id is not UNSET: + field_dict["clanId"] = clan_id + if clan is not UNSET: + field_dict["clan"] = clan + if global_map_captured is not UNSET: + field_dict["globalMapCaptured"] = global_map_captured + if players_count is not UNSET: + field_dict["playersCount"] = players_count + if pp is not UNSET: + field_dict["pp"] = pp + if rank is not UNSET: + field_dict["rank"] = rank + if average_rank is not UNSET: + field_dict["averageRank"] = average_rank + if average_accuracy is not UNSET: + field_dict["averageAccuracy"] = average_accuracy + if capture_leaderboards_count is not UNSET: + field_dict["captureLeaderboardsCount"] = capture_leaderboards_count + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan import Clan + + d = src_dict.copy() + id = d.pop("id", UNSET) + + timestamp = d.pop("timestamp", UNSET) + + clan_id = d.pop("clanId", UNSET) + + _clan = d.pop("clan", UNSET) + clan: Union[Unset, Clan] + if isinstance(_clan, Unset): + clan = UNSET + else: + clan = Clan.from_dict(_clan) + + global_map_captured = d.pop("globalMapCaptured", UNSET) + + players_count = d.pop("playersCount", UNSET) + + pp = d.pop("pp", UNSET) + + rank = d.pop("rank", UNSET) + + average_rank = d.pop("averageRank", UNSET) + + average_accuracy = d.pop("averageAccuracy", UNSET) + + capture_leaderboards_count = d.pop("captureLeaderboardsCount", UNSET) + + global_map_history = cls( + id=id, + timestamp=timestamp, + clan_id=clan_id, + clan=clan, + global_map_captured=global_map_captured, + players_count=players_count, + pp=pp, + rank=rank, + average_rank=average_rank, + average_accuracy=average_accuracy, + capture_leaderboards_count=capture_leaderboards_count, + ) + + return global_map_history diff --git a/src/clients/beatleader/models/history_compact_response.py b/src/clients/beatleader/models/history_compact_response.py new file mode 100644 index 0000000..2135a8b --- /dev/null +++ b/src/clients/beatleader/models/history_compact_response.py @@ -0,0 +1,164 @@ +from typing import Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="HistoryCompactResponse") + + +@_attrs_define +class HistoryCompactResponse: + """ + Attributes: + timestamp (Union[Unset, int]): + pp (Union[Unset, float]): + rank (Union[Unset, int]): + country_rank (Union[Unset, int]): + average_ranked_accuracy (Union[Unset, float]): + average_unranked_accuracy (Union[Unset, float]): + average_accuracy (Union[Unset, float]): + median_ranked_accuracy (Union[Unset, float]): + median_accuracy (Union[Unset, float]): + ranked_play_count (Union[Unset, int]): + unranked_play_count (Union[Unset, int]): + total_play_count (Union[Unset, int]): + ranked_improvements_count (Union[Unset, int]): + unranked_improvements_count (Union[Unset, int]): + total_improvements_count (Union[Unset, int]): + """ + + timestamp: Union[Unset, int] = UNSET + pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country_rank: Union[Unset, int] = UNSET + average_ranked_accuracy: Union[Unset, float] = UNSET + average_unranked_accuracy: Union[Unset, float] = UNSET + average_accuracy: Union[Unset, float] = UNSET + median_ranked_accuracy: Union[Unset, float] = UNSET + median_accuracy: Union[Unset, float] = UNSET + ranked_play_count: Union[Unset, int] = UNSET + unranked_play_count: Union[Unset, int] = UNSET + total_play_count: Union[Unset, int] = UNSET + ranked_improvements_count: Union[Unset, int] = UNSET + unranked_improvements_count: Union[Unset, int] = UNSET + total_improvements_count: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + timestamp = self.timestamp + + pp = self.pp + + rank = self.rank + + country_rank = self.country_rank + + average_ranked_accuracy = self.average_ranked_accuracy + + average_unranked_accuracy = self.average_unranked_accuracy + + average_accuracy = self.average_accuracy + + median_ranked_accuracy = self.median_ranked_accuracy + + median_accuracy = self.median_accuracy + + ranked_play_count = self.ranked_play_count + + unranked_play_count = self.unranked_play_count + + total_play_count = self.total_play_count + + ranked_improvements_count = self.ranked_improvements_count + + unranked_improvements_count = self.unranked_improvements_count + + total_improvements_count = self.total_improvements_count + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if timestamp is not UNSET: + field_dict["timestamp"] = timestamp + if pp is not UNSET: + field_dict["pp"] = pp + if rank is not UNSET: + field_dict["rank"] = rank + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if average_ranked_accuracy is not UNSET: + field_dict["averageRankedAccuracy"] = average_ranked_accuracy + if average_unranked_accuracy is not UNSET: + field_dict["averageUnrankedAccuracy"] = average_unranked_accuracy + if average_accuracy is not UNSET: + field_dict["averageAccuracy"] = average_accuracy + if median_ranked_accuracy is not UNSET: + field_dict["medianRankedAccuracy"] = median_ranked_accuracy + if median_accuracy is not UNSET: + field_dict["medianAccuracy"] = median_accuracy + if ranked_play_count is not UNSET: + field_dict["rankedPlayCount"] = ranked_play_count + if unranked_play_count is not UNSET: + field_dict["unrankedPlayCount"] = unranked_play_count + if total_play_count is not UNSET: + field_dict["totalPlayCount"] = total_play_count + if ranked_improvements_count is not UNSET: + field_dict["rankedImprovementsCount"] = ranked_improvements_count + if unranked_improvements_count is not UNSET: + field_dict["unrankedImprovementsCount"] = unranked_improvements_count + if total_improvements_count is not UNSET: + field_dict["totalImprovementsCount"] = total_improvements_count + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + timestamp = d.pop("timestamp", UNSET) + + pp = d.pop("pp", UNSET) + + rank = d.pop("rank", UNSET) + + country_rank = d.pop("countryRank", UNSET) + + average_ranked_accuracy = d.pop("averageRankedAccuracy", UNSET) + + average_unranked_accuracy = d.pop("averageUnrankedAccuracy", UNSET) + + average_accuracy = d.pop("averageAccuracy", UNSET) + + median_ranked_accuracy = d.pop("medianRankedAccuracy", UNSET) + + median_accuracy = d.pop("medianAccuracy", UNSET) + + ranked_play_count = d.pop("rankedPlayCount", UNSET) + + unranked_play_count = d.pop("unrankedPlayCount", UNSET) + + total_play_count = d.pop("totalPlayCount", UNSET) + + ranked_improvements_count = d.pop("rankedImprovementsCount", UNSET) + + unranked_improvements_count = d.pop("unrankedImprovementsCount", UNSET) + + total_improvements_count = d.pop("totalImprovementsCount", UNSET) + + history_compact_response = cls( + timestamp=timestamp, + pp=pp, + rank=rank, + country_rank=country_rank, + average_ranked_accuracy=average_ranked_accuracy, + average_unranked_accuracy=average_unranked_accuracy, + average_accuracy=average_accuracy, + median_ranked_accuracy=median_ranked_accuracy, + median_accuracy=median_accuracy, + ranked_play_count=ranked_play_count, + unranked_play_count=unranked_play_count, + total_play_count=total_play_count, + ranked_improvements_count=ranked_improvements_count, + unranked_improvements_count=unranked_improvements_count, + total_improvements_count=total_improvements_count, + ) + + return history_compact_response diff --git a/src/clients/beatleader/models/hmd.py b/src/clients/beatleader/models/hmd.py new file mode 100644 index 0000000..6581cbd --- /dev/null +++ b/src/clients/beatleader/models/hmd.py @@ -0,0 +1,56 @@ +from enum import Enum + + +class HMD(str, Enum): + ACERWMR = "acerWmr" + ARPARA = "arpara" + ASUSWMR = "asusWmr" + BIGSCREENBEYOND = "bigscreenbeyond" + CLOUDXR = "cloudxr" + CONTROLLABLE = "controllable" + DELLVISOR = "dellVisor" + DISCO = "disco" + E3 = "e3" + E4 = "e4" + GLASSES20 = "glasses20" + HEDY = "hedy" + HPREVERB = "hpReverb" + HUAWEIVR = "huaweivr" + HYPEREAL = "hypereal" + INDEX = "index" + LENOVOEXPLORER = "lenovoExplorer" + MEDION = "medion" + MEGANE1 = "megane1" + MIRAMAR = "miramar" + NOLOSONIC = "nolosonic" + PICONEO2 = "picoNeo2" + PICONEO3 = "picoNeo3" + PICONEO4 = "picoNeo4" + PIMAX5K = "pimax5k" + PIMAX8K = "pimax8k" + PIMAXARTISAN = "pimaxArtisan" + PIMAXCRYSTAL = "pimaxCrystal" + PSVR2 = "psvr2" + QIYUDREAM = "qiyuDream" + QUEST = "quest" + QUEST2 = "quest2" + QUEST3 = "quest3" + QUESTPRO = "questPro" + RIFT = "rift" + RIFTS = "riftS" + SAMSUNGWMR = "samsungWmr" + UNKNOWN = "unknown" + VAPOREON = "vaporeon" + VARJOAERO = "varjoaero" + VIVE = "vive" + VIVECOSMOS = "viveCosmos" + VIVEDVT = "viveDvt" + VIVEELITE = "viveElite" + VIVEFOCUS = "viveFocus" + VIVEPRO = "vivePro" + VIVEPRO2 = "vivePro2" + VRIDGE = "vridge" + WMR = "wmr" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/info_to_highlight.py b/src/clients/beatleader/models/info_to_highlight.py new file mode 100644 index 0000000..32c39a2 --- /dev/null +++ b/src/clients/beatleader/models/info_to_highlight.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class InfoToHighlight(str, Enum): + NONE = "none" + PLAYCOUNT = "playCount" + WATCHCOUNT = "watchCount" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/leaderboard.py b/src/clients/beatleader/models/leaderboard.py new file mode 100644 index 0000000..20ac46b --- /dev/null +++ b/src/clients/beatleader/models/leaderboard.py @@ -0,0 +1,340 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.difficulty_description import DifficultyDescription + from ..models.event_ranking import EventRanking + from ..models.leaderboard_change import LeaderboardChange + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.song import Song + + +T = TypeVar("T", bound="Leaderboard") + + +@_attrs_define +class Leaderboard: + """ + Attributes: + id (Union[None, Unset, str]): + song_id (Union[None, Unset, str]): + song (Union[Unset, Song]): + difficulty (Union[Unset, DifficultyDescription]): + qualification (Union[Unset, RankQualification]): + reweight (Union[Unset, RankUpdate]): + timestamp (Union[Unset, int]): + changes (Union[List['LeaderboardChange'], None, Unset]): + events (Union[List['EventRanking'], None, Unset]): + plays (Union[Unset, int]): + play_count (Union[Unset, int]): + positive_votes (Union[Unset, int]): + star_votes (Union[Unset, int]): + negative_votes (Union[Unset, int]): + vote_stars (Union[Unset, float]): + clan_id (Union[None, Unset, int]): + captured_time (Union[None, Unset, int]): + clan_ranking_contested (Union[Unset, bool]): + """ + + id: Union[None, Unset, str] = UNSET + song_id: Union[None, Unset, str] = UNSET + song: Union[Unset, "Song"] = UNSET + difficulty: Union[Unset, "DifficultyDescription"] = UNSET + qualification: Union[Unset, "RankQualification"] = UNSET + reweight: Union[Unset, "RankUpdate"] = UNSET + timestamp: Union[Unset, int] = UNSET + changes: Union[List["LeaderboardChange"], None, Unset] = UNSET + events: Union[List["EventRanking"], None, Unset] = UNSET + plays: Union[Unset, int] = UNSET + play_count: Union[Unset, int] = UNSET + positive_votes: Union[Unset, int] = UNSET + star_votes: Union[Unset, int] = UNSET + negative_votes: Union[Unset, int] = UNSET + vote_stars: Union[Unset, float] = UNSET + clan_id: Union[None, Unset, int] = UNSET + captured_time: Union[None, Unset, int] = UNSET + clan_ranking_contested: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + song_id: Union[None, Unset, str] + if isinstance(self.song_id, Unset): + song_id = UNSET + else: + song_id = self.song_id + + song: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.song, Unset): + song = self.song.to_dict() + + difficulty: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.difficulty, Unset): + difficulty = self.difficulty.to_dict() + + qualification: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.qualification, Unset): + qualification = self.qualification.to_dict() + + reweight: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.reweight, Unset): + reweight = self.reweight.to_dict() + + timestamp = self.timestamp + + changes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.changes, Unset): + changes = UNSET + elif isinstance(self.changes, list): + changes = [] + for changes_type_0_item_data in self.changes: + changes_type_0_item = changes_type_0_item_data.to_dict() + changes.append(changes_type_0_item) + + else: + changes = self.changes + + events: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.events, Unset): + events = UNSET + elif isinstance(self.events, list): + events = [] + for events_type_0_item_data in self.events: + events_type_0_item = events_type_0_item_data.to_dict() + events.append(events_type_0_item) + + else: + events = self.events + + plays = self.plays + + play_count = self.play_count + + positive_votes = self.positive_votes + + star_votes = self.star_votes + + negative_votes = self.negative_votes + + vote_stars = self.vote_stars + + clan_id: Union[None, Unset, int] + if isinstance(self.clan_id, Unset): + clan_id = UNSET + else: + clan_id = self.clan_id + + captured_time: Union[None, Unset, int] + if isinstance(self.captured_time, Unset): + captured_time = UNSET + else: + captured_time = self.captured_time + + clan_ranking_contested = self.clan_ranking_contested + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if song_id is not UNSET: + field_dict["songId"] = song_id + if song is not UNSET: + field_dict["song"] = song + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + if qualification is not UNSET: + field_dict["qualification"] = qualification + if reweight is not UNSET: + field_dict["reweight"] = reweight + if timestamp is not UNSET: + field_dict["timestamp"] = timestamp + if changes is not UNSET: + field_dict["changes"] = changes + if events is not UNSET: + field_dict["events"] = events + if plays is not UNSET: + field_dict["plays"] = plays + if play_count is not UNSET: + field_dict["playCount"] = play_count + if positive_votes is not UNSET: + field_dict["positiveVotes"] = positive_votes + if star_votes is not UNSET: + field_dict["starVotes"] = star_votes + if negative_votes is not UNSET: + field_dict["negativeVotes"] = negative_votes + if vote_stars is not UNSET: + field_dict["voteStars"] = vote_stars + if clan_id is not UNSET: + field_dict["clanId"] = clan_id + if captured_time is not UNSET: + field_dict["capturedTime"] = captured_time + if clan_ranking_contested is not UNSET: + field_dict["clanRankingContested"] = clan_ranking_contested + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.difficulty_description import DifficultyDescription + from ..models.event_ranking import EventRanking + from ..models.leaderboard_change import LeaderboardChange + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.song import Song + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_song_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + song_id = _parse_song_id(d.pop("songId", UNSET)) + + _song = d.pop("song", UNSET) + song: Union[Unset, Song] + if isinstance(_song, Unset): + song = UNSET + else: + song = Song.from_dict(_song) + + _difficulty = d.pop("difficulty", UNSET) + difficulty: Union[Unset, DifficultyDescription] + if isinstance(_difficulty, Unset): + difficulty = UNSET + else: + difficulty = DifficultyDescription.from_dict(_difficulty) + + _qualification = d.pop("qualification", UNSET) + qualification: Union[Unset, RankQualification] + if isinstance(_qualification, Unset): + qualification = UNSET + else: + qualification = RankQualification.from_dict(_qualification) + + _reweight = d.pop("reweight", UNSET) + reweight: Union[Unset, RankUpdate] + if isinstance(_reweight, Unset): + reweight = UNSET + else: + reweight = RankUpdate.from_dict(_reweight) + + timestamp = d.pop("timestamp", UNSET) + + def _parse_changes(data: object) -> Union[List["LeaderboardChange"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + changes_type_0 = [] + _changes_type_0 = data + for changes_type_0_item_data in _changes_type_0: + changes_type_0_item = LeaderboardChange.from_dict(changes_type_0_item_data) + + changes_type_0.append(changes_type_0_item) + + return changes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["LeaderboardChange"], None, Unset], data) + + changes = _parse_changes(d.pop("changes", UNSET)) + + def _parse_events(data: object) -> Union[List["EventRanking"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + events_type_0 = [] + _events_type_0 = data + for events_type_0_item_data in _events_type_0: + events_type_0_item = EventRanking.from_dict(events_type_0_item_data) + + events_type_0.append(events_type_0_item) + + return events_type_0 + except: # noqa: E722 + pass + return cast(Union[List["EventRanking"], None, Unset], data) + + events = _parse_events(d.pop("events", UNSET)) + + plays = d.pop("plays", UNSET) + + play_count = d.pop("playCount", UNSET) + + positive_votes = d.pop("positiveVotes", UNSET) + + star_votes = d.pop("starVotes", UNSET) + + negative_votes = d.pop("negativeVotes", UNSET) + + vote_stars = d.pop("voteStars", UNSET) + + def _parse_clan_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + clan_id = _parse_clan_id(d.pop("clanId", UNSET)) + + def _parse_captured_time(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + captured_time = _parse_captured_time(d.pop("capturedTime", UNSET)) + + clan_ranking_contested = d.pop("clanRankingContested", UNSET) + + leaderboard = cls( + id=id, + song_id=song_id, + song=song, + difficulty=difficulty, + qualification=qualification, + reweight=reweight, + timestamp=timestamp, + changes=changes, + events=events, + plays=plays, + play_count=play_count, + positive_votes=positive_votes, + star_votes=star_votes, + negative_votes=negative_votes, + vote_stars=vote_stars, + clan_id=clan_id, + captured_time=captured_time, + clan_ranking_contested=clan_ranking_contested, + ) + + return leaderboard diff --git a/src/clients/beatleader/models/leaderboard_change.py b/src/clients/beatleader/models/leaderboard_change.py new file mode 100644 index 0000000..f7f9e31 --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_change.py @@ -0,0 +1,265 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + + +T = TypeVar("T", bound="LeaderboardChange") + + +@_attrs_define +class LeaderboardChange: + """ + Attributes: + id (Union[Unset, int]): + timeset (Union[Unset, int]): + player_id (Union[None, Unset, str]): + old_rankability (Union[Unset, float]): + old_stars (Union[Unset, float]): + old_acc_rating (Union[Unset, float]): + old_pass_rating (Union[Unset, float]): + old_tech_rating (Union[Unset, float]): + old_type (Union[Unset, int]): + old_criteria_met (Union[Unset, int]): + old_modifiers (Union[Unset, ModifiersMap]): + old_modifiers_rating (Union[Unset, ModifiersRating]): + new_rankability (Union[Unset, float]): + new_stars (Union[Unset, float]): + new_acc_rating (Union[Unset, float]): + new_pass_rating (Union[Unset, float]): + new_tech_rating (Union[Unset, float]): + new_type (Union[Unset, int]): + new_criteria_met (Union[Unset, int]): + new_modifiers (Union[Unset, ModifiersMap]): + new_modifiers_rating (Union[Unset, ModifiersRating]): + """ + + id: Union[Unset, int] = UNSET + timeset: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + old_rankability: Union[Unset, float] = UNSET + old_stars: Union[Unset, float] = UNSET + old_acc_rating: Union[Unset, float] = UNSET + old_pass_rating: Union[Unset, float] = UNSET + old_tech_rating: Union[Unset, float] = UNSET + old_type: Union[Unset, int] = UNSET + old_criteria_met: Union[Unset, int] = UNSET + old_modifiers: Union[Unset, "ModifiersMap"] = UNSET + old_modifiers_rating: Union[Unset, "ModifiersRating"] = UNSET + new_rankability: Union[Unset, float] = UNSET + new_stars: Union[Unset, float] = UNSET + new_acc_rating: Union[Unset, float] = UNSET + new_pass_rating: Union[Unset, float] = UNSET + new_tech_rating: Union[Unset, float] = UNSET + new_type: Union[Unset, int] = UNSET + new_criteria_met: Union[Unset, int] = UNSET + new_modifiers: Union[Unset, "ModifiersMap"] = UNSET + new_modifiers_rating: Union[Unset, "ModifiersRating"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timeset = self.timeset + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + old_rankability = self.old_rankability + + old_stars = self.old_stars + + old_acc_rating = self.old_acc_rating + + old_pass_rating = self.old_pass_rating + + old_tech_rating = self.old_tech_rating + + old_type = self.old_type + + old_criteria_met = self.old_criteria_met + + old_modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.old_modifiers, Unset): + old_modifiers = self.old_modifiers.to_dict() + + old_modifiers_rating: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.old_modifiers_rating, Unset): + old_modifiers_rating = self.old_modifiers_rating.to_dict() + + new_rankability = self.new_rankability + + new_stars = self.new_stars + + new_acc_rating = self.new_acc_rating + + new_pass_rating = self.new_pass_rating + + new_tech_rating = self.new_tech_rating + + new_type = self.new_type + + new_criteria_met = self.new_criteria_met + + new_modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.new_modifiers, Unset): + new_modifiers = self.new_modifiers.to_dict() + + new_modifiers_rating: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.new_modifiers_rating, Unset): + new_modifiers_rating = self.new_modifiers_rating.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if player_id is not UNSET: + field_dict["playerId"] = player_id + if old_rankability is not UNSET: + field_dict["oldRankability"] = old_rankability + if old_stars is not UNSET: + field_dict["oldStars"] = old_stars + if old_acc_rating is not UNSET: + field_dict["oldAccRating"] = old_acc_rating + if old_pass_rating is not UNSET: + field_dict["oldPassRating"] = old_pass_rating + if old_tech_rating is not UNSET: + field_dict["oldTechRating"] = old_tech_rating + if old_type is not UNSET: + field_dict["oldType"] = old_type + if old_criteria_met is not UNSET: + field_dict["oldCriteriaMet"] = old_criteria_met + if old_modifiers is not UNSET: + field_dict["oldModifiers"] = old_modifiers + if old_modifiers_rating is not UNSET: + field_dict["oldModifiersRating"] = old_modifiers_rating + if new_rankability is not UNSET: + field_dict["newRankability"] = new_rankability + if new_stars is not UNSET: + field_dict["newStars"] = new_stars + if new_acc_rating is not UNSET: + field_dict["newAccRating"] = new_acc_rating + if new_pass_rating is not UNSET: + field_dict["newPassRating"] = new_pass_rating + if new_tech_rating is not UNSET: + field_dict["newTechRating"] = new_tech_rating + if new_type is not UNSET: + field_dict["newType"] = new_type + if new_criteria_met is not UNSET: + field_dict["newCriteriaMet"] = new_criteria_met + if new_modifiers is not UNSET: + field_dict["newModifiers"] = new_modifiers + if new_modifiers_rating is not UNSET: + field_dict["newModifiersRating"] = new_modifiers_rating + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + + d = src_dict.copy() + id = d.pop("id", UNSET) + + timeset = d.pop("timeset", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + old_rankability = d.pop("oldRankability", UNSET) + + old_stars = d.pop("oldStars", UNSET) + + old_acc_rating = d.pop("oldAccRating", UNSET) + + old_pass_rating = d.pop("oldPassRating", UNSET) + + old_tech_rating = d.pop("oldTechRating", UNSET) + + old_type = d.pop("oldType", UNSET) + + old_criteria_met = d.pop("oldCriteriaMet", UNSET) + + _old_modifiers = d.pop("oldModifiers", UNSET) + old_modifiers: Union[Unset, ModifiersMap] + if isinstance(_old_modifiers, Unset): + old_modifiers = UNSET + else: + old_modifiers = ModifiersMap.from_dict(_old_modifiers) + + _old_modifiers_rating = d.pop("oldModifiersRating", UNSET) + old_modifiers_rating: Union[Unset, ModifiersRating] + if isinstance(_old_modifiers_rating, Unset): + old_modifiers_rating = UNSET + else: + old_modifiers_rating = ModifiersRating.from_dict(_old_modifiers_rating) + + new_rankability = d.pop("newRankability", UNSET) + + new_stars = d.pop("newStars", UNSET) + + new_acc_rating = d.pop("newAccRating", UNSET) + + new_pass_rating = d.pop("newPassRating", UNSET) + + new_tech_rating = d.pop("newTechRating", UNSET) + + new_type = d.pop("newType", UNSET) + + new_criteria_met = d.pop("newCriteriaMet", UNSET) + + _new_modifiers = d.pop("newModifiers", UNSET) + new_modifiers: Union[Unset, ModifiersMap] + if isinstance(_new_modifiers, Unset): + new_modifiers = UNSET + else: + new_modifiers = ModifiersMap.from_dict(_new_modifiers) + + _new_modifiers_rating = d.pop("newModifiersRating", UNSET) + new_modifiers_rating: Union[Unset, ModifiersRating] + if isinstance(_new_modifiers_rating, Unset): + new_modifiers_rating = UNSET + else: + new_modifiers_rating = ModifiersRating.from_dict(_new_modifiers_rating) + + leaderboard_change = cls( + id=id, + timeset=timeset, + player_id=player_id, + old_rankability=old_rankability, + old_stars=old_stars, + old_acc_rating=old_acc_rating, + old_pass_rating=old_pass_rating, + old_tech_rating=old_tech_rating, + old_type=old_type, + old_criteria_met=old_criteria_met, + old_modifiers=old_modifiers, + old_modifiers_rating=old_modifiers_rating, + new_rankability=new_rankability, + new_stars=new_stars, + new_acc_rating=new_acc_rating, + new_pass_rating=new_pass_rating, + new_tech_rating=new_tech_rating, + new_type=new_type, + new_criteria_met=new_criteria_met, + new_modifiers=new_modifiers, + new_modifiers_rating=new_modifiers_rating, + ) + + return leaderboard_change diff --git a/src/clients/beatleader/models/leaderboard_clan_ranking_response.py b/src/clients/beatleader/models/leaderboard_clan_ranking_response.py new file mode 100644 index 0000000..123c9b2 --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_clan_ranking_response.py @@ -0,0 +1,367 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_ranking_response import ClanRankingResponse + from ..models.clan_response_full import ClanResponseFull + from ..models.difficulty_response import DifficultyResponse + from ..models.featured_playlist import FeaturedPlaylist + from ..models.leaderboard_change import LeaderboardChange + from ..models.leaderboard_group_entry import LeaderboardGroupEntry + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response import ScoreResponse + from ..models.song_response import SongResponse + + +T = TypeVar("T", bound="LeaderboardClanRankingResponse") + + +@_attrs_define +class LeaderboardClanRankingResponse: + """ + Attributes: + id (Union[None, Unset, str]): + song (Union[Unset, SongResponse]): + difficulty (Union[Unset, DifficultyResponse]): + scores (Union[List['ScoreResponse'], None, Unset]): + changes (Union[List['LeaderboardChange'], None, Unset]): + featured_playlists (Union[List['FeaturedPlaylist'], None, Unset]): + qualification (Union[Unset, RankQualification]): + reweight (Union[Unset, RankUpdate]): + leaderboard_group (Union[List['LeaderboardGroupEntry'], None, Unset]): + plays (Union[Unset, int]): + clan (Union[Unset, ClanResponseFull]): + clan_ranking_contested (Union[Unset, bool]): + clan_ranking (Union[List['ClanRankingResponse'], None, Unset]): + """ + + id: Union[None, Unset, str] = UNSET + song: Union[Unset, "SongResponse"] = UNSET + difficulty: Union[Unset, "DifficultyResponse"] = UNSET + scores: Union[List["ScoreResponse"], None, Unset] = UNSET + changes: Union[List["LeaderboardChange"], None, Unset] = UNSET + featured_playlists: Union[List["FeaturedPlaylist"], None, Unset] = UNSET + qualification: Union[Unset, "RankQualification"] = UNSET + reweight: Union[Unset, "RankUpdate"] = UNSET + leaderboard_group: Union[List["LeaderboardGroupEntry"], None, Unset] = UNSET + plays: Union[Unset, int] = UNSET + clan: Union[Unset, "ClanResponseFull"] = UNSET + clan_ranking_contested: Union[Unset, bool] = UNSET + clan_ranking: Union[List["ClanRankingResponse"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + song: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.song, Unset): + song = self.song.to_dict() + + difficulty: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.difficulty, Unset): + difficulty = self.difficulty.to_dict() + + scores: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.scores, Unset): + scores = UNSET + elif isinstance(self.scores, list): + scores = [] + for scores_type_0_item_data in self.scores: + scores_type_0_item = scores_type_0_item_data.to_dict() + scores.append(scores_type_0_item) + + else: + scores = self.scores + + changes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.changes, Unset): + changes = UNSET + elif isinstance(self.changes, list): + changes = [] + for changes_type_0_item_data in self.changes: + changes_type_0_item = changes_type_0_item_data.to_dict() + changes.append(changes_type_0_item) + + else: + changes = self.changes + + featured_playlists: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.featured_playlists, Unset): + featured_playlists = UNSET + elif isinstance(self.featured_playlists, list): + featured_playlists = [] + for featured_playlists_type_0_item_data in self.featured_playlists: + featured_playlists_type_0_item = featured_playlists_type_0_item_data.to_dict() + featured_playlists.append(featured_playlists_type_0_item) + + else: + featured_playlists = self.featured_playlists + + qualification: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.qualification, Unset): + qualification = self.qualification.to_dict() + + reweight: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.reweight, Unset): + reweight = self.reweight.to_dict() + + leaderboard_group: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.leaderboard_group, Unset): + leaderboard_group = UNSET + elif isinstance(self.leaderboard_group, list): + leaderboard_group = [] + for leaderboard_group_type_0_item_data in self.leaderboard_group: + leaderboard_group_type_0_item = leaderboard_group_type_0_item_data.to_dict() + leaderboard_group.append(leaderboard_group_type_0_item) + + else: + leaderboard_group = self.leaderboard_group + + plays = self.plays + + clan: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.clan, Unset): + clan = self.clan.to_dict() + + clan_ranking_contested = self.clan_ranking_contested + + clan_ranking: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.clan_ranking, Unset): + clan_ranking = UNSET + elif isinstance(self.clan_ranking, list): + clan_ranking = [] + for clan_ranking_type_0_item_data in self.clan_ranking: + clan_ranking_type_0_item = clan_ranking_type_0_item_data.to_dict() + clan_ranking.append(clan_ranking_type_0_item) + + else: + clan_ranking = self.clan_ranking + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if song is not UNSET: + field_dict["song"] = song + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + if scores is not UNSET: + field_dict["scores"] = scores + if changes is not UNSET: + field_dict["changes"] = changes + if featured_playlists is not UNSET: + field_dict["featuredPlaylists"] = featured_playlists + if qualification is not UNSET: + field_dict["qualification"] = qualification + if reweight is not UNSET: + field_dict["reweight"] = reweight + if leaderboard_group is not UNSET: + field_dict["leaderboardGroup"] = leaderboard_group + if plays is not UNSET: + field_dict["plays"] = plays + if clan is not UNSET: + field_dict["clan"] = clan + if clan_ranking_contested is not UNSET: + field_dict["clanRankingContested"] = clan_ranking_contested + if clan_ranking is not UNSET: + field_dict["clanRanking"] = clan_ranking + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_ranking_response import ClanRankingResponse + from ..models.clan_response_full import ClanResponseFull + from ..models.difficulty_response import DifficultyResponse + from ..models.featured_playlist import FeaturedPlaylist + from ..models.leaderboard_change import LeaderboardChange + from ..models.leaderboard_group_entry import LeaderboardGroupEntry + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response import ScoreResponse + from ..models.song_response import SongResponse + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + _song = d.pop("song", UNSET) + song: Union[Unset, SongResponse] + if isinstance(_song, Unset): + song = UNSET + else: + song = SongResponse.from_dict(_song) + + _difficulty = d.pop("difficulty", UNSET) + difficulty: Union[Unset, DifficultyResponse] + if isinstance(_difficulty, Unset): + difficulty = UNSET + else: + difficulty = DifficultyResponse.from_dict(_difficulty) + + def _parse_scores(data: object) -> Union[List["ScoreResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + scores_type_0 = [] + _scores_type_0 = data + for scores_type_0_item_data in _scores_type_0: + scores_type_0_item = ScoreResponse.from_dict(scores_type_0_item_data) + + scores_type_0.append(scores_type_0_item) + + return scores_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ScoreResponse"], None, Unset], data) + + scores = _parse_scores(d.pop("scores", UNSET)) + + def _parse_changes(data: object) -> Union[List["LeaderboardChange"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + changes_type_0 = [] + _changes_type_0 = data + for changes_type_0_item_data in _changes_type_0: + changes_type_0_item = LeaderboardChange.from_dict(changes_type_0_item_data) + + changes_type_0.append(changes_type_0_item) + + return changes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["LeaderboardChange"], None, Unset], data) + + changes = _parse_changes(d.pop("changes", UNSET)) + + def _parse_featured_playlists(data: object) -> Union[List["FeaturedPlaylist"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + featured_playlists_type_0 = [] + _featured_playlists_type_0 = data + for featured_playlists_type_0_item_data in _featured_playlists_type_0: + featured_playlists_type_0_item = FeaturedPlaylist.from_dict(featured_playlists_type_0_item_data) + + featured_playlists_type_0.append(featured_playlists_type_0_item) + + return featured_playlists_type_0 + except: # noqa: E722 + pass + return cast(Union[List["FeaturedPlaylist"], None, Unset], data) + + featured_playlists = _parse_featured_playlists(d.pop("featuredPlaylists", UNSET)) + + _qualification = d.pop("qualification", UNSET) + qualification: Union[Unset, RankQualification] + if isinstance(_qualification, Unset): + qualification = UNSET + else: + qualification = RankQualification.from_dict(_qualification) + + _reweight = d.pop("reweight", UNSET) + reweight: Union[Unset, RankUpdate] + if isinstance(_reweight, Unset): + reweight = UNSET + else: + reweight = RankUpdate.from_dict(_reweight) + + def _parse_leaderboard_group(data: object) -> Union[List["LeaderboardGroupEntry"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + leaderboard_group_type_0 = [] + _leaderboard_group_type_0 = data + for leaderboard_group_type_0_item_data in _leaderboard_group_type_0: + leaderboard_group_type_0_item = LeaderboardGroupEntry.from_dict(leaderboard_group_type_0_item_data) + + leaderboard_group_type_0.append(leaderboard_group_type_0_item) + + return leaderboard_group_type_0 + except: # noqa: E722 + pass + return cast(Union[List["LeaderboardGroupEntry"], None, Unset], data) + + leaderboard_group = _parse_leaderboard_group(d.pop("leaderboardGroup", UNSET)) + + plays = d.pop("plays", UNSET) + + _clan = d.pop("clan", UNSET) + clan: Union[Unset, ClanResponseFull] + if isinstance(_clan, Unset): + clan = UNSET + else: + clan = ClanResponseFull.from_dict(_clan) + + clan_ranking_contested = d.pop("clanRankingContested", UNSET) + + def _parse_clan_ranking(data: object) -> Union[List["ClanRankingResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + clan_ranking_type_0 = [] + _clan_ranking_type_0 = data + for clan_ranking_type_0_item_data in _clan_ranking_type_0: + clan_ranking_type_0_item = ClanRankingResponse.from_dict(clan_ranking_type_0_item_data) + + clan_ranking_type_0.append(clan_ranking_type_0_item) + + return clan_ranking_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanRankingResponse"], None, Unset], data) + + clan_ranking = _parse_clan_ranking(d.pop("clanRanking", UNSET)) + + leaderboard_clan_ranking_response = cls( + id=id, + song=song, + difficulty=difficulty, + scores=scores, + changes=changes, + featured_playlists=featured_playlists, + qualification=qualification, + reweight=reweight, + leaderboard_group=leaderboard_group, + plays=plays, + clan=clan, + clan_ranking_contested=clan_ranking_contested, + clan_ranking=clan_ranking, + ) + + return leaderboard_clan_ranking_response diff --git a/src/clients/beatleader/models/leaderboard_contexts.py b/src/clients/beatleader/models/leaderboard_contexts.py new file mode 100644 index 0000000..011e2ea --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_contexts.py @@ -0,0 +1,15 @@ +from enum import Enum + + +class LeaderboardContexts(str, Enum): + GENERAL = "general" + GOLF = "golf" + NOMODS = "noMods" + NONE = "none" + NOPAUSE = "noPause" + SCPM = "sCPM" + SPEEDRUN = "speedrun" + SPEEDRUNBACKUP = "speedrunBackup" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/leaderboard_group_entry.py b/src/clients/beatleader/models/leaderboard_group_entry.py new file mode 100644 index 0000000..0cee3c7 --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_group_entry.py @@ -0,0 +1,76 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.difficulty_status import DifficultyStatus +from ..types import UNSET, Unset + +T = TypeVar("T", bound="LeaderboardGroupEntry") + + +@_attrs_define +class LeaderboardGroupEntry: + """ + Attributes: + id (Union[None, Unset, str]): + status (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + timestamp (Union[Unset, int]): + """ + + id: Union[None, Unset, str] = UNSET + status: Union[Unset, DifficultyStatus] = UNSET + timestamp: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + status: Union[Unset, str] = UNSET + if not isinstance(self.status, Unset): + status = self.status.value + + timestamp = self.timestamp + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if status is not UNSET: + field_dict["status"] = status + if timestamp is not UNSET: + field_dict["timestamp"] = timestamp + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + _status = d.pop("status", UNSET) + status: Union[Unset, DifficultyStatus] + if isinstance(_status, Unset): + status = UNSET + else: + status = DifficultyStatus(_status) + + timestamp = d.pop("timestamp", UNSET) + + leaderboard_group_entry = cls( + id=id, + status=status, + timestamp=timestamp, + ) + + return leaderboard_group_entry diff --git a/src/clients/beatleader/models/leaderboard_info_response.py b/src/clients/beatleader/models/leaderboard_info_response.py new file mode 100644 index 0000000..801f972 --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_info_response.py @@ -0,0 +1,216 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response_full import ClanResponseFull + from ..models.difficulty_response import DifficultyResponse + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response_with_acc import ScoreResponseWithAcc + from ..models.song import Song + + +T = TypeVar("T", bound="LeaderboardInfoResponse") + + +@_attrs_define +class LeaderboardInfoResponse: + """ + Attributes: + id (Union[None, Unset, str]): + song (Union[Unset, Song]): + difficulty (Union[Unset, DifficultyResponse]): + plays (Union[Unset, int]): + positive_votes (Union[Unset, int]): + star_votes (Union[Unset, int]): + negative_votes (Union[Unset, int]): + vote_stars (Union[Unset, float]): + clan (Union[Unset, ClanResponseFull]): + clan_ranking_contested (Union[Unset, bool]): + my_score (Union[Unset, ScoreResponseWithAcc]): + qualification (Union[Unset, RankQualification]): + reweight (Union[Unset, RankUpdate]): + """ + + id: Union[None, Unset, str] = UNSET + song: Union[Unset, "Song"] = UNSET + difficulty: Union[Unset, "DifficultyResponse"] = UNSET + plays: Union[Unset, int] = UNSET + positive_votes: Union[Unset, int] = UNSET + star_votes: Union[Unset, int] = UNSET + negative_votes: Union[Unset, int] = UNSET + vote_stars: Union[Unset, float] = UNSET + clan: Union[Unset, "ClanResponseFull"] = UNSET + clan_ranking_contested: Union[Unset, bool] = UNSET + my_score: Union[Unset, "ScoreResponseWithAcc"] = UNSET + qualification: Union[Unset, "RankQualification"] = UNSET + reweight: Union[Unset, "RankUpdate"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + song: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.song, Unset): + song = self.song.to_dict() + + difficulty: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.difficulty, Unset): + difficulty = self.difficulty.to_dict() + + plays = self.plays + + positive_votes = self.positive_votes + + star_votes = self.star_votes + + negative_votes = self.negative_votes + + vote_stars = self.vote_stars + + clan: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.clan, Unset): + clan = self.clan.to_dict() + + clan_ranking_contested = self.clan_ranking_contested + + my_score: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.my_score, Unset): + my_score = self.my_score.to_dict() + + qualification: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.qualification, Unset): + qualification = self.qualification.to_dict() + + reweight: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.reweight, Unset): + reweight = self.reweight.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if song is not UNSET: + field_dict["song"] = song + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + if plays is not UNSET: + field_dict["plays"] = plays + if positive_votes is not UNSET: + field_dict["positiveVotes"] = positive_votes + if star_votes is not UNSET: + field_dict["starVotes"] = star_votes + if negative_votes is not UNSET: + field_dict["negativeVotes"] = negative_votes + if vote_stars is not UNSET: + field_dict["voteStars"] = vote_stars + if clan is not UNSET: + field_dict["clan"] = clan + if clan_ranking_contested is not UNSET: + field_dict["clanRankingContested"] = clan_ranking_contested + if my_score is not UNSET: + field_dict["myScore"] = my_score + if qualification is not UNSET: + field_dict["qualification"] = qualification + if reweight is not UNSET: + field_dict["reweight"] = reweight + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response_full import ClanResponseFull + from ..models.difficulty_response import DifficultyResponse + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response_with_acc import ScoreResponseWithAcc + from ..models.song import Song + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + _song = d.pop("song", UNSET) + song: Union[Unset, Song] + if isinstance(_song, Unset): + song = UNSET + else: + song = Song.from_dict(_song) + + _difficulty = d.pop("difficulty", UNSET) + difficulty: Union[Unset, DifficultyResponse] + if isinstance(_difficulty, Unset): + difficulty = UNSET + else: + difficulty = DifficultyResponse.from_dict(_difficulty) + + plays = d.pop("plays", UNSET) + + positive_votes = d.pop("positiveVotes", UNSET) + + star_votes = d.pop("starVotes", UNSET) + + negative_votes = d.pop("negativeVotes", UNSET) + + vote_stars = d.pop("voteStars", UNSET) + + _clan = d.pop("clan", UNSET) + clan: Union[Unset, ClanResponseFull] + if isinstance(_clan, Unset): + clan = UNSET + else: + clan = ClanResponseFull.from_dict(_clan) + + clan_ranking_contested = d.pop("clanRankingContested", UNSET) + + _my_score = d.pop("myScore", UNSET) + my_score: Union[Unset, ScoreResponseWithAcc] + if isinstance(_my_score, Unset): + my_score = UNSET + else: + my_score = ScoreResponseWithAcc.from_dict(_my_score) + + _qualification = d.pop("qualification", UNSET) + qualification: Union[Unset, RankQualification] + if isinstance(_qualification, Unset): + qualification = UNSET + else: + qualification = RankQualification.from_dict(_qualification) + + _reweight = d.pop("reweight", UNSET) + reweight: Union[Unset, RankUpdate] + if isinstance(_reweight, Unset): + reweight = UNSET + else: + reweight = RankUpdate.from_dict(_reweight) + + leaderboard_info_response = cls( + id=id, + song=song, + difficulty=difficulty, + plays=plays, + positive_votes=positive_votes, + star_votes=star_votes, + negative_votes=negative_votes, + vote_stars=vote_stars, + clan=clan, + clan_ranking_contested=clan_ranking_contested, + my_score=my_score, + qualification=qualification, + reweight=reweight, + ) + + return leaderboard_info_response diff --git a/src/clients/beatleader/models/leaderboard_info_response_response_with_metadata.py b/src/clients/beatleader/models/leaderboard_info_response_response_with_metadata.py new file mode 100644 index 0000000..98f80a9 --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_info_response_response_with_metadata.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.leaderboard_info_response import LeaderboardInfoResponse + from ..models.metadata import Metadata + + +T = TypeVar("T", bound="LeaderboardInfoResponseResponseWithMetadata") + + +@_attrs_define +class LeaderboardInfoResponseResponseWithMetadata: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['LeaderboardInfoResponse'], None, Unset]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["LeaderboardInfoResponse"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.leaderboard_info_response import LeaderboardInfoResponse + from ..models.metadata import Metadata + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["LeaderboardInfoResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = LeaderboardInfoResponse.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["LeaderboardInfoResponse"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + leaderboard_info_response_response_with_metadata = cls( + metadata=metadata, + data=data, + ) + + return leaderboard_info_response_response_with_metadata diff --git a/src/clients/beatleader/models/leaderboard_response.py b/src/clients/beatleader/models/leaderboard_response.py new file mode 100644 index 0000000..d6624b6 --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_response.py @@ -0,0 +1,326 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response_full import ClanResponseFull + from ..models.difficulty_response import DifficultyResponse + from ..models.featured_playlist import FeaturedPlaylist + from ..models.leaderboard_change import LeaderboardChange + from ..models.leaderboard_group_entry import LeaderboardGroupEntry + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response import ScoreResponse + from ..models.song_response import SongResponse + + +T = TypeVar("T", bound="LeaderboardResponse") + + +@_attrs_define +class LeaderboardResponse: + """ + Attributes: + id (Union[None, Unset, str]): + song (Union[Unset, SongResponse]): + difficulty (Union[Unset, DifficultyResponse]): + scores (Union[List['ScoreResponse'], None, Unset]): + changes (Union[List['LeaderboardChange'], None, Unset]): + featured_playlists (Union[List['FeaturedPlaylist'], None, Unset]): + qualification (Union[Unset, RankQualification]): + reweight (Union[Unset, RankUpdate]): + leaderboard_group (Union[List['LeaderboardGroupEntry'], None, Unset]): + plays (Union[Unset, int]): + clan (Union[Unset, ClanResponseFull]): + clan_ranking_contested (Union[Unset, bool]): + """ + + id: Union[None, Unset, str] = UNSET + song: Union[Unset, "SongResponse"] = UNSET + difficulty: Union[Unset, "DifficultyResponse"] = UNSET + scores: Union[List["ScoreResponse"], None, Unset] = UNSET + changes: Union[List["LeaderboardChange"], None, Unset] = UNSET + featured_playlists: Union[List["FeaturedPlaylist"], None, Unset] = UNSET + qualification: Union[Unset, "RankQualification"] = UNSET + reweight: Union[Unset, "RankUpdate"] = UNSET + leaderboard_group: Union[List["LeaderboardGroupEntry"], None, Unset] = UNSET + plays: Union[Unset, int] = UNSET + clan: Union[Unset, "ClanResponseFull"] = UNSET + clan_ranking_contested: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + song: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.song, Unset): + song = self.song.to_dict() + + difficulty: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.difficulty, Unset): + difficulty = self.difficulty.to_dict() + + scores: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.scores, Unset): + scores = UNSET + elif isinstance(self.scores, list): + scores = [] + for scores_type_0_item_data in self.scores: + scores_type_0_item = scores_type_0_item_data.to_dict() + scores.append(scores_type_0_item) + + else: + scores = self.scores + + changes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.changes, Unset): + changes = UNSET + elif isinstance(self.changes, list): + changes = [] + for changes_type_0_item_data in self.changes: + changes_type_0_item = changes_type_0_item_data.to_dict() + changes.append(changes_type_0_item) + + else: + changes = self.changes + + featured_playlists: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.featured_playlists, Unset): + featured_playlists = UNSET + elif isinstance(self.featured_playlists, list): + featured_playlists = [] + for featured_playlists_type_0_item_data in self.featured_playlists: + featured_playlists_type_0_item = featured_playlists_type_0_item_data.to_dict() + featured_playlists.append(featured_playlists_type_0_item) + + else: + featured_playlists = self.featured_playlists + + qualification: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.qualification, Unset): + qualification = self.qualification.to_dict() + + reweight: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.reweight, Unset): + reweight = self.reweight.to_dict() + + leaderboard_group: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.leaderboard_group, Unset): + leaderboard_group = UNSET + elif isinstance(self.leaderboard_group, list): + leaderboard_group = [] + for leaderboard_group_type_0_item_data in self.leaderboard_group: + leaderboard_group_type_0_item = leaderboard_group_type_0_item_data.to_dict() + leaderboard_group.append(leaderboard_group_type_0_item) + + else: + leaderboard_group = self.leaderboard_group + + plays = self.plays + + clan: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.clan, Unset): + clan = self.clan.to_dict() + + clan_ranking_contested = self.clan_ranking_contested + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if song is not UNSET: + field_dict["song"] = song + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + if scores is not UNSET: + field_dict["scores"] = scores + if changes is not UNSET: + field_dict["changes"] = changes + if featured_playlists is not UNSET: + field_dict["featuredPlaylists"] = featured_playlists + if qualification is not UNSET: + field_dict["qualification"] = qualification + if reweight is not UNSET: + field_dict["reweight"] = reweight + if leaderboard_group is not UNSET: + field_dict["leaderboardGroup"] = leaderboard_group + if plays is not UNSET: + field_dict["plays"] = plays + if clan is not UNSET: + field_dict["clan"] = clan + if clan_ranking_contested is not UNSET: + field_dict["clanRankingContested"] = clan_ranking_contested + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response_full import ClanResponseFull + from ..models.difficulty_response import DifficultyResponse + from ..models.featured_playlist import FeaturedPlaylist + from ..models.leaderboard_change import LeaderboardChange + from ..models.leaderboard_group_entry import LeaderboardGroupEntry + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response import ScoreResponse + from ..models.song_response import SongResponse + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + _song = d.pop("song", UNSET) + song: Union[Unset, SongResponse] + if isinstance(_song, Unset): + song = UNSET + else: + song = SongResponse.from_dict(_song) + + _difficulty = d.pop("difficulty", UNSET) + difficulty: Union[Unset, DifficultyResponse] + if isinstance(_difficulty, Unset): + difficulty = UNSET + else: + difficulty = DifficultyResponse.from_dict(_difficulty) + + def _parse_scores(data: object) -> Union[List["ScoreResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + scores_type_0 = [] + _scores_type_0 = data + for scores_type_0_item_data in _scores_type_0: + scores_type_0_item = ScoreResponse.from_dict(scores_type_0_item_data) + + scores_type_0.append(scores_type_0_item) + + return scores_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ScoreResponse"], None, Unset], data) + + scores = _parse_scores(d.pop("scores", UNSET)) + + def _parse_changes(data: object) -> Union[List["LeaderboardChange"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + changes_type_0 = [] + _changes_type_0 = data + for changes_type_0_item_data in _changes_type_0: + changes_type_0_item = LeaderboardChange.from_dict(changes_type_0_item_data) + + changes_type_0.append(changes_type_0_item) + + return changes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["LeaderboardChange"], None, Unset], data) + + changes = _parse_changes(d.pop("changes", UNSET)) + + def _parse_featured_playlists(data: object) -> Union[List["FeaturedPlaylist"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + featured_playlists_type_0 = [] + _featured_playlists_type_0 = data + for featured_playlists_type_0_item_data in _featured_playlists_type_0: + featured_playlists_type_0_item = FeaturedPlaylist.from_dict(featured_playlists_type_0_item_data) + + featured_playlists_type_0.append(featured_playlists_type_0_item) + + return featured_playlists_type_0 + except: # noqa: E722 + pass + return cast(Union[List["FeaturedPlaylist"], None, Unset], data) + + featured_playlists = _parse_featured_playlists(d.pop("featuredPlaylists", UNSET)) + + _qualification = d.pop("qualification", UNSET) + qualification: Union[Unset, RankQualification] + if isinstance(_qualification, Unset): + qualification = UNSET + else: + qualification = RankQualification.from_dict(_qualification) + + _reweight = d.pop("reweight", UNSET) + reweight: Union[Unset, RankUpdate] + if isinstance(_reweight, Unset): + reweight = UNSET + else: + reweight = RankUpdate.from_dict(_reweight) + + def _parse_leaderboard_group(data: object) -> Union[List["LeaderboardGroupEntry"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + leaderboard_group_type_0 = [] + _leaderboard_group_type_0 = data + for leaderboard_group_type_0_item_data in _leaderboard_group_type_0: + leaderboard_group_type_0_item = LeaderboardGroupEntry.from_dict(leaderboard_group_type_0_item_data) + + leaderboard_group_type_0.append(leaderboard_group_type_0_item) + + return leaderboard_group_type_0 + except: # noqa: E722 + pass + return cast(Union[List["LeaderboardGroupEntry"], None, Unset], data) + + leaderboard_group = _parse_leaderboard_group(d.pop("leaderboardGroup", UNSET)) + + plays = d.pop("plays", UNSET) + + _clan = d.pop("clan", UNSET) + clan: Union[Unset, ClanResponseFull] + if isinstance(_clan, Unset): + clan = UNSET + else: + clan = ClanResponseFull.from_dict(_clan) + + clan_ranking_contested = d.pop("clanRankingContested", UNSET) + + leaderboard_response = cls( + id=id, + song=song, + difficulty=difficulty, + scores=scores, + changes=changes, + featured_playlists=featured_playlists, + qualification=qualification, + reweight=reweight, + leaderboard_group=leaderboard_group, + plays=plays, + clan=clan, + clan_ranking_contested=clan_ranking_contested, + ) + + return leaderboard_response diff --git a/src/clients/beatleader/models/leaderboard_sort_by.py b/src/clients/beatleader/models/leaderboard_sort_by.py new file mode 100644 index 0000000..6a6a836 --- /dev/null +++ b/src/clients/beatleader/models/leaderboard_sort_by.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class LeaderboardSortBy(str, Enum): + ACC = "acc" + DATE = "date" + MAXSTREAK = "maxStreak" + MISTAKES = "mistakes" + PAUSES = "pauses" + PP = "pp" + RANK = "rank" + WEIGHT = "weight" + WEIGHTEDPP = "weightedPp" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/legacy_modifiers.py b/src/clients/beatleader/models/legacy_modifiers.py new file mode 100644 index 0000000..adef682 --- /dev/null +++ b/src/clients/beatleader/models/legacy_modifiers.py @@ -0,0 +1,128 @@ +from typing import Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="LegacyModifiers") + + +@_attrs_define +class LegacyModifiers: + """ + Attributes: + da (Union[Unset, float]): Dissapearing arrows + fs (Union[Unset, float]): Faster song + ss (Union[Unset, float]): Slower song + sf (Union[Unset, float]): Super fast song + gn (Union[Unset, float]): Ghost notes + na (Union[Unset, float]): No arrows + nb (Union[Unset, float]): No bombs + nf (Union[Unset, float]): No fail + no (Union[Unset, float]): No walls + pm (Union[Unset, float]): Pro mode + sc (Union[Unset, float]): Smaller notes + """ + + da: Union[Unset, float] = UNSET + fs: Union[Unset, float] = UNSET + ss: Union[Unset, float] = UNSET + sf: Union[Unset, float] = UNSET + gn: Union[Unset, float] = UNSET + na: Union[Unset, float] = UNSET + nb: Union[Unset, float] = UNSET + nf: Union[Unset, float] = UNSET + no: Union[Unset, float] = UNSET + pm: Union[Unset, float] = UNSET + sc: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + da = self.da + + fs = self.fs + + ss = self.ss + + sf = self.sf + + gn = self.gn + + na = self.na + + nb = self.nb + + nf = self.nf + + no = self.no + + pm = self.pm + + sc = self.sc + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if da is not UNSET: + field_dict["da"] = da + if fs is not UNSET: + field_dict["fs"] = fs + if ss is not UNSET: + field_dict["ss"] = ss + if sf is not UNSET: + field_dict["sf"] = sf + if gn is not UNSET: + field_dict["gn"] = gn + if na is not UNSET: + field_dict["na"] = na + if nb is not UNSET: + field_dict["nb"] = nb + if nf is not UNSET: + field_dict["nf"] = nf + if no is not UNSET: + field_dict["no"] = no + if pm is not UNSET: + field_dict["pm"] = pm + if sc is not UNSET: + field_dict["sc"] = sc + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + da = d.pop("da", UNSET) + + fs = d.pop("fs", UNSET) + + ss = d.pop("ss", UNSET) + + sf = d.pop("sf", UNSET) + + gn = d.pop("gn", UNSET) + + na = d.pop("na", UNSET) + + nb = d.pop("nb", UNSET) + + nf = d.pop("nf", UNSET) + + no = d.pop("no", UNSET) + + pm = d.pop("pm", UNSET) + + sc = d.pop("sc", UNSET) + + legacy_modifiers = cls( + da=da, + fs=fs, + ss=ss, + sf=sf, + gn=gn, + na=na, + nb=nb, + nf=nf, + no=no, + pm=pm, + sc=sc, + ) + + return legacy_modifiers diff --git a/src/clients/beatleader/models/link_response.py b/src/clients/beatleader/models/link_response.py new file mode 100644 index 0000000..5f91a59 --- /dev/null +++ b/src/clients/beatleader/models/link_response.py @@ -0,0 +1,90 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="LinkResponse") + + +@_attrs_define +class LinkResponse: + """ + Attributes: + quest_id (Union[None, Unset, int]): + steam_id (Union[None, Unset, str]): + oculus_pc_id (Union[None, Unset, str]): + """ + + quest_id: Union[None, Unset, int] = UNSET + steam_id: Union[None, Unset, str] = UNSET + oculus_pc_id: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + quest_id: Union[None, Unset, int] + if isinstance(self.quest_id, Unset): + quest_id = UNSET + else: + quest_id = self.quest_id + + steam_id: Union[None, Unset, str] + if isinstance(self.steam_id, Unset): + steam_id = UNSET + else: + steam_id = self.steam_id + + oculus_pc_id: Union[None, Unset, str] + if isinstance(self.oculus_pc_id, Unset): + oculus_pc_id = UNSET + else: + oculus_pc_id = self.oculus_pc_id + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if quest_id is not UNSET: + field_dict["questId"] = quest_id + if steam_id is not UNSET: + field_dict["steamId"] = steam_id + if oculus_pc_id is not UNSET: + field_dict["oculusPCId"] = oculus_pc_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_quest_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + quest_id = _parse_quest_id(d.pop("questId", UNSET)) + + def _parse_steam_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + steam_id = _parse_steam_id(d.pop("steamId", UNSET)) + + def _parse_oculus_pc_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + oculus_pc_id = _parse_oculus_pc_id(d.pop("oculusPCId", UNSET)) + + link_response = cls( + quest_id=quest_id, + steam_id=steam_id, + oculus_pc_id=oculus_pc_id, + ) + + return link_response diff --git a/src/clients/beatleader/models/map_diff_response.py b/src/clients/beatleader/models/map_diff_response.py new file mode 100644 index 0000000..06bf320 --- /dev/null +++ b/src/clients/beatleader/models/map_diff_response.py @@ -0,0 +1,542 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.difficulty_status import DifficultyStatus +from ..models.requirements import Requirements +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response_full import ClanResponseFull + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response_with_acc import ScoreResponseWithAcc + + +T = TypeVar("T", bound="MapDiffResponse") + + +@_attrs_define +class MapDiffResponse: + """ + Attributes: + id (Union[Unset, int]): + value (Union[Unset, int]): + mode (Union[Unset, int]): + difficulty_name (Union[None, Unset, str]): + mode_name (Union[None, Unset, str]): + status (Union[Unset, DifficultyStatus]): Represents the difficulty status of a map. + modifier_values (Union[Unset, ModifiersMap]): + modifiers_rating (Union[Unset, ModifiersRating]): + nominated_time (Union[Unset, int]): + qualified_time (Union[Unset, int]): + ranked_time (Union[Unset, int]): + speed_tags (Union[Unset, int]): + style_tags (Union[Unset, int]): + feature_tags (Union[Unset, int]): + stars (Union[None, Unset, float]): + predicted_acc (Union[None, Unset, float]): + pass_rating (Union[None, Unset, float]): + acc_rating (Union[None, Unset, float]): + tech_rating (Union[None, Unset, float]): + type (Union[Unset, int]): + njs (Union[Unset, float]): + nps (Union[Unset, float]): + notes (Union[Unset, int]): + bombs (Union[Unset, int]): + walls (Union[Unset, int]): + max_score (Union[Unset, int]): + duration (Union[Unset, float]): + requirements (Union[Unset, Requirements]): + leaderboard_id (Union[None, Unset, str]): + plays (Union[Unset, int]): + positive_votes (Union[Unset, int]): + star_votes (Union[Unset, int]): + negative_votes (Union[Unset, int]): + vote_stars (Union[Unset, float]): + clan (Union[Unset, ClanResponseFull]): + clan_ranking_contested (Union[Unset, bool]): + my_score (Union[Unset, ScoreResponseWithAcc]): + qualification (Union[Unset, RankQualification]): + reweight (Union[Unset, RankUpdate]): + """ + + id: Union[Unset, int] = UNSET + value: Union[Unset, int] = UNSET + mode: Union[Unset, int] = UNSET + difficulty_name: Union[None, Unset, str] = UNSET + mode_name: Union[None, Unset, str] = UNSET + status: Union[Unset, DifficultyStatus] = UNSET + modifier_values: Union[Unset, "ModifiersMap"] = UNSET + modifiers_rating: Union[Unset, "ModifiersRating"] = UNSET + nominated_time: Union[Unset, int] = UNSET + qualified_time: Union[Unset, int] = UNSET + ranked_time: Union[Unset, int] = UNSET + speed_tags: Union[Unset, int] = UNSET + style_tags: Union[Unset, int] = UNSET + feature_tags: Union[Unset, int] = UNSET + stars: Union[None, Unset, float] = UNSET + predicted_acc: Union[None, Unset, float] = UNSET + pass_rating: Union[None, Unset, float] = UNSET + acc_rating: Union[None, Unset, float] = UNSET + tech_rating: Union[None, Unset, float] = UNSET + type: Union[Unset, int] = UNSET + njs: Union[Unset, float] = UNSET + nps: Union[Unset, float] = UNSET + notes: Union[Unset, int] = UNSET + bombs: Union[Unset, int] = UNSET + walls: Union[Unset, int] = UNSET + max_score: Union[Unset, int] = UNSET + duration: Union[Unset, float] = UNSET + requirements: Union[Unset, Requirements] = UNSET + leaderboard_id: Union[None, Unset, str] = UNSET + plays: Union[Unset, int] = UNSET + positive_votes: Union[Unset, int] = UNSET + star_votes: Union[Unset, int] = UNSET + negative_votes: Union[Unset, int] = UNSET + vote_stars: Union[Unset, float] = UNSET + clan: Union[Unset, "ClanResponseFull"] = UNSET + clan_ranking_contested: Union[Unset, bool] = UNSET + my_score: Union[Unset, "ScoreResponseWithAcc"] = UNSET + qualification: Union[Unset, "RankQualification"] = UNSET + reweight: Union[Unset, "RankUpdate"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + value = self.value + + mode = self.mode + + difficulty_name: Union[None, Unset, str] + if isinstance(self.difficulty_name, Unset): + difficulty_name = UNSET + else: + difficulty_name = self.difficulty_name + + mode_name: Union[None, Unset, str] + if isinstance(self.mode_name, Unset): + mode_name = UNSET + else: + mode_name = self.mode_name + + status: Union[Unset, str] = UNSET + if not isinstance(self.status, Unset): + status = self.status.value + + modifier_values: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifier_values, Unset): + modifier_values = self.modifier_values.to_dict() + + modifiers_rating: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifiers_rating, Unset): + modifiers_rating = self.modifiers_rating.to_dict() + + nominated_time = self.nominated_time + + qualified_time = self.qualified_time + + ranked_time = self.ranked_time + + speed_tags = self.speed_tags + + style_tags = self.style_tags + + feature_tags = self.feature_tags + + stars: Union[None, Unset, float] + if isinstance(self.stars, Unset): + stars = UNSET + else: + stars = self.stars + + predicted_acc: Union[None, Unset, float] + if isinstance(self.predicted_acc, Unset): + predicted_acc = UNSET + else: + predicted_acc = self.predicted_acc + + pass_rating: Union[None, Unset, float] + if isinstance(self.pass_rating, Unset): + pass_rating = UNSET + else: + pass_rating = self.pass_rating + + acc_rating: Union[None, Unset, float] + if isinstance(self.acc_rating, Unset): + acc_rating = UNSET + else: + acc_rating = self.acc_rating + + tech_rating: Union[None, Unset, float] + if isinstance(self.tech_rating, Unset): + tech_rating = UNSET + else: + tech_rating = self.tech_rating + + type = self.type + + njs = self.njs + + nps = self.nps + + notes = self.notes + + bombs = self.bombs + + walls = self.walls + + max_score = self.max_score + + duration = self.duration + + requirements: Union[Unset, str] = UNSET + if not isinstance(self.requirements, Unset): + requirements = self.requirements.value + + leaderboard_id: Union[None, Unset, str] + if isinstance(self.leaderboard_id, Unset): + leaderboard_id = UNSET + else: + leaderboard_id = self.leaderboard_id + + plays = self.plays + + positive_votes = self.positive_votes + + star_votes = self.star_votes + + negative_votes = self.negative_votes + + vote_stars = self.vote_stars + + clan: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.clan, Unset): + clan = self.clan.to_dict() + + clan_ranking_contested = self.clan_ranking_contested + + my_score: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.my_score, Unset): + my_score = self.my_score.to_dict() + + qualification: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.qualification, Unset): + qualification = self.qualification.to_dict() + + reweight: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.reweight, Unset): + reweight = self.reweight.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if value is not UNSET: + field_dict["value"] = value + if mode is not UNSET: + field_dict["mode"] = mode + if difficulty_name is not UNSET: + field_dict["difficultyName"] = difficulty_name + if mode_name is not UNSET: + field_dict["modeName"] = mode_name + if status is not UNSET: + field_dict["status"] = status + if modifier_values is not UNSET: + field_dict["modifierValues"] = modifier_values + if modifiers_rating is not UNSET: + field_dict["modifiersRating"] = modifiers_rating + if nominated_time is not UNSET: + field_dict["nominatedTime"] = nominated_time + if qualified_time is not UNSET: + field_dict["qualifiedTime"] = qualified_time + if ranked_time is not UNSET: + field_dict["rankedTime"] = ranked_time + if speed_tags is not UNSET: + field_dict["speedTags"] = speed_tags + if style_tags is not UNSET: + field_dict["styleTags"] = style_tags + if feature_tags is not UNSET: + field_dict["featureTags"] = feature_tags + if stars is not UNSET: + field_dict["stars"] = stars + if predicted_acc is not UNSET: + field_dict["predictedAcc"] = predicted_acc + if pass_rating is not UNSET: + field_dict["passRating"] = pass_rating + if acc_rating is not UNSET: + field_dict["accRating"] = acc_rating + if tech_rating is not UNSET: + field_dict["techRating"] = tech_rating + if type is not UNSET: + field_dict["type"] = type + if njs is not UNSET: + field_dict["njs"] = njs + if nps is not UNSET: + field_dict["nps"] = nps + if notes is not UNSET: + field_dict["notes"] = notes + if bombs is not UNSET: + field_dict["bombs"] = bombs + if walls is not UNSET: + field_dict["walls"] = walls + if max_score is not UNSET: + field_dict["maxScore"] = max_score + if duration is not UNSET: + field_dict["duration"] = duration + if requirements is not UNSET: + field_dict["requirements"] = requirements + if leaderboard_id is not UNSET: + field_dict["leaderboardId"] = leaderboard_id + if plays is not UNSET: + field_dict["plays"] = plays + if positive_votes is not UNSET: + field_dict["positiveVotes"] = positive_votes + if star_votes is not UNSET: + field_dict["starVotes"] = star_votes + if negative_votes is not UNSET: + field_dict["negativeVotes"] = negative_votes + if vote_stars is not UNSET: + field_dict["voteStars"] = vote_stars + if clan is not UNSET: + field_dict["clan"] = clan + if clan_ranking_contested is not UNSET: + field_dict["clanRankingContested"] = clan_ranking_contested + if my_score is not UNSET: + field_dict["myScore"] = my_score + if qualification is not UNSET: + field_dict["qualification"] = qualification + if reweight is not UNSET: + field_dict["reweight"] = reweight + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response_full import ClanResponseFull + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + from ..models.rank_qualification import RankQualification + from ..models.rank_update import RankUpdate + from ..models.score_response_with_acc import ScoreResponseWithAcc + + d = src_dict.copy() + id = d.pop("id", UNSET) + + value = d.pop("value", UNSET) + + mode = d.pop("mode", UNSET) + + def _parse_difficulty_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + difficulty_name = _parse_difficulty_name(d.pop("difficultyName", UNSET)) + + def _parse_mode_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mode_name = _parse_mode_name(d.pop("modeName", UNSET)) + + _status = d.pop("status", UNSET) + status: Union[Unset, DifficultyStatus] + if isinstance(_status, Unset): + status = UNSET + else: + status = DifficultyStatus(_status) + + _modifier_values = d.pop("modifierValues", UNSET) + modifier_values: Union[Unset, ModifiersMap] + if isinstance(_modifier_values, Unset): + modifier_values = UNSET + else: + modifier_values = ModifiersMap.from_dict(_modifier_values) + + _modifiers_rating = d.pop("modifiersRating", UNSET) + modifiers_rating: Union[Unset, ModifiersRating] + if isinstance(_modifiers_rating, Unset): + modifiers_rating = UNSET + else: + modifiers_rating = ModifiersRating.from_dict(_modifiers_rating) + + nominated_time = d.pop("nominatedTime", UNSET) + + qualified_time = d.pop("qualifiedTime", UNSET) + + ranked_time = d.pop("rankedTime", UNSET) + + speed_tags = d.pop("speedTags", UNSET) + + style_tags = d.pop("styleTags", UNSET) + + feature_tags = d.pop("featureTags", UNSET) + + def _parse_stars(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + stars = _parse_stars(d.pop("stars", UNSET)) + + def _parse_predicted_acc(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + predicted_acc = _parse_predicted_acc(d.pop("predictedAcc", UNSET)) + + def _parse_pass_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + pass_rating = _parse_pass_rating(d.pop("passRating", UNSET)) + + def _parse_acc_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + acc_rating = _parse_acc_rating(d.pop("accRating", UNSET)) + + def _parse_tech_rating(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + tech_rating = _parse_tech_rating(d.pop("techRating", UNSET)) + + type = d.pop("type", UNSET) + + njs = d.pop("njs", UNSET) + + nps = d.pop("nps", UNSET) + + notes = d.pop("notes", UNSET) + + bombs = d.pop("bombs", UNSET) + + walls = d.pop("walls", UNSET) + + max_score = d.pop("maxScore", UNSET) + + duration = d.pop("duration", UNSET) + + _requirements = d.pop("requirements", UNSET) + requirements: Union[Unset, Requirements] + if isinstance(_requirements, Unset): + requirements = UNSET + else: + requirements = Requirements(_requirements) + + def _parse_leaderboard_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leaderboard_id = _parse_leaderboard_id(d.pop("leaderboardId", UNSET)) + + plays = d.pop("plays", UNSET) + + positive_votes = d.pop("positiveVotes", UNSET) + + star_votes = d.pop("starVotes", UNSET) + + negative_votes = d.pop("negativeVotes", UNSET) + + vote_stars = d.pop("voteStars", UNSET) + + _clan = d.pop("clan", UNSET) + clan: Union[Unset, ClanResponseFull] + if isinstance(_clan, Unset): + clan = UNSET + else: + clan = ClanResponseFull.from_dict(_clan) + + clan_ranking_contested = d.pop("clanRankingContested", UNSET) + + _my_score = d.pop("myScore", UNSET) + my_score: Union[Unset, ScoreResponseWithAcc] + if isinstance(_my_score, Unset): + my_score = UNSET + else: + my_score = ScoreResponseWithAcc.from_dict(_my_score) + + _qualification = d.pop("qualification", UNSET) + qualification: Union[Unset, RankQualification] + if isinstance(_qualification, Unset): + qualification = UNSET + else: + qualification = RankQualification.from_dict(_qualification) + + _reweight = d.pop("reweight", UNSET) + reweight: Union[Unset, RankUpdate] + if isinstance(_reweight, Unset): + reweight = UNSET + else: + reweight = RankUpdate.from_dict(_reweight) + + map_diff_response = cls( + id=id, + value=value, + mode=mode, + difficulty_name=difficulty_name, + mode_name=mode_name, + status=status, + modifier_values=modifier_values, + modifiers_rating=modifiers_rating, + nominated_time=nominated_time, + qualified_time=qualified_time, + ranked_time=ranked_time, + speed_tags=speed_tags, + style_tags=style_tags, + feature_tags=feature_tags, + stars=stars, + predicted_acc=predicted_acc, + pass_rating=pass_rating, + acc_rating=acc_rating, + tech_rating=tech_rating, + type=type, + njs=njs, + nps=nps, + notes=notes, + bombs=bombs, + walls=walls, + max_score=max_score, + duration=duration, + requirements=requirements, + leaderboard_id=leaderboard_id, + plays=plays, + positive_votes=positive_votes, + star_votes=star_votes, + negative_votes=negative_votes, + vote_stars=vote_stars, + clan=clan, + clan_ranking_contested=clan_ranking_contested, + my_score=my_score, + qualification=qualification, + reweight=reweight, + ) + + return map_diff_response diff --git a/src/clients/beatleader/models/map_info_response.py b/src/clients/beatleader/models/map_info_response.py new file mode 100644 index 0000000..5e29155 --- /dev/null +++ b/src/clients/beatleader/models/map_info_response.py @@ -0,0 +1,413 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.external_status import ExternalStatus + from ..models.map_diff_response import MapDiffResponse + from ..models.mapper_response import MapperResponse + + +T = TypeVar("T", bound="MapInfoResponse") + + +@_attrs_define +class MapInfoResponse: + """ + Attributes: + id (Union[None, Unset, str]): + difficulties (Union[List['MapDiffResponse'], None, Unset]): + hash_ (Union[None, Unset, str]): + name (Union[None, Unset, str]): + sub_name (Union[None, Unset, str]): + author (Union[None, Unset, str]): + mapper (Union[None, Unset, str]): + mappers (Union[List['MapperResponse'], None, Unset]): + mapper_id (Union[Unset, int]): + collaborator_ids (Union[None, Unset, str]): + cover_image (Union[None, Unset, str]): + full_cover_image (Union[None, Unset, str]): + download_url (Union[None, Unset, str]): + bpm (Union[Unset, float]): + duration (Union[Unset, float]): + tags (Union[None, Unset, str]): + upload_time (Union[Unset, int]): + external_statuses (Union[List['ExternalStatus'], None, Unset]): + """ + + id: Union[None, Unset, str] = UNSET + difficulties: Union[List["MapDiffResponse"], None, Unset] = UNSET + hash_: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + sub_name: Union[None, Unset, str] = UNSET + author: Union[None, Unset, str] = UNSET + mapper: Union[None, Unset, str] = UNSET + mappers: Union[List["MapperResponse"], None, Unset] = UNSET + mapper_id: Union[Unset, int] = UNSET + collaborator_ids: Union[None, Unset, str] = UNSET + cover_image: Union[None, Unset, str] = UNSET + full_cover_image: Union[None, Unset, str] = UNSET + download_url: Union[None, Unset, str] = UNSET + bpm: Union[Unset, float] = UNSET + duration: Union[Unset, float] = UNSET + tags: Union[None, Unset, str] = UNSET + upload_time: Union[Unset, int] = UNSET + external_statuses: Union[List["ExternalStatus"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + difficulties: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.difficulties, Unset): + difficulties = UNSET + elif isinstance(self.difficulties, list): + difficulties = [] + for difficulties_type_0_item_data in self.difficulties: + difficulties_type_0_item = difficulties_type_0_item_data.to_dict() + difficulties.append(difficulties_type_0_item) + + else: + difficulties = self.difficulties + + hash_: Union[None, Unset, str] + if isinstance(self.hash_, Unset): + hash_ = UNSET + else: + hash_ = self.hash_ + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + sub_name: Union[None, Unset, str] + if isinstance(self.sub_name, Unset): + sub_name = UNSET + else: + sub_name = self.sub_name + + author: Union[None, Unset, str] + if isinstance(self.author, Unset): + author = UNSET + else: + author = self.author + + mapper: Union[None, Unset, str] + if isinstance(self.mapper, Unset): + mapper = UNSET + else: + mapper = self.mapper + + mappers: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.mappers, Unset): + mappers = UNSET + elif isinstance(self.mappers, list): + mappers = [] + for mappers_type_0_item_data in self.mappers: + mappers_type_0_item = mappers_type_0_item_data.to_dict() + mappers.append(mappers_type_0_item) + + else: + mappers = self.mappers + + mapper_id = self.mapper_id + + collaborator_ids: Union[None, Unset, str] + if isinstance(self.collaborator_ids, Unset): + collaborator_ids = UNSET + else: + collaborator_ids = self.collaborator_ids + + cover_image: Union[None, Unset, str] + if isinstance(self.cover_image, Unset): + cover_image = UNSET + else: + cover_image = self.cover_image + + full_cover_image: Union[None, Unset, str] + if isinstance(self.full_cover_image, Unset): + full_cover_image = UNSET + else: + full_cover_image = self.full_cover_image + + download_url: Union[None, Unset, str] + if isinstance(self.download_url, Unset): + download_url = UNSET + else: + download_url = self.download_url + + bpm = self.bpm + + duration = self.duration + + tags: Union[None, Unset, str] + if isinstance(self.tags, Unset): + tags = UNSET + else: + tags = self.tags + + upload_time = self.upload_time + + external_statuses: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.external_statuses, Unset): + external_statuses = UNSET + elif isinstance(self.external_statuses, list): + external_statuses = [] + for external_statuses_type_0_item_data in self.external_statuses: + external_statuses_type_0_item = external_statuses_type_0_item_data.to_dict() + external_statuses.append(external_statuses_type_0_item) + + else: + external_statuses = self.external_statuses + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if difficulties is not UNSET: + field_dict["difficulties"] = difficulties + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if name is not UNSET: + field_dict["name"] = name + if sub_name is not UNSET: + field_dict["subName"] = sub_name + if author is not UNSET: + field_dict["author"] = author + if mapper is not UNSET: + field_dict["mapper"] = mapper + if mappers is not UNSET: + field_dict["mappers"] = mappers + if mapper_id is not UNSET: + field_dict["mapperId"] = mapper_id + if collaborator_ids is not UNSET: + field_dict["collaboratorIds"] = collaborator_ids + if cover_image is not UNSET: + field_dict["coverImage"] = cover_image + if full_cover_image is not UNSET: + field_dict["fullCoverImage"] = full_cover_image + if download_url is not UNSET: + field_dict["downloadUrl"] = download_url + if bpm is not UNSET: + field_dict["bpm"] = bpm + if duration is not UNSET: + field_dict["duration"] = duration + if tags is not UNSET: + field_dict["tags"] = tags + if upload_time is not UNSET: + field_dict["uploadTime"] = upload_time + if external_statuses is not UNSET: + field_dict["externalStatuses"] = external_statuses + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.external_status import ExternalStatus + from ..models.map_diff_response import MapDiffResponse + from ..models.mapper_response import MapperResponse + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_difficulties(data: object) -> Union[List["MapDiffResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + difficulties_type_0 = [] + _difficulties_type_0 = data + for difficulties_type_0_item_data in _difficulties_type_0: + difficulties_type_0_item = MapDiffResponse.from_dict(difficulties_type_0_item_data) + + difficulties_type_0.append(difficulties_type_0_item) + + return difficulties_type_0 + except: # noqa: E722 + pass + return cast(Union[List["MapDiffResponse"], None, Unset], data) + + difficulties = _parse_difficulties(d.pop("difficulties", UNSET)) + + def _parse_hash_(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + hash_ = _parse_hash_(d.pop("hash", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_sub_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + sub_name = _parse_sub_name(d.pop("subName", UNSET)) + + def _parse_author(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + author = _parse_author(d.pop("author", UNSET)) + + def _parse_mapper(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mapper = _parse_mapper(d.pop("mapper", UNSET)) + + def _parse_mappers(data: object) -> Union[List["MapperResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + mappers_type_0 = [] + _mappers_type_0 = data + for mappers_type_0_item_data in _mappers_type_0: + mappers_type_0_item = MapperResponse.from_dict(mappers_type_0_item_data) + + mappers_type_0.append(mappers_type_0_item) + + return mappers_type_0 + except: # noqa: E722 + pass + return cast(Union[List["MapperResponse"], None, Unset], data) + + mappers = _parse_mappers(d.pop("mappers", UNSET)) + + mapper_id = d.pop("mapperId", UNSET) + + def _parse_collaborator_ids(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + collaborator_ids = _parse_collaborator_ids(d.pop("collaboratorIds", UNSET)) + + def _parse_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover_image = _parse_cover_image(d.pop("coverImage", UNSET)) + + def _parse_full_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + full_cover_image = _parse_full_cover_image(d.pop("fullCoverImage", UNSET)) + + def _parse_download_url(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + download_url = _parse_download_url(d.pop("downloadUrl", UNSET)) + + bpm = d.pop("bpm", UNSET) + + duration = d.pop("duration", UNSET) + + def _parse_tags(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + tags = _parse_tags(d.pop("tags", UNSET)) + + upload_time = d.pop("uploadTime", UNSET) + + def _parse_external_statuses(data: object) -> Union[List["ExternalStatus"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + external_statuses_type_0 = [] + _external_statuses_type_0 = data + for external_statuses_type_0_item_data in _external_statuses_type_0: + external_statuses_type_0_item = ExternalStatus.from_dict(external_statuses_type_0_item_data) + + external_statuses_type_0.append(external_statuses_type_0_item) + + return external_statuses_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ExternalStatus"], None, Unset], data) + + external_statuses = _parse_external_statuses(d.pop("externalStatuses", UNSET)) + + map_info_response = cls( + id=id, + difficulties=difficulties, + hash_=hash_, + name=name, + sub_name=sub_name, + author=author, + mapper=mapper, + mappers=mappers, + mapper_id=mapper_id, + collaborator_ids=collaborator_ids, + cover_image=cover_image, + full_cover_image=full_cover_image, + download_url=download_url, + bpm=bpm, + duration=duration, + tags=tags, + upload_time=upload_time, + external_statuses=external_statuses, + ) + + return map_info_response diff --git a/src/clients/beatleader/models/map_info_response_response_with_metadata.py b/src/clients/beatleader/models/map_info_response_response_with_metadata.py new file mode 100644 index 0000000..9597b2f --- /dev/null +++ b/src/clients/beatleader/models/map_info_response_response_with_metadata.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.map_info_response import MapInfoResponse + from ..models.metadata import Metadata + + +T = TypeVar("T", bound="MapInfoResponseResponseWithMetadata") + + +@_attrs_define +class MapInfoResponseResponseWithMetadata: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['MapInfoResponse'], None, Unset]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["MapInfoResponse"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.map_info_response import MapInfoResponse + from ..models.metadata import Metadata + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["MapInfoResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = MapInfoResponse.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["MapInfoResponse"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + map_info_response_response_with_metadata = cls( + metadata=metadata, + data=data, + ) + + return map_info_response_response_with_metadata diff --git a/src/clients/beatleader/models/map_quality.py b/src/clients/beatleader/models/map_quality.py new file mode 100644 index 0000000..b2b6513 --- /dev/null +++ b/src/clients/beatleader/models/map_quality.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class MapQuality(str, Enum): + BAD = "bad" + GOOD = "good" + OK = "ok" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/map_sort_by.py b/src/clients/beatleader/models/map_sort_by.py new file mode 100644 index 0000000..1883219 --- /dev/null +++ b/src/clients/beatleader/models/map_sort_by.py @@ -0,0 +1,20 @@ +from enum import Enum + + +class MapSortBy(str, Enum): + ACCRATING = "accRating" + DURATION = "duration" + NAME = "name" + NONE = "none" + PASSRATING = "passRating" + PLAYCOUNT = "playCount" + SCORETIME = "scoreTime" + STARS = "stars" + TECHRATING = "techRating" + TIMESTAMP = "timestamp" + VOTECOUNT = "voteCount" + VOTERATIO = "voteRatio" + VOTING = "voting" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/mapper.py b/src/clients/beatleader/models/mapper.py new file mode 100644 index 0000000..73bcb02 --- /dev/null +++ b/src/clients/beatleader/models/mapper.py @@ -0,0 +1,190 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.player import Player + from ..models.song import Song + + +T = TypeVar("T", bound="Mapper") + + +@_attrs_define +class Mapper: + """ + Attributes: + id (Union[Unset, int]): + name (Union[None, Unset, str]): + avatar (Union[None, Unset, str]): + curator (Union[None, Unset, bool]): + verified_mapper (Union[Unset, bool]): + playlist_url (Union[None, Unset, str]): + songs (Union[List['Song'], None, Unset]): + player (Union[Unset, Player]): + """ + + id: Union[Unset, int] = UNSET + name: Union[None, Unset, str] = UNSET + avatar: Union[None, Unset, str] = UNSET + curator: Union[None, Unset, bool] = UNSET + verified_mapper: Union[Unset, bool] = UNSET + playlist_url: Union[None, Unset, str] = UNSET + songs: Union[List["Song"], None, Unset] = UNSET + player: Union[Unset, "Player"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + avatar: Union[None, Unset, str] + if isinstance(self.avatar, Unset): + avatar = UNSET + else: + avatar = self.avatar + + curator: Union[None, Unset, bool] + if isinstance(self.curator, Unset): + curator = UNSET + else: + curator = self.curator + + verified_mapper = self.verified_mapper + + playlist_url: Union[None, Unset, str] + if isinstance(self.playlist_url, Unset): + playlist_url = UNSET + else: + playlist_url = self.playlist_url + + songs: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.songs, Unset): + songs = UNSET + elif isinstance(self.songs, list): + songs = [] + for songs_type_0_item_data in self.songs: + songs_type_0_item = songs_type_0_item_data.to_dict() + songs.append(songs_type_0_item) + + else: + songs = self.songs + + player: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.player, Unset): + player = self.player.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if avatar is not UNSET: + field_dict["avatar"] = avatar + if curator is not UNSET: + field_dict["curator"] = curator + if verified_mapper is not UNSET: + field_dict["verifiedMapper"] = verified_mapper + if playlist_url is not UNSET: + field_dict["playlistUrl"] = playlist_url + if songs is not UNSET: + field_dict["songs"] = songs + if player is not UNSET: + field_dict["player"] = player + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.player import Player + from ..models.song import Song + + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + avatar = _parse_avatar(d.pop("avatar", UNSET)) + + def _parse_curator(data: object) -> Union[None, Unset, bool]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, bool], data) + + curator = _parse_curator(d.pop("curator", UNSET)) + + verified_mapper = d.pop("verifiedMapper", UNSET) + + def _parse_playlist_url(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + playlist_url = _parse_playlist_url(d.pop("playlistUrl", UNSET)) + + def _parse_songs(data: object) -> Union[List["Song"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + songs_type_0 = [] + _songs_type_0 = data + for songs_type_0_item_data in _songs_type_0: + songs_type_0_item = Song.from_dict(songs_type_0_item_data) + + songs_type_0.append(songs_type_0_item) + + return songs_type_0 + except: # noqa: E722 + pass + return cast(Union[List["Song"], None, Unset], data) + + songs = _parse_songs(d.pop("songs", UNSET)) + + _player = d.pop("player", UNSET) + player: Union[Unset, Player] + if isinstance(_player, Unset): + player = UNSET + else: + player = Player.from_dict(_player) + + mapper = cls( + id=id, + name=name, + avatar=avatar, + curator=curator, + verified_mapper=verified_mapper, + playlist_url=playlist_url, + songs=songs, + player=player, + ) + + return mapper diff --git a/src/clients/beatleader/models/mapper_response.py b/src/clients/beatleader/models/mapper_response.py new file mode 100644 index 0000000..65351f6 --- /dev/null +++ b/src/clients/beatleader/models/mapper_response.py @@ -0,0 +1,139 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MapperResponse") + + +@_attrs_define +class MapperResponse: + """ + Attributes: + id (Union[None, Unset, int]): + player_id (Union[None, Unset, str]): + name (Union[None, Unset, str]): + avatar (Union[None, Unset, str]): + curator (Union[None, Unset, bool]): + verified_mapper (Union[Unset, bool]): + """ + + id: Union[None, Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + avatar: Union[None, Unset, str] = UNSET + curator: Union[None, Unset, bool] = UNSET + verified_mapper: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, int] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + avatar: Union[None, Unset, str] + if isinstance(self.avatar, Unset): + avatar = UNSET + else: + avatar = self.avatar + + curator: Union[None, Unset, bool] + if isinstance(self.curator, Unset): + curator = UNSET + else: + curator = self.curator + + verified_mapper = self.verified_mapper + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if name is not UNSET: + field_dict["name"] = name + if avatar is not UNSET: + field_dict["avatar"] = avatar + if curator is not UNSET: + field_dict["curator"] = curator + if verified_mapper is not UNSET: + field_dict["verifiedMapper"] = verified_mapper + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + avatar = _parse_avatar(d.pop("avatar", UNSET)) + + def _parse_curator(data: object) -> Union[None, Unset, bool]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, bool], data) + + curator = _parse_curator(d.pop("curator", UNSET)) + + verified_mapper = d.pop("verifiedMapper", UNSET) + + mapper_response = cls( + id=id, + player_id=player_id, + name=name, + avatar=avatar, + curator=curator, + verified_mapper=verified_mapper, + ) + + return mapper_response diff --git a/src/clients/beatleader/models/maps_type.py b/src/clients/beatleader/models/maps_type.py new file mode 100644 index 0000000..6c4b935 --- /dev/null +++ b/src/clients/beatleader/models/maps_type.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class MapsType(str, Enum): + ALL = "all" + RANKED = "ranked" + UNRANKED = "unranked" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/metadata.py b/src/clients/beatleader/models/metadata.py new file mode 100644 index 0000000..3c17a63 --- /dev/null +++ b/src/clients/beatleader/models/metadata.py @@ -0,0 +1,56 @@ +from typing import Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Metadata") + + +@_attrs_define +class Metadata: + """ + Attributes: + items_per_page (Union[Unset, int]): + page (Union[Unset, int]): + total (Union[Unset, int]): + """ + + items_per_page: Union[Unset, int] = UNSET + page: Union[Unset, int] = UNSET + total: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + items_per_page = self.items_per_page + + page = self.page + + total = self.total + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if items_per_page is not UNSET: + field_dict["itemsPerPage"] = items_per_page + if page is not UNSET: + field_dict["page"] = page + if total is not UNSET: + field_dict["total"] = total + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + items_per_page = d.pop("itemsPerPage", UNSET) + + page = d.pop("page", UNSET) + + total = d.pop("total", UNSET) + + metadata = cls( + items_per_page=items_per_page, + page=page, + total=total, + ) + + return metadata diff --git a/src/clients/beatleader/models/modifiers_map.py b/src/clients/beatleader/models/modifiers_map.py new file mode 100644 index 0000000..6f2797e --- /dev/null +++ b/src/clients/beatleader/models/modifiers_map.py @@ -0,0 +1,191 @@ +from typing import Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModifiersMap") + + +@_attrs_define +class ModifiersMap: + """ + Attributes: + modifier_id (Union[Unset, int]): + da (Union[Unset, float]): + fs (Union[Unset, float]): + sf (Union[Unset, float]): + ss (Union[Unset, float]): + gn (Union[Unset, float]): + na (Union[Unset, float]): + nb (Union[Unset, float]): + nf (Union[Unset, float]): + no (Union[Unset, float]): + pm (Union[Unset, float]): + sc (Union[Unset, float]): + sa (Union[Unset, float]): + op (Union[Unset, float]): + ez (Union[Unset, float]): + hd (Union[Unset, float]): + smc (Union[Unset, float]): + ohp (Union[Unset, float]): + """ + + modifier_id: Union[Unset, int] = UNSET + da: Union[Unset, float] = UNSET + fs: Union[Unset, float] = UNSET + sf: Union[Unset, float] = UNSET + ss: Union[Unset, float] = UNSET + gn: Union[Unset, float] = UNSET + na: Union[Unset, float] = UNSET + nb: Union[Unset, float] = UNSET + nf: Union[Unset, float] = UNSET + no: Union[Unset, float] = UNSET + pm: Union[Unset, float] = UNSET + sc: Union[Unset, float] = UNSET + sa: Union[Unset, float] = UNSET + op: Union[Unset, float] = UNSET + ez: Union[Unset, float] = UNSET + hd: Union[Unset, float] = UNSET + smc: Union[Unset, float] = UNSET + ohp: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + modifier_id = self.modifier_id + + da = self.da + + fs = self.fs + + sf = self.sf + + ss = self.ss + + gn = self.gn + + na = self.na + + nb = self.nb + + nf = self.nf + + no = self.no + + pm = self.pm + + sc = self.sc + + sa = self.sa + + op = self.op + + ez = self.ez + + hd = self.hd + + smc = self.smc + + ohp = self.ohp + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if modifier_id is not UNSET: + field_dict["modifierId"] = modifier_id + if da is not UNSET: + field_dict["da"] = da + if fs is not UNSET: + field_dict["fs"] = fs + if sf is not UNSET: + field_dict["sf"] = sf + if ss is not UNSET: + field_dict["ss"] = ss + if gn is not UNSET: + field_dict["gn"] = gn + if na is not UNSET: + field_dict["na"] = na + if nb is not UNSET: + field_dict["nb"] = nb + if nf is not UNSET: + field_dict["nf"] = nf + if no is not UNSET: + field_dict["no"] = no + if pm is not UNSET: + field_dict["pm"] = pm + if sc is not UNSET: + field_dict["sc"] = sc + if sa is not UNSET: + field_dict["sa"] = sa + if op is not UNSET: + field_dict["op"] = op + if ez is not UNSET: + field_dict["ez"] = ez + if hd is not UNSET: + field_dict["hd"] = hd + if smc is not UNSET: + field_dict["smc"] = smc + if ohp is not UNSET: + field_dict["ohp"] = ohp + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + modifier_id = d.pop("modifierId", UNSET) + + da = d.pop("da", UNSET) + + fs = d.pop("fs", UNSET) + + sf = d.pop("sf", UNSET) + + ss = d.pop("ss", UNSET) + + gn = d.pop("gn", UNSET) + + na = d.pop("na", UNSET) + + nb = d.pop("nb", UNSET) + + nf = d.pop("nf", UNSET) + + no = d.pop("no", UNSET) + + pm = d.pop("pm", UNSET) + + sc = d.pop("sc", UNSET) + + sa = d.pop("sa", UNSET) + + op = d.pop("op", UNSET) + + ez = d.pop("ez", UNSET) + + hd = d.pop("hd", UNSET) + + smc = d.pop("smc", UNSET) + + ohp = d.pop("ohp", UNSET) + + modifiers_map = cls( + modifier_id=modifier_id, + da=da, + fs=fs, + sf=sf, + ss=ss, + gn=gn, + na=na, + nb=nb, + nf=nf, + no=no, + pm=pm, + sc=sc, + sa=sa, + op=op, + ez=ez, + hd=hd, + smc=smc, + ohp=ohp, + ) + + return modifiers_map diff --git a/src/clients/beatleader/models/modifiers_rating.py b/src/clients/beatleader/models/modifiers_rating.py new file mode 100644 index 0000000..f62d77c --- /dev/null +++ b/src/clients/beatleader/models/modifiers_rating.py @@ -0,0 +1,263 @@ +from typing import Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModifiersRating") + + +@_attrs_define +class ModifiersRating: + """ + Attributes: + id (Union[Unset, int]): + ss_predicted_acc (Union[Unset, float]): + ss_pass_rating (Union[Unset, float]): + ss_acc_rating (Union[Unset, float]): + ss_tech_rating (Union[Unset, float]): + ss_stars (Union[Unset, float]): + fs_predicted_acc (Union[Unset, float]): + fs_pass_rating (Union[Unset, float]): + fs_acc_rating (Union[Unset, float]): + fs_tech_rating (Union[Unset, float]): + fs_stars (Union[Unset, float]): + sf_predicted_acc (Union[Unset, float]): + sf_pass_rating (Union[Unset, float]): + sf_acc_rating (Union[Unset, float]): + sf_tech_rating (Union[Unset, float]): + sf_stars (Union[Unset, float]): + bfs_predicted_acc (Union[Unset, float]): + bfs_pass_rating (Union[Unset, float]): + bfs_acc_rating (Union[Unset, float]): + bfs_tech_rating (Union[Unset, float]): + bfs_stars (Union[Unset, float]): + bsf_predicted_acc (Union[Unset, float]): + bsf_pass_rating (Union[Unset, float]): + bsf_acc_rating (Union[Unset, float]): + bsf_tech_rating (Union[Unset, float]): + bsf_stars (Union[Unset, float]): + """ + + id: Union[Unset, int] = UNSET + ss_predicted_acc: Union[Unset, float] = UNSET + ss_pass_rating: Union[Unset, float] = UNSET + ss_acc_rating: Union[Unset, float] = UNSET + ss_tech_rating: Union[Unset, float] = UNSET + ss_stars: Union[Unset, float] = UNSET + fs_predicted_acc: Union[Unset, float] = UNSET + fs_pass_rating: Union[Unset, float] = UNSET + fs_acc_rating: Union[Unset, float] = UNSET + fs_tech_rating: Union[Unset, float] = UNSET + fs_stars: Union[Unset, float] = UNSET + sf_predicted_acc: Union[Unset, float] = UNSET + sf_pass_rating: Union[Unset, float] = UNSET + sf_acc_rating: Union[Unset, float] = UNSET + sf_tech_rating: Union[Unset, float] = UNSET + sf_stars: Union[Unset, float] = UNSET + bfs_predicted_acc: Union[Unset, float] = UNSET + bfs_pass_rating: Union[Unset, float] = UNSET + bfs_acc_rating: Union[Unset, float] = UNSET + bfs_tech_rating: Union[Unset, float] = UNSET + bfs_stars: Union[Unset, float] = UNSET + bsf_predicted_acc: Union[Unset, float] = UNSET + bsf_pass_rating: Union[Unset, float] = UNSET + bsf_acc_rating: Union[Unset, float] = UNSET + bsf_tech_rating: Union[Unset, float] = UNSET + bsf_stars: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + ss_predicted_acc = self.ss_predicted_acc + + ss_pass_rating = self.ss_pass_rating + + ss_acc_rating = self.ss_acc_rating + + ss_tech_rating = self.ss_tech_rating + + ss_stars = self.ss_stars + + fs_predicted_acc = self.fs_predicted_acc + + fs_pass_rating = self.fs_pass_rating + + fs_acc_rating = self.fs_acc_rating + + fs_tech_rating = self.fs_tech_rating + + fs_stars = self.fs_stars + + sf_predicted_acc = self.sf_predicted_acc + + sf_pass_rating = self.sf_pass_rating + + sf_acc_rating = self.sf_acc_rating + + sf_tech_rating = self.sf_tech_rating + + sf_stars = self.sf_stars + + bfs_predicted_acc = self.bfs_predicted_acc + + bfs_pass_rating = self.bfs_pass_rating + + bfs_acc_rating = self.bfs_acc_rating + + bfs_tech_rating = self.bfs_tech_rating + + bfs_stars = self.bfs_stars + + bsf_predicted_acc = self.bsf_predicted_acc + + bsf_pass_rating = self.bsf_pass_rating + + bsf_acc_rating = self.bsf_acc_rating + + bsf_tech_rating = self.bsf_tech_rating + + bsf_stars = self.bsf_stars + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if ss_predicted_acc is not UNSET: + field_dict["ssPredictedAcc"] = ss_predicted_acc + if ss_pass_rating is not UNSET: + field_dict["ssPassRating"] = ss_pass_rating + if ss_acc_rating is not UNSET: + field_dict["ssAccRating"] = ss_acc_rating + if ss_tech_rating is not UNSET: + field_dict["ssTechRating"] = ss_tech_rating + if ss_stars is not UNSET: + field_dict["ssStars"] = ss_stars + if fs_predicted_acc is not UNSET: + field_dict["fsPredictedAcc"] = fs_predicted_acc + if fs_pass_rating is not UNSET: + field_dict["fsPassRating"] = fs_pass_rating + if fs_acc_rating is not UNSET: + field_dict["fsAccRating"] = fs_acc_rating + if fs_tech_rating is not UNSET: + field_dict["fsTechRating"] = fs_tech_rating + if fs_stars is not UNSET: + field_dict["fsStars"] = fs_stars + if sf_predicted_acc is not UNSET: + field_dict["sfPredictedAcc"] = sf_predicted_acc + if sf_pass_rating is not UNSET: + field_dict["sfPassRating"] = sf_pass_rating + if sf_acc_rating is not UNSET: + field_dict["sfAccRating"] = sf_acc_rating + if sf_tech_rating is not UNSET: + field_dict["sfTechRating"] = sf_tech_rating + if sf_stars is not UNSET: + field_dict["sfStars"] = sf_stars + if bfs_predicted_acc is not UNSET: + field_dict["bfsPredictedAcc"] = bfs_predicted_acc + if bfs_pass_rating is not UNSET: + field_dict["bfsPassRating"] = bfs_pass_rating + if bfs_acc_rating is not UNSET: + field_dict["bfsAccRating"] = bfs_acc_rating + if bfs_tech_rating is not UNSET: + field_dict["bfsTechRating"] = bfs_tech_rating + if bfs_stars is not UNSET: + field_dict["bfsStars"] = bfs_stars + if bsf_predicted_acc is not UNSET: + field_dict["bsfPredictedAcc"] = bsf_predicted_acc + if bsf_pass_rating is not UNSET: + field_dict["bsfPassRating"] = bsf_pass_rating + if bsf_acc_rating is not UNSET: + field_dict["bsfAccRating"] = bsf_acc_rating + if bsf_tech_rating is not UNSET: + field_dict["bsfTechRating"] = bsf_tech_rating + if bsf_stars is not UNSET: + field_dict["bsfStars"] = bsf_stars + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + ss_predicted_acc = d.pop("ssPredictedAcc", UNSET) + + ss_pass_rating = d.pop("ssPassRating", UNSET) + + ss_acc_rating = d.pop("ssAccRating", UNSET) + + ss_tech_rating = d.pop("ssTechRating", UNSET) + + ss_stars = d.pop("ssStars", UNSET) + + fs_predicted_acc = d.pop("fsPredictedAcc", UNSET) + + fs_pass_rating = d.pop("fsPassRating", UNSET) + + fs_acc_rating = d.pop("fsAccRating", UNSET) + + fs_tech_rating = d.pop("fsTechRating", UNSET) + + fs_stars = d.pop("fsStars", UNSET) + + sf_predicted_acc = d.pop("sfPredictedAcc", UNSET) + + sf_pass_rating = d.pop("sfPassRating", UNSET) + + sf_acc_rating = d.pop("sfAccRating", UNSET) + + sf_tech_rating = d.pop("sfTechRating", UNSET) + + sf_stars = d.pop("sfStars", UNSET) + + bfs_predicted_acc = d.pop("bfsPredictedAcc", UNSET) + + bfs_pass_rating = d.pop("bfsPassRating", UNSET) + + bfs_acc_rating = d.pop("bfsAccRating", UNSET) + + bfs_tech_rating = d.pop("bfsTechRating", UNSET) + + bfs_stars = d.pop("bfsStars", UNSET) + + bsf_predicted_acc = d.pop("bsfPredictedAcc", UNSET) + + bsf_pass_rating = d.pop("bsfPassRating", UNSET) + + bsf_acc_rating = d.pop("bsfAccRating", UNSET) + + bsf_tech_rating = d.pop("bsfTechRating", UNSET) + + bsf_stars = d.pop("bsfStars", UNSET) + + modifiers_rating = cls( + id=id, + ss_predicted_acc=ss_predicted_acc, + ss_pass_rating=ss_pass_rating, + ss_acc_rating=ss_acc_rating, + ss_tech_rating=ss_tech_rating, + ss_stars=ss_stars, + fs_predicted_acc=fs_predicted_acc, + fs_pass_rating=fs_pass_rating, + fs_acc_rating=fs_acc_rating, + fs_tech_rating=fs_tech_rating, + fs_stars=fs_stars, + sf_predicted_acc=sf_predicted_acc, + sf_pass_rating=sf_pass_rating, + sf_acc_rating=sf_acc_rating, + sf_tech_rating=sf_tech_rating, + sf_stars=sf_stars, + bfs_predicted_acc=bfs_predicted_acc, + bfs_pass_rating=bfs_pass_rating, + bfs_acc_rating=bfs_acc_rating, + bfs_tech_rating=bfs_tech_rating, + bfs_stars=bfs_stars, + bsf_predicted_acc=bsf_predicted_acc, + bsf_pass_rating=bsf_pass_rating, + bsf_acc_rating=bsf_acc_rating, + bsf_tech_rating=bsf_tech_rating, + bsf_stars=bsf_stars, + ) + + return modifiers_rating diff --git a/src/clients/beatleader/models/my_type.py b/src/clients/beatleader/models/my_type.py new file mode 100644 index 0000000..68e2482 --- /dev/null +++ b/src/clients/beatleader/models/my_type.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class MyType(str, Enum): + MYMAPS = "myMaps" + MYNOMINATED = "myNominated" + NONE = "none" + OTHERSNOMINATED = "othersNominated" + PLAYED = "played" + UNPLAYED = "unplayed" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/operation.py b/src/clients/beatleader/models/operation.py new file mode 100644 index 0000000..01ba484 --- /dev/null +++ b/src/clients/beatleader/models/operation.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class Operation(str, Enum): + ALL = "all" + ANY = "any" + NOT = "not" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/order.py b/src/clients/beatleader/models/order.py new file mode 100644 index 0000000..a7f1413 --- /dev/null +++ b/src/clients/beatleader/models/order.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class Order(str, Enum): + ASC = "asc" + DESC = "desc" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/participating_event_response.py b/src/clients/beatleader/models/participating_event_response.py new file mode 100644 index 0000000..efba839 --- /dev/null +++ b/src/clients/beatleader/models/participating_event_response.py @@ -0,0 +1,70 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ParticipatingEventResponse") + + +@_attrs_define +class ParticipatingEventResponse: + """ + Attributes: + id (Union[None, Unset, int]): + name (Union[None, Unset, str]): + """ + + id: Union[None, Unset, int] = UNSET + name: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, int] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + participating_event_response = cls( + id=id, + name=name, + ) + + return participating_event_response diff --git a/src/clients/beatleader/models/patreon_features.py b/src/clients/beatleader/models/patreon_features.py new file mode 100644 index 0000000..a6d9000 --- /dev/null +++ b/src/clients/beatleader/models/patreon_features.py @@ -0,0 +1,118 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PatreonFeatures") + + +@_attrs_define +class PatreonFeatures: + """ + Attributes: + id (Union[Unset, int]): + bio (Union[None, Unset, str]): + message (Union[None, Unset, str]): + left_saber_color (Union[None, Unset, str]): + right_saber_color (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + bio: Union[None, Unset, str] = UNSET + message: Union[None, Unset, str] = UNSET + left_saber_color: Union[None, Unset, str] = UNSET + right_saber_color: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + bio: Union[None, Unset, str] + if isinstance(self.bio, Unset): + bio = UNSET + else: + bio = self.bio + + message: Union[None, Unset, str] + if isinstance(self.message, Unset): + message = UNSET + else: + message = self.message + + left_saber_color: Union[None, Unset, str] + if isinstance(self.left_saber_color, Unset): + left_saber_color = UNSET + else: + left_saber_color = self.left_saber_color + + right_saber_color: Union[None, Unset, str] + if isinstance(self.right_saber_color, Unset): + right_saber_color = UNSET + else: + right_saber_color = self.right_saber_color + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if bio is not UNSET: + field_dict["bio"] = bio + if message is not UNSET: + field_dict["message"] = message + if left_saber_color is not UNSET: + field_dict["leftSaberColor"] = left_saber_color + if right_saber_color is not UNSET: + field_dict["rightSaberColor"] = right_saber_color + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_bio(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + bio = _parse_bio(d.pop("bio", UNSET)) + + def _parse_message(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + message = _parse_message(d.pop("message", UNSET)) + + def _parse_left_saber_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + left_saber_color = _parse_left_saber_color(d.pop("leftSaberColor", UNSET)) + + def _parse_right_saber_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + right_saber_color = _parse_right_saber_color(d.pop("rightSaberColor", UNSET)) + + patreon_features = cls( + id=id, + bio=bio, + message=message, + left_saber_color=left_saber_color, + right_saber_color=right_saber_color, + ) + + return patreon_features diff --git a/src/clients/beatleader/models/player.py b/src/clients/beatleader/models/player.py new file mode 100644 index 0000000..7c29dc7 --- /dev/null +++ b/src/clients/beatleader/models/player.py @@ -0,0 +1,747 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.achievement import Achievement + from ..models.badge import Badge + from ..models.event_player import EventPlayer + from ..models.mapper import Mapper + from ..models.patreon_features import PatreonFeatures + from ..models.player_change import PlayerChange + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_score_stats_history import PlayerScoreStatsHistory + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + + +T = TypeVar("T", bound="Player") + + +@_attrs_define +class Player: + """ + Attributes: + id (Union[None, Unset, str]): + name (Union[None, Unset, str]): + platform (Union[None, Unset, str]): + avatar (Union[None, Unset, str]): + web_avatar (Union[None, Unset, str]): + country (Union[None, Unset, str]): + alias (Union[None, Unset, str]): + old_alias (Union[None, Unset, str]): + role (Union[None, Unset, str]): + mapper_id (Union[None, Unset, int]): + mapper (Union[Unset, Mapper]): + pp (Union[Unset, float]): + acc_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + rank (Union[Unset, int]): + country_rank (Union[Unset, int]): + last_week_pp (Union[Unset, float]): + last_week_rank (Union[Unset, int]): + last_week_country_rank (Union[Unset, int]): + banned (Union[Unset, bool]): + bot (Union[Unset, bool]): + inactive (Union[Unset, bool]): + external_profile_url (Union[None, Unset, str]): + rich_bio_timeset (Union[Unset, int]): + created_at (Union[Unset, int]): + speedrun_start (Union[Unset, int]): + score_stats_id (Union[None, Unset, int]): + score_stats (Union[Unset, PlayerScoreStats]): + clan_order (Union[None, Unset, str]): + badges (Union[List['Badge'], None, Unset]): + patreon_features (Union[Unset, PatreonFeatures]): + profile_settings (Union[Unset, ProfileSettings]): + changes (Union[List['PlayerChange'], None, Unset]): + history (Union[List['PlayerScoreStatsHistory'], None, Unset]): + events_participating (Union[List['EventPlayer'], None, Unset]): + socials (Union[List['PlayerSocial'], None, Unset]): + achievements (Union[List['Achievement'], None, Unset]): + """ + + id: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + platform: Union[None, Unset, str] = UNSET + avatar: Union[None, Unset, str] = UNSET + web_avatar: Union[None, Unset, str] = UNSET + country: Union[None, Unset, str] = UNSET + alias: Union[None, Unset, str] = UNSET + old_alias: Union[None, Unset, str] = UNSET + role: Union[None, Unset, str] = UNSET + mapper_id: Union[None, Unset, int] = UNSET + mapper: Union[Unset, "Mapper"] = UNSET + pp: Union[Unset, float] = UNSET + acc_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country_rank: Union[Unset, int] = UNSET + last_week_pp: Union[Unset, float] = UNSET + last_week_rank: Union[Unset, int] = UNSET + last_week_country_rank: Union[Unset, int] = UNSET + banned: Union[Unset, bool] = UNSET + bot: Union[Unset, bool] = UNSET + inactive: Union[Unset, bool] = UNSET + external_profile_url: Union[None, Unset, str] = UNSET + rich_bio_timeset: Union[Unset, int] = UNSET + created_at: Union[Unset, int] = UNSET + speedrun_start: Union[Unset, int] = UNSET + score_stats_id: Union[None, Unset, int] = UNSET + score_stats: Union[Unset, "PlayerScoreStats"] = UNSET + clan_order: Union[None, Unset, str] = UNSET + badges: Union[List["Badge"], None, Unset] = UNSET + patreon_features: Union[Unset, "PatreonFeatures"] = UNSET + profile_settings: Union[Unset, "ProfileSettings"] = UNSET + changes: Union[List["PlayerChange"], None, Unset] = UNSET + history: Union[List["PlayerScoreStatsHistory"], None, Unset] = UNSET + events_participating: Union[List["EventPlayer"], None, Unset] = UNSET + socials: Union[List["PlayerSocial"], None, Unset] = UNSET + achievements: Union[List["Achievement"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + platform: Union[None, Unset, str] + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + avatar: Union[None, Unset, str] + if isinstance(self.avatar, Unset): + avatar = UNSET + else: + avatar = self.avatar + + web_avatar: Union[None, Unset, str] + if isinstance(self.web_avatar, Unset): + web_avatar = UNSET + else: + web_avatar = self.web_avatar + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + alias: Union[None, Unset, str] + if isinstance(self.alias, Unset): + alias = UNSET + else: + alias = self.alias + + old_alias: Union[None, Unset, str] + if isinstance(self.old_alias, Unset): + old_alias = UNSET + else: + old_alias = self.old_alias + + role: Union[None, Unset, str] + if isinstance(self.role, Unset): + role = UNSET + else: + role = self.role + + mapper_id: Union[None, Unset, int] + if isinstance(self.mapper_id, Unset): + mapper_id = UNSET + else: + mapper_id = self.mapper_id + + mapper: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.mapper, Unset): + mapper = self.mapper.to_dict() + + pp = self.pp + + acc_pp = self.acc_pp + + tech_pp = self.tech_pp + + pass_pp = self.pass_pp + + rank = self.rank + + country_rank = self.country_rank + + last_week_pp = self.last_week_pp + + last_week_rank = self.last_week_rank + + last_week_country_rank = self.last_week_country_rank + + banned = self.banned + + bot = self.bot + + inactive = self.inactive + + external_profile_url: Union[None, Unset, str] + if isinstance(self.external_profile_url, Unset): + external_profile_url = UNSET + else: + external_profile_url = self.external_profile_url + + rich_bio_timeset = self.rich_bio_timeset + + created_at = self.created_at + + speedrun_start = self.speedrun_start + + score_stats_id: Union[None, Unset, int] + if isinstance(self.score_stats_id, Unset): + score_stats_id = UNSET + else: + score_stats_id = self.score_stats_id + + score_stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score_stats, Unset): + score_stats = self.score_stats.to_dict() + + clan_order: Union[None, Unset, str] + if isinstance(self.clan_order, Unset): + clan_order = UNSET + else: + clan_order = self.clan_order + + badges: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.badges, Unset): + badges = UNSET + elif isinstance(self.badges, list): + badges = [] + for badges_type_0_item_data in self.badges: + badges_type_0_item = badges_type_0_item_data.to_dict() + badges.append(badges_type_0_item) + + else: + badges = self.badges + + patreon_features: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.patreon_features, Unset): + patreon_features = self.patreon_features.to_dict() + + profile_settings: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.profile_settings, Unset): + profile_settings = self.profile_settings.to_dict() + + changes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.changes, Unset): + changes = UNSET + elif isinstance(self.changes, list): + changes = [] + for changes_type_0_item_data in self.changes: + changes_type_0_item = changes_type_0_item_data.to_dict() + changes.append(changes_type_0_item) + + else: + changes = self.changes + + history: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.history, Unset): + history = UNSET + elif isinstance(self.history, list): + history = [] + for history_type_0_item_data in self.history: + history_type_0_item = history_type_0_item_data.to_dict() + history.append(history_type_0_item) + + else: + history = self.history + + events_participating: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.events_participating, Unset): + events_participating = UNSET + elif isinstance(self.events_participating, list): + events_participating = [] + for events_participating_type_0_item_data in self.events_participating: + events_participating_type_0_item = events_participating_type_0_item_data.to_dict() + events_participating.append(events_participating_type_0_item) + + else: + events_participating = self.events_participating + + socials: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.socials, Unset): + socials = UNSET + elif isinstance(self.socials, list): + socials = [] + for socials_type_0_item_data in self.socials: + socials_type_0_item = socials_type_0_item_data.to_dict() + socials.append(socials_type_0_item) + + else: + socials = self.socials + + achievements: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.achievements, Unset): + achievements = UNSET + elif isinstance(self.achievements, list): + achievements = [] + for achievements_type_0_item_data in self.achievements: + achievements_type_0_item = achievements_type_0_item_data.to_dict() + achievements.append(achievements_type_0_item) + + else: + achievements = self.achievements + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if platform is not UNSET: + field_dict["platform"] = platform + if avatar is not UNSET: + field_dict["avatar"] = avatar + if web_avatar is not UNSET: + field_dict["webAvatar"] = web_avatar + if country is not UNSET: + field_dict["country"] = country + if alias is not UNSET: + field_dict["alias"] = alias + if old_alias is not UNSET: + field_dict["oldAlias"] = old_alias + if role is not UNSET: + field_dict["role"] = role + if mapper_id is not UNSET: + field_dict["mapperId"] = mapper_id + if mapper is not UNSET: + field_dict["mapper"] = mapper + if pp is not UNSET: + field_dict["pp"] = pp + if acc_pp is not UNSET: + field_dict["accPp"] = acc_pp + if tech_pp is not UNSET: + field_dict["techPp"] = tech_pp + if pass_pp is not UNSET: + field_dict["passPp"] = pass_pp + if rank is not UNSET: + field_dict["rank"] = rank + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if last_week_pp is not UNSET: + field_dict["lastWeekPp"] = last_week_pp + if last_week_rank is not UNSET: + field_dict["lastWeekRank"] = last_week_rank + if last_week_country_rank is not UNSET: + field_dict["lastWeekCountryRank"] = last_week_country_rank + if banned is not UNSET: + field_dict["banned"] = banned + if bot is not UNSET: + field_dict["bot"] = bot + if inactive is not UNSET: + field_dict["inactive"] = inactive + if external_profile_url is not UNSET: + field_dict["externalProfileUrl"] = external_profile_url + if rich_bio_timeset is not UNSET: + field_dict["richBioTimeset"] = rich_bio_timeset + if created_at is not UNSET: + field_dict["createdAt"] = created_at + if speedrun_start is not UNSET: + field_dict["speedrunStart"] = speedrun_start + if score_stats_id is not UNSET: + field_dict["scoreStatsId"] = score_stats_id + if score_stats is not UNSET: + field_dict["scoreStats"] = score_stats + if clan_order is not UNSET: + field_dict["clanOrder"] = clan_order + if badges is not UNSET: + field_dict["badges"] = badges + if patreon_features is not UNSET: + field_dict["patreonFeatures"] = patreon_features + if profile_settings is not UNSET: + field_dict["profileSettings"] = profile_settings + if changes is not UNSET: + field_dict["changes"] = changes + if history is not UNSET: + field_dict["history"] = history + if events_participating is not UNSET: + field_dict["eventsParticipating"] = events_participating + if socials is not UNSET: + field_dict["socials"] = socials + if achievements is not UNSET: + field_dict["achievements"] = achievements + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.achievement import Achievement + from ..models.badge import Badge + from ..models.event_player import EventPlayer + from ..models.mapper import Mapper + from ..models.patreon_features import PatreonFeatures + from ..models.player_change import PlayerChange + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_score_stats_history import PlayerScoreStatsHistory + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + def _parse_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + avatar = _parse_avatar(d.pop("avatar", UNSET)) + + def _parse_web_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + web_avatar = _parse_web_avatar(d.pop("webAvatar", UNSET)) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + def _parse_alias(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + alias = _parse_alias(d.pop("alias", UNSET)) + + def _parse_old_alias(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + old_alias = _parse_old_alias(d.pop("oldAlias", UNSET)) + + def _parse_role(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + role = _parse_role(d.pop("role", UNSET)) + + def _parse_mapper_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + mapper_id = _parse_mapper_id(d.pop("mapperId", UNSET)) + + _mapper = d.pop("mapper", UNSET) + mapper: Union[Unset, Mapper] + if isinstance(_mapper, Unset): + mapper = UNSET + else: + mapper = Mapper.from_dict(_mapper) + + pp = d.pop("pp", UNSET) + + acc_pp = d.pop("accPp", UNSET) + + tech_pp = d.pop("techPp", UNSET) + + pass_pp = d.pop("passPp", UNSET) + + rank = d.pop("rank", UNSET) + + country_rank = d.pop("countryRank", UNSET) + + last_week_pp = d.pop("lastWeekPp", UNSET) + + last_week_rank = d.pop("lastWeekRank", UNSET) + + last_week_country_rank = d.pop("lastWeekCountryRank", UNSET) + + banned = d.pop("banned", UNSET) + + bot = d.pop("bot", UNSET) + + inactive = d.pop("inactive", UNSET) + + def _parse_external_profile_url(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + external_profile_url = _parse_external_profile_url(d.pop("externalProfileUrl", UNSET)) + + rich_bio_timeset = d.pop("richBioTimeset", UNSET) + + created_at = d.pop("createdAt", UNSET) + + speedrun_start = d.pop("speedrunStart", UNSET) + + def _parse_score_stats_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + score_stats_id = _parse_score_stats_id(d.pop("scoreStatsId", UNSET)) + + _score_stats = d.pop("scoreStats", UNSET) + score_stats: Union[Unset, PlayerScoreStats] + if isinstance(_score_stats, Unset): + score_stats = UNSET + else: + score_stats = PlayerScoreStats.from_dict(_score_stats) + + def _parse_clan_order(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + clan_order = _parse_clan_order(d.pop("clanOrder", UNSET)) + + def _parse_badges(data: object) -> Union[List["Badge"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + badges_type_0 = [] + _badges_type_0 = data + for badges_type_0_item_data in _badges_type_0: + badges_type_0_item = Badge.from_dict(badges_type_0_item_data) + + badges_type_0.append(badges_type_0_item) + + return badges_type_0 + except: # noqa: E722 + pass + return cast(Union[List["Badge"], None, Unset], data) + + badges = _parse_badges(d.pop("badges", UNSET)) + + _patreon_features = d.pop("patreonFeatures", UNSET) + patreon_features: Union[Unset, PatreonFeatures] + if isinstance(_patreon_features, Unset): + patreon_features = UNSET + else: + patreon_features = PatreonFeatures.from_dict(_patreon_features) + + _profile_settings = d.pop("profileSettings", UNSET) + profile_settings: Union[Unset, ProfileSettings] + if isinstance(_profile_settings, Unset): + profile_settings = UNSET + else: + profile_settings = ProfileSettings.from_dict(_profile_settings) + + def _parse_changes(data: object) -> Union[List["PlayerChange"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + changes_type_0 = [] + _changes_type_0 = data + for changes_type_0_item_data in _changes_type_0: + changes_type_0_item = PlayerChange.from_dict(changes_type_0_item_data) + + changes_type_0.append(changes_type_0_item) + + return changes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerChange"], None, Unset], data) + + changes = _parse_changes(d.pop("changes", UNSET)) + + def _parse_history(data: object) -> Union[List["PlayerScoreStatsHistory"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + history_type_0 = [] + _history_type_0 = data + for history_type_0_item_data in _history_type_0: + history_type_0_item = PlayerScoreStatsHistory.from_dict(history_type_0_item_data) + + history_type_0.append(history_type_0_item) + + return history_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerScoreStatsHistory"], None, Unset], data) + + history = _parse_history(d.pop("history", UNSET)) + + def _parse_events_participating(data: object) -> Union[List["EventPlayer"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + events_participating_type_0 = [] + _events_participating_type_0 = data + for events_participating_type_0_item_data in _events_participating_type_0: + events_participating_type_0_item = EventPlayer.from_dict(events_participating_type_0_item_data) + + events_participating_type_0.append(events_participating_type_0_item) + + return events_participating_type_0 + except: # noqa: E722 + pass + return cast(Union[List["EventPlayer"], None, Unset], data) + + events_participating = _parse_events_participating(d.pop("eventsParticipating", UNSET)) + + def _parse_socials(data: object) -> Union[List["PlayerSocial"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + socials_type_0 = [] + _socials_type_0 = data + for socials_type_0_item_data in _socials_type_0: + socials_type_0_item = PlayerSocial.from_dict(socials_type_0_item_data) + + socials_type_0.append(socials_type_0_item) + + return socials_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerSocial"], None, Unset], data) + + socials = _parse_socials(d.pop("socials", UNSET)) + + def _parse_achievements(data: object) -> Union[List["Achievement"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + achievements_type_0 = [] + _achievements_type_0 = data + for achievements_type_0_item_data in _achievements_type_0: + achievements_type_0_item = Achievement.from_dict(achievements_type_0_item_data) + + achievements_type_0.append(achievements_type_0_item) + + return achievements_type_0 + except: # noqa: E722 + pass + return cast(Union[List["Achievement"], None, Unset], data) + + achievements = _parse_achievements(d.pop("achievements", UNSET)) + + player = cls( + id=id, + name=name, + platform=platform, + avatar=avatar, + web_avatar=web_avatar, + country=country, + alias=alias, + old_alias=old_alias, + role=role, + mapper_id=mapper_id, + mapper=mapper, + pp=pp, + acc_pp=acc_pp, + tech_pp=tech_pp, + pass_pp=pass_pp, + rank=rank, + country_rank=country_rank, + last_week_pp=last_week_pp, + last_week_rank=last_week_rank, + last_week_country_rank=last_week_country_rank, + banned=banned, + bot=bot, + inactive=inactive, + external_profile_url=external_profile_url, + rich_bio_timeset=rich_bio_timeset, + created_at=created_at, + speedrun_start=speedrun_start, + score_stats_id=score_stats_id, + score_stats=score_stats, + clan_order=clan_order, + badges=badges, + patreon_features=patreon_features, + profile_settings=profile_settings, + changes=changes, + history=history, + events_participating=events_participating, + socials=socials, + achievements=achievements, + ) + + return player diff --git a/src/clients/beatleader/models/player_change.py b/src/clients/beatleader/models/player_change.py new file mode 100644 index 0000000..ac0e113 --- /dev/null +++ b/src/clients/beatleader/models/player_change.py @@ -0,0 +1,167 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlayerChange") + + +@_attrs_define +class PlayerChange: + """ + Attributes: + id (Union[Unset, int]): + timestamp (Union[Unset, int]): + player_id (Union[None, Unset, str]): + old_name (Union[None, Unset, str]): + new_name (Union[None, Unset, str]): + old_country (Union[None, Unset, str]): + new_country (Union[None, Unset, str]): + changer (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + timestamp: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + old_name: Union[None, Unset, str] = UNSET + new_name: Union[None, Unset, str] = UNSET + old_country: Union[None, Unset, str] = UNSET + new_country: Union[None, Unset, str] = UNSET + changer: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timestamp = self.timestamp + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + old_name: Union[None, Unset, str] + if isinstance(self.old_name, Unset): + old_name = UNSET + else: + old_name = self.old_name + + new_name: Union[None, Unset, str] + if isinstance(self.new_name, Unset): + new_name = UNSET + else: + new_name = self.new_name + + old_country: Union[None, Unset, str] + if isinstance(self.old_country, Unset): + old_country = UNSET + else: + old_country = self.old_country + + new_country: Union[None, Unset, str] + if isinstance(self.new_country, Unset): + new_country = UNSET + else: + new_country = self.new_country + + changer: Union[None, Unset, str] + if isinstance(self.changer, Unset): + changer = UNSET + else: + changer = self.changer + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timestamp is not UNSET: + field_dict["timestamp"] = timestamp + if player_id is not UNSET: + field_dict["playerId"] = player_id + if old_name is not UNSET: + field_dict["oldName"] = old_name + if new_name is not UNSET: + field_dict["newName"] = new_name + if old_country is not UNSET: + field_dict["oldCountry"] = old_country + if new_country is not UNSET: + field_dict["newCountry"] = new_country + if changer is not UNSET: + field_dict["changer"] = changer + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + timestamp = d.pop("timestamp", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + def _parse_old_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + old_name = _parse_old_name(d.pop("oldName", UNSET)) + + def _parse_new_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + new_name = _parse_new_name(d.pop("newName", UNSET)) + + def _parse_old_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + old_country = _parse_old_country(d.pop("oldCountry", UNSET)) + + def _parse_new_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + new_country = _parse_new_country(d.pop("newCountry", UNSET)) + + def _parse_changer(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + changer = _parse_changer(d.pop("changer", UNSET)) + + player_change = cls( + id=id, + timestamp=timestamp, + player_id=player_id, + old_name=old_name, + new_name=new_name, + old_country=old_country, + new_country=new_country, + changer=changer, + ) + + return player_change diff --git a/src/clients/beatleader/models/player_context_extension.py b/src/clients/beatleader/models/player_context_extension.py new file mode 100644 index 0000000..e8a3d27 --- /dev/null +++ b/src/clients/beatleader/models/player_context_extension.py @@ -0,0 +1,286 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.leaderboard_contexts import LeaderboardContexts +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.player import Player + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_search import PlayerSearch + + +T = TypeVar("T", bound="PlayerContextExtension") + + +@_attrs_define +class PlayerContextExtension: + """ + Attributes: + id (Union[Unset, int]): + context (Union[Unset, LeaderboardContexts]): + pp (Union[Unset, float]): + acc_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + rank (Union[Unset, int]): + country (Union[None, Unset, str]): + country_rank (Union[Unset, int]): + last_week_pp (Union[Unset, float]): + last_week_rank (Union[Unset, int]): + last_week_country_rank (Union[Unset, int]): + player_id (Union[None, Unset, str]): + player_instance (Union[Unset, Player]): + score_stats (Union[Unset, PlayerScoreStats]): + banned (Union[Unset, bool]): + searches (Union[List['PlayerSearch'], None, Unset]): + name (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + context: Union[Unset, LeaderboardContexts] = UNSET + pp: Union[Unset, float] = UNSET + acc_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country: Union[None, Unset, str] = UNSET + country_rank: Union[Unset, int] = UNSET + last_week_pp: Union[Unset, float] = UNSET + last_week_rank: Union[Unset, int] = UNSET + last_week_country_rank: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + player_instance: Union[Unset, "Player"] = UNSET + score_stats: Union[Unset, "PlayerScoreStats"] = UNSET + banned: Union[Unset, bool] = UNSET + searches: Union[List["PlayerSearch"], None, Unset] = UNSET + name: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + context: Union[Unset, str] = UNSET + if not isinstance(self.context, Unset): + context = self.context.value + + pp = self.pp + + acc_pp = self.acc_pp + + tech_pp = self.tech_pp + + pass_pp = self.pass_pp + + rank = self.rank + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + country_rank = self.country_rank + + last_week_pp = self.last_week_pp + + last_week_rank = self.last_week_rank + + last_week_country_rank = self.last_week_country_rank + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + player_instance: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.player_instance, Unset): + player_instance = self.player_instance.to_dict() + + score_stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score_stats, Unset): + score_stats = self.score_stats.to_dict() + + banned = self.banned + + searches: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.searches, Unset): + searches = UNSET + elif isinstance(self.searches, list): + searches = [] + for searches_type_0_item_data in self.searches: + searches_type_0_item = searches_type_0_item_data.to_dict() + searches.append(searches_type_0_item) + + else: + searches = self.searches + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if context is not UNSET: + field_dict["context"] = context + if pp is not UNSET: + field_dict["pp"] = pp + if acc_pp is not UNSET: + field_dict["accPp"] = acc_pp + if tech_pp is not UNSET: + field_dict["techPp"] = tech_pp + if pass_pp is not UNSET: + field_dict["passPp"] = pass_pp + if rank is not UNSET: + field_dict["rank"] = rank + if country is not UNSET: + field_dict["country"] = country + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if last_week_pp is not UNSET: + field_dict["lastWeekPp"] = last_week_pp + if last_week_rank is not UNSET: + field_dict["lastWeekRank"] = last_week_rank + if last_week_country_rank is not UNSET: + field_dict["lastWeekCountryRank"] = last_week_country_rank + if player_id is not UNSET: + field_dict["playerId"] = player_id + if player_instance is not UNSET: + field_dict["playerInstance"] = player_instance + if score_stats is not UNSET: + field_dict["scoreStats"] = score_stats + if banned is not UNSET: + field_dict["banned"] = banned + if searches is not UNSET: + field_dict["searches"] = searches + if name is not UNSET: + field_dict["name"] = name + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.player import Player + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_search import PlayerSearch + + d = src_dict.copy() + id = d.pop("id", UNSET) + + _context = d.pop("context", UNSET) + context: Union[Unset, LeaderboardContexts] + if isinstance(_context, Unset): + context = UNSET + else: + context = LeaderboardContexts(_context) + + pp = d.pop("pp", UNSET) + + acc_pp = d.pop("accPp", UNSET) + + tech_pp = d.pop("techPp", UNSET) + + pass_pp = d.pop("passPp", UNSET) + + rank = d.pop("rank", UNSET) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + country_rank = d.pop("countryRank", UNSET) + + last_week_pp = d.pop("lastWeekPp", UNSET) + + last_week_rank = d.pop("lastWeekRank", UNSET) + + last_week_country_rank = d.pop("lastWeekCountryRank", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + _player_instance = d.pop("playerInstance", UNSET) + player_instance: Union[Unset, Player] + if isinstance(_player_instance, Unset): + player_instance = UNSET + else: + player_instance = Player.from_dict(_player_instance) + + _score_stats = d.pop("scoreStats", UNSET) + score_stats: Union[Unset, PlayerScoreStats] + if isinstance(_score_stats, Unset): + score_stats = UNSET + else: + score_stats = PlayerScoreStats.from_dict(_score_stats) + + banned = d.pop("banned", UNSET) + + def _parse_searches(data: object) -> Union[List["PlayerSearch"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + searches_type_0 = [] + _searches_type_0 = data + for searches_type_0_item_data in _searches_type_0: + searches_type_0_item = PlayerSearch.from_dict(searches_type_0_item_data) + + searches_type_0.append(searches_type_0_item) + + return searches_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerSearch"], None, Unset], data) + + searches = _parse_searches(d.pop("searches", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + player_context_extension = cls( + id=id, + context=context, + pp=pp, + acc_pp=acc_pp, + tech_pp=tech_pp, + pass_pp=pass_pp, + rank=rank, + country=country, + country_rank=country_rank, + last_week_pp=last_week_pp, + last_week_rank=last_week_rank, + last_week_country_rank=last_week_country_rank, + player_id=player_id, + player_instance=player_instance, + score_stats=score_stats, + banned=banned, + searches=searches, + name=name, + ) + + return player_context_extension diff --git a/src/clients/beatleader/models/player_follower.py b/src/clients/beatleader/models/player_follower.py new file mode 100644 index 0000000..9faee49 --- /dev/null +++ b/src/clients/beatleader/models/player_follower.py @@ -0,0 +1,139 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlayerFollower") + + +@_attrs_define +class PlayerFollower: + """ + Attributes: + id (Union[None, Unset, str]): + alias (Union[None, Unset, str]): + name (Union[None, Unset, str]): + avatar (Union[None, Unset, str]): + count (Union[None, Unset, int]): + mutual (Union[Unset, bool]): + """ + + id: Union[None, Unset, str] = UNSET + alias: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + avatar: Union[None, Unset, str] = UNSET + count: Union[None, Unset, int] = UNSET + mutual: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + alias: Union[None, Unset, str] + if isinstance(self.alias, Unset): + alias = UNSET + else: + alias = self.alias + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + avatar: Union[None, Unset, str] + if isinstance(self.avatar, Unset): + avatar = UNSET + else: + avatar = self.avatar + + count: Union[None, Unset, int] + if isinstance(self.count, Unset): + count = UNSET + else: + count = self.count + + mutual = self.mutual + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if alias is not UNSET: + field_dict["alias"] = alias + if name is not UNSET: + field_dict["name"] = name + if avatar is not UNSET: + field_dict["avatar"] = avatar + if count is not UNSET: + field_dict["count"] = count + if mutual is not UNSET: + field_dict["mutual"] = mutual + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_alias(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + alias = _parse_alias(d.pop("alias", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + avatar = _parse_avatar(d.pop("avatar", UNSET)) + + def _parse_count(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + count = _parse_count(d.pop("count", UNSET)) + + mutual = d.pop("mutual", UNSET) + + player_follower = cls( + id=id, + alias=alias, + name=name, + avatar=avatar, + count=count, + mutual=mutual, + ) + + return player_follower diff --git a/src/clients/beatleader/models/player_followers_info_response.py b/src/clients/beatleader/models/player_followers_info_response.py new file mode 100644 index 0000000..c0e8b4f --- /dev/null +++ b/src/clients/beatleader/models/player_followers_info_response.py @@ -0,0 +1,150 @@ +from typing import Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlayerFollowersInfoResponse") + + +@_attrs_define +class PlayerFollowersInfoResponse: + """ + Attributes: + following_count (Union[None, Unset, int]): + me_following (Union[Unset, bool]): + following (Union[List[str], None, Unset]): + followers_count (Union[None, Unset, int]): + i_follow (Union[Unset, bool]): + followers (Union[List[str], None, Unset]): + """ + + following_count: Union[None, Unset, int] = UNSET + me_following: Union[Unset, bool] = UNSET + following: Union[List[str], None, Unset] = UNSET + followers_count: Union[None, Unset, int] = UNSET + i_follow: Union[Unset, bool] = UNSET + followers: Union[List[str], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + following_count: Union[None, Unset, int] + if isinstance(self.following_count, Unset): + following_count = UNSET + else: + following_count = self.following_count + + me_following = self.me_following + + following: Union[List[str], None, Unset] + if isinstance(self.following, Unset): + following = UNSET + elif isinstance(self.following, list): + following = self.following + + else: + following = self.following + + followers_count: Union[None, Unset, int] + if isinstance(self.followers_count, Unset): + followers_count = UNSET + else: + followers_count = self.followers_count + + i_follow = self.i_follow + + followers: Union[List[str], None, Unset] + if isinstance(self.followers, Unset): + followers = UNSET + elif isinstance(self.followers, list): + followers = self.followers + + else: + followers = self.followers + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if following_count is not UNSET: + field_dict["followingCount"] = following_count + if me_following is not UNSET: + field_dict["meFollowing"] = me_following + if following is not UNSET: + field_dict["following"] = following + if followers_count is not UNSET: + field_dict["followersCount"] = followers_count + if i_follow is not UNSET: + field_dict["iFollow"] = i_follow + if followers is not UNSET: + field_dict["followers"] = followers + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_following_count(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + following_count = _parse_following_count(d.pop("followingCount", UNSET)) + + me_following = d.pop("meFollowing", UNSET) + + def _parse_following(data: object) -> Union[List[str], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + following_type_0 = cast(List[str], data) + + return following_type_0 + except: # noqa: E722 + pass + return cast(Union[List[str], None, Unset], data) + + following = _parse_following(d.pop("following", UNSET)) + + def _parse_followers_count(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + followers_count = _parse_followers_count(d.pop("followersCount", UNSET)) + + i_follow = d.pop("iFollow", UNSET) + + def _parse_followers(data: object) -> Union[List[str], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + followers_type_0 = cast(List[str], data) + + return followers_type_0 + except: # noqa: E722 + pass + return cast(Union[List[str], None, Unset], data) + + followers = _parse_followers(d.pop("followers", UNSET)) + + player_followers_info_response = cls( + following_count=following_count, + me_following=me_following, + following=following, + followers_count=followers_count, + i_follow=i_follow, + followers=followers, + ) + + return player_followers_info_response diff --git a/src/clients/beatleader/models/player_response.py b/src/clients/beatleader/models/player_response.py new file mode 100644 index 0000000..823da1d --- /dev/null +++ b/src/clients/beatleader/models/player_response.py @@ -0,0 +1,391 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response import ClanResponse + from ..models.patreon_features import PatreonFeatures + from ..models.player_context_extension import PlayerContextExtension + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + + +T = TypeVar("T", bound="PlayerResponse") + + +@_attrs_define +class PlayerResponse: + """ + Attributes: + id (Union[None, Unset, str]): + name (Union[None, Unset, str]): + platform (Union[None, Unset, str]): + avatar (Union[None, Unset, str]): + country (Union[None, Unset, str]): + alias (Union[None, Unset, str]): + bot (Union[Unset, bool]): + pp (Union[Unset, float]): + rank (Union[Unset, int]): + country_rank (Union[Unset, int]): + role (Union[None, Unset, str]): + socials (Union[List['PlayerSocial'], None, Unset]): + context_extensions (Union[List['PlayerContextExtension'], None, Unset]): + patreon_features (Union[Unset, PatreonFeatures]): + profile_settings (Union[Unset, ProfileSettings]): + clan_order (Union[None, Unset, str]): + clans (Union[List['ClanResponse'], None, Unset]): + """ + + id: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + platform: Union[None, Unset, str] = UNSET + avatar: Union[None, Unset, str] = UNSET + country: Union[None, Unset, str] = UNSET + alias: Union[None, Unset, str] = UNSET + bot: Union[Unset, bool] = UNSET + pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country_rank: Union[Unset, int] = UNSET + role: Union[None, Unset, str] = UNSET + socials: Union[List["PlayerSocial"], None, Unset] = UNSET + context_extensions: Union[List["PlayerContextExtension"], None, Unset] = UNSET + patreon_features: Union[Unset, "PatreonFeatures"] = UNSET + profile_settings: Union[Unset, "ProfileSettings"] = UNSET + clan_order: Union[None, Unset, str] = UNSET + clans: Union[List["ClanResponse"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + platform: Union[None, Unset, str] + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + avatar: Union[None, Unset, str] + if isinstance(self.avatar, Unset): + avatar = UNSET + else: + avatar = self.avatar + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + alias: Union[None, Unset, str] + if isinstance(self.alias, Unset): + alias = UNSET + else: + alias = self.alias + + bot = self.bot + + pp = self.pp + + rank = self.rank + + country_rank = self.country_rank + + role: Union[None, Unset, str] + if isinstance(self.role, Unset): + role = UNSET + else: + role = self.role + + socials: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.socials, Unset): + socials = UNSET + elif isinstance(self.socials, list): + socials = [] + for socials_type_0_item_data in self.socials: + socials_type_0_item = socials_type_0_item_data.to_dict() + socials.append(socials_type_0_item) + + else: + socials = self.socials + + context_extensions: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.context_extensions, Unset): + context_extensions = UNSET + elif isinstance(self.context_extensions, list): + context_extensions = [] + for context_extensions_type_0_item_data in self.context_extensions: + context_extensions_type_0_item = context_extensions_type_0_item_data.to_dict() + context_extensions.append(context_extensions_type_0_item) + + else: + context_extensions = self.context_extensions + + patreon_features: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.patreon_features, Unset): + patreon_features = self.patreon_features.to_dict() + + profile_settings: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.profile_settings, Unset): + profile_settings = self.profile_settings.to_dict() + + clan_order: Union[None, Unset, str] + if isinstance(self.clan_order, Unset): + clan_order = UNSET + else: + clan_order = self.clan_order + + clans: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.clans, Unset): + clans = UNSET + elif isinstance(self.clans, list): + clans = [] + for clans_type_0_item_data in self.clans: + clans_type_0_item = clans_type_0_item_data.to_dict() + clans.append(clans_type_0_item) + + else: + clans = self.clans + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if platform is not UNSET: + field_dict["platform"] = platform + if avatar is not UNSET: + field_dict["avatar"] = avatar + if country is not UNSET: + field_dict["country"] = country + if alias is not UNSET: + field_dict["alias"] = alias + if bot is not UNSET: + field_dict["bot"] = bot + if pp is not UNSET: + field_dict["pp"] = pp + if rank is not UNSET: + field_dict["rank"] = rank + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if role is not UNSET: + field_dict["role"] = role + if socials is not UNSET: + field_dict["socials"] = socials + if context_extensions is not UNSET: + field_dict["contextExtensions"] = context_extensions + if patreon_features is not UNSET: + field_dict["patreonFeatures"] = patreon_features + if profile_settings is not UNSET: + field_dict["profileSettings"] = profile_settings + if clan_order is not UNSET: + field_dict["clanOrder"] = clan_order + if clans is not UNSET: + field_dict["clans"] = clans + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response import ClanResponse + from ..models.patreon_features import PatreonFeatures + from ..models.player_context_extension import PlayerContextExtension + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + def _parse_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + avatar = _parse_avatar(d.pop("avatar", UNSET)) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + def _parse_alias(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + alias = _parse_alias(d.pop("alias", UNSET)) + + bot = d.pop("bot", UNSET) + + pp = d.pop("pp", UNSET) + + rank = d.pop("rank", UNSET) + + country_rank = d.pop("countryRank", UNSET) + + def _parse_role(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + role = _parse_role(d.pop("role", UNSET)) + + def _parse_socials(data: object) -> Union[List["PlayerSocial"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + socials_type_0 = [] + _socials_type_0 = data + for socials_type_0_item_data in _socials_type_0: + socials_type_0_item = PlayerSocial.from_dict(socials_type_0_item_data) + + socials_type_0.append(socials_type_0_item) + + return socials_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerSocial"], None, Unset], data) + + socials = _parse_socials(d.pop("socials", UNSET)) + + def _parse_context_extensions(data: object) -> Union[List["PlayerContextExtension"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + context_extensions_type_0 = [] + _context_extensions_type_0 = data + for context_extensions_type_0_item_data in _context_extensions_type_0: + context_extensions_type_0_item = PlayerContextExtension.from_dict( + context_extensions_type_0_item_data + ) + + context_extensions_type_0.append(context_extensions_type_0_item) + + return context_extensions_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerContextExtension"], None, Unset], data) + + context_extensions = _parse_context_extensions(d.pop("contextExtensions", UNSET)) + + _patreon_features = d.pop("patreonFeatures", UNSET) + patreon_features: Union[Unset, PatreonFeatures] + if isinstance(_patreon_features, Unset): + patreon_features = UNSET + else: + patreon_features = PatreonFeatures.from_dict(_patreon_features) + + _profile_settings = d.pop("profileSettings", UNSET) + profile_settings: Union[Unset, ProfileSettings] + if isinstance(_profile_settings, Unset): + profile_settings = UNSET + else: + profile_settings = ProfileSettings.from_dict(_profile_settings) + + def _parse_clan_order(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + clan_order = _parse_clan_order(d.pop("clanOrder", UNSET)) + + def _parse_clans(data: object) -> Union[List["ClanResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + clans_type_0 = [] + _clans_type_0 = data + for clans_type_0_item_data in _clans_type_0: + clans_type_0_item = ClanResponse.from_dict(clans_type_0_item_data) + + clans_type_0.append(clans_type_0_item) + + return clans_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanResponse"], None, Unset], data) + + clans = _parse_clans(d.pop("clans", UNSET)) + + player_response = cls( + id=id, + name=name, + platform=platform, + avatar=avatar, + country=country, + alias=alias, + bot=bot, + pp=pp, + rank=rank, + country_rank=country_rank, + role=role, + socials=socials, + context_extensions=context_extensions, + patreon_features=patreon_features, + profile_settings=profile_settings, + clan_order=clan_order, + clans=clans, + ) + + return player_response diff --git a/src/clients/beatleader/models/player_response_clan_response_full_response_with_metadata_and_container.py b/src/clients/beatleader/models/player_response_clan_response_full_response_with_metadata_and_container.py new file mode 100644 index 0000000..4021de9 --- /dev/null +++ b/src/clients/beatleader/models/player_response_clan_response_full_response_with_metadata_and_container.py @@ -0,0 +1,110 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response_full import ClanResponseFull + from ..models.metadata import Metadata + from ..models.player_response import PlayerResponse + + +T = TypeVar("T", bound="PlayerResponseClanResponseFullResponseWithMetadataAndContainer") + + +@_attrs_define +class PlayerResponseClanResponseFullResponseWithMetadataAndContainer: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['PlayerResponse'], None, Unset]): + container (Union[Unset, ClanResponseFull]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["PlayerResponse"], None, Unset] = UNSET + container: Union[Unset, "ClanResponseFull"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + container: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.container, Unset): + container = self.container.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + if container is not UNSET: + field_dict["container"] = container + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response_full import ClanResponseFull + from ..models.metadata import Metadata + from ..models.player_response import PlayerResponse + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["PlayerResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = PlayerResponse.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerResponse"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + _container = d.pop("container", UNSET) + container: Union[Unset, ClanResponseFull] + if isinstance(_container, Unset): + container = UNSET + else: + container = ClanResponseFull.from_dict(_container) + + player_response_clan_response_full_response_with_metadata_and_container = cls( + metadata=metadata, + data=data, + container=container, + ) + + return player_response_clan_response_full_response_with_metadata_and_container diff --git a/src/clients/beatleader/models/player_response_full.py b/src/clients/beatleader/models/player_response_full.py new file mode 100644 index 0000000..a96c592 --- /dev/null +++ b/src/clients/beatleader/models/player_response_full.py @@ -0,0 +1,737 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.badge import Badge + from ..models.ban import Ban + from ..models.clan_response import ClanResponse + from ..models.link_response import LinkResponse + from ..models.patreon_features import PatreonFeatures + from ..models.player_change import PlayerChange + from ..models.player_context_extension import PlayerContextExtension + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_score_stats_history import PlayerScoreStatsHistory + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + from ..models.score_response_with_my_score import ScoreResponseWithMyScore + + +T = TypeVar("T", bound="PlayerResponseFull") + + +@_attrs_define +class PlayerResponseFull: + """ + Attributes: + id (Union[None, Unset, str]): + name (Union[None, Unset, str]): + platform (Union[None, Unset, str]): + avatar (Union[None, Unset, str]): + country (Union[None, Unset, str]): + alias (Union[None, Unset, str]): + bot (Union[Unset, bool]): + pp (Union[Unset, float]): + rank (Union[Unset, int]): + country_rank (Union[Unset, int]): + role (Union[None, Unset, str]): + socials (Union[List['PlayerSocial'], None, Unset]): + context_extensions (Union[List['PlayerContextExtension'], None, Unset]): + patreon_features (Union[Unset, PatreonFeatures]): + profile_settings (Union[Unset, ProfileSettings]): + clan_order (Union[None, Unset, str]): + clans (Union[List['ClanResponse'], None, Unset]): + acc_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + score_stats (Union[Unset, PlayerScoreStats]): + last_week_pp (Union[Unset, float]): + last_week_rank (Union[Unset, int]): + last_week_country_rank (Union[Unset, int]): + extension_id (Union[Unset, int]): + mapper_id (Union[Unset, int]): + banned (Union[Unset, bool]): + inactive (Union[Unset, bool]): + ban_description (Union[Unset, Ban]): + external_profile_url (Union[None, Unset, str]): + rich_bio_timeset (Union[Unset, int]): + speedrun_start (Union[Unset, int]): + linked_ids (Union[Unset, LinkResponse]): + history (Union[List['PlayerScoreStatsHistory'], None, Unset]): + badges (Union[List['Badge'], None, Unset]): + pinned_scores (Union[List['ScoreResponseWithMyScore'], None, Unset]): + changes (Union[List['PlayerChange'], None, Unset]): + """ + + id: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + platform: Union[None, Unset, str] = UNSET + avatar: Union[None, Unset, str] = UNSET + country: Union[None, Unset, str] = UNSET + alias: Union[None, Unset, str] = UNSET + bot: Union[Unset, bool] = UNSET + pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country_rank: Union[Unset, int] = UNSET + role: Union[None, Unset, str] = UNSET + socials: Union[List["PlayerSocial"], None, Unset] = UNSET + context_extensions: Union[List["PlayerContextExtension"], None, Unset] = UNSET + patreon_features: Union[Unset, "PatreonFeatures"] = UNSET + profile_settings: Union[Unset, "ProfileSettings"] = UNSET + clan_order: Union[None, Unset, str] = UNSET + clans: Union[List["ClanResponse"], None, Unset] = UNSET + acc_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + score_stats: Union[Unset, "PlayerScoreStats"] = UNSET + last_week_pp: Union[Unset, float] = UNSET + last_week_rank: Union[Unset, int] = UNSET + last_week_country_rank: Union[Unset, int] = UNSET + extension_id: Union[Unset, int] = UNSET + mapper_id: Union[Unset, int] = UNSET + banned: Union[Unset, bool] = UNSET + inactive: Union[Unset, bool] = UNSET + ban_description: Union[Unset, "Ban"] = UNSET + external_profile_url: Union[None, Unset, str] = UNSET + rich_bio_timeset: Union[Unset, int] = UNSET + speedrun_start: Union[Unset, int] = UNSET + linked_ids: Union[Unset, "LinkResponse"] = UNSET + history: Union[List["PlayerScoreStatsHistory"], None, Unset] = UNSET + badges: Union[List["Badge"], None, Unset] = UNSET + pinned_scores: Union[List["ScoreResponseWithMyScore"], None, Unset] = UNSET + changes: Union[List["PlayerChange"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + platform: Union[None, Unset, str] + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + avatar: Union[None, Unset, str] + if isinstance(self.avatar, Unset): + avatar = UNSET + else: + avatar = self.avatar + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + alias: Union[None, Unset, str] + if isinstance(self.alias, Unset): + alias = UNSET + else: + alias = self.alias + + bot = self.bot + + pp = self.pp + + rank = self.rank + + country_rank = self.country_rank + + role: Union[None, Unset, str] + if isinstance(self.role, Unset): + role = UNSET + else: + role = self.role + + socials: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.socials, Unset): + socials = UNSET + elif isinstance(self.socials, list): + socials = [] + for socials_type_0_item_data in self.socials: + socials_type_0_item = socials_type_0_item_data.to_dict() + socials.append(socials_type_0_item) + + else: + socials = self.socials + + context_extensions: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.context_extensions, Unset): + context_extensions = UNSET + elif isinstance(self.context_extensions, list): + context_extensions = [] + for context_extensions_type_0_item_data in self.context_extensions: + context_extensions_type_0_item = context_extensions_type_0_item_data.to_dict() + context_extensions.append(context_extensions_type_0_item) + + else: + context_extensions = self.context_extensions + + patreon_features: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.patreon_features, Unset): + patreon_features = self.patreon_features.to_dict() + + profile_settings: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.profile_settings, Unset): + profile_settings = self.profile_settings.to_dict() + + clan_order: Union[None, Unset, str] + if isinstance(self.clan_order, Unset): + clan_order = UNSET + else: + clan_order = self.clan_order + + clans: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.clans, Unset): + clans = UNSET + elif isinstance(self.clans, list): + clans = [] + for clans_type_0_item_data in self.clans: + clans_type_0_item = clans_type_0_item_data.to_dict() + clans.append(clans_type_0_item) + + else: + clans = self.clans + + acc_pp = self.acc_pp + + pass_pp = self.pass_pp + + tech_pp = self.tech_pp + + score_stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score_stats, Unset): + score_stats = self.score_stats.to_dict() + + last_week_pp = self.last_week_pp + + last_week_rank = self.last_week_rank + + last_week_country_rank = self.last_week_country_rank + + extension_id = self.extension_id + + mapper_id = self.mapper_id + + banned = self.banned + + inactive = self.inactive + + ban_description: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.ban_description, Unset): + ban_description = self.ban_description.to_dict() + + external_profile_url: Union[None, Unset, str] + if isinstance(self.external_profile_url, Unset): + external_profile_url = UNSET + else: + external_profile_url = self.external_profile_url + + rich_bio_timeset = self.rich_bio_timeset + + speedrun_start = self.speedrun_start + + linked_ids: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.linked_ids, Unset): + linked_ids = self.linked_ids.to_dict() + + history: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.history, Unset): + history = UNSET + elif isinstance(self.history, list): + history = [] + for history_type_0_item_data in self.history: + history_type_0_item = history_type_0_item_data.to_dict() + history.append(history_type_0_item) + + else: + history = self.history + + badges: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.badges, Unset): + badges = UNSET + elif isinstance(self.badges, list): + badges = [] + for badges_type_0_item_data in self.badges: + badges_type_0_item = badges_type_0_item_data.to_dict() + badges.append(badges_type_0_item) + + else: + badges = self.badges + + pinned_scores: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.pinned_scores, Unset): + pinned_scores = UNSET + elif isinstance(self.pinned_scores, list): + pinned_scores = [] + for pinned_scores_type_0_item_data in self.pinned_scores: + pinned_scores_type_0_item = pinned_scores_type_0_item_data.to_dict() + pinned_scores.append(pinned_scores_type_0_item) + + else: + pinned_scores = self.pinned_scores + + changes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.changes, Unset): + changes = UNSET + elif isinstance(self.changes, list): + changes = [] + for changes_type_0_item_data in self.changes: + changes_type_0_item = changes_type_0_item_data.to_dict() + changes.append(changes_type_0_item) + + else: + changes = self.changes + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if platform is not UNSET: + field_dict["platform"] = platform + if avatar is not UNSET: + field_dict["avatar"] = avatar + if country is not UNSET: + field_dict["country"] = country + if alias is not UNSET: + field_dict["alias"] = alias + if bot is not UNSET: + field_dict["bot"] = bot + if pp is not UNSET: + field_dict["pp"] = pp + if rank is not UNSET: + field_dict["rank"] = rank + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if role is not UNSET: + field_dict["role"] = role + if socials is not UNSET: + field_dict["socials"] = socials + if context_extensions is not UNSET: + field_dict["contextExtensions"] = context_extensions + if patreon_features is not UNSET: + field_dict["patreonFeatures"] = patreon_features + if profile_settings is not UNSET: + field_dict["profileSettings"] = profile_settings + if clan_order is not UNSET: + field_dict["clanOrder"] = clan_order + if clans is not UNSET: + field_dict["clans"] = clans + if acc_pp is not UNSET: + field_dict["accPp"] = acc_pp + if pass_pp is not UNSET: + field_dict["passPp"] = pass_pp + if tech_pp is not UNSET: + field_dict["techPp"] = tech_pp + if score_stats is not UNSET: + field_dict["scoreStats"] = score_stats + if last_week_pp is not UNSET: + field_dict["lastWeekPp"] = last_week_pp + if last_week_rank is not UNSET: + field_dict["lastWeekRank"] = last_week_rank + if last_week_country_rank is not UNSET: + field_dict["lastWeekCountryRank"] = last_week_country_rank + if extension_id is not UNSET: + field_dict["extensionId"] = extension_id + if mapper_id is not UNSET: + field_dict["mapperId"] = mapper_id + if banned is not UNSET: + field_dict["banned"] = banned + if inactive is not UNSET: + field_dict["inactive"] = inactive + if ban_description is not UNSET: + field_dict["banDescription"] = ban_description + if external_profile_url is not UNSET: + field_dict["externalProfileUrl"] = external_profile_url + if rich_bio_timeset is not UNSET: + field_dict["richBioTimeset"] = rich_bio_timeset + if speedrun_start is not UNSET: + field_dict["speedrunStart"] = speedrun_start + if linked_ids is not UNSET: + field_dict["linkedIds"] = linked_ids + if history is not UNSET: + field_dict["history"] = history + if badges is not UNSET: + field_dict["badges"] = badges + if pinned_scores is not UNSET: + field_dict["pinnedScores"] = pinned_scores + if changes is not UNSET: + field_dict["changes"] = changes + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.badge import Badge + from ..models.ban import Ban + from ..models.clan_response import ClanResponse + from ..models.link_response import LinkResponse + from ..models.patreon_features import PatreonFeatures + from ..models.player_change import PlayerChange + from ..models.player_context_extension import PlayerContextExtension + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_score_stats_history import PlayerScoreStatsHistory + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + from ..models.score_response_with_my_score import ScoreResponseWithMyScore + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + def _parse_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + avatar = _parse_avatar(d.pop("avatar", UNSET)) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + def _parse_alias(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + alias = _parse_alias(d.pop("alias", UNSET)) + + bot = d.pop("bot", UNSET) + + pp = d.pop("pp", UNSET) + + rank = d.pop("rank", UNSET) + + country_rank = d.pop("countryRank", UNSET) + + def _parse_role(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + role = _parse_role(d.pop("role", UNSET)) + + def _parse_socials(data: object) -> Union[List["PlayerSocial"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + socials_type_0 = [] + _socials_type_0 = data + for socials_type_0_item_data in _socials_type_0: + socials_type_0_item = PlayerSocial.from_dict(socials_type_0_item_data) + + socials_type_0.append(socials_type_0_item) + + return socials_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerSocial"], None, Unset], data) + + socials = _parse_socials(d.pop("socials", UNSET)) + + def _parse_context_extensions(data: object) -> Union[List["PlayerContextExtension"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + context_extensions_type_0 = [] + _context_extensions_type_0 = data + for context_extensions_type_0_item_data in _context_extensions_type_0: + context_extensions_type_0_item = PlayerContextExtension.from_dict( + context_extensions_type_0_item_data + ) + + context_extensions_type_0.append(context_extensions_type_0_item) + + return context_extensions_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerContextExtension"], None, Unset], data) + + context_extensions = _parse_context_extensions(d.pop("contextExtensions", UNSET)) + + _patreon_features = d.pop("patreonFeatures", UNSET) + patreon_features: Union[Unset, PatreonFeatures] + if isinstance(_patreon_features, Unset): + patreon_features = UNSET + else: + patreon_features = PatreonFeatures.from_dict(_patreon_features) + + _profile_settings = d.pop("profileSettings", UNSET) + profile_settings: Union[Unset, ProfileSettings] + if isinstance(_profile_settings, Unset): + profile_settings = UNSET + else: + profile_settings = ProfileSettings.from_dict(_profile_settings) + + def _parse_clan_order(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + clan_order = _parse_clan_order(d.pop("clanOrder", UNSET)) + + def _parse_clans(data: object) -> Union[List["ClanResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + clans_type_0 = [] + _clans_type_0 = data + for clans_type_0_item_data in _clans_type_0: + clans_type_0_item = ClanResponse.from_dict(clans_type_0_item_data) + + clans_type_0.append(clans_type_0_item) + + return clans_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanResponse"], None, Unset], data) + + clans = _parse_clans(d.pop("clans", UNSET)) + + acc_pp = d.pop("accPp", UNSET) + + pass_pp = d.pop("passPp", UNSET) + + tech_pp = d.pop("techPp", UNSET) + + _score_stats = d.pop("scoreStats", UNSET) + score_stats: Union[Unset, PlayerScoreStats] + if isinstance(_score_stats, Unset): + score_stats = UNSET + else: + score_stats = PlayerScoreStats.from_dict(_score_stats) + + last_week_pp = d.pop("lastWeekPp", UNSET) + + last_week_rank = d.pop("lastWeekRank", UNSET) + + last_week_country_rank = d.pop("lastWeekCountryRank", UNSET) + + extension_id = d.pop("extensionId", UNSET) + + mapper_id = d.pop("mapperId", UNSET) + + banned = d.pop("banned", UNSET) + + inactive = d.pop("inactive", UNSET) + + _ban_description = d.pop("banDescription", UNSET) + ban_description: Union[Unset, Ban] + if isinstance(_ban_description, Unset): + ban_description = UNSET + else: + ban_description = Ban.from_dict(_ban_description) + + def _parse_external_profile_url(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + external_profile_url = _parse_external_profile_url(d.pop("externalProfileUrl", UNSET)) + + rich_bio_timeset = d.pop("richBioTimeset", UNSET) + + speedrun_start = d.pop("speedrunStart", UNSET) + + _linked_ids = d.pop("linkedIds", UNSET) + linked_ids: Union[Unset, LinkResponse] + if isinstance(_linked_ids, Unset): + linked_ids = UNSET + else: + linked_ids = LinkResponse.from_dict(_linked_ids) + + def _parse_history(data: object) -> Union[List["PlayerScoreStatsHistory"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + history_type_0 = [] + _history_type_0 = data + for history_type_0_item_data in _history_type_0: + history_type_0_item = PlayerScoreStatsHistory.from_dict(history_type_0_item_data) + + history_type_0.append(history_type_0_item) + + return history_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerScoreStatsHistory"], None, Unset], data) + + history = _parse_history(d.pop("history", UNSET)) + + def _parse_badges(data: object) -> Union[List["Badge"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + badges_type_0 = [] + _badges_type_0 = data + for badges_type_0_item_data in _badges_type_0: + badges_type_0_item = Badge.from_dict(badges_type_0_item_data) + + badges_type_0.append(badges_type_0_item) + + return badges_type_0 + except: # noqa: E722 + pass + return cast(Union[List["Badge"], None, Unset], data) + + badges = _parse_badges(d.pop("badges", UNSET)) + + def _parse_pinned_scores(data: object) -> Union[List["ScoreResponseWithMyScore"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + pinned_scores_type_0 = [] + _pinned_scores_type_0 = data + for pinned_scores_type_0_item_data in _pinned_scores_type_0: + pinned_scores_type_0_item = ScoreResponseWithMyScore.from_dict(pinned_scores_type_0_item_data) + + pinned_scores_type_0.append(pinned_scores_type_0_item) + + return pinned_scores_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ScoreResponseWithMyScore"], None, Unset], data) + + pinned_scores = _parse_pinned_scores(d.pop("pinnedScores", UNSET)) + + def _parse_changes(data: object) -> Union[List["PlayerChange"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + changes_type_0 = [] + _changes_type_0 = data + for changes_type_0_item_data in _changes_type_0: + changes_type_0_item = PlayerChange.from_dict(changes_type_0_item_data) + + changes_type_0.append(changes_type_0_item) + + return changes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerChange"], None, Unset], data) + + changes = _parse_changes(d.pop("changes", UNSET)) + + player_response_full = cls( + id=id, + name=name, + platform=platform, + avatar=avatar, + country=country, + alias=alias, + bot=bot, + pp=pp, + rank=rank, + country_rank=country_rank, + role=role, + socials=socials, + context_extensions=context_extensions, + patreon_features=patreon_features, + profile_settings=profile_settings, + clan_order=clan_order, + clans=clans, + acc_pp=acc_pp, + pass_pp=pass_pp, + tech_pp=tech_pp, + score_stats=score_stats, + last_week_pp=last_week_pp, + last_week_rank=last_week_rank, + last_week_country_rank=last_week_country_rank, + extension_id=extension_id, + mapper_id=mapper_id, + banned=banned, + inactive=inactive, + ban_description=ban_description, + external_profile_url=external_profile_url, + rich_bio_timeset=rich_bio_timeset, + speedrun_start=speedrun_start, + linked_ids=linked_ids, + history=history, + badges=badges, + pinned_scores=pinned_scores, + changes=changes, + ) + + return player_response_full diff --git a/src/clients/beatleader/models/player_response_with_stats.py b/src/clients/beatleader/models/player_response_with_stats.py new file mode 100644 index 0000000..3029013 --- /dev/null +++ b/src/clients/beatleader/models/player_response_with_stats.py @@ -0,0 +1,472 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.clan_response import ClanResponse + from ..models.patreon_features import PatreonFeatures + from ..models.player_context_extension import PlayerContextExtension + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + + +T = TypeVar("T", bound="PlayerResponseWithStats") + + +@_attrs_define +class PlayerResponseWithStats: + """ + Attributes: + id (Union[None, Unset, str]): + name (Union[None, Unset, str]): + platform (Union[None, Unset, str]): + avatar (Union[None, Unset, str]): + country (Union[None, Unset, str]): + alias (Union[None, Unset, str]): + bot (Union[Unset, bool]): + pp (Union[Unset, float]): + rank (Union[Unset, int]): + country_rank (Union[Unset, int]): + role (Union[None, Unset, str]): + socials (Union[List['PlayerSocial'], None, Unset]): + context_extensions (Union[List['PlayerContextExtension'], None, Unset]): + patreon_features (Union[Unset, PatreonFeatures]): + profile_settings (Union[Unset, ProfileSettings]): + clan_order (Union[None, Unset, str]): + clans (Union[List['ClanResponse'], None, Unset]): + acc_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + score_stats (Union[Unset, PlayerScoreStats]): + last_week_pp (Union[Unset, float]): + last_week_rank (Union[Unset, int]): + last_week_country_rank (Union[Unset, int]): + extension_id (Union[Unset, int]): + """ + + id: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + platform: Union[None, Unset, str] = UNSET + avatar: Union[None, Unset, str] = UNSET + country: Union[None, Unset, str] = UNSET + alias: Union[None, Unset, str] = UNSET + bot: Union[Unset, bool] = UNSET + pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country_rank: Union[Unset, int] = UNSET + role: Union[None, Unset, str] = UNSET + socials: Union[List["PlayerSocial"], None, Unset] = UNSET + context_extensions: Union[List["PlayerContextExtension"], None, Unset] = UNSET + patreon_features: Union[Unset, "PatreonFeatures"] = UNSET + profile_settings: Union[Unset, "ProfileSettings"] = UNSET + clan_order: Union[None, Unset, str] = UNSET + clans: Union[List["ClanResponse"], None, Unset] = UNSET + acc_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + score_stats: Union[Unset, "PlayerScoreStats"] = UNSET + last_week_pp: Union[Unset, float] = UNSET + last_week_rank: Union[Unset, int] = UNSET + last_week_country_rank: Union[Unset, int] = UNSET + extension_id: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + platform: Union[None, Unset, str] + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + avatar: Union[None, Unset, str] + if isinstance(self.avatar, Unset): + avatar = UNSET + else: + avatar = self.avatar + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + alias: Union[None, Unset, str] + if isinstance(self.alias, Unset): + alias = UNSET + else: + alias = self.alias + + bot = self.bot + + pp = self.pp + + rank = self.rank + + country_rank = self.country_rank + + role: Union[None, Unset, str] + if isinstance(self.role, Unset): + role = UNSET + else: + role = self.role + + socials: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.socials, Unset): + socials = UNSET + elif isinstance(self.socials, list): + socials = [] + for socials_type_0_item_data in self.socials: + socials_type_0_item = socials_type_0_item_data.to_dict() + socials.append(socials_type_0_item) + + else: + socials = self.socials + + context_extensions: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.context_extensions, Unset): + context_extensions = UNSET + elif isinstance(self.context_extensions, list): + context_extensions = [] + for context_extensions_type_0_item_data in self.context_extensions: + context_extensions_type_0_item = context_extensions_type_0_item_data.to_dict() + context_extensions.append(context_extensions_type_0_item) + + else: + context_extensions = self.context_extensions + + patreon_features: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.patreon_features, Unset): + patreon_features = self.patreon_features.to_dict() + + profile_settings: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.profile_settings, Unset): + profile_settings = self.profile_settings.to_dict() + + clan_order: Union[None, Unset, str] + if isinstance(self.clan_order, Unset): + clan_order = UNSET + else: + clan_order = self.clan_order + + clans: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.clans, Unset): + clans = UNSET + elif isinstance(self.clans, list): + clans = [] + for clans_type_0_item_data in self.clans: + clans_type_0_item = clans_type_0_item_data.to_dict() + clans.append(clans_type_0_item) + + else: + clans = self.clans + + acc_pp = self.acc_pp + + pass_pp = self.pass_pp + + tech_pp = self.tech_pp + + score_stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score_stats, Unset): + score_stats = self.score_stats.to_dict() + + last_week_pp = self.last_week_pp + + last_week_rank = self.last_week_rank + + last_week_country_rank = self.last_week_country_rank + + extension_id = self.extension_id + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if platform is not UNSET: + field_dict["platform"] = platform + if avatar is not UNSET: + field_dict["avatar"] = avatar + if country is not UNSET: + field_dict["country"] = country + if alias is not UNSET: + field_dict["alias"] = alias + if bot is not UNSET: + field_dict["bot"] = bot + if pp is not UNSET: + field_dict["pp"] = pp + if rank is not UNSET: + field_dict["rank"] = rank + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if role is not UNSET: + field_dict["role"] = role + if socials is not UNSET: + field_dict["socials"] = socials + if context_extensions is not UNSET: + field_dict["contextExtensions"] = context_extensions + if patreon_features is not UNSET: + field_dict["patreonFeatures"] = patreon_features + if profile_settings is not UNSET: + field_dict["profileSettings"] = profile_settings + if clan_order is not UNSET: + field_dict["clanOrder"] = clan_order + if clans is not UNSET: + field_dict["clans"] = clans + if acc_pp is not UNSET: + field_dict["accPp"] = acc_pp + if pass_pp is not UNSET: + field_dict["passPp"] = pass_pp + if tech_pp is not UNSET: + field_dict["techPp"] = tech_pp + if score_stats is not UNSET: + field_dict["scoreStats"] = score_stats + if last_week_pp is not UNSET: + field_dict["lastWeekPp"] = last_week_pp + if last_week_rank is not UNSET: + field_dict["lastWeekRank"] = last_week_rank + if last_week_country_rank is not UNSET: + field_dict["lastWeekCountryRank"] = last_week_country_rank + if extension_id is not UNSET: + field_dict["extensionId"] = extension_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.clan_response import ClanResponse + from ..models.patreon_features import PatreonFeatures + from ..models.player_context_extension import PlayerContextExtension + from ..models.player_score_stats import PlayerScoreStats + from ..models.player_social import PlayerSocial + from ..models.profile_settings import ProfileSettings + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + def _parse_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + avatar = _parse_avatar(d.pop("avatar", UNSET)) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + def _parse_alias(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + alias = _parse_alias(d.pop("alias", UNSET)) + + bot = d.pop("bot", UNSET) + + pp = d.pop("pp", UNSET) + + rank = d.pop("rank", UNSET) + + country_rank = d.pop("countryRank", UNSET) + + def _parse_role(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + role = _parse_role(d.pop("role", UNSET)) + + def _parse_socials(data: object) -> Union[List["PlayerSocial"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + socials_type_0 = [] + _socials_type_0 = data + for socials_type_0_item_data in _socials_type_0: + socials_type_0_item = PlayerSocial.from_dict(socials_type_0_item_data) + + socials_type_0.append(socials_type_0_item) + + return socials_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerSocial"], None, Unset], data) + + socials = _parse_socials(d.pop("socials", UNSET)) + + def _parse_context_extensions(data: object) -> Union[List["PlayerContextExtension"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + context_extensions_type_0 = [] + _context_extensions_type_0 = data + for context_extensions_type_0_item_data in _context_extensions_type_0: + context_extensions_type_0_item = PlayerContextExtension.from_dict( + context_extensions_type_0_item_data + ) + + context_extensions_type_0.append(context_extensions_type_0_item) + + return context_extensions_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerContextExtension"], None, Unset], data) + + context_extensions = _parse_context_extensions(d.pop("contextExtensions", UNSET)) + + _patreon_features = d.pop("patreonFeatures", UNSET) + patreon_features: Union[Unset, PatreonFeatures] + if isinstance(_patreon_features, Unset): + patreon_features = UNSET + else: + patreon_features = PatreonFeatures.from_dict(_patreon_features) + + _profile_settings = d.pop("profileSettings", UNSET) + profile_settings: Union[Unset, ProfileSettings] + if isinstance(_profile_settings, Unset): + profile_settings = UNSET + else: + profile_settings = ProfileSettings.from_dict(_profile_settings) + + def _parse_clan_order(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + clan_order = _parse_clan_order(d.pop("clanOrder", UNSET)) + + def _parse_clans(data: object) -> Union[List["ClanResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + clans_type_0 = [] + _clans_type_0 = data + for clans_type_0_item_data in _clans_type_0: + clans_type_0_item = ClanResponse.from_dict(clans_type_0_item_data) + + clans_type_0.append(clans_type_0_item) + + return clans_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ClanResponse"], None, Unset], data) + + clans = _parse_clans(d.pop("clans", UNSET)) + + acc_pp = d.pop("accPp", UNSET) + + pass_pp = d.pop("passPp", UNSET) + + tech_pp = d.pop("techPp", UNSET) + + _score_stats = d.pop("scoreStats", UNSET) + score_stats: Union[Unset, PlayerScoreStats] + if isinstance(_score_stats, Unset): + score_stats = UNSET + else: + score_stats = PlayerScoreStats.from_dict(_score_stats) + + last_week_pp = d.pop("lastWeekPp", UNSET) + + last_week_rank = d.pop("lastWeekRank", UNSET) + + last_week_country_rank = d.pop("lastWeekCountryRank", UNSET) + + extension_id = d.pop("extensionId", UNSET) + + player_response_with_stats = cls( + id=id, + name=name, + platform=platform, + avatar=avatar, + country=country, + alias=alias, + bot=bot, + pp=pp, + rank=rank, + country_rank=country_rank, + role=role, + socials=socials, + context_extensions=context_extensions, + patreon_features=patreon_features, + profile_settings=profile_settings, + clan_order=clan_order, + clans=clans, + acc_pp=acc_pp, + pass_pp=pass_pp, + tech_pp=tech_pp, + score_stats=score_stats, + last_week_pp=last_week_pp, + last_week_rank=last_week_rank, + last_week_country_rank=last_week_country_rank, + extension_id=extension_id, + ) + + return player_response_with_stats diff --git a/src/clients/beatleader/models/player_response_with_stats_response_with_metadata.py b/src/clients/beatleader/models/player_response_with_stats_response_with_metadata.py new file mode 100644 index 0000000..6c88aa3 --- /dev/null +++ b/src/clients/beatleader/models/player_response_with_stats_response_with_metadata.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.metadata import Metadata + from ..models.player_response_with_stats import PlayerResponseWithStats + + +T = TypeVar("T", bound="PlayerResponseWithStatsResponseWithMetadata") + + +@_attrs_define +class PlayerResponseWithStatsResponseWithMetadata: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['PlayerResponseWithStats'], None, Unset]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["PlayerResponseWithStats"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.metadata import Metadata + from ..models.player_response_with_stats import PlayerResponseWithStats + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["PlayerResponseWithStats"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = PlayerResponseWithStats.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["PlayerResponseWithStats"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + player_response_with_stats_response_with_metadata = cls( + metadata=metadata, + data=data, + ) + + return player_response_with_stats_response_with_metadata diff --git a/src/clients/beatleader/models/player_score_stats.py b/src/clients/beatleader/models/player_score_stats.py new file mode 100644 index 0000000..f4b1afc --- /dev/null +++ b/src/clients/beatleader/models/player_score_stats.py @@ -0,0 +1,552 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.hmd import HMD +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlayerScoreStats") + + +@_attrs_define +class PlayerScoreStats: + """ + Attributes: + id (Union[Unset, int]): + total_score (Union[Unset, int]): + total_unranked_score (Union[Unset, int]): + total_ranked_score (Union[Unset, int]): + last_score_time (Union[Unset, int]): + last_unranked_score_time (Union[Unset, int]): + last_ranked_score_time (Union[Unset, int]): + average_ranked_accuracy (Union[Unset, float]): + average_weighted_ranked_accuracy (Union[Unset, float]): + average_unranked_accuracy (Union[Unset, float]): + average_accuracy (Union[Unset, float]): + median_ranked_accuracy (Union[Unset, float]): + median_accuracy (Union[Unset, float]): + top_ranked_accuracy (Union[Unset, float]): + top_unranked_accuracy (Union[Unset, float]): + top_accuracy (Union[Unset, float]): + top_pp (Union[Unset, float]): + top_bonus_pp (Union[Unset, float]): + top_pass_pp (Union[Unset, float]): + top_acc_pp (Union[Unset, float]): + top_tech_pp (Union[Unset, float]): + peak_rank (Union[Unset, float]): + ranked_max_streak (Union[Unset, int]): + unranked_max_streak (Union[Unset, int]): + max_streak (Union[Unset, int]): + average_left_timing (Union[Unset, float]): + average_right_timing (Union[Unset, float]): + ranked_play_count (Union[Unset, int]): + unranked_play_count (Union[Unset, int]): + total_play_count (Union[Unset, int]): + ranked_improvements_count (Union[Unset, int]): + unranked_improvements_count (Union[Unset, int]): + total_improvements_count (Union[Unset, int]): + ranked_top_1_count (Union[Unset, int]): + unranked_top_1_count (Union[Unset, int]): + top_1_count (Union[Unset, int]): + ranked_top_1_score (Union[Unset, int]): + unranked_top_1_score (Union[Unset, int]): + top_1_score (Union[Unset, int]): + average_ranked_rank (Union[Unset, float]): + average_weighted_ranked_rank (Union[Unset, float]): + average_unranked_rank (Union[Unset, float]): + average_rank (Union[Unset, float]): + ssp_plays (Union[Unset, int]): + ss_plays (Union[Unset, int]): + sp_plays (Union[Unset, int]): + s_plays (Union[Unset, int]): + a_plays (Union[Unset, int]): + top_platform (Union[None, Unset, str]): + top_hmd (Union[Unset, HMD]): + top_percentile (Union[Unset, float]): + country_top_percentile (Union[Unset, float]): + daily_improvements (Union[Unset, int]): + authorized_replay_watched (Union[Unset, int]): + anonimus_replay_watched (Union[Unset, int]): + watched_replays (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + total_score: Union[Unset, int] = UNSET + total_unranked_score: Union[Unset, int] = UNSET + total_ranked_score: Union[Unset, int] = UNSET + last_score_time: Union[Unset, int] = UNSET + last_unranked_score_time: Union[Unset, int] = UNSET + last_ranked_score_time: Union[Unset, int] = UNSET + average_ranked_accuracy: Union[Unset, float] = UNSET + average_weighted_ranked_accuracy: Union[Unset, float] = UNSET + average_unranked_accuracy: Union[Unset, float] = UNSET + average_accuracy: Union[Unset, float] = UNSET + median_ranked_accuracy: Union[Unset, float] = UNSET + median_accuracy: Union[Unset, float] = UNSET + top_ranked_accuracy: Union[Unset, float] = UNSET + top_unranked_accuracy: Union[Unset, float] = UNSET + top_accuracy: Union[Unset, float] = UNSET + top_pp: Union[Unset, float] = UNSET + top_bonus_pp: Union[Unset, float] = UNSET + top_pass_pp: Union[Unset, float] = UNSET + top_acc_pp: Union[Unset, float] = UNSET + top_tech_pp: Union[Unset, float] = UNSET + peak_rank: Union[Unset, float] = UNSET + ranked_max_streak: Union[Unset, int] = UNSET + unranked_max_streak: Union[Unset, int] = UNSET + max_streak: Union[Unset, int] = UNSET + average_left_timing: Union[Unset, float] = UNSET + average_right_timing: Union[Unset, float] = UNSET + ranked_play_count: Union[Unset, int] = UNSET + unranked_play_count: Union[Unset, int] = UNSET + total_play_count: Union[Unset, int] = UNSET + ranked_improvements_count: Union[Unset, int] = UNSET + unranked_improvements_count: Union[Unset, int] = UNSET + total_improvements_count: Union[Unset, int] = UNSET + ranked_top_1_count: Union[Unset, int] = UNSET + unranked_top_1_count: Union[Unset, int] = UNSET + top_1_count: Union[Unset, int] = UNSET + ranked_top_1_score: Union[Unset, int] = UNSET + unranked_top_1_score: Union[Unset, int] = UNSET + top_1_score: Union[Unset, int] = UNSET + average_ranked_rank: Union[Unset, float] = UNSET + average_weighted_ranked_rank: Union[Unset, float] = UNSET + average_unranked_rank: Union[Unset, float] = UNSET + average_rank: Union[Unset, float] = UNSET + ssp_plays: Union[Unset, int] = UNSET + ss_plays: Union[Unset, int] = UNSET + sp_plays: Union[Unset, int] = UNSET + s_plays: Union[Unset, int] = UNSET + a_plays: Union[Unset, int] = UNSET + top_platform: Union[None, Unset, str] = UNSET + top_hmd: Union[Unset, HMD] = UNSET + top_percentile: Union[Unset, float] = UNSET + country_top_percentile: Union[Unset, float] = UNSET + daily_improvements: Union[Unset, int] = UNSET + authorized_replay_watched: Union[Unset, int] = UNSET + anonimus_replay_watched: Union[Unset, int] = UNSET + watched_replays: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + total_score = self.total_score + + total_unranked_score = self.total_unranked_score + + total_ranked_score = self.total_ranked_score + + last_score_time = self.last_score_time + + last_unranked_score_time = self.last_unranked_score_time + + last_ranked_score_time = self.last_ranked_score_time + + average_ranked_accuracy = self.average_ranked_accuracy + + average_weighted_ranked_accuracy = self.average_weighted_ranked_accuracy + + average_unranked_accuracy = self.average_unranked_accuracy + + average_accuracy = self.average_accuracy + + median_ranked_accuracy = self.median_ranked_accuracy + + median_accuracy = self.median_accuracy + + top_ranked_accuracy = self.top_ranked_accuracy + + top_unranked_accuracy = self.top_unranked_accuracy + + top_accuracy = self.top_accuracy + + top_pp = self.top_pp + + top_bonus_pp = self.top_bonus_pp + + top_pass_pp = self.top_pass_pp + + top_acc_pp = self.top_acc_pp + + top_tech_pp = self.top_tech_pp + + peak_rank = self.peak_rank + + ranked_max_streak = self.ranked_max_streak + + unranked_max_streak = self.unranked_max_streak + + max_streak = self.max_streak + + average_left_timing = self.average_left_timing + + average_right_timing = self.average_right_timing + + ranked_play_count = self.ranked_play_count + + unranked_play_count = self.unranked_play_count + + total_play_count = self.total_play_count + + ranked_improvements_count = self.ranked_improvements_count + + unranked_improvements_count = self.unranked_improvements_count + + total_improvements_count = self.total_improvements_count + + ranked_top_1_count = self.ranked_top_1_count + + unranked_top_1_count = self.unranked_top_1_count + + top_1_count = self.top_1_count + + ranked_top_1_score = self.ranked_top_1_score + + unranked_top_1_score = self.unranked_top_1_score + + top_1_score = self.top_1_score + + average_ranked_rank = self.average_ranked_rank + + average_weighted_ranked_rank = self.average_weighted_ranked_rank + + average_unranked_rank = self.average_unranked_rank + + average_rank = self.average_rank + + ssp_plays = self.ssp_plays + + ss_plays = self.ss_plays + + sp_plays = self.sp_plays + + s_plays = self.s_plays + + a_plays = self.a_plays + + top_platform: Union[None, Unset, str] + if isinstance(self.top_platform, Unset): + top_platform = UNSET + else: + top_platform = self.top_platform + + top_hmd: Union[Unset, str] = UNSET + if not isinstance(self.top_hmd, Unset): + top_hmd = self.top_hmd.value + + top_percentile = self.top_percentile + + country_top_percentile = self.country_top_percentile + + daily_improvements = self.daily_improvements + + authorized_replay_watched = self.authorized_replay_watched + + anonimus_replay_watched = self.anonimus_replay_watched + + watched_replays = self.watched_replays + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if total_score is not UNSET: + field_dict["totalScore"] = total_score + if total_unranked_score is not UNSET: + field_dict["totalUnrankedScore"] = total_unranked_score + if total_ranked_score is not UNSET: + field_dict["totalRankedScore"] = total_ranked_score + if last_score_time is not UNSET: + field_dict["lastScoreTime"] = last_score_time + if last_unranked_score_time is not UNSET: + field_dict["lastUnrankedScoreTime"] = last_unranked_score_time + if last_ranked_score_time is not UNSET: + field_dict["lastRankedScoreTime"] = last_ranked_score_time + if average_ranked_accuracy is not UNSET: + field_dict["averageRankedAccuracy"] = average_ranked_accuracy + if average_weighted_ranked_accuracy is not UNSET: + field_dict["averageWeightedRankedAccuracy"] = average_weighted_ranked_accuracy + if average_unranked_accuracy is not UNSET: + field_dict["averageUnrankedAccuracy"] = average_unranked_accuracy + if average_accuracy is not UNSET: + field_dict["averageAccuracy"] = average_accuracy + if median_ranked_accuracy is not UNSET: + field_dict["medianRankedAccuracy"] = median_ranked_accuracy + if median_accuracy is not UNSET: + field_dict["medianAccuracy"] = median_accuracy + if top_ranked_accuracy is not UNSET: + field_dict["topRankedAccuracy"] = top_ranked_accuracy + if top_unranked_accuracy is not UNSET: + field_dict["topUnrankedAccuracy"] = top_unranked_accuracy + if top_accuracy is not UNSET: + field_dict["topAccuracy"] = top_accuracy + if top_pp is not UNSET: + field_dict["topPp"] = top_pp + if top_bonus_pp is not UNSET: + field_dict["topBonusPP"] = top_bonus_pp + if top_pass_pp is not UNSET: + field_dict["topPassPP"] = top_pass_pp + if top_acc_pp is not UNSET: + field_dict["topAccPP"] = top_acc_pp + if top_tech_pp is not UNSET: + field_dict["topTechPP"] = top_tech_pp + if peak_rank is not UNSET: + field_dict["peakRank"] = peak_rank + if ranked_max_streak is not UNSET: + field_dict["rankedMaxStreak"] = ranked_max_streak + if unranked_max_streak is not UNSET: + field_dict["unrankedMaxStreak"] = unranked_max_streak + if max_streak is not UNSET: + field_dict["maxStreak"] = max_streak + if average_left_timing is not UNSET: + field_dict["averageLeftTiming"] = average_left_timing + if average_right_timing is not UNSET: + field_dict["averageRightTiming"] = average_right_timing + if ranked_play_count is not UNSET: + field_dict["rankedPlayCount"] = ranked_play_count + if unranked_play_count is not UNSET: + field_dict["unrankedPlayCount"] = unranked_play_count + if total_play_count is not UNSET: + field_dict["totalPlayCount"] = total_play_count + if ranked_improvements_count is not UNSET: + field_dict["rankedImprovementsCount"] = ranked_improvements_count + if unranked_improvements_count is not UNSET: + field_dict["unrankedImprovementsCount"] = unranked_improvements_count + if total_improvements_count is not UNSET: + field_dict["totalImprovementsCount"] = total_improvements_count + if ranked_top_1_count is not UNSET: + field_dict["rankedTop1Count"] = ranked_top_1_count + if unranked_top_1_count is not UNSET: + field_dict["unrankedTop1Count"] = unranked_top_1_count + if top_1_count is not UNSET: + field_dict["top1Count"] = top_1_count + if ranked_top_1_score is not UNSET: + field_dict["rankedTop1Score"] = ranked_top_1_score + if unranked_top_1_score is not UNSET: + field_dict["unrankedTop1Score"] = unranked_top_1_score + if top_1_score is not UNSET: + field_dict["top1Score"] = top_1_score + if average_ranked_rank is not UNSET: + field_dict["averageRankedRank"] = average_ranked_rank + if average_weighted_ranked_rank is not UNSET: + field_dict["averageWeightedRankedRank"] = average_weighted_ranked_rank + if average_unranked_rank is not UNSET: + field_dict["averageUnrankedRank"] = average_unranked_rank + if average_rank is not UNSET: + field_dict["averageRank"] = average_rank + if ssp_plays is not UNSET: + field_dict["sspPlays"] = ssp_plays + if ss_plays is not UNSET: + field_dict["ssPlays"] = ss_plays + if sp_plays is not UNSET: + field_dict["spPlays"] = sp_plays + if s_plays is not UNSET: + field_dict["sPlays"] = s_plays + if a_plays is not UNSET: + field_dict["aPlays"] = a_plays + if top_platform is not UNSET: + field_dict["topPlatform"] = top_platform + if top_hmd is not UNSET: + field_dict["topHMD"] = top_hmd + if top_percentile is not UNSET: + field_dict["topPercentile"] = top_percentile + if country_top_percentile is not UNSET: + field_dict["countryTopPercentile"] = country_top_percentile + if daily_improvements is not UNSET: + field_dict["dailyImprovements"] = daily_improvements + if authorized_replay_watched is not UNSET: + field_dict["authorizedReplayWatched"] = authorized_replay_watched + if anonimus_replay_watched is not UNSET: + field_dict["anonimusReplayWatched"] = anonimus_replay_watched + if watched_replays is not UNSET: + field_dict["watchedReplays"] = watched_replays + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + total_score = d.pop("totalScore", UNSET) + + total_unranked_score = d.pop("totalUnrankedScore", UNSET) + + total_ranked_score = d.pop("totalRankedScore", UNSET) + + last_score_time = d.pop("lastScoreTime", UNSET) + + last_unranked_score_time = d.pop("lastUnrankedScoreTime", UNSET) + + last_ranked_score_time = d.pop("lastRankedScoreTime", UNSET) + + average_ranked_accuracy = d.pop("averageRankedAccuracy", UNSET) + + average_weighted_ranked_accuracy = d.pop("averageWeightedRankedAccuracy", UNSET) + + average_unranked_accuracy = d.pop("averageUnrankedAccuracy", UNSET) + + average_accuracy = d.pop("averageAccuracy", UNSET) + + median_ranked_accuracy = d.pop("medianRankedAccuracy", UNSET) + + median_accuracy = d.pop("medianAccuracy", UNSET) + + top_ranked_accuracy = d.pop("topRankedAccuracy", UNSET) + + top_unranked_accuracy = d.pop("topUnrankedAccuracy", UNSET) + + top_accuracy = d.pop("topAccuracy", UNSET) + + top_pp = d.pop("topPp", UNSET) + + top_bonus_pp = d.pop("topBonusPP", UNSET) + + top_pass_pp = d.pop("topPassPP", UNSET) + + top_acc_pp = d.pop("topAccPP", UNSET) + + top_tech_pp = d.pop("topTechPP", UNSET) + + peak_rank = d.pop("peakRank", UNSET) + + ranked_max_streak = d.pop("rankedMaxStreak", UNSET) + + unranked_max_streak = d.pop("unrankedMaxStreak", UNSET) + + max_streak = d.pop("maxStreak", UNSET) + + average_left_timing = d.pop("averageLeftTiming", UNSET) + + average_right_timing = d.pop("averageRightTiming", UNSET) + + ranked_play_count = d.pop("rankedPlayCount", UNSET) + + unranked_play_count = d.pop("unrankedPlayCount", UNSET) + + total_play_count = d.pop("totalPlayCount", UNSET) + + ranked_improvements_count = d.pop("rankedImprovementsCount", UNSET) + + unranked_improvements_count = d.pop("unrankedImprovementsCount", UNSET) + + total_improvements_count = d.pop("totalImprovementsCount", UNSET) + + ranked_top_1_count = d.pop("rankedTop1Count", UNSET) + + unranked_top_1_count = d.pop("unrankedTop1Count", UNSET) + + top_1_count = d.pop("top1Count", UNSET) + + ranked_top_1_score = d.pop("rankedTop1Score", UNSET) + + unranked_top_1_score = d.pop("unrankedTop1Score", UNSET) + + top_1_score = d.pop("top1Score", UNSET) + + average_ranked_rank = d.pop("averageRankedRank", UNSET) + + average_weighted_ranked_rank = d.pop("averageWeightedRankedRank", UNSET) + + average_unranked_rank = d.pop("averageUnrankedRank", UNSET) + + average_rank = d.pop("averageRank", UNSET) + + ssp_plays = d.pop("sspPlays", UNSET) + + ss_plays = d.pop("ssPlays", UNSET) + + sp_plays = d.pop("spPlays", UNSET) + + s_plays = d.pop("sPlays", UNSET) + + a_plays = d.pop("aPlays", UNSET) + + def _parse_top_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + top_platform = _parse_top_platform(d.pop("topPlatform", UNSET)) + + _top_hmd = d.pop("topHMD", UNSET) + top_hmd: Union[Unset, HMD] + if isinstance(_top_hmd, Unset): + top_hmd = UNSET + else: + top_hmd = HMD(_top_hmd) + + top_percentile = d.pop("topPercentile", UNSET) + + country_top_percentile = d.pop("countryTopPercentile", UNSET) + + daily_improvements = d.pop("dailyImprovements", UNSET) + + authorized_replay_watched = d.pop("authorizedReplayWatched", UNSET) + + anonimus_replay_watched = d.pop("anonimusReplayWatched", UNSET) + + watched_replays = d.pop("watchedReplays", UNSET) + + player_score_stats = cls( + id=id, + total_score=total_score, + total_unranked_score=total_unranked_score, + total_ranked_score=total_ranked_score, + last_score_time=last_score_time, + last_unranked_score_time=last_unranked_score_time, + last_ranked_score_time=last_ranked_score_time, + average_ranked_accuracy=average_ranked_accuracy, + average_weighted_ranked_accuracy=average_weighted_ranked_accuracy, + average_unranked_accuracy=average_unranked_accuracy, + average_accuracy=average_accuracy, + median_ranked_accuracy=median_ranked_accuracy, + median_accuracy=median_accuracy, + top_ranked_accuracy=top_ranked_accuracy, + top_unranked_accuracy=top_unranked_accuracy, + top_accuracy=top_accuracy, + top_pp=top_pp, + top_bonus_pp=top_bonus_pp, + top_pass_pp=top_pass_pp, + top_acc_pp=top_acc_pp, + top_tech_pp=top_tech_pp, + peak_rank=peak_rank, + ranked_max_streak=ranked_max_streak, + unranked_max_streak=unranked_max_streak, + max_streak=max_streak, + average_left_timing=average_left_timing, + average_right_timing=average_right_timing, + ranked_play_count=ranked_play_count, + unranked_play_count=unranked_play_count, + total_play_count=total_play_count, + ranked_improvements_count=ranked_improvements_count, + unranked_improvements_count=unranked_improvements_count, + total_improvements_count=total_improvements_count, + ranked_top_1_count=ranked_top_1_count, + unranked_top_1_count=unranked_top_1_count, + top_1_count=top_1_count, + ranked_top_1_score=ranked_top_1_score, + unranked_top_1_score=unranked_top_1_score, + top_1_score=top_1_score, + average_ranked_rank=average_ranked_rank, + average_weighted_ranked_rank=average_weighted_ranked_rank, + average_unranked_rank=average_unranked_rank, + average_rank=average_rank, + ssp_plays=ssp_plays, + ss_plays=ss_plays, + sp_plays=sp_plays, + s_plays=s_plays, + a_plays=a_plays, + top_platform=top_platform, + top_hmd=top_hmd, + top_percentile=top_percentile, + country_top_percentile=country_top_percentile, + daily_improvements=daily_improvements, + authorized_replay_watched=authorized_replay_watched, + anonimus_replay_watched=anonimus_replay_watched, + watched_replays=watched_replays, + ) + + return player_score_stats diff --git a/src/clients/beatleader/models/player_score_stats_history.py b/src/clients/beatleader/models/player_score_stats_history.py new file mode 100644 index 0000000..de9ec32 --- /dev/null +++ b/src/clients/beatleader/models/player_score_stats_history.py @@ -0,0 +1,526 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.hmd import HMD +from ..models.leaderboard_contexts import LeaderboardContexts +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlayerScoreStatsHistory") + + +@_attrs_define +class PlayerScoreStatsHistory: + """ + Attributes: + id (Union[Unset, int]): + context (Union[Unset, LeaderboardContexts]): + timestamp (Union[Unset, int]): + player_id (Union[None, Unset, str]): + pp (Union[Unset, float]): + acc_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + rank (Union[Unset, int]): + country_rank (Union[Unset, int]): + total_score (Union[Unset, int]): + total_unranked_score (Union[Unset, int]): + total_ranked_score (Union[Unset, int]): + last_score_time (Union[Unset, int]): + last_unranked_score_time (Union[Unset, int]): + last_ranked_score_time (Union[Unset, int]): + average_ranked_accuracy (Union[Unset, float]): + average_weighted_ranked_accuracy (Union[Unset, float]): + average_unranked_accuracy (Union[Unset, float]): + average_accuracy (Union[Unset, float]): + median_ranked_accuracy (Union[Unset, float]): + median_accuracy (Union[Unset, float]): + top_ranked_accuracy (Union[Unset, float]): + top_unranked_accuracy (Union[Unset, float]): + top_accuracy (Union[Unset, float]): + top_pp (Union[Unset, float]): + top_bonus_pp (Union[Unset, float]): + peak_rank (Union[Unset, float]): + max_streak (Union[Unset, int]): + average_left_timing (Union[Unset, float]): + average_right_timing (Union[Unset, float]): + ranked_play_count (Union[Unset, int]): + unranked_play_count (Union[Unset, int]): + total_play_count (Union[Unset, int]): + ranked_improvements_count (Union[Unset, int]): + unranked_improvements_count (Union[Unset, int]): + total_improvements_count (Union[Unset, int]): + average_ranked_rank (Union[Unset, float]): + average_weighted_ranked_rank (Union[Unset, float]): + average_unranked_rank (Union[Unset, float]): + average_rank (Union[Unset, float]): + ssp_plays (Union[Unset, int]): + ss_plays (Union[Unset, int]): + sp_plays (Union[Unset, int]): + s_plays (Union[Unset, int]): + a_plays (Union[Unset, int]): + top_platform (Union[None, Unset, str]): + top_hmd (Union[Unset, HMD]): + daily_improvements (Union[Unset, int]): + replays_watched (Union[Unset, int]): + watched_replays (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + context: Union[Unset, LeaderboardContexts] = UNSET + timestamp: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + pp: Union[Unset, float] = UNSET + acc_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country_rank: Union[Unset, int] = UNSET + total_score: Union[Unset, int] = UNSET + total_unranked_score: Union[Unset, int] = UNSET + total_ranked_score: Union[Unset, int] = UNSET + last_score_time: Union[Unset, int] = UNSET + last_unranked_score_time: Union[Unset, int] = UNSET + last_ranked_score_time: Union[Unset, int] = UNSET + average_ranked_accuracy: Union[Unset, float] = UNSET + average_weighted_ranked_accuracy: Union[Unset, float] = UNSET + average_unranked_accuracy: Union[Unset, float] = UNSET + average_accuracy: Union[Unset, float] = UNSET + median_ranked_accuracy: Union[Unset, float] = UNSET + median_accuracy: Union[Unset, float] = UNSET + top_ranked_accuracy: Union[Unset, float] = UNSET + top_unranked_accuracy: Union[Unset, float] = UNSET + top_accuracy: Union[Unset, float] = UNSET + top_pp: Union[Unset, float] = UNSET + top_bonus_pp: Union[Unset, float] = UNSET + peak_rank: Union[Unset, float] = UNSET + max_streak: Union[Unset, int] = UNSET + average_left_timing: Union[Unset, float] = UNSET + average_right_timing: Union[Unset, float] = UNSET + ranked_play_count: Union[Unset, int] = UNSET + unranked_play_count: Union[Unset, int] = UNSET + total_play_count: Union[Unset, int] = UNSET + ranked_improvements_count: Union[Unset, int] = UNSET + unranked_improvements_count: Union[Unset, int] = UNSET + total_improvements_count: Union[Unset, int] = UNSET + average_ranked_rank: Union[Unset, float] = UNSET + average_weighted_ranked_rank: Union[Unset, float] = UNSET + average_unranked_rank: Union[Unset, float] = UNSET + average_rank: Union[Unset, float] = UNSET + ssp_plays: Union[Unset, int] = UNSET + ss_plays: Union[Unset, int] = UNSET + sp_plays: Union[Unset, int] = UNSET + s_plays: Union[Unset, int] = UNSET + a_plays: Union[Unset, int] = UNSET + top_platform: Union[None, Unset, str] = UNSET + top_hmd: Union[Unset, HMD] = UNSET + daily_improvements: Union[Unset, int] = UNSET + replays_watched: Union[Unset, int] = UNSET + watched_replays: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + context: Union[Unset, str] = UNSET + if not isinstance(self.context, Unset): + context = self.context.value + + timestamp = self.timestamp + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + pp = self.pp + + acc_pp = self.acc_pp + + pass_pp = self.pass_pp + + tech_pp = self.tech_pp + + rank = self.rank + + country_rank = self.country_rank + + total_score = self.total_score + + total_unranked_score = self.total_unranked_score + + total_ranked_score = self.total_ranked_score + + last_score_time = self.last_score_time + + last_unranked_score_time = self.last_unranked_score_time + + last_ranked_score_time = self.last_ranked_score_time + + average_ranked_accuracy = self.average_ranked_accuracy + + average_weighted_ranked_accuracy = self.average_weighted_ranked_accuracy + + average_unranked_accuracy = self.average_unranked_accuracy + + average_accuracy = self.average_accuracy + + median_ranked_accuracy = self.median_ranked_accuracy + + median_accuracy = self.median_accuracy + + top_ranked_accuracy = self.top_ranked_accuracy + + top_unranked_accuracy = self.top_unranked_accuracy + + top_accuracy = self.top_accuracy + + top_pp = self.top_pp + + top_bonus_pp = self.top_bonus_pp + + peak_rank = self.peak_rank + + max_streak = self.max_streak + + average_left_timing = self.average_left_timing + + average_right_timing = self.average_right_timing + + ranked_play_count = self.ranked_play_count + + unranked_play_count = self.unranked_play_count + + total_play_count = self.total_play_count + + ranked_improvements_count = self.ranked_improvements_count + + unranked_improvements_count = self.unranked_improvements_count + + total_improvements_count = self.total_improvements_count + + average_ranked_rank = self.average_ranked_rank + + average_weighted_ranked_rank = self.average_weighted_ranked_rank + + average_unranked_rank = self.average_unranked_rank + + average_rank = self.average_rank + + ssp_plays = self.ssp_plays + + ss_plays = self.ss_plays + + sp_plays = self.sp_plays + + s_plays = self.s_plays + + a_plays = self.a_plays + + top_platform: Union[None, Unset, str] + if isinstance(self.top_platform, Unset): + top_platform = UNSET + else: + top_platform = self.top_platform + + top_hmd: Union[Unset, str] = UNSET + if not isinstance(self.top_hmd, Unset): + top_hmd = self.top_hmd.value + + daily_improvements = self.daily_improvements + + replays_watched = self.replays_watched + + watched_replays = self.watched_replays + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if context is not UNSET: + field_dict["context"] = context + if timestamp is not UNSET: + field_dict["timestamp"] = timestamp + if player_id is not UNSET: + field_dict["playerId"] = player_id + if pp is not UNSET: + field_dict["pp"] = pp + if acc_pp is not UNSET: + field_dict["accPp"] = acc_pp + if pass_pp is not UNSET: + field_dict["passPp"] = pass_pp + if tech_pp is not UNSET: + field_dict["techPp"] = tech_pp + if rank is not UNSET: + field_dict["rank"] = rank + if country_rank is not UNSET: + field_dict["countryRank"] = country_rank + if total_score is not UNSET: + field_dict["totalScore"] = total_score + if total_unranked_score is not UNSET: + field_dict["totalUnrankedScore"] = total_unranked_score + if total_ranked_score is not UNSET: + field_dict["totalRankedScore"] = total_ranked_score + if last_score_time is not UNSET: + field_dict["lastScoreTime"] = last_score_time + if last_unranked_score_time is not UNSET: + field_dict["lastUnrankedScoreTime"] = last_unranked_score_time + if last_ranked_score_time is not UNSET: + field_dict["lastRankedScoreTime"] = last_ranked_score_time + if average_ranked_accuracy is not UNSET: + field_dict["averageRankedAccuracy"] = average_ranked_accuracy + if average_weighted_ranked_accuracy is not UNSET: + field_dict["averageWeightedRankedAccuracy"] = average_weighted_ranked_accuracy + if average_unranked_accuracy is not UNSET: + field_dict["averageUnrankedAccuracy"] = average_unranked_accuracy + if average_accuracy is not UNSET: + field_dict["averageAccuracy"] = average_accuracy + if median_ranked_accuracy is not UNSET: + field_dict["medianRankedAccuracy"] = median_ranked_accuracy + if median_accuracy is not UNSET: + field_dict["medianAccuracy"] = median_accuracy + if top_ranked_accuracy is not UNSET: + field_dict["topRankedAccuracy"] = top_ranked_accuracy + if top_unranked_accuracy is not UNSET: + field_dict["topUnrankedAccuracy"] = top_unranked_accuracy + if top_accuracy is not UNSET: + field_dict["topAccuracy"] = top_accuracy + if top_pp is not UNSET: + field_dict["topPp"] = top_pp + if top_bonus_pp is not UNSET: + field_dict["topBonusPP"] = top_bonus_pp + if peak_rank is not UNSET: + field_dict["peakRank"] = peak_rank + if max_streak is not UNSET: + field_dict["maxStreak"] = max_streak + if average_left_timing is not UNSET: + field_dict["averageLeftTiming"] = average_left_timing + if average_right_timing is not UNSET: + field_dict["averageRightTiming"] = average_right_timing + if ranked_play_count is not UNSET: + field_dict["rankedPlayCount"] = ranked_play_count + if unranked_play_count is not UNSET: + field_dict["unrankedPlayCount"] = unranked_play_count + if total_play_count is not UNSET: + field_dict["totalPlayCount"] = total_play_count + if ranked_improvements_count is not UNSET: + field_dict["rankedImprovementsCount"] = ranked_improvements_count + if unranked_improvements_count is not UNSET: + field_dict["unrankedImprovementsCount"] = unranked_improvements_count + if total_improvements_count is not UNSET: + field_dict["totalImprovementsCount"] = total_improvements_count + if average_ranked_rank is not UNSET: + field_dict["averageRankedRank"] = average_ranked_rank + if average_weighted_ranked_rank is not UNSET: + field_dict["averageWeightedRankedRank"] = average_weighted_ranked_rank + if average_unranked_rank is not UNSET: + field_dict["averageUnrankedRank"] = average_unranked_rank + if average_rank is not UNSET: + field_dict["averageRank"] = average_rank + if ssp_plays is not UNSET: + field_dict["sspPlays"] = ssp_plays + if ss_plays is not UNSET: + field_dict["ssPlays"] = ss_plays + if sp_plays is not UNSET: + field_dict["spPlays"] = sp_plays + if s_plays is not UNSET: + field_dict["sPlays"] = s_plays + if a_plays is not UNSET: + field_dict["aPlays"] = a_plays + if top_platform is not UNSET: + field_dict["topPlatform"] = top_platform + if top_hmd is not UNSET: + field_dict["topHMD"] = top_hmd + if daily_improvements is not UNSET: + field_dict["dailyImprovements"] = daily_improvements + if replays_watched is not UNSET: + field_dict["replaysWatched"] = replays_watched + if watched_replays is not UNSET: + field_dict["watchedReplays"] = watched_replays + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + _context = d.pop("context", UNSET) + context: Union[Unset, LeaderboardContexts] + if isinstance(_context, Unset): + context = UNSET + else: + context = LeaderboardContexts(_context) + + timestamp = d.pop("timestamp", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + pp = d.pop("pp", UNSET) + + acc_pp = d.pop("accPp", UNSET) + + pass_pp = d.pop("passPp", UNSET) + + tech_pp = d.pop("techPp", UNSET) + + rank = d.pop("rank", UNSET) + + country_rank = d.pop("countryRank", UNSET) + + total_score = d.pop("totalScore", UNSET) + + total_unranked_score = d.pop("totalUnrankedScore", UNSET) + + total_ranked_score = d.pop("totalRankedScore", UNSET) + + last_score_time = d.pop("lastScoreTime", UNSET) + + last_unranked_score_time = d.pop("lastUnrankedScoreTime", UNSET) + + last_ranked_score_time = d.pop("lastRankedScoreTime", UNSET) + + average_ranked_accuracy = d.pop("averageRankedAccuracy", UNSET) + + average_weighted_ranked_accuracy = d.pop("averageWeightedRankedAccuracy", UNSET) + + average_unranked_accuracy = d.pop("averageUnrankedAccuracy", UNSET) + + average_accuracy = d.pop("averageAccuracy", UNSET) + + median_ranked_accuracy = d.pop("medianRankedAccuracy", UNSET) + + median_accuracy = d.pop("medianAccuracy", UNSET) + + top_ranked_accuracy = d.pop("topRankedAccuracy", UNSET) + + top_unranked_accuracy = d.pop("topUnrankedAccuracy", UNSET) + + top_accuracy = d.pop("topAccuracy", UNSET) + + top_pp = d.pop("topPp", UNSET) + + top_bonus_pp = d.pop("topBonusPP", UNSET) + + peak_rank = d.pop("peakRank", UNSET) + + max_streak = d.pop("maxStreak", UNSET) + + average_left_timing = d.pop("averageLeftTiming", UNSET) + + average_right_timing = d.pop("averageRightTiming", UNSET) + + ranked_play_count = d.pop("rankedPlayCount", UNSET) + + unranked_play_count = d.pop("unrankedPlayCount", UNSET) + + total_play_count = d.pop("totalPlayCount", UNSET) + + ranked_improvements_count = d.pop("rankedImprovementsCount", UNSET) + + unranked_improvements_count = d.pop("unrankedImprovementsCount", UNSET) + + total_improvements_count = d.pop("totalImprovementsCount", UNSET) + + average_ranked_rank = d.pop("averageRankedRank", UNSET) + + average_weighted_ranked_rank = d.pop("averageWeightedRankedRank", UNSET) + + average_unranked_rank = d.pop("averageUnrankedRank", UNSET) + + average_rank = d.pop("averageRank", UNSET) + + ssp_plays = d.pop("sspPlays", UNSET) + + ss_plays = d.pop("ssPlays", UNSET) + + sp_plays = d.pop("spPlays", UNSET) + + s_plays = d.pop("sPlays", UNSET) + + a_plays = d.pop("aPlays", UNSET) + + def _parse_top_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + top_platform = _parse_top_platform(d.pop("topPlatform", UNSET)) + + _top_hmd = d.pop("topHMD", UNSET) + top_hmd: Union[Unset, HMD] + if isinstance(_top_hmd, Unset): + top_hmd = UNSET + else: + top_hmd = HMD(_top_hmd) + + daily_improvements = d.pop("dailyImprovements", UNSET) + + replays_watched = d.pop("replaysWatched", UNSET) + + watched_replays = d.pop("watchedReplays", UNSET) + + player_score_stats_history = cls( + id=id, + context=context, + timestamp=timestamp, + player_id=player_id, + pp=pp, + acc_pp=acc_pp, + pass_pp=pass_pp, + tech_pp=tech_pp, + rank=rank, + country_rank=country_rank, + total_score=total_score, + total_unranked_score=total_unranked_score, + total_ranked_score=total_ranked_score, + last_score_time=last_score_time, + last_unranked_score_time=last_unranked_score_time, + last_ranked_score_time=last_ranked_score_time, + average_ranked_accuracy=average_ranked_accuracy, + average_weighted_ranked_accuracy=average_weighted_ranked_accuracy, + average_unranked_accuracy=average_unranked_accuracy, + average_accuracy=average_accuracy, + median_ranked_accuracy=median_ranked_accuracy, + median_accuracy=median_accuracy, + top_ranked_accuracy=top_ranked_accuracy, + top_unranked_accuracy=top_unranked_accuracy, + top_accuracy=top_accuracy, + top_pp=top_pp, + top_bonus_pp=top_bonus_pp, + peak_rank=peak_rank, + max_streak=max_streak, + average_left_timing=average_left_timing, + average_right_timing=average_right_timing, + ranked_play_count=ranked_play_count, + unranked_play_count=unranked_play_count, + total_play_count=total_play_count, + ranked_improvements_count=ranked_improvements_count, + unranked_improvements_count=unranked_improvements_count, + total_improvements_count=total_improvements_count, + average_ranked_rank=average_ranked_rank, + average_weighted_ranked_rank=average_weighted_ranked_rank, + average_unranked_rank=average_unranked_rank, + average_rank=average_rank, + ssp_plays=ssp_plays, + ss_plays=ss_plays, + sp_plays=sp_plays, + s_plays=s_plays, + a_plays=a_plays, + top_platform=top_platform, + top_hmd=top_hmd, + daily_improvements=daily_improvements, + replays_watched=replays_watched, + watched_replays=watched_replays, + ) + + return player_score_stats_history diff --git a/src/clients/beatleader/models/player_search.py b/src/clients/beatleader/models/player_search.py new file mode 100644 index 0000000..66f7d0e --- /dev/null +++ b/src/clients/beatleader/models/player_search.py @@ -0,0 +1,98 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.player import Player + + +T = TypeVar("T", bound="PlayerSearch") + + +@_attrs_define +class PlayerSearch: + """ + Attributes: + id (Union[Unset, int]): + score (Union[Unset, int]): + search_id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + player (Union[Unset, Player]): + """ + + id: Union[Unset, int] = UNSET + score: Union[Unset, int] = UNSET + search_id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + player: Union[Unset, "Player"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + score = self.score + + search_id = self.search_id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + player: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.player, Unset): + player = self.player.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if score is not UNSET: + field_dict["score"] = score + if search_id is not UNSET: + field_dict["searchId"] = search_id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if player is not UNSET: + field_dict["player"] = player + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.player import Player + + d = src_dict.copy() + id = d.pop("id", UNSET) + + score = d.pop("score", UNSET) + + search_id = d.pop("searchId", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + _player = d.pop("player", UNSET) + player: Union[Unset, Player] + if isinstance(_player, Unset): + player = UNSET + else: + player = Player.from_dict(_player) + + player_search = cls( + id=id, + score=score, + search_id=search_id, + player_id=player_id, + player=player, + ) + + return player_search diff --git a/src/clients/beatleader/models/player_social.py b/src/clients/beatleader/models/player_social.py new file mode 100644 index 0000000..db01a76 --- /dev/null +++ b/src/clients/beatleader/models/player_social.py @@ -0,0 +1,147 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlayerSocial") + + +@_attrs_define +class PlayerSocial: + """ + Attributes: + id (Union[Unset, int]): + service (Union[None, Unset, str]): + link (Union[None, Unset, str]): + user (Union[None, Unset, str]): + user_id (Union[None, Unset, str]): + player_id (Union[None, Unset, str]): + hidden (Union[Unset, bool]): + """ + + id: Union[Unset, int] = UNSET + service: Union[None, Unset, str] = UNSET + link: Union[None, Unset, str] = UNSET + user: Union[None, Unset, str] = UNSET + user_id: Union[None, Unset, str] = UNSET + player_id: Union[None, Unset, str] = UNSET + hidden: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + service: Union[None, Unset, str] + if isinstance(self.service, Unset): + service = UNSET + else: + service = self.service + + link: Union[None, Unset, str] + if isinstance(self.link, Unset): + link = UNSET + else: + link = self.link + + user: Union[None, Unset, str] + if isinstance(self.user, Unset): + user = UNSET + else: + user = self.user + + user_id: Union[None, Unset, str] + if isinstance(self.user_id, Unset): + user_id = UNSET + else: + user_id = self.user_id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + hidden = self.hidden + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if service is not UNSET: + field_dict["service"] = service + if link is not UNSET: + field_dict["link"] = link + if user is not UNSET: + field_dict["user"] = user + if user_id is not UNSET: + field_dict["userId"] = user_id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if hidden is not UNSET: + field_dict["hidden"] = hidden + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_service(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + service = _parse_service(d.pop("service", UNSET)) + + def _parse_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + link = _parse_link(d.pop("link", UNSET)) + + def _parse_user(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + user = _parse_user(d.pop("user", UNSET)) + + def _parse_user_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + user_id = _parse_user_id(d.pop("userId", UNSET)) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + hidden = d.pop("hidden", UNSET) + + player_social = cls( + id=id, + service=service, + link=link, + user=user, + user_id=user_id, + player_id=player_id, + hidden=hidden, + ) + + return player_social diff --git a/src/clients/beatleader/models/player_sort_by.py b/src/clients/beatleader/models/player_sort_by.py new file mode 100644 index 0000000..8a7f374 --- /dev/null +++ b/src/clients/beatleader/models/player_sort_by.py @@ -0,0 +1,25 @@ +from enum import Enum + + +class PlayerSortBy(str, Enum): + ACC = "acc" + DAILYIMPROVEMENTS = "dailyImprovements" + HMD = "hmd" + LASTPLAY = "lastplay" + MAXSTREAK = "maxStreak" + NAME = "name" + PLAYCOUNT = "playCount" + PP = "pp" + RANK = "rank" + REPLAYSWATCHED = "replaysWatched" + SCORE = "score" + TIMING = "timing" + TOP1COUNT = "top1Count" + TOP1SCORE = "top1Score" + TOPACC = "topAcc" + TOPPP = "topPp" + WEIGHTEDACC = "weightedAcc" + WEIGHTEDRANK = "weightedRank" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/pp_type.py b/src/clients/beatleader/models/pp_type.py new file mode 100644 index 0000000..d9dc74e --- /dev/null +++ b/src/clients/beatleader/models/pp_type.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class PpType(str, Enum): + ACC = "acc" + GENERAL = "general" + PASS = "pass" + TECH = "tech" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/profile_settings.py b/src/clients/beatleader/models/profile_settings.py new file mode 100644 index 0000000..3266870 --- /dev/null +++ b/src/clients/beatleader/models/profile_settings.py @@ -0,0 +1,303 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ProfileSettings") + + +@_attrs_define +class ProfileSettings: + """ + Attributes: + id (Union[Unset, int]): + bio (Union[None, Unset, str]): + message (Union[None, Unset, str]): + effect_name (Union[None, Unset, str]): + profile_appearance (Union[None, Unset, str]): + hue (Union[None, Unset, float]): + saturation (Union[None, Unset, float]): + left_saber_color (Union[None, Unset, str]): + right_saber_color (Union[None, Unset, str]): + profile_cover (Union[None, Unset, str]): + starred_friends (Union[None, Unset, str]): + horizontal_rich_bio (Union[Unset, bool]): + ranked_mapper_sort (Union[None, Unset, str]): + show_bots (Union[Unset, bool]): + show_all_ratings (Union[Unset, bool]): + show_stats_public (Union[Unset, bool]): + show_stats_public_pinned (Union[Unset, bool]): + """ + + id: Union[Unset, int] = UNSET + bio: Union[None, Unset, str] = UNSET + message: Union[None, Unset, str] = UNSET + effect_name: Union[None, Unset, str] = UNSET + profile_appearance: Union[None, Unset, str] = UNSET + hue: Union[None, Unset, float] = UNSET + saturation: Union[None, Unset, float] = UNSET + left_saber_color: Union[None, Unset, str] = UNSET + right_saber_color: Union[None, Unset, str] = UNSET + profile_cover: Union[None, Unset, str] = UNSET + starred_friends: Union[None, Unset, str] = UNSET + horizontal_rich_bio: Union[Unset, bool] = UNSET + ranked_mapper_sort: Union[None, Unset, str] = UNSET + show_bots: Union[Unset, bool] = UNSET + show_all_ratings: Union[Unset, bool] = UNSET + show_stats_public: Union[Unset, bool] = UNSET + show_stats_public_pinned: Union[Unset, bool] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + bio: Union[None, Unset, str] + if isinstance(self.bio, Unset): + bio = UNSET + else: + bio = self.bio + + message: Union[None, Unset, str] + if isinstance(self.message, Unset): + message = UNSET + else: + message = self.message + + effect_name: Union[None, Unset, str] + if isinstance(self.effect_name, Unset): + effect_name = UNSET + else: + effect_name = self.effect_name + + profile_appearance: Union[None, Unset, str] + if isinstance(self.profile_appearance, Unset): + profile_appearance = UNSET + else: + profile_appearance = self.profile_appearance + + hue: Union[None, Unset, float] + if isinstance(self.hue, Unset): + hue = UNSET + else: + hue = self.hue + + saturation: Union[None, Unset, float] + if isinstance(self.saturation, Unset): + saturation = UNSET + else: + saturation = self.saturation + + left_saber_color: Union[None, Unset, str] + if isinstance(self.left_saber_color, Unset): + left_saber_color = UNSET + else: + left_saber_color = self.left_saber_color + + right_saber_color: Union[None, Unset, str] + if isinstance(self.right_saber_color, Unset): + right_saber_color = UNSET + else: + right_saber_color = self.right_saber_color + + profile_cover: Union[None, Unset, str] + if isinstance(self.profile_cover, Unset): + profile_cover = UNSET + else: + profile_cover = self.profile_cover + + starred_friends: Union[None, Unset, str] + if isinstance(self.starred_friends, Unset): + starred_friends = UNSET + else: + starred_friends = self.starred_friends + + horizontal_rich_bio = self.horizontal_rich_bio + + ranked_mapper_sort: Union[None, Unset, str] + if isinstance(self.ranked_mapper_sort, Unset): + ranked_mapper_sort = UNSET + else: + ranked_mapper_sort = self.ranked_mapper_sort + + show_bots = self.show_bots + + show_all_ratings = self.show_all_ratings + + show_stats_public = self.show_stats_public + + show_stats_public_pinned = self.show_stats_public_pinned + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if bio is not UNSET: + field_dict["bio"] = bio + if message is not UNSET: + field_dict["message"] = message + if effect_name is not UNSET: + field_dict["effectName"] = effect_name + if profile_appearance is not UNSET: + field_dict["profileAppearance"] = profile_appearance + if hue is not UNSET: + field_dict["hue"] = hue + if saturation is not UNSET: + field_dict["saturation"] = saturation + if left_saber_color is not UNSET: + field_dict["leftSaberColor"] = left_saber_color + if right_saber_color is not UNSET: + field_dict["rightSaberColor"] = right_saber_color + if profile_cover is not UNSET: + field_dict["profileCover"] = profile_cover + if starred_friends is not UNSET: + field_dict["starredFriends"] = starred_friends + if horizontal_rich_bio is not UNSET: + field_dict["horizontalRichBio"] = horizontal_rich_bio + if ranked_mapper_sort is not UNSET: + field_dict["rankedMapperSort"] = ranked_mapper_sort + if show_bots is not UNSET: + field_dict["showBots"] = show_bots + if show_all_ratings is not UNSET: + field_dict["showAllRatings"] = show_all_ratings + if show_stats_public is not UNSET: + field_dict["showStatsPublic"] = show_stats_public + if show_stats_public_pinned is not UNSET: + field_dict["showStatsPublicPinned"] = show_stats_public_pinned + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_bio(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + bio = _parse_bio(d.pop("bio", UNSET)) + + def _parse_message(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + message = _parse_message(d.pop("message", UNSET)) + + def _parse_effect_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + effect_name = _parse_effect_name(d.pop("effectName", UNSET)) + + def _parse_profile_appearance(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + profile_appearance = _parse_profile_appearance(d.pop("profileAppearance", UNSET)) + + def _parse_hue(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + hue = _parse_hue(d.pop("hue", UNSET)) + + def _parse_saturation(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + saturation = _parse_saturation(d.pop("saturation", UNSET)) + + def _parse_left_saber_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + left_saber_color = _parse_left_saber_color(d.pop("leftSaberColor", UNSET)) + + def _parse_right_saber_color(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + right_saber_color = _parse_right_saber_color(d.pop("rightSaberColor", UNSET)) + + def _parse_profile_cover(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + profile_cover = _parse_profile_cover(d.pop("profileCover", UNSET)) + + def _parse_starred_friends(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + starred_friends = _parse_starred_friends(d.pop("starredFriends", UNSET)) + + horizontal_rich_bio = d.pop("horizontalRichBio", UNSET) + + def _parse_ranked_mapper_sort(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + ranked_mapper_sort = _parse_ranked_mapper_sort(d.pop("rankedMapperSort", UNSET)) + + show_bots = d.pop("showBots", UNSET) + + show_all_ratings = d.pop("showAllRatings", UNSET) + + show_stats_public = d.pop("showStatsPublic", UNSET) + + show_stats_public_pinned = d.pop("showStatsPublicPinned", UNSET) + + profile_settings = cls( + id=id, + bio=bio, + message=message, + effect_name=effect_name, + profile_appearance=profile_appearance, + hue=hue, + saturation=saturation, + left_saber_color=left_saber_color, + right_saber_color=right_saber_color, + profile_cover=profile_cover, + starred_friends=starred_friends, + horizontal_rich_bio=horizontal_rich_bio, + ranked_mapper_sort=ranked_mapper_sort, + show_bots=show_bots, + show_all_ratings=show_all_ratings, + show_stats_public=show_stats_public, + show_stats_public_pinned=show_stats_public_pinned, + ) + + return profile_settings diff --git a/src/clients/beatleader/models/qualification_change.py b/src/clients/beatleader/models/qualification_change.py new file mode 100644 index 0000000..f53a63a --- /dev/null +++ b/src/clients/beatleader/models/qualification_change.py @@ -0,0 +1,271 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.modifiers_map import ModifiersMap + + +T = TypeVar("T", bound="QualificationChange") + + +@_attrs_define +class QualificationChange: + """ + Attributes: + id (Union[Unset, int]): + timeset (Union[Unset, int]): + player_id (Union[None, Unset, str]): + old_rankability (Union[Unset, float]): + old_stars (Union[Unset, float]): + old_acc_rating (Union[Unset, float]): + old_pass_rating (Union[Unset, float]): + old_tech_rating (Union[Unset, float]): + old_type (Union[Unset, int]): + old_criteria_met (Union[Unset, int]): + old_criteria_commentary (Union[None, Unset, str]): + old_modifiers (Union[Unset, ModifiersMap]): + new_rankability (Union[Unset, float]): + new_stars (Union[Unset, float]): + new_acc_rating (Union[Unset, float]): + new_pass_rating (Union[Unset, float]): + new_tech_rating (Union[Unset, float]): + new_type (Union[Unset, int]): + new_criteria_met (Union[Unset, int]): + new_criteria_commentary (Union[None, Unset, str]): + new_modifiers (Union[Unset, ModifiersMap]): + """ + + id: Union[Unset, int] = UNSET + timeset: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + old_rankability: Union[Unset, float] = UNSET + old_stars: Union[Unset, float] = UNSET + old_acc_rating: Union[Unset, float] = UNSET + old_pass_rating: Union[Unset, float] = UNSET + old_tech_rating: Union[Unset, float] = UNSET + old_type: Union[Unset, int] = UNSET + old_criteria_met: Union[Unset, int] = UNSET + old_criteria_commentary: Union[None, Unset, str] = UNSET + old_modifiers: Union[Unset, "ModifiersMap"] = UNSET + new_rankability: Union[Unset, float] = UNSET + new_stars: Union[Unset, float] = UNSET + new_acc_rating: Union[Unset, float] = UNSET + new_pass_rating: Union[Unset, float] = UNSET + new_tech_rating: Union[Unset, float] = UNSET + new_type: Union[Unset, int] = UNSET + new_criteria_met: Union[Unset, int] = UNSET + new_criteria_commentary: Union[None, Unset, str] = UNSET + new_modifiers: Union[Unset, "ModifiersMap"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timeset = self.timeset + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + old_rankability = self.old_rankability + + old_stars = self.old_stars + + old_acc_rating = self.old_acc_rating + + old_pass_rating = self.old_pass_rating + + old_tech_rating = self.old_tech_rating + + old_type = self.old_type + + old_criteria_met = self.old_criteria_met + + old_criteria_commentary: Union[None, Unset, str] + if isinstance(self.old_criteria_commentary, Unset): + old_criteria_commentary = UNSET + else: + old_criteria_commentary = self.old_criteria_commentary + + old_modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.old_modifiers, Unset): + old_modifiers = self.old_modifiers.to_dict() + + new_rankability = self.new_rankability + + new_stars = self.new_stars + + new_acc_rating = self.new_acc_rating + + new_pass_rating = self.new_pass_rating + + new_tech_rating = self.new_tech_rating + + new_type = self.new_type + + new_criteria_met = self.new_criteria_met + + new_criteria_commentary: Union[None, Unset, str] + if isinstance(self.new_criteria_commentary, Unset): + new_criteria_commentary = UNSET + else: + new_criteria_commentary = self.new_criteria_commentary + + new_modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.new_modifiers, Unset): + new_modifiers = self.new_modifiers.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if player_id is not UNSET: + field_dict["playerId"] = player_id + if old_rankability is not UNSET: + field_dict["oldRankability"] = old_rankability + if old_stars is not UNSET: + field_dict["oldStars"] = old_stars + if old_acc_rating is not UNSET: + field_dict["oldAccRating"] = old_acc_rating + if old_pass_rating is not UNSET: + field_dict["oldPassRating"] = old_pass_rating + if old_tech_rating is not UNSET: + field_dict["oldTechRating"] = old_tech_rating + if old_type is not UNSET: + field_dict["oldType"] = old_type + if old_criteria_met is not UNSET: + field_dict["oldCriteriaMet"] = old_criteria_met + if old_criteria_commentary is not UNSET: + field_dict["oldCriteriaCommentary"] = old_criteria_commentary + if old_modifiers is not UNSET: + field_dict["oldModifiers"] = old_modifiers + if new_rankability is not UNSET: + field_dict["newRankability"] = new_rankability + if new_stars is not UNSET: + field_dict["newStars"] = new_stars + if new_acc_rating is not UNSET: + field_dict["newAccRating"] = new_acc_rating + if new_pass_rating is not UNSET: + field_dict["newPassRating"] = new_pass_rating + if new_tech_rating is not UNSET: + field_dict["newTechRating"] = new_tech_rating + if new_type is not UNSET: + field_dict["newType"] = new_type + if new_criteria_met is not UNSET: + field_dict["newCriteriaMet"] = new_criteria_met + if new_criteria_commentary is not UNSET: + field_dict["newCriteriaCommentary"] = new_criteria_commentary + if new_modifiers is not UNSET: + field_dict["newModifiers"] = new_modifiers + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.modifiers_map import ModifiersMap + + d = src_dict.copy() + id = d.pop("id", UNSET) + + timeset = d.pop("timeset", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + old_rankability = d.pop("oldRankability", UNSET) + + old_stars = d.pop("oldStars", UNSET) + + old_acc_rating = d.pop("oldAccRating", UNSET) + + old_pass_rating = d.pop("oldPassRating", UNSET) + + old_tech_rating = d.pop("oldTechRating", UNSET) + + old_type = d.pop("oldType", UNSET) + + old_criteria_met = d.pop("oldCriteriaMet", UNSET) + + def _parse_old_criteria_commentary(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + old_criteria_commentary = _parse_old_criteria_commentary(d.pop("oldCriteriaCommentary", UNSET)) + + _old_modifiers = d.pop("oldModifiers", UNSET) + old_modifiers: Union[Unset, ModifiersMap] + if isinstance(_old_modifiers, Unset): + old_modifiers = UNSET + else: + old_modifiers = ModifiersMap.from_dict(_old_modifiers) + + new_rankability = d.pop("newRankability", UNSET) + + new_stars = d.pop("newStars", UNSET) + + new_acc_rating = d.pop("newAccRating", UNSET) + + new_pass_rating = d.pop("newPassRating", UNSET) + + new_tech_rating = d.pop("newTechRating", UNSET) + + new_type = d.pop("newType", UNSET) + + new_criteria_met = d.pop("newCriteriaMet", UNSET) + + def _parse_new_criteria_commentary(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + new_criteria_commentary = _parse_new_criteria_commentary(d.pop("newCriteriaCommentary", UNSET)) + + _new_modifiers = d.pop("newModifiers", UNSET) + new_modifiers: Union[Unset, ModifiersMap] + if isinstance(_new_modifiers, Unset): + new_modifiers = UNSET + else: + new_modifiers = ModifiersMap.from_dict(_new_modifiers) + + qualification_change = cls( + id=id, + timeset=timeset, + player_id=player_id, + old_rankability=old_rankability, + old_stars=old_stars, + old_acc_rating=old_acc_rating, + old_pass_rating=old_pass_rating, + old_tech_rating=old_tech_rating, + old_type=old_type, + old_criteria_met=old_criteria_met, + old_criteria_commentary=old_criteria_commentary, + old_modifiers=old_modifiers, + new_rankability=new_rankability, + new_stars=new_stars, + new_acc_rating=new_acc_rating, + new_pass_rating=new_pass_rating, + new_tech_rating=new_tech_rating, + new_type=new_type, + new_criteria_met=new_criteria_met, + new_criteria_commentary=new_criteria_commentary, + new_modifiers=new_modifiers, + ) + + return qualification_change diff --git a/src/clients/beatleader/models/qualification_commentary.py b/src/clients/beatleader/models/qualification_commentary.py new file mode 100644 index 0000000..ba2b6bc --- /dev/null +++ b/src/clients/beatleader/models/qualification_commentary.py @@ -0,0 +1,156 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="QualificationCommentary") + + +@_attrs_define +class QualificationCommentary: + """ + Attributes: + id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + timeset (Union[Unset, int]): + value (Union[None, Unset, str]): + edit_timeset (Union[None, Unset, int]): + edited (Union[Unset, bool]): + rank_qualification_id (Union[None, Unset, int]): + discord_message_id (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + timeset: Union[Unset, int] = UNSET + value: Union[None, Unset, str] = UNSET + edit_timeset: Union[None, Unset, int] = UNSET + edited: Union[Unset, bool] = UNSET + rank_qualification_id: Union[None, Unset, int] = UNSET + discord_message_id: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + timeset = self.timeset + + value: Union[None, Unset, str] + if isinstance(self.value, Unset): + value = UNSET + else: + value = self.value + + edit_timeset: Union[None, Unset, int] + if isinstance(self.edit_timeset, Unset): + edit_timeset = UNSET + else: + edit_timeset = self.edit_timeset + + edited = self.edited + + rank_qualification_id: Union[None, Unset, int] + if isinstance(self.rank_qualification_id, Unset): + rank_qualification_id = UNSET + else: + rank_qualification_id = self.rank_qualification_id + + discord_message_id: Union[None, Unset, str] + if isinstance(self.discord_message_id, Unset): + discord_message_id = UNSET + else: + discord_message_id = self.discord_message_id + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if value is not UNSET: + field_dict["value"] = value + if edit_timeset is not UNSET: + field_dict["editTimeset"] = edit_timeset + if edited is not UNSET: + field_dict["edited"] = edited + if rank_qualification_id is not UNSET: + field_dict["rankQualificationId"] = rank_qualification_id + if discord_message_id is not UNSET: + field_dict["discordMessageId"] = discord_message_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + timeset = d.pop("timeset", UNSET) + + def _parse_value(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + value = _parse_value(d.pop("value", UNSET)) + + def _parse_edit_timeset(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + edit_timeset = _parse_edit_timeset(d.pop("editTimeset", UNSET)) + + edited = d.pop("edited", UNSET) + + def _parse_rank_qualification_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + rank_qualification_id = _parse_rank_qualification_id(d.pop("rankQualificationId", UNSET)) + + def _parse_discord_message_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + discord_message_id = _parse_discord_message_id(d.pop("discordMessageId", UNSET)) + + qualification_commentary = cls( + id=id, + player_id=player_id, + timeset=timeset, + value=value, + edit_timeset=edit_timeset, + edited=edited, + rank_qualification_id=rank_qualification_id, + discord_message_id=discord_message_id, + ) + + return qualification_commentary diff --git a/src/clients/beatleader/models/qualification_vote.py b/src/clients/beatleader/models/qualification_vote.py new file mode 100644 index 0000000..c282a14 --- /dev/null +++ b/src/clients/beatleader/models/qualification_vote.py @@ -0,0 +1,153 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.map_quality import MapQuality +from ..types import UNSET, Unset + +T = TypeVar("T", bound="QualificationVote") + + +@_attrs_define +class QualificationVote: + """ + Attributes: + id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + timeset (Union[Unset, int]): + value (Union[Unset, MapQuality]): + edit_timeset (Union[None, Unset, int]): + edited (Union[Unset, bool]): + rank_qualification_id (Union[None, Unset, int]): + discord_rt_message_id (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + timeset: Union[Unset, int] = UNSET + value: Union[Unset, MapQuality] = UNSET + edit_timeset: Union[None, Unset, int] = UNSET + edited: Union[Unset, bool] = UNSET + rank_qualification_id: Union[None, Unset, int] = UNSET + discord_rt_message_id: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + timeset = self.timeset + + value: Union[Unset, str] = UNSET + if not isinstance(self.value, Unset): + value = self.value.value + + edit_timeset: Union[None, Unset, int] + if isinstance(self.edit_timeset, Unset): + edit_timeset = UNSET + else: + edit_timeset = self.edit_timeset + + edited = self.edited + + rank_qualification_id: Union[None, Unset, int] + if isinstance(self.rank_qualification_id, Unset): + rank_qualification_id = UNSET + else: + rank_qualification_id = self.rank_qualification_id + + discord_rt_message_id: Union[None, Unset, str] + if isinstance(self.discord_rt_message_id, Unset): + discord_rt_message_id = UNSET + else: + discord_rt_message_id = self.discord_rt_message_id + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if value is not UNSET: + field_dict["value"] = value + if edit_timeset is not UNSET: + field_dict["editTimeset"] = edit_timeset + if edited is not UNSET: + field_dict["edited"] = edited + if rank_qualification_id is not UNSET: + field_dict["rankQualificationId"] = rank_qualification_id + if discord_rt_message_id is not UNSET: + field_dict["discordRTMessageId"] = discord_rt_message_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + timeset = d.pop("timeset", UNSET) + + _value = d.pop("value", UNSET) + value: Union[Unset, MapQuality] + if isinstance(_value, Unset): + value = UNSET + else: + value = MapQuality(_value) + + def _parse_edit_timeset(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + edit_timeset = _parse_edit_timeset(d.pop("editTimeset", UNSET)) + + edited = d.pop("edited", UNSET) + + def _parse_rank_qualification_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + rank_qualification_id = _parse_rank_qualification_id(d.pop("rankQualificationId", UNSET)) + + def _parse_discord_rt_message_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + discord_rt_message_id = _parse_discord_rt_message_id(d.pop("discordRTMessageId", UNSET)) + + qualification_vote = cls( + id=id, + player_id=player_id, + timeset=timeset, + value=value, + edit_timeset=edit_timeset, + edited=edited, + rank_qualification_id=rank_qualification_id, + discord_rt_message_id=discord_rt_message_id, + ) + + return qualification_vote diff --git a/src/clients/beatleader/models/rank_qualification.py b/src/clients/beatleader/models/rank_qualification.py new file mode 100644 index 0000000..0ae272a --- /dev/null +++ b/src/clients/beatleader/models/rank_qualification.py @@ -0,0 +1,474 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.criteria_commentary import CriteriaCommentary + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + from ..models.qualification_change import QualificationChange + from ..models.qualification_commentary import QualificationCommentary + from ..models.qualification_vote import QualificationVote + + +T = TypeVar("T", bound="RankQualification") + + +@_attrs_define +class RankQualification: + """ + Attributes: + id (Union[Unset, int]): + timeset (Union[Unset, int]): + rt_member (Union[None, Unset, str]): + criteria_timeset (Union[Unset, int]): + criteria_met (Union[Unset, int]): + criteria_checker (Union[None, Unset, str]): + criteria_commentary (Union[None, Unset, str]): + mapper_allowed (Union[Unset, bool]): + mapper_id (Union[None, Unset, str]): + mapper_qualification (Union[Unset, bool]): + approval_timeset (Union[Unset, int]): + approved (Union[Unset, bool]): + approvers (Union[None, Unset, str]): + criteria_check (Union[None, Unset, str]): + modifiers (Union[Unset, ModifiersMap]): + modifiers_rating (Union[Unset, ModifiersRating]): + changes (Union[List['QualificationChange'], None, Unset]): + comments (Union[List['QualificationCommentary'], None, Unset]): + criteria_comments (Union[List['CriteriaCommentary'], None, Unset]): + quality_vote (Union[Unset, int]): + votes (Union[List['QualificationVote'], None, Unset]): + discord_channel_id (Union[None, Unset, str]): + discord_rt_channel_id (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + timeset: Union[Unset, int] = UNSET + rt_member: Union[None, Unset, str] = UNSET + criteria_timeset: Union[Unset, int] = UNSET + criteria_met: Union[Unset, int] = UNSET + criteria_checker: Union[None, Unset, str] = UNSET + criteria_commentary: Union[None, Unset, str] = UNSET + mapper_allowed: Union[Unset, bool] = UNSET + mapper_id: Union[None, Unset, str] = UNSET + mapper_qualification: Union[Unset, bool] = UNSET + approval_timeset: Union[Unset, int] = UNSET + approved: Union[Unset, bool] = UNSET + approvers: Union[None, Unset, str] = UNSET + criteria_check: Union[None, Unset, str] = UNSET + modifiers: Union[Unset, "ModifiersMap"] = UNSET + modifiers_rating: Union[Unset, "ModifiersRating"] = UNSET + changes: Union[List["QualificationChange"], None, Unset] = UNSET + comments: Union[List["QualificationCommentary"], None, Unset] = UNSET + criteria_comments: Union[List["CriteriaCommentary"], None, Unset] = UNSET + quality_vote: Union[Unset, int] = UNSET + votes: Union[List["QualificationVote"], None, Unset] = UNSET + discord_channel_id: Union[None, Unset, str] = UNSET + discord_rt_channel_id: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timeset = self.timeset + + rt_member: Union[None, Unset, str] + if isinstance(self.rt_member, Unset): + rt_member = UNSET + else: + rt_member = self.rt_member + + criteria_timeset = self.criteria_timeset + + criteria_met = self.criteria_met + + criteria_checker: Union[None, Unset, str] + if isinstance(self.criteria_checker, Unset): + criteria_checker = UNSET + else: + criteria_checker = self.criteria_checker + + criteria_commentary: Union[None, Unset, str] + if isinstance(self.criteria_commentary, Unset): + criteria_commentary = UNSET + else: + criteria_commentary = self.criteria_commentary + + mapper_allowed = self.mapper_allowed + + mapper_id: Union[None, Unset, str] + if isinstance(self.mapper_id, Unset): + mapper_id = UNSET + else: + mapper_id = self.mapper_id + + mapper_qualification = self.mapper_qualification + + approval_timeset = self.approval_timeset + + approved = self.approved + + approvers: Union[None, Unset, str] + if isinstance(self.approvers, Unset): + approvers = UNSET + else: + approvers = self.approvers + + criteria_check: Union[None, Unset, str] + if isinstance(self.criteria_check, Unset): + criteria_check = UNSET + else: + criteria_check = self.criteria_check + + modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifiers, Unset): + modifiers = self.modifiers.to_dict() + + modifiers_rating: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifiers_rating, Unset): + modifiers_rating = self.modifiers_rating.to_dict() + + changes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.changes, Unset): + changes = UNSET + elif isinstance(self.changes, list): + changes = [] + for changes_type_0_item_data in self.changes: + changes_type_0_item = changes_type_0_item_data.to_dict() + changes.append(changes_type_0_item) + + else: + changes = self.changes + + comments: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.comments, Unset): + comments = UNSET + elif isinstance(self.comments, list): + comments = [] + for comments_type_0_item_data in self.comments: + comments_type_0_item = comments_type_0_item_data.to_dict() + comments.append(comments_type_0_item) + + else: + comments = self.comments + + criteria_comments: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.criteria_comments, Unset): + criteria_comments = UNSET + elif isinstance(self.criteria_comments, list): + criteria_comments = [] + for criteria_comments_type_0_item_data in self.criteria_comments: + criteria_comments_type_0_item = criteria_comments_type_0_item_data.to_dict() + criteria_comments.append(criteria_comments_type_0_item) + + else: + criteria_comments = self.criteria_comments + + quality_vote = self.quality_vote + + votes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.votes, Unset): + votes = UNSET + elif isinstance(self.votes, list): + votes = [] + for votes_type_0_item_data in self.votes: + votes_type_0_item = votes_type_0_item_data.to_dict() + votes.append(votes_type_0_item) + + else: + votes = self.votes + + discord_channel_id: Union[None, Unset, str] + if isinstance(self.discord_channel_id, Unset): + discord_channel_id = UNSET + else: + discord_channel_id = self.discord_channel_id + + discord_rt_channel_id: Union[None, Unset, str] + if isinstance(self.discord_rt_channel_id, Unset): + discord_rt_channel_id = UNSET + else: + discord_rt_channel_id = self.discord_rt_channel_id + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if rt_member is not UNSET: + field_dict["rtMember"] = rt_member + if criteria_timeset is not UNSET: + field_dict["criteriaTimeset"] = criteria_timeset + if criteria_met is not UNSET: + field_dict["criteriaMet"] = criteria_met + if criteria_checker is not UNSET: + field_dict["criteriaChecker"] = criteria_checker + if criteria_commentary is not UNSET: + field_dict["criteriaCommentary"] = criteria_commentary + if mapper_allowed is not UNSET: + field_dict["mapperAllowed"] = mapper_allowed + if mapper_id is not UNSET: + field_dict["mapperId"] = mapper_id + if mapper_qualification is not UNSET: + field_dict["mapperQualification"] = mapper_qualification + if approval_timeset is not UNSET: + field_dict["approvalTimeset"] = approval_timeset + if approved is not UNSET: + field_dict["approved"] = approved + if approvers is not UNSET: + field_dict["approvers"] = approvers + if criteria_check is not UNSET: + field_dict["criteriaCheck"] = criteria_check + if modifiers is not UNSET: + field_dict["modifiers"] = modifiers + if modifiers_rating is not UNSET: + field_dict["modifiersRating"] = modifiers_rating + if changes is not UNSET: + field_dict["changes"] = changes + if comments is not UNSET: + field_dict["comments"] = comments + if criteria_comments is not UNSET: + field_dict["criteriaComments"] = criteria_comments + if quality_vote is not UNSET: + field_dict["qualityVote"] = quality_vote + if votes is not UNSET: + field_dict["votes"] = votes + if discord_channel_id is not UNSET: + field_dict["discordChannelId"] = discord_channel_id + if discord_rt_channel_id is not UNSET: + field_dict["discordRTChannelId"] = discord_rt_channel_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.criteria_commentary import CriteriaCommentary + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + from ..models.qualification_change import QualificationChange + from ..models.qualification_commentary import QualificationCommentary + from ..models.qualification_vote import QualificationVote + + d = src_dict.copy() + id = d.pop("id", UNSET) + + timeset = d.pop("timeset", UNSET) + + def _parse_rt_member(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + rt_member = _parse_rt_member(d.pop("rtMember", UNSET)) + + criteria_timeset = d.pop("criteriaTimeset", UNSET) + + criteria_met = d.pop("criteriaMet", UNSET) + + def _parse_criteria_checker(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + criteria_checker = _parse_criteria_checker(d.pop("criteriaChecker", UNSET)) + + def _parse_criteria_commentary(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + criteria_commentary = _parse_criteria_commentary(d.pop("criteriaCommentary", UNSET)) + + mapper_allowed = d.pop("mapperAllowed", UNSET) + + def _parse_mapper_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mapper_id = _parse_mapper_id(d.pop("mapperId", UNSET)) + + mapper_qualification = d.pop("mapperQualification", UNSET) + + approval_timeset = d.pop("approvalTimeset", UNSET) + + approved = d.pop("approved", UNSET) + + def _parse_approvers(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + approvers = _parse_approvers(d.pop("approvers", UNSET)) + + def _parse_criteria_check(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + criteria_check = _parse_criteria_check(d.pop("criteriaCheck", UNSET)) + + _modifiers = d.pop("modifiers", UNSET) + modifiers: Union[Unset, ModifiersMap] + if isinstance(_modifiers, Unset): + modifiers = UNSET + else: + modifiers = ModifiersMap.from_dict(_modifiers) + + _modifiers_rating = d.pop("modifiersRating", UNSET) + modifiers_rating: Union[Unset, ModifiersRating] + if isinstance(_modifiers_rating, Unset): + modifiers_rating = UNSET + else: + modifiers_rating = ModifiersRating.from_dict(_modifiers_rating) + + def _parse_changes(data: object) -> Union[List["QualificationChange"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + changes_type_0 = [] + _changes_type_0 = data + for changes_type_0_item_data in _changes_type_0: + changes_type_0_item = QualificationChange.from_dict(changes_type_0_item_data) + + changes_type_0.append(changes_type_0_item) + + return changes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["QualificationChange"], None, Unset], data) + + changes = _parse_changes(d.pop("changes", UNSET)) + + def _parse_comments(data: object) -> Union[List["QualificationCommentary"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + comments_type_0 = [] + _comments_type_0 = data + for comments_type_0_item_data in _comments_type_0: + comments_type_0_item = QualificationCommentary.from_dict(comments_type_0_item_data) + + comments_type_0.append(comments_type_0_item) + + return comments_type_0 + except: # noqa: E722 + pass + return cast(Union[List["QualificationCommentary"], None, Unset], data) + + comments = _parse_comments(d.pop("comments", UNSET)) + + def _parse_criteria_comments(data: object) -> Union[List["CriteriaCommentary"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + criteria_comments_type_0 = [] + _criteria_comments_type_0 = data + for criteria_comments_type_0_item_data in _criteria_comments_type_0: + criteria_comments_type_0_item = CriteriaCommentary.from_dict(criteria_comments_type_0_item_data) + + criteria_comments_type_0.append(criteria_comments_type_0_item) + + return criteria_comments_type_0 + except: # noqa: E722 + pass + return cast(Union[List["CriteriaCommentary"], None, Unset], data) + + criteria_comments = _parse_criteria_comments(d.pop("criteriaComments", UNSET)) + + quality_vote = d.pop("qualityVote", UNSET) + + def _parse_votes(data: object) -> Union[List["QualificationVote"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + votes_type_0 = [] + _votes_type_0 = data + for votes_type_0_item_data in _votes_type_0: + votes_type_0_item = QualificationVote.from_dict(votes_type_0_item_data) + + votes_type_0.append(votes_type_0_item) + + return votes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["QualificationVote"], None, Unset], data) + + votes = _parse_votes(d.pop("votes", UNSET)) + + def _parse_discord_channel_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + discord_channel_id = _parse_discord_channel_id(d.pop("discordChannelId", UNSET)) + + def _parse_discord_rt_channel_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + discord_rt_channel_id = _parse_discord_rt_channel_id(d.pop("discordRTChannelId", UNSET)) + + rank_qualification = cls( + id=id, + timeset=timeset, + rt_member=rt_member, + criteria_timeset=criteria_timeset, + criteria_met=criteria_met, + criteria_checker=criteria_checker, + criteria_commentary=criteria_commentary, + mapper_allowed=mapper_allowed, + mapper_id=mapper_id, + mapper_qualification=mapper_qualification, + approval_timeset=approval_timeset, + approved=approved, + approvers=approvers, + criteria_check=criteria_check, + modifiers=modifiers, + modifiers_rating=modifiers_rating, + changes=changes, + comments=comments, + criteria_comments=criteria_comments, + quality_vote=quality_vote, + votes=votes, + discord_channel_id=discord_channel_id, + discord_rt_channel_id=discord_rt_channel_id, + ) + + return rank_qualification diff --git a/src/clients/beatleader/models/rank_update.py b/src/clients/beatleader/models/rank_update.py new file mode 100644 index 0000000..215b171 --- /dev/null +++ b/src/clients/beatleader/models/rank_update.py @@ -0,0 +1,240 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + from ..models.rank_update_change import RankUpdateChange + + +T = TypeVar("T", bound="RankUpdate") + + +@_attrs_define +class RankUpdate: + """ + Attributes: + id (Union[Unset, int]): + timeset (Union[Unset, int]): + rt_member (Union[None, Unset, str]): + keep (Union[Unset, bool]): + stars (Union[Unset, float]): + pass_rating (Union[Unset, float]): + tech_rating (Union[Unset, float]): + predicted_acc (Union[Unset, float]): + type (Union[Unset, int]): + criteria_met (Union[Unset, int]): + criteria_commentary (Union[None, Unset, str]): + finished (Union[Unset, bool]): + modifiers (Union[Unset, ModifiersMap]): + modifiers_rating (Union[Unset, ModifiersRating]): + changes (Union[List['RankUpdateChange'], None, Unset]): + """ + + id: Union[Unset, int] = UNSET + timeset: Union[Unset, int] = UNSET + rt_member: Union[None, Unset, str] = UNSET + keep: Union[Unset, bool] = UNSET + stars: Union[Unset, float] = UNSET + pass_rating: Union[Unset, float] = UNSET + tech_rating: Union[Unset, float] = UNSET + predicted_acc: Union[Unset, float] = UNSET + type: Union[Unset, int] = UNSET + criteria_met: Union[Unset, int] = UNSET + criteria_commentary: Union[None, Unset, str] = UNSET + finished: Union[Unset, bool] = UNSET + modifiers: Union[Unset, "ModifiersMap"] = UNSET + modifiers_rating: Union[Unset, "ModifiersRating"] = UNSET + changes: Union[List["RankUpdateChange"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timeset = self.timeset + + rt_member: Union[None, Unset, str] + if isinstance(self.rt_member, Unset): + rt_member = UNSET + else: + rt_member = self.rt_member + + keep = self.keep + + stars = self.stars + + pass_rating = self.pass_rating + + tech_rating = self.tech_rating + + predicted_acc = self.predicted_acc + + type = self.type + + criteria_met = self.criteria_met + + criteria_commentary: Union[None, Unset, str] + if isinstance(self.criteria_commentary, Unset): + criteria_commentary = UNSET + else: + criteria_commentary = self.criteria_commentary + + finished = self.finished + + modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifiers, Unset): + modifiers = self.modifiers.to_dict() + + modifiers_rating: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.modifiers_rating, Unset): + modifiers_rating = self.modifiers_rating.to_dict() + + changes: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.changes, Unset): + changes = UNSET + elif isinstance(self.changes, list): + changes = [] + for changes_type_0_item_data in self.changes: + changes_type_0_item = changes_type_0_item_data.to_dict() + changes.append(changes_type_0_item) + + else: + changes = self.changes + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if rt_member is not UNSET: + field_dict["rtMember"] = rt_member + if keep is not UNSET: + field_dict["keep"] = keep + if stars is not UNSET: + field_dict["stars"] = stars + if pass_rating is not UNSET: + field_dict["passRating"] = pass_rating + if tech_rating is not UNSET: + field_dict["techRating"] = tech_rating + if predicted_acc is not UNSET: + field_dict["predictedAcc"] = predicted_acc + if type is not UNSET: + field_dict["type"] = type + if criteria_met is not UNSET: + field_dict["criteriaMet"] = criteria_met + if criteria_commentary is not UNSET: + field_dict["criteriaCommentary"] = criteria_commentary + if finished is not UNSET: + field_dict["finished"] = finished + if modifiers is not UNSET: + field_dict["modifiers"] = modifiers + if modifiers_rating is not UNSET: + field_dict["modifiersRating"] = modifiers_rating + if changes is not UNSET: + field_dict["changes"] = changes + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.modifiers_map import ModifiersMap + from ..models.modifiers_rating import ModifiersRating + from ..models.rank_update_change import RankUpdateChange + + d = src_dict.copy() + id = d.pop("id", UNSET) + + timeset = d.pop("timeset", UNSET) + + def _parse_rt_member(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + rt_member = _parse_rt_member(d.pop("rtMember", UNSET)) + + keep = d.pop("keep", UNSET) + + stars = d.pop("stars", UNSET) + + pass_rating = d.pop("passRating", UNSET) + + tech_rating = d.pop("techRating", UNSET) + + predicted_acc = d.pop("predictedAcc", UNSET) + + type = d.pop("type", UNSET) + + criteria_met = d.pop("criteriaMet", UNSET) + + def _parse_criteria_commentary(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + criteria_commentary = _parse_criteria_commentary(d.pop("criteriaCommentary", UNSET)) + + finished = d.pop("finished", UNSET) + + _modifiers = d.pop("modifiers", UNSET) + modifiers: Union[Unset, ModifiersMap] + if isinstance(_modifiers, Unset): + modifiers = UNSET + else: + modifiers = ModifiersMap.from_dict(_modifiers) + + _modifiers_rating = d.pop("modifiersRating", UNSET) + modifiers_rating: Union[Unset, ModifiersRating] + if isinstance(_modifiers_rating, Unset): + modifiers_rating = UNSET + else: + modifiers_rating = ModifiersRating.from_dict(_modifiers_rating) + + def _parse_changes(data: object) -> Union[List["RankUpdateChange"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + changes_type_0 = [] + _changes_type_0 = data + for changes_type_0_item_data in _changes_type_0: + changes_type_0_item = RankUpdateChange.from_dict(changes_type_0_item_data) + + changes_type_0.append(changes_type_0_item) + + return changes_type_0 + except: # noqa: E722 + pass + return cast(Union[List["RankUpdateChange"], None, Unset], data) + + changes = _parse_changes(d.pop("changes", UNSET)) + + rank_update = cls( + id=id, + timeset=timeset, + rt_member=rt_member, + keep=keep, + stars=stars, + pass_rating=pass_rating, + tech_rating=tech_rating, + predicted_acc=predicted_acc, + type=type, + criteria_met=criteria_met, + criteria_commentary=criteria_commentary, + finished=finished, + modifiers=modifiers, + modifiers_rating=modifiers_rating, + changes=changes, + ) + + return rank_update diff --git a/src/clients/beatleader/models/rank_update_change.py b/src/clients/beatleader/models/rank_update_change.py new file mode 100644 index 0000000..8e48786 --- /dev/null +++ b/src/clients/beatleader/models/rank_update_change.py @@ -0,0 +1,217 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.modifiers_map import ModifiersMap + + +T = TypeVar("T", bound="RankUpdateChange") + + +@_attrs_define +class RankUpdateChange: + """ + Attributes: + id (Union[Unset, int]): + timeset (Union[Unset, int]): + player_id (Union[None, Unset, str]): + old_keep (Union[Unset, bool]): + old_stars (Union[Unset, float]): + old_type (Union[Unset, int]): + old_criteria_met (Union[Unset, int]): + old_criteria_commentary (Union[None, Unset, str]): + old_modifiers (Union[Unset, ModifiersMap]): + new_keep (Union[Unset, bool]): + new_stars (Union[Unset, float]): + new_type (Union[Unset, int]): + new_criteria_met (Union[Unset, int]): + new_criteria_commentary (Union[None, Unset, str]): + new_modifiers (Union[Unset, ModifiersMap]): + """ + + id: Union[Unset, int] = UNSET + timeset: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + old_keep: Union[Unset, bool] = UNSET + old_stars: Union[Unset, float] = UNSET + old_type: Union[Unset, int] = UNSET + old_criteria_met: Union[Unset, int] = UNSET + old_criteria_commentary: Union[None, Unset, str] = UNSET + old_modifiers: Union[Unset, "ModifiersMap"] = UNSET + new_keep: Union[Unset, bool] = UNSET + new_stars: Union[Unset, float] = UNSET + new_type: Union[Unset, int] = UNSET + new_criteria_met: Union[Unset, int] = UNSET + new_criteria_commentary: Union[None, Unset, str] = UNSET + new_modifiers: Union[Unset, "ModifiersMap"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timeset = self.timeset + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + old_keep = self.old_keep + + old_stars = self.old_stars + + old_type = self.old_type + + old_criteria_met = self.old_criteria_met + + old_criteria_commentary: Union[None, Unset, str] + if isinstance(self.old_criteria_commentary, Unset): + old_criteria_commentary = UNSET + else: + old_criteria_commentary = self.old_criteria_commentary + + old_modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.old_modifiers, Unset): + old_modifiers = self.old_modifiers.to_dict() + + new_keep = self.new_keep + + new_stars = self.new_stars + + new_type = self.new_type + + new_criteria_met = self.new_criteria_met + + new_criteria_commentary: Union[None, Unset, str] + if isinstance(self.new_criteria_commentary, Unset): + new_criteria_commentary = UNSET + else: + new_criteria_commentary = self.new_criteria_commentary + + new_modifiers: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.new_modifiers, Unset): + new_modifiers = self.new_modifiers.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if player_id is not UNSET: + field_dict["playerId"] = player_id + if old_keep is not UNSET: + field_dict["oldKeep"] = old_keep + if old_stars is not UNSET: + field_dict["oldStars"] = old_stars + if old_type is not UNSET: + field_dict["oldType"] = old_type + if old_criteria_met is not UNSET: + field_dict["oldCriteriaMet"] = old_criteria_met + if old_criteria_commentary is not UNSET: + field_dict["oldCriteriaCommentary"] = old_criteria_commentary + if old_modifiers is not UNSET: + field_dict["oldModifiers"] = old_modifiers + if new_keep is not UNSET: + field_dict["newKeep"] = new_keep + if new_stars is not UNSET: + field_dict["newStars"] = new_stars + if new_type is not UNSET: + field_dict["newType"] = new_type + if new_criteria_met is not UNSET: + field_dict["newCriteriaMet"] = new_criteria_met + if new_criteria_commentary is not UNSET: + field_dict["newCriteriaCommentary"] = new_criteria_commentary + if new_modifiers is not UNSET: + field_dict["newModifiers"] = new_modifiers + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.modifiers_map import ModifiersMap + + d = src_dict.copy() + id = d.pop("id", UNSET) + + timeset = d.pop("timeset", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + old_keep = d.pop("oldKeep", UNSET) + + old_stars = d.pop("oldStars", UNSET) + + old_type = d.pop("oldType", UNSET) + + old_criteria_met = d.pop("oldCriteriaMet", UNSET) + + def _parse_old_criteria_commentary(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + old_criteria_commentary = _parse_old_criteria_commentary(d.pop("oldCriteriaCommentary", UNSET)) + + _old_modifiers = d.pop("oldModifiers", UNSET) + old_modifiers: Union[Unset, ModifiersMap] + if isinstance(_old_modifiers, Unset): + old_modifiers = UNSET + else: + old_modifiers = ModifiersMap.from_dict(_old_modifiers) + + new_keep = d.pop("newKeep", UNSET) + + new_stars = d.pop("newStars", UNSET) + + new_type = d.pop("newType", UNSET) + + new_criteria_met = d.pop("newCriteriaMet", UNSET) + + def _parse_new_criteria_commentary(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + new_criteria_commentary = _parse_new_criteria_commentary(d.pop("newCriteriaCommentary", UNSET)) + + _new_modifiers = d.pop("newModifiers", UNSET) + new_modifiers: Union[Unset, ModifiersMap] + if isinstance(_new_modifiers, Unset): + new_modifiers = UNSET + else: + new_modifiers = ModifiersMap.from_dict(_new_modifiers) + + rank_update_change = cls( + id=id, + timeset=timeset, + player_id=player_id, + old_keep=old_keep, + old_stars=old_stars, + old_type=old_type, + old_criteria_met=old_criteria_met, + old_criteria_commentary=old_criteria_commentary, + old_modifiers=old_modifiers, + new_keep=new_keep, + new_stars=new_stars, + new_type=new_type, + new_criteria_met=new_criteria_met, + new_criteria_commentary=new_criteria_commentary, + new_modifiers=new_modifiers, + ) + + return rank_update_change diff --git a/src/clients/beatleader/models/rank_voting.py b/src/clients/beatleader/models/rank_voting.py new file mode 100644 index 0000000..04e225c --- /dev/null +++ b/src/clients/beatleader/models/rank_voting.py @@ -0,0 +1,199 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.voter_feedback import VoterFeedback + + +T = TypeVar("T", bound="RankVoting") + + +@_attrs_define +class RankVoting: + """ + Attributes: + score_id (Union[Unset, int]): + player_id (Union[None, Unset, str]): + hash_ (Union[None, Unset, str]): + diff (Union[None, Unset, str]): + mode (Union[None, Unset, str]): + rankability (Union[Unset, float]): + stars (Union[Unset, float]): + type (Union[Unset, int]): + timeset (Union[Unset, int]): + feedbacks (Union[List['VoterFeedback'], None, Unset]): + """ + + score_id: Union[Unset, int] = UNSET + player_id: Union[None, Unset, str] = UNSET + hash_: Union[None, Unset, str] = UNSET + diff: Union[None, Unset, str] = UNSET + mode: Union[None, Unset, str] = UNSET + rankability: Union[Unset, float] = UNSET + stars: Union[Unset, float] = UNSET + type: Union[Unset, int] = UNSET + timeset: Union[Unset, int] = UNSET + feedbacks: Union[List["VoterFeedback"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + score_id = self.score_id + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + hash_: Union[None, Unset, str] + if isinstance(self.hash_, Unset): + hash_ = UNSET + else: + hash_ = self.hash_ + + diff: Union[None, Unset, str] + if isinstance(self.diff, Unset): + diff = UNSET + else: + diff = self.diff + + mode: Union[None, Unset, str] + if isinstance(self.mode, Unset): + mode = UNSET + else: + mode = self.mode + + rankability = self.rankability + + stars = self.stars + + type = self.type + + timeset = self.timeset + + feedbacks: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.feedbacks, Unset): + feedbacks = UNSET + elif isinstance(self.feedbacks, list): + feedbacks = [] + for feedbacks_type_0_item_data in self.feedbacks: + feedbacks_type_0_item = feedbacks_type_0_item_data.to_dict() + feedbacks.append(feedbacks_type_0_item) + + else: + feedbacks = self.feedbacks + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if score_id is not UNSET: + field_dict["scoreId"] = score_id + if player_id is not UNSET: + field_dict["playerId"] = player_id + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if diff is not UNSET: + field_dict["diff"] = diff + if mode is not UNSET: + field_dict["mode"] = mode + if rankability is not UNSET: + field_dict["rankability"] = rankability + if stars is not UNSET: + field_dict["stars"] = stars + if type is not UNSET: + field_dict["type"] = type + if timeset is not UNSET: + field_dict["timeset"] = timeset + if feedbacks is not UNSET: + field_dict["feedbacks"] = feedbacks + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.voter_feedback import VoterFeedback + + d = src_dict.copy() + score_id = d.pop("scoreId", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + def _parse_hash_(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + hash_ = _parse_hash_(d.pop("hash", UNSET)) + + def _parse_diff(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + diff = _parse_diff(d.pop("diff", UNSET)) + + def _parse_mode(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mode = _parse_mode(d.pop("mode", UNSET)) + + rankability = d.pop("rankability", UNSET) + + stars = d.pop("stars", UNSET) + + type = d.pop("type", UNSET) + + timeset = d.pop("timeset", UNSET) + + def _parse_feedbacks(data: object) -> Union[List["VoterFeedback"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + feedbacks_type_0 = [] + _feedbacks_type_0 = data + for feedbacks_type_0_item_data in _feedbacks_type_0: + feedbacks_type_0_item = VoterFeedback.from_dict(feedbacks_type_0_item_data) + + feedbacks_type_0.append(feedbacks_type_0_item) + + return feedbacks_type_0 + except: # noqa: E722 + pass + return cast(Union[List["VoterFeedback"], None, Unset], data) + + feedbacks = _parse_feedbacks(d.pop("feedbacks", UNSET)) + + rank_voting = cls( + score_id=score_id, + player_id=player_id, + hash_=hash_, + diff=diff, + mode=mode, + rankability=rankability, + stars=stars, + type=type, + timeset=timeset, + feedbacks=feedbacks, + ) + + return rank_voting diff --git a/src/clients/beatleader/models/ranked_map.py b/src/clients/beatleader/models/ranked_map.py new file mode 100644 index 0000000..54615a1 --- /dev/null +++ b/src/clients/beatleader/models/ranked_map.py @@ -0,0 +1,110 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="RankedMap") + + +@_attrs_define +class RankedMap: + """ + Attributes: + name (Union[None, Unset, str]): + song_id (Union[None, Unset, str]): + cover (Union[None, Unset, str]): + stars (Union[None, Unset, float]): + """ + + name: Union[None, Unset, str] = UNSET + song_id: Union[None, Unset, str] = UNSET + cover: Union[None, Unset, str] = UNSET + stars: Union[None, Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + song_id: Union[None, Unset, str] + if isinstance(self.song_id, Unset): + song_id = UNSET + else: + song_id = self.song_id + + cover: Union[None, Unset, str] + if isinstance(self.cover, Unset): + cover = UNSET + else: + cover = self.cover + + stars: Union[None, Unset, float] + if isinstance(self.stars, Unset): + stars = UNSET + else: + stars = self.stars + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if name is not UNSET: + field_dict["name"] = name + if song_id is not UNSET: + field_dict["songId"] = song_id + if cover is not UNSET: + field_dict["cover"] = cover + if stars is not UNSET: + field_dict["stars"] = stars + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_song_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + song_id = _parse_song_id(d.pop("songId", UNSET)) + + def _parse_cover(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover = _parse_cover(d.pop("cover", UNSET)) + + def _parse_stars(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + stars = _parse_stars(d.pop("stars", UNSET)) + + ranked_map = cls( + name=name, + song_id=song_id, + cover=cover, + stars=stars, + ) + + return ranked_map diff --git a/src/clients/beatleader/models/ranked_mapper_response.py b/src/clients/beatleader/models/ranked_mapper_response.py new file mode 100644 index 0000000..fb301a7 --- /dev/null +++ b/src/clients/beatleader/models/ranked_mapper_response.py @@ -0,0 +1,101 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.ranked_map import RankedMap + + +T = TypeVar("T", bound="RankedMapperResponse") + + +@_attrs_define +class RankedMapperResponse: + """ + Attributes: + players_count (Union[Unset, int]): + total_pp (Union[Unset, float]): + maps (Union[List['RankedMap'], None, Unset]): + total_map_count (Union[Unset, int]): + """ + + players_count: Union[Unset, int] = UNSET + total_pp: Union[Unset, float] = UNSET + maps: Union[List["RankedMap"], None, Unset] = UNSET + total_map_count: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + players_count = self.players_count + + total_pp = self.total_pp + + maps: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.maps, Unset): + maps = UNSET + elif isinstance(self.maps, list): + maps = [] + for maps_type_0_item_data in self.maps: + maps_type_0_item = maps_type_0_item_data.to_dict() + maps.append(maps_type_0_item) + + else: + maps = self.maps + + total_map_count = self.total_map_count + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if players_count is not UNSET: + field_dict["playersCount"] = players_count + if total_pp is not UNSET: + field_dict["totalPp"] = total_pp + if maps is not UNSET: + field_dict["maps"] = maps + if total_map_count is not UNSET: + field_dict["totalMapCount"] = total_map_count + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.ranked_map import RankedMap + + d = src_dict.copy() + players_count = d.pop("playersCount", UNSET) + + total_pp = d.pop("totalPp", UNSET) + + def _parse_maps(data: object) -> Union[List["RankedMap"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + maps_type_0 = [] + _maps_type_0 = data + for maps_type_0_item_data in _maps_type_0: + maps_type_0_item = RankedMap.from_dict(maps_type_0_item_data) + + maps_type_0.append(maps_type_0_item) + + return maps_type_0 + except: # noqa: E722 + pass + return cast(Union[List["RankedMap"], None, Unset], data) + + maps = _parse_maps(d.pop("maps", UNSET)) + + total_map_count = d.pop("totalMapCount", UNSET) + + ranked_mapper_response = cls( + players_count=players_count, + total_pp=total_pp, + maps=maps, + total_map_count=total_map_count, + ) + + return ranked_mapper_response diff --git a/src/clients/beatleader/models/replay_offsets.py b/src/clients/beatleader/models/replay_offsets.py new file mode 100644 index 0000000..2681578 --- /dev/null +++ b/src/clients/beatleader/models/replay_offsets.py @@ -0,0 +1,83 @@ +from typing import Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ReplayOffsets") + + +@_attrs_define +class ReplayOffsets: + """ + Attributes: + id (Union[Unset, int]): + frames (Union[Unset, int]): + notes (Union[Unset, int]): + walls (Union[Unset, int]): + heights (Union[Unset, int]): + pauses (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + frames: Union[Unset, int] = UNSET + notes: Union[Unset, int] = UNSET + walls: Union[Unset, int] = UNSET + heights: Union[Unset, int] = UNSET + pauses: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + frames = self.frames + + notes = self.notes + + walls = self.walls + + heights = self.heights + + pauses = self.pauses + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if frames is not UNSET: + field_dict["frames"] = frames + if notes is not UNSET: + field_dict["notes"] = notes + if walls is not UNSET: + field_dict["walls"] = walls + if heights is not UNSET: + field_dict["heights"] = heights + if pauses is not UNSET: + field_dict["pauses"] = pauses + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + frames = d.pop("frames", UNSET) + + notes = d.pop("notes", UNSET) + + walls = d.pop("walls", UNSET) + + heights = d.pop("heights", UNSET) + + pauses = d.pop("pauses", UNSET) + + replay_offsets = cls( + id=id, + frames=frames, + notes=notes, + walls=walls, + heights=heights, + pauses=pauses, + ) + + return replay_offsets diff --git a/src/clients/beatleader/models/requirements.py b/src/clients/beatleader/models/requirements.py new file mode 100644 index 0000000..3db6a3d --- /dev/null +++ b/src/clients/beatleader/models/requirements.py @@ -0,0 +1,15 @@ +from enum import Enum + + +class Requirements(str, Enum): + CHROMA = "chroma" + CINEMA = "cinema" + IGNORE = "ignore" + MAPPINGEXTENSIONS = "mappingExtensions" + NONE = "none" + NOODLES = "noodles" + OPTIONALPROPERTIES = "optionalProperties" + V3 = "v3" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/score_filter_status.py b/src/clients/beatleader/models/score_filter_status.py new file mode 100644 index 0000000..b7eca55 --- /dev/null +++ b/src/clients/beatleader/models/score_filter_status.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class ScoreFilterStatus(str, Enum): + NONE = "none" + SUSPICIOUS = "suspicious" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/score_graph_entry.py b/src/clients/beatleader/models/score_graph_entry.py new file mode 100644 index 0000000..78c8492 --- /dev/null +++ b/src/clients/beatleader/models/score_graph_entry.py @@ -0,0 +1,222 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ScoreGraphEntry") + + +@_attrs_define +class ScoreGraphEntry: + """ + Attributes: + player_id (Union[None, Unset, str]): + weight (Union[Unset, float]): + rank (Union[Unset, int]): + timepost (Union[Unset, int]): + pauses (Union[Unset, int]): + max_streak (Union[None, Unset, int]): + mistakes (Union[Unset, int]): + modifiers (Union[None, Unset, str]): + player_rank (Union[Unset, int]): + player_name (Union[None, Unset, str]): + player_avatar (Union[None, Unset, str]): + player_alias (Union[None, Unset, str]): + accuracy (Union[Unset, float]): + pp (Union[Unset, float]): + """ + + player_id: Union[None, Unset, str] = UNSET + weight: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + timepost: Union[Unset, int] = UNSET + pauses: Union[Unset, int] = UNSET + max_streak: Union[None, Unset, int] = UNSET + mistakes: Union[Unset, int] = UNSET + modifiers: Union[None, Unset, str] = UNSET + player_rank: Union[Unset, int] = UNSET + player_name: Union[None, Unset, str] = UNSET + player_avatar: Union[None, Unset, str] = UNSET + player_alias: Union[None, Unset, str] = UNSET + accuracy: Union[Unset, float] = UNSET + pp: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + weight = self.weight + + rank = self.rank + + timepost = self.timepost + + pauses = self.pauses + + max_streak: Union[None, Unset, int] + if isinstance(self.max_streak, Unset): + max_streak = UNSET + else: + max_streak = self.max_streak + + mistakes = self.mistakes + + modifiers: Union[None, Unset, str] + if isinstance(self.modifiers, Unset): + modifiers = UNSET + else: + modifiers = self.modifiers + + player_rank = self.player_rank + + player_name: Union[None, Unset, str] + if isinstance(self.player_name, Unset): + player_name = UNSET + else: + player_name = self.player_name + + player_avatar: Union[None, Unset, str] + if isinstance(self.player_avatar, Unset): + player_avatar = UNSET + else: + player_avatar = self.player_avatar + + player_alias: Union[None, Unset, str] + if isinstance(self.player_alias, Unset): + player_alias = UNSET + else: + player_alias = self.player_alias + + accuracy = self.accuracy + + pp = self.pp + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if player_id is not UNSET: + field_dict["playerId"] = player_id + if weight is not UNSET: + field_dict["weight"] = weight + if rank is not UNSET: + field_dict["rank"] = rank + if timepost is not UNSET: + field_dict["timepost"] = timepost + if pauses is not UNSET: + field_dict["pauses"] = pauses + if max_streak is not UNSET: + field_dict["maxStreak"] = max_streak + if mistakes is not UNSET: + field_dict["mistakes"] = mistakes + if modifiers is not UNSET: + field_dict["modifiers"] = modifiers + if player_rank is not UNSET: + field_dict["playerRank"] = player_rank + if player_name is not UNSET: + field_dict["playerName"] = player_name + if player_avatar is not UNSET: + field_dict["playerAvatar"] = player_avatar + if player_alias is not UNSET: + field_dict["playerAlias"] = player_alias + if accuracy is not UNSET: + field_dict["accuracy"] = accuracy + if pp is not UNSET: + field_dict["pp"] = pp + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + weight = d.pop("weight", UNSET) + + rank = d.pop("rank", UNSET) + + timepost = d.pop("timepost", UNSET) + + pauses = d.pop("pauses", UNSET) + + def _parse_max_streak(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + max_streak = _parse_max_streak(d.pop("maxStreak", UNSET)) + + mistakes = d.pop("mistakes", UNSET) + + def _parse_modifiers(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + modifiers = _parse_modifiers(d.pop("modifiers", UNSET)) + + player_rank = d.pop("playerRank", UNSET) + + def _parse_player_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_name = _parse_player_name(d.pop("playerName", UNSET)) + + def _parse_player_avatar(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_avatar = _parse_player_avatar(d.pop("playerAvatar", UNSET)) + + def _parse_player_alias(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_alias = _parse_player_alias(d.pop("playerAlias", UNSET)) + + accuracy = d.pop("accuracy", UNSET) + + pp = d.pop("pp", UNSET) + + score_graph_entry = cls( + player_id=player_id, + weight=weight, + rank=rank, + timepost=timepost, + pauses=pauses, + max_streak=max_streak, + mistakes=mistakes, + modifiers=modifiers, + player_rank=player_rank, + player_name=player_name, + player_avatar=player_avatar, + player_alias=player_alias, + accuracy=accuracy, + pp=pp, + ) + + return score_graph_entry diff --git a/src/clients/beatleader/models/score_improvement.py b/src/clients/beatleader/models/score_improvement.py new file mode 100644 index 0000000..0a59eaa --- /dev/null +++ b/src/clients/beatleader/models/score_improvement.py @@ -0,0 +1,193 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ScoreImprovement") + + +@_attrs_define +class ScoreImprovement: + """ + Attributes: + id (Union[Unset, int]): + timeset (Union[None, Unset, str]): + score (Union[Unset, int]): + accuracy (Union[Unset, float]): + pp (Union[Unset, float]): + bonus_pp (Union[Unset, float]): + rank (Union[Unset, int]): + acc_right (Union[Unset, float]): + acc_left (Union[Unset, float]): + average_ranked_accuracy (Union[Unset, float]): + total_pp (Union[Unset, float]): + total_rank (Union[Unset, int]): + bad_cuts (Union[Unset, int]): + missed_notes (Union[Unset, int]): + bomb_cuts (Union[Unset, int]): + walls_hit (Union[Unset, int]): + pauses (Union[Unset, int]): + """ + + id: Union[Unset, int] = UNSET + timeset: Union[None, Unset, str] = UNSET + score: Union[Unset, int] = UNSET + accuracy: Union[Unset, float] = UNSET + pp: Union[Unset, float] = UNSET + bonus_pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + acc_right: Union[Unset, float] = UNSET + acc_left: Union[Unset, float] = UNSET + average_ranked_accuracy: Union[Unset, float] = UNSET + total_pp: Union[Unset, float] = UNSET + total_rank: Union[Unset, int] = UNSET + bad_cuts: Union[Unset, int] = UNSET + missed_notes: Union[Unset, int] = UNSET + bomb_cuts: Union[Unset, int] = UNSET + walls_hit: Union[Unset, int] = UNSET + pauses: Union[Unset, int] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + timeset: Union[None, Unset, str] + if isinstance(self.timeset, Unset): + timeset = UNSET + else: + timeset = self.timeset + + score = self.score + + accuracy = self.accuracy + + pp = self.pp + + bonus_pp = self.bonus_pp + + rank = self.rank + + acc_right = self.acc_right + + acc_left = self.acc_left + + average_ranked_accuracy = self.average_ranked_accuracy + + total_pp = self.total_pp + + total_rank = self.total_rank + + bad_cuts = self.bad_cuts + + missed_notes = self.missed_notes + + bomb_cuts = self.bomb_cuts + + walls_hit = self.walls_hit + + pauses = self.pauses + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if score is not UNSET: + field_dict["score"] = score + if accuracy is not UNSET: + field_dict["accuracy"] = accuracy + if pp is not UNSET: + field_dict["pp"] = pp + if bonus_pp is not UNSET: + field_dict["bonusPp"] = bonus_pp + if rank is not UNSET: + field_dict["rank"] = rank + if acc_right is not UNSET: + field_dict["accRight"] = acc_right + if acc_left is not UNSET: + field_dict["accLeft"] = acc_left + if average_ranked_accuracy is not UNSET: + field_dict["averageRankedAccuracy"] = average_ranked_accuracy + if total_pp is not UNSET: + field_dict["totalPp"] = total_pp + if total_rank is not UNSET: + field_dict["totalRank"] = total_rank + if bad_cuts is not UNSET: + field_dict["badCuts"] = bad_cuts + if missed_notes is not UNSET: + field_dict["missedNotes"] = missed_notes + if bomb_cuts is not UNSET: + field_dict["bombCuts"] = bomb_cuts + if walls_hit is not UNSET: + field_dict["wallsHit"] = walls_hit + if pauses is not UNSET: + field_dict["pauses"] = pauses + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_timeset(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + timeset = _parse_timeset(d.pop("timeset", UNSET)) + + score = d.pop("score", UNSET) + + accuracy = d.pop("accuracy", UNSET) + + pp = d.pop("pp", UNSET) + + bonus_pp = d.pop("bonusPp", UNSET) + + rank = d.pop("rank", UNSET) + + acc_right = d.pop("accRight", UNSET) + + acc_left = d.pop("accLeft", UNSET) + + average_ranked_accuracy = d.pop("averageRankedAccuracy", UNSET) + + total_pp = d.pop("totalPp", UNSET) + + total_rank = d.pop("totalRank", UNSET) + + bad_cuts = d.pop("badCuts", UNSET) + + missed_notes = d.pop("missedNotes", UNSET) + + bomb_cuts = d.pop("bombCuts", UNSET) + + walls_hit = d.pop("wallsHit", UNSET) + + pauses = d.pop("pauses", UNSET) + + score_improvement = cls( + id=id, + timeset=timeset, + score=score, + accuracy=accuracy, + pp=pp, + bonus_pp=bonus_pp, + rank=rank, + acc_right=acc_right, + acc_left=acc_left, + average_ranked_accuracy=average_ranked_accuracy, + total_pp=total_pp, + total_rank=total_rank, + bad_cuts=bad_cuts, + missed_notes=missed_notes, + bomb_cuts=bomb_cuts, + walls_hit=walls_hit, + pauses=pauses, + ) + + return score_improvement diff --git a/src/clients/beatleader/models/score_metadata.py b/src/clients/beatleader/models/score_metadata.py new file mode 100644 index 0000000..545f180 --- /dev/null +++ b/src/clients/beatleader/models/score_metadata.py @@ -0,0 +1,161 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.info_to_highlight import InfoToHighlight +from ..models.leaderboard_contexts import LeaderboardContexts +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ScoreMetadata") + + +@_attrs_define +class ScoreMetadata: + """ + Attributes: + id (Union[Unset, int]): + pinned_contexts (Union[Unset, LeaderboardContexts]): + highlighted_info (Union[Unset, InfoToHighlight]): + priority (Union[Unset, int]): + description (Union[None, Unset, str]): + link_service (Union[None, Unset, str]): + link_service_icon (Union[None, Unset, str]): + link (Union[None, Unset, str]): + """ + + id: Union[Unset, int] = UNSET + pinned_contexts: Union[Unset, LeaderboardContexts] = UNSET + highlighted_info: Union[Unset, InfoToHighlight] = UNSET + priority: Union[Unset, int] = UNSET + description: Union[None, Unset, str] = UNSET + link_service: Union[None, Unset, str] = UNSET + link_service_icon: Union[None, Unset, str] = UNSET + link: Union[None, Unset, str] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + pinned_contexts: Union[Unset, str] = UNSET + if not isinstance(self.pinned_contexts, Unset): + pinned_contexts = self.pinned_contexts.value + + highlighted_info: Union[Unset, str] = UNSET + if not isinstance(self.highlighted_info, Unset): + highlighted_info = self.highlighted_info.value + + priority = self.priority + + description: Union[None, Unset, str] + if isinstance(self.description, Unset): + description = UNSET + else: + description = self.description + + link_service: Union[None, Unset, str] + if isinstance(self.link_service, Unset): + link_service = UNSET + else: + link_service = self.link_service + + link_service_icon: Union[None, Unset, str] + if isinstance(self.link_service_icon, Unset): + link_service_icon = UNSET + else: + link_service_icon = self.link_service_icon + + link: Union[None, Unset, str] + if isinstance(self.link, Unset): + link = UNSET + else: + link = self.link + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if pinned_contexts is not UNSET: + field_dict["pinnedContexts"] = pinned_contexts + if highlighted_info is not UNSET: + field_dict["highlightedInfo"] = highlighted_info + if priority is not UNSET: + field_dict["priority"] = priority + if description is not UNSET: + field_dict["description"] = description + if link_service is not UNSET: + field_dict["linkService"] = link_service + if link_service_icon is not UNSET: + field_dict["linkServiceIcon"] = link_service_icon + if link is not UNSET: + field_dict["link"] = link + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + _pinned_contexts = d.pop("pinnedContexts", UNSET) + pinned_contexts: Union[Unset, LeaderboardContexts] + if isinstance(_pinned_contexts, Unset): + pinned_contexts = UNSET + else: + pinned_contexts = LeaderboardContexts(_pinned_contexts) + + _highlighted_info = d.pop("highlightedInfo", UNSET) + highlighted_info: Union[Unset, InfoToHighlight] + if isinstance(_highlighted_info, Unset): + highlighted_info = UNSET + else: + highlighted_info = InfoToHighlight(_highlighted_info) + + priority = d.pop("priority", UNSET) + + def _parse_description(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + description = _parse_description(d.pop("description", UNSET)) + + def _parse_link_service(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + link_service = _parse_link_service(d.pop("linkService", UNSET)) + + def _parse_link_service_icon(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + link_service_icon = _parse_link_service_icon(d.pop("linkServiceIcon", UNSET)) + + def _parse_link(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + link = _parse_link(d.pop("link", UNSET)) + + score_metadata = cls( + id=id, + pinned_contexts=pinned_contexts, + highlighted_info=highlighted_info, + priority=priority, + description=description, + link_service=link_service, + link_service_icon=link_service_icon, + link=link, + ) + + return score_metadata diff --git a/src/clients/beatleader/models/score_response.py b/src/clients/beatleader/models/score_response.py new file mode 100644 index 0000000..587298f --- /dev/null +++ b/src/clients/beatleader/models/score_response.py @@ -0,0 +1,554 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.controller_enum import ControllerEnum +from ..models.hmd import HMD +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.player_response import PlayerResponse + from ..models.rank_voting import RankVoting + from ..models.replay_offsets import ReplayOffsets + from ..models.score_improvement import ScoreImprovement + from ..models.score_metadata import ScoreMetadata + + +T = TypeVar("T", bound="ScoreResponse") + + +@_attrs_define +class ScoreResponse: + """ + Attributes: + id (Union[None, Unset, int]): + base_score (Union[Unset, int]): + modified_score (Union[Unset, int]): + accuracy (Union[Unset, float]): + player_id (Union[None, Unset, str]): + pp (Union[Unset, float]): + bonus_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + acc_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + rank (Union[Unset, int]): + country (Union[None, Unset, str]): + fc_accuracy (Union[Unset, float]): + fc_pp (Union[Unset, float]): + weight (Union[Unset, float]): + replay (Union[None, Unset, str]): + modifiers (Union[None, Unset, str]): + bad_cuts (Union[Unset, int]): + missed_notes (Union[Unset, int]): + bomb_cuts (Union[Unset, int]): + walls_hit (Union[Unset, int]): + pauses (Union[Unset, int]): + full_combo (Union[Unset, bool]): + platform (Union[None, Unset, str]): + max_combo (Union[Unset, int]): + max_streak (Union[None, Unset, int]): + hmd (Union[Unset, HMD]): + controller (Union[Unset, ControllerEnum]): + leaderboard_id (Union[None, Unset, str]): + timeset (Union[None, Unset, str]): + timepost (Union[Unset, int]): + replays_watched (Union[Unset, int]): + play_count (Union[Unset, int]): + last_try_time (Union[Unset, int]): + priority (Union[Unset, int]): + player (Union[Unset, PlayerResponse]): + score_improvement (Union[Unset, ScoreImprovement]): + rank_voting (Union[Unset, RankVoting]): + metadata (Union[Unset, ScoreMetadata]): + offsets (Union[Unset, ReplayOffsets]): + """ + + id: Union[None, Unset, int] = UNSET + base_score: Union[Unset, int] = UNSET + modified_score: Union[Unset, int] = UNSET + accuracy: Union[Unset, float] = UNSET + player_id: Union[None, Unset, str] = UNSET + pp: Union[Unset, float] = UNSET + bonus_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + acc_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country: Union[None, Unset, str] = UNSET + fc_accuracy: Union[Unset, float] = UNSET + fc_pp: Union[Unset, float] = UNSET + weight: Union[Unset, float] = UNSET + replay: Union[None, Unset, str] = UNSET + modifiers: Union[None, Unset, str] = UNSET + bad_cuts: Union[Unset, int] = UNSET + missed_notes: Union[Unset, int] = UNSET + bomb_cuts: Union[Unset, int] = UNSET + walls_hit: Union[Unset, int] = UNSET + pauses: Union[Unset, int] = UNSET + full_combo: Union[Unset, bool] = UNSET + platform: Union[None, Unset, str] = UNSET + max_combo: Union[Unset, int] = UNSET + max_streak: Union[None, Unset, int] = UNSET + hmd: Union[Unset, HMD] = UNSET + controller: Union[Unset, ControllerEnum] = UNSET + leaderboard_id: Union[None, Unset, str] = UNSET + timeset: Union[None, Unset, str] = UNSET + timepost: Union[Unset, int] = UNSET + replays_watched: Union[Unset, int] = UNSET + play_count: Union[Unset, int] = UNSET + last_try_time: Union[Unset, int] = UNSET + priority: Union[Unset, int] = UNSET + player: Union[Unset, "PlayerResponse"] = UNSET + score_improvement: Union[Unset, "ScoreImprovement"] = UNSET + rank_voting: Union[Unset, "RankVoting"] = UNSET + metadata: Union[Unset, "ScoreMetadata"] = UNSET + offsets: Union[Unset, "ReplayOffsets"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, int] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + base_score = self.base_score + + modified_score = self.modified_score + + accuracy = self.accuracy + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + pp = self.pp + + bonus_pp = self.bonus_pp + + pass_pp = self.pass_pp + + acc_pp = self.acc_pp + + tech_pp = self.tech_pp + + rank = self.rank + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + fc_accuracy = self.fc_accuracy + + fc_pp = self.fc_pp + + weight = self.weight + + replay: Union[None, Unset, str] + if isinstance(self.replay, Unset): + replay = UNSET + else: + replay = self.replay + + modifiers: Union[None, Unset, str] + if isinstance(self.modifiers, Unset): + modifiers = UNSET + else: + modifiers = self.modifiers + + bad_cuts = self.bad_cuts + + missed_notes = self.missed_notes + + bomb_cuts = self.bomb_cuts + + walls_hit = self.walls_hit + + pauses = self.pauses + + full_combo = self.full_combo + + platform: Union[None, Unset, str] + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + max_combo = self.max_combo + + max_streak: Union[None, Unset, int] + if isinstance(self.max_streak, Unset): + max_streak = UNSET + else: + max_streak = self.max_streak + + hmd: Union[Unset, str] = UNSET + if not isinstance(self.hmd, Unset): + hmd = self.hmd.value + + controller: Union[Unset, str] = UNSET + if not isinstance(self.controller, Unset): + controller = self.controller.value + + leaderboard_id: Union[None, Unset, str] + if isinstance(self.leaderboard_id, Unset): + leaderboard_id = UNSET + else: + leaderboard_id = self.leaderboard_id + + timeset: Union[None, Unset, str] + if isinstance(self.timeset, Unset): + timeset = UNSET + else: + timeset = self.timeset + + timepost = self.timepost + + replays_watched = self.replays_watched + + play_count = self.play_count + + last_try_time = self.last_try_time + + priority = self.priority + + player: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.player, Unset): + player = self.player.to_dict() + + score_improvement: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score_improvement, Unset): + score_improvement = self.score_improvement.to_dict() + + rank_voting: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.rank_voting, Unset): + rank_voting = self.rank_voting.to_dict() + + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + offsets: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.offsets, Unset): + offsets = self.offsets.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if base_score is not UNSET: + field_dict["baseScore"] = base_score + if modified_score is not UNSET: + field_dict["modifiedScore"] = modified_score + if accuracy is not UNSET: + field_dict["accuracy"] = accuracy + if player_id is not UNSET: + field_dict["playerId"] = player_id + if pp is not UNSET: + field_dict["pp"] = pp + if bonus_pp is not UNSET: + field_dict["bonusPp"] = bonus_pp + if pass_pp is not UNSET: + field_dict["passPP"] = pass_pp + if acc_pp is not UNSET: + field_dict["accPP"] = acc_pp + if tech_pp is not UNSET: + field_dict["techPP"] = tech_pp + if rank is not UNSET: + field_dict["rank"] = rank + if country is not UNSET: + field_dict["country"] = country + if fc_accuracy is not UNSET: + field_dict["fcAccuracy"] = fc_accuracy + if fc_pp is not UNSET: + field_dict["fcPp"] = fc_pp + if weight is not UNSET: + field_dict["weight"] = weight + if replay is not UNSET: + field_dict["replay"] = replay + if modifiers is not UNSET: + field_dict["modifiers"] = modifiers + if bad_cuts is not UNSET: + field_dict["badCuts"] = bad_cuts + if missed_notes is not UNSET: + field_dict["missedNotes"] = missed_notes + if bomb_cuts is not UNSET: + field_dict["bombCuts"] = bomb_cuts + if walls_hit is not UNSET: + field_dict["wallsHit"] = walls_hit + if pauses is not UNSET: + field_dict["pauses"] = pauses + if full_combo is not UNSET: + field_dict["fullCombo"] = full_combo + if platform is not UNSET: + field_dict["platform"] = platform + if max_combo is not UNSET: + field_dict["maxCombo"] = max_combo + if max_streak is not UNSET: + field_dict["maxStreak"] = max_streak + if hmd is not UNSET: + field_dict["hmd"] = hmd + if controller is not UNSET: + field_dict["controller"] = controller + if leaderboard_id is not UNSET: + field_dict["leaderboardId"] = leaderboard_id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if timepost is not UNSET: + field_dict["timepost"] = timepost + if replays_watched is not UNSET: + field_dict["replaysWatched"] = replays_watched + if play_count is not UNSET: + field_dict["playCount"] = play_count + if last_try_time is not UNSET: + field_dict["lastTryTime"] = last_try_time + if priority is not UNSET: + field_dict["priority"] = priority + if player is not UNSET: + field_dict["player"] = player + if score_improvement is not UNSET: + field_dict["scoreImprovement"] = score_improvement + if rank_voting is not UNSET: + field_dict["rankVoting"] = rank_voting + if metadata is not UNSET: + field_dict["metadata"] = metadata + if offsets is not UNSET: + field_dict["offsets"] = offsets + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.player_response import PlayerResponse + from ..models.rank_voting import RankVoting + from ..models.replay_offsets import ReplayOffsets + from ..models.score_improvement import ScoreImprovement + from ..models.score_metadata import ScoreMetadata + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + id = _parse_id(d.pop("id", UNSET)) + + base_score = d.pop("baseScore", UNSET) + + modified_score = d.pop("modifiedScore", UNSET) + + accuracy = d.pop("accuracy", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + pp = d.pop("pp", UNSET) + + bonus_pp = d.pop("bonusPp", UNSET) + + pass_pp = d.pop("passPP", UNSET) + + acc_pp = d.pop("accPP", UNSET) + + tech_pp = d.pop("techPP", UNSET) + + rank = d.pop("rank", UNSET) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + fc_accuracy = d.pop("fcAccuracy", UNSET) + + fc_pp = d.pop("fcPp", UNSET) + + weight = d.pop("weight", UNSET) + + def _parse_replay(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + replay = _parse_replay(d.pop("replay", UNSET)) + + def _parse_modifiers(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + modifiers = _parse_modifiers(d.pop("modifiers", UNSET)) + + bad_cuts = d.pop("badCuts", UNSET) + + missed_notes = d.pop("missedNotes", UNSET) + + bomb_cuts = d.pop("bombCuts", UNSET) + + walls_hit = d.pop("wallsHit", UNSET) + + pauses = d.pop("pauses", UNSET) + + full_combo = d.pop("fullCombo", UNSET) + + def _parse_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + max_combo = d.pop("maxCombo", UNSET) + + def _parse_max_streak(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + max_streak = _parse_max_streak(d.pop("maxStreak", UNSET)) + + _hmd = d.pop("hmd", UNSET) + hmd: Union[Unset, HMD] + if isinstance(_hmd, Unset): + hmd = UNSET + else: + hmd = HMD(_hmd) + + _controller = d.pop("controller", UNSET) + controller: Union[Unset, ControllerEnum] + if isinstance(_controller, Unset): + controller = UNSET + else: + controller = ControllerEnum(_controller) + + def _parse_leaderboard_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leaderboard_id = _parse_leaderboard_id(d.pop("leaderboardId", UNSET)) + + def _parse_timeset(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + timeset = _parse_timeset(d.pop("timeset", UNSET)) + + timepost = d.pop("timepost", UNSET) + + replays_watched = d.pop("replaysWatched", UNSET) + + play_count = d.pop("playCount", UNSET) + + last_try_time = d.pop("lastTryTime", UNSET) + + priority = d.pop("priority", UNSET) + + _player = d.pop("player", UNSET) + player: Union[Unset, PlayerResponse] + if isinstance(_player, Unset): + player = UNSET + else: + player = PlayerResponse.from_dict(_player) + + _score_improvement = d.pop("scoreImprovement", UNSET) + score_improvement: Union[Unset, ScoreImprovement] + if isinstance(_score_improvement, Unset): + score_improvement = UNSET + else: + score_improvement = ScoreImprovement.from_dict(_score_improvement) + + _rank_voting = d.pop("rankVoting", UNSET) + rank_voting: Union[Unset, RankVoting] + if isinstance(_rank_voting, Unset): + rank_voting = UNSET + else: + rank_voting = RankVoting.from_dict(_rank_voting) + + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, ScoreMetadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = ScoreMetadata.from_dict(_metadata) + + _offsets = d.pop("offsets", UNSET) + offsets: Union[Unset, ReplayOffsets] + if isinstance(_offsets, Unset): + offsets = UNSET + else: + offsets = ReplayOffsets.from_dict(_offsets) + + score_response = cls( + id=id, + base_score=base_score, + modified_score=modified_score, + accuracy=accuracy, + player_id=player_id, + pp=pp, + bonus_pp=bonus_pp, + pass_pp=pass_pp, + acc_pp=acc_pp, + tech_pp=tech_pp, + rank=rank, + country=country, + fc_accuracy=fc_accuracy, + fc_pp=fc_pp, + weight=weight, + replay=replay, + modifiers=modifiers, + bad_cuts=bad_cuts, + missed_notes=missed_notes, + bomb_cuts=bomb_cuts, + walls_hit=walls_hit, + pauses=pauses, + full_combo=full_combo, + platform=platform, + max_combo=max_combo, + max_streak=max_streak, + hmd=hmd, + controller=controller, + leaderboard_id=leaderboard_id, + timeset=timeset, + timepost=timepost, + replays_watched=replays_watched, + play_count=play_count, + last_try_time=last_try_time, + priority=priority, + player=player, + score_improvement=score_improvement, + rank_voting=rank_voting, + metadata=metadata, + offsets=offsets, + ) + + return score_response diff --git a/src/clients/beatleader/models/score_response_with_acc.py b/src/clients/beatleader/models/score_response_with_acc.py new file mode 100644 index 0000000..3c8e463 --- /dev/null +++ b/src/clients/beatleader/models/score_response_with_acc.py @@ -0,0 +1,572 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.controller_enum import ControllerEnum +from ..models.hmd import HMD +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.player_response import PlayerResponse + from ..models.rank_voting import RankVoting + from ..models.replay_offsets import ReplayOffsets + from ..models.score_improvement import ScoreImprovement + from ..models.score_metadata import ScoreMetadata + + +T = TypeVar("T", bound="ScoreResponseWithAcc") + + +@_attrs_define +class ScoreResponseWithAcc: + """ + Attributes: + id (Union[None, Unset, int]): + base_score (Union[Unset, int]): + modified_score (Union[Unset, int]): + accuracy (Union[Unset, float]): + player_id (Union[None, Unset, str]): + pp (Union[Unset, float]): + bonus_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + acc_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + rank (Union[Unset, int]): + country (Union[None, Unset, str]): + fc_accuracy (Union[Unset, float]): + fc_pp (Union[Unset, float]): + weight (Union[Unset, float]): + replay (Union[None, Unset, str]): + modifiers (Union[None, Unset, str]): + bad_cuts (Union[Unset, int]): + missed_notes (Union[Unset, int]): + bomb_cuts (Union[Unset, int]): + walls_hit (Union[Unset, int]): + pauses (Union[Unset, int]): + full_combo (Union[Unset, bool]): + platform (Union[None, Unset, str]): + max_combo (Union[Unset, int]): + max_streak (Union[None, Unset, int]): + hmd (Union[Unset, HMD]): + controller (Union[Unset, ControllerEnum]): + leaderboard_id (Union[None, Unset, str]): + timeset (Union[None, Unset, str]): + timepost (Union[Unset, int]): + replays_watched (Union[Unset, int]): + play_count (Union[Unset, int]): + last_try_time (Union[Unset, int]): + priority (Union[Unset, int]): + player (Union[Unset, PlayerResponse]): + score_improvement (Union[Unset, ScoreImprovement]): + rank_voting (Union[Unset, RankVoting]): + metadata (Union[Unset, ScoreMetadata]): + offsets (Union[Unset, ReplayOffsets]): + acc_left (Union[Unset, float]): + acc_right (Union[Unset, float]): + """ + + id: Union[None, Unset, int] = UNSET + base_score: Union[Unset, int] = UNSET + modified_score: Union[Unset, int] = UNSET + accuracy: Union[Unset, float] = UNSET + player_id: Union[None, Unset, str] = UNSET + pp: Union[Unset, float] = UNSET + bonus_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + acc_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country: Union[None, Unset, str] = UNSET + fc_accuracy: Union[Unset, float] = UNSET + fc_pp: Union[Unset, float] = UNSET + weight: Union[Unset, float] = UNSET + replay: Union[None, Unset, str] = UNSET + modifiers: Union[None, Unset, str] = UNSET + bad_cuts: Union[Unset, int] = UNSET + missed_notes: Union[Unset, int] = UNSET + bomb_cuts: Union[Unset, int] = UNSET + walls_hit: Union[Unset, int] = UNSET + pauses: Union[Unset, int] = UNSET + full_combo: Union[Unset, bool] = UNSET + platform: Union[None, Unset, str] = UNSET + max_combo: Union[Unset, int] = UNSET + max_streak: Union[None, Unset, int] = UNSET + hmd: Union[Unset, HMD] = UNSET + controller: Union[Unset, ControllerEnum] = UNSET + leaderboard_id: Union[None, Unset, str] = UNSET + timeset: Union[None, Unset, str] = UNSET + timepost: Union[Unset, int] = UNSET + replays_watched: Union[Unset, int] = UNSET + play_count: Union[Unset, int] = UNSET + last_try_time: Union[Unset, int] = UNSET + priority: Union[Unset, int] = UNSET + player: Union[Unset, "PlayerResponse"] = UNSET + score_improvement: Union[Unset, "ScoreImprovement"] = UNSET + rank_voting: Union[Unset, "RankVoting"] = UNSET + metadata: Union[Unset, "ScoreMetadata"] = UNSET + offsets: Union[Unset, "ReplayOffsets"] = UNSET + acc_left: Union[Unset, float] = UNSET + acc_right: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, int] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + base_score = self.base_score + + modified_score = self.modified_score + + accuracy = self.accuracy + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + pp = self.pp + + bonus_pp = self.bonus_pp + + pass_pp = self.pass_pp + + acc_pp = self.acc_pp + + tech_pp = self.tech_pp + + rank = self.rank + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + fc_accuracy = self.fc_accuracy + + fc_pp = self.fc_pp + + weight = self.weight + + replay: Union[None, Unset, str] + if isinstance(self.replay, Unset): + replay = UNSET + else: + replay = self.replay + + modifiers: Union[None, Unset, str] + if isinstance(self.modifiers, Unset): + modifiers = UNSET + else: + modifiers = self.modifiers + + bad_cuts = self.bad_cuts + + missed_notes = self.missed_notes + + bomb_cuts = self.bomb_cuts + + walls_hit = self.walls_hit + + pauses = self.pauses + + full_combo = self.full_combo + + platform: Union[None, Unset, str] + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + max_combo = self.max_combo + + max_streak: Union[None, Unset, int] + if isinstance(self.max_streak, Unset): + max_streak = UNSET + else: + max_streak = self.max_streak + + hmd: Union[Unset, str] = UNSET + if not isinstance(self.hmd, Unset): + hmd = self.hmd.value + + controller: Union[Unset, str] = UNSET + if not isinstance(self.controller, Unset): + controller = self.controller.value + + leaderboard_id: Union[None, Unset, str] + if isinstance(self.leaderboard_id, Unset): + leaderboard_id = UNSET + else: + leaderboard_id = self.leaderboard_id + + timeset: Union[None, Unset, str] + if isinstance(self.timeset, Unset): + timeset = UNSET + else: + timeset = self.timeset + + timepost = self.timepost + + replays_watched = self.replays_watched + + play_count = self.play_count + + last_try_time = self.last_try_time + + priority = self.priority + + player: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.player, Unset): + player = self.player.to_dict() + + score_improvement: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score_improvement, Unset): + score_improvement = self.score_improvement.to_dict() + + rank_voting: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.rank_voting, Unset): + rank_voting = self.rank_voting.to_dict() + + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + offsets: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.offsets, Unset): + offsets = self.offsets.to_dict() + + acc_left = self.acc_left + + acc_right = self.acc_right + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if base_score is not UNSET: + field_dict["baseScore"] = base_score + if modified_score is not UNSET: + field_dict["modifiedScore"] = modified_score + if accuracy is not UNSET: + field_dict["accuracy"] = accuracy + if player_id is not UNSET: + field_dict["playerId"] = player_id + if pp is not UNSET: + field_dict["pp"] = pp + if bonus_pp is not UNSET: + field_dict["bonusPp"] = bonus_pp + if pass_pp is not UNSET: + field_dict["passPP"] = pass_pp + if acc_pp is not UNSET: + field_dict["accPP"] = acc_pp + if tech_pp is not UNSET: + field_dict["techPP"] = tech_pp + if rank is not UNSET: + field_dict["rank"] = rank + if country is not UNSET: + field_dict["country"] = country + if fc_accuracy is not UNSET: + field_dict["fcAccuracy"] = fc_accuracy + if fc_pp is not UNSET: + field_dict["fcPp"] = fc_pp + if weight is not UNSET: + field_dict["weight"] = weight + if replay is not UNSET: + field_dict["replay"] = replay + if modifiers is not UNSET: + field_dict["modifiers"] = modifiers + if bad_cuts is not UNSET: + field_dict["badCuts"] = bad_cuts + if missed_notes is not UNSET: + field_dict["missedNotes"] = missed_notes + if bomb_cuts is not UNSET: + field_dict["bombCuts"] = bomb_cuts + if walls_hit is not UNSET: + field_dict["wallsHit"] = walls_hit + if pauses is not UNSET: + field_dict["pauses"] = pauses + if full_combo is not UNSET: + field_dict["fullCombo"] = full_combo + if platform is not UNSET: + field_dict["platform"] = platform + if max_combo is not UNSET: + field_dict["maxCombo"] = max_combo + if max_streak is not UNSET: + field_dict["maxStreak"] = max_streak + if hmd is not UNSET: + field_dict["hmd"] = hmd + if controller is not UNSET: + field_dict["controller"] = controller + if leaderboard_id is not UNSET: + field_dict["leaderboardId"] = leaderboard_id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if timepost is not UNSET: + field_dict["timepost"] = timepost + if replays_watched is not UNSET: + field_dict["replaysWatched"] = replays_watched + if play_count is not UNSET: + field_dict["playCount"] = play_count + if last_try_time is not UNSET: + field_dict["lastTryTime"] = last_try_time + if priority is not UNSET: + field_dict["priority"] = priority + if player is not UNSET: + field_dict["player"] = player + if score_improvement is not UNSET: + field_dict["scoreImprovement"] = score_improvement + if rank_voting is not UNSET: + field_dict["rankVoting"] = rank_voting + if metadata is not UNSET: + field_dict["metadata"] = metadata + if offsets is not UNSET: + field_dict["offsets"] = offsets + if acc_left is not UNSET: + field_dict["accLeft"] = acc_left + if acc_right is not UNSET: + field_dict["accRight"] = acc_right + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.player_response import PlayerResponse + from ..models.rank_voting import RankVoting + from ..models.replay_offsets import ReplayOffsets + from ..models.score_improvement import ScoreImprovement + from ..models.score_metadata import ScoreMetadata + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + id = _parse_id(d.pop("id", UNSET)) + + base_score = d.pop("baseScore", UNSET) + + modified_score = d.pop("modifiedScore", UNSET) + + accuracy = d.pop("accuracy", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + pp = d.pop("pp", UNSET) + + bonus_pp = d.pop("bonusPp", UNSET) + + pass_pp = d.pop("passPP", UNSET) + + acc_pp = d.pop("accPP", UNSET) + + tech_pp = d.pop("techPP", UNSET) + + rank = d.pop("rank", UNSET) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + fc_accuracy = d.pop("fcAccuracy", UNSET) + + fc_pp = d.pop("fcPp", UNSET) + + weight = d.pop("weight", UNSET) + + def _parse_replay(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + replay = _parse_replay(d.pop("replay", UNSET)) + + def _parse_modifiers(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + modifiers = _parse_modifiers(d.pop("modifiers", UNSET)) + + bad_cuts = d.pop("badCuts", UNSET) + + missed_notes = d.pop("missedNotes", UNSET) + + bomb_cuts = d.pop("bombCuts", UNSET) + + walls_hit = d.pop("wallsHit", UNSET) + + pauses = d.pop("pauses", UNSET) + + full_combo = d.pop("fullCombo", UNSET) + + def _parse_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + max_combo = d.pop("maxCombo", UNSET) + + def _parse_max_streak(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + max_streak = _parse_max_streak(d.pop("maxStreak", UNSET)) + + _hmd = d.pop("hmd", UNSET) + hmd: Union[Unset, HMD] + if isinstance(_hmd, Unset): + hmd = UNSET + else: + hmd = HMD(_hmd) + + _controller = d.pop("controller", UNSET) + controller: Union[Unset, ControllerEnum] + if isinstance(_controller, Unset): + controller = UNSET + else: + controller = ControllerEnum(_controller) + + def _parse_leaderboard_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leaderboard_id = _parse_leaderboard_id(d.pop("leaderboardId", UNSET)) + + def _parse_timeset(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + timeset = _parse_timeset(d.pop("timeset", UNSET)) + + timepost = d.pop("timepost", UNSET) + + replays_watched = d.pop("replaysWatched", UNSET) + + play_count = d.pop("playCount", UNSET) + + last_try_time = d.pop("lastTryTime", UNSET) + + priority = d.pop("priority", UNSET) + + _player = d.pop("player", UNSET) + player: Union[Unset, PlayerResponse] + if isinstance(_player, Unset): + player = UNSET + else: + player = PlayerResponse.from_dict(_player) + + _score_improvement = d.pop("scoreImprovement", UNSET) + score_improvement: Union[Unset, ScoreImprovement] + if isinstance(_score_improvement, Unset): + score_improvement = UNSET + else: + score_improvement = ScoreImprovement.from_dict(_score_improvement) + + _rank_voting = d.pop("rankVoting", UNSET) + rank_voting: Union[Unset, RankVoting] + if isinstance(_rank_voting, Unset): + rank_voting = UNSET + else: + rank_voting = RankVoting.from_dict(_rank_voting) + + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, ScoreMetadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = ScoreMetadata.from_dict(_metadata) + + _offsets = d.pop("offsets", UNSET) + offsets: Union[Unset, ReplayOffsets] + if isinstance(_offsets, Unset): + offsets = UNSET + else: + offsets = ReplayOffsets.from_dict(_offsets) + + acc_left = d.pop("accLeft", UNSET) + + acc_right = d.pop("accRight", UNSET) + + score_response_with_acc = cls( + id=id, + base_score=base_score, + modified_score=modified_score, + accuracy=accuracy, + player_id=player_id, + pp=pp, + bonus_pp=bonus_pp, + pass_pp=pass_pp, + acc_pp=acc_pp, + tech_pp=tech_pp, + rank=rank, + country=country, + fc_accuracy=fc_accuracy, + fc_pp=fc_pp, + weight=weight, + replay=replay, + modifiers=modifiers, + bad_cuts=bad_cuts, + missed_notes=missed_notes, + bomb_cuts=bomb_cuts, + walls_hit=walls_hit, + pauses=pauses, + full_combo=full_combo, + platform=platform, + max_combo=max_combo, + max_streak=max_streak, + hmd=hmd, + controller=controller, + leaderboard_id=leaderboard_id, + timeset=timeset, + timepost=timepost, + replays_watched=replays_watched, + play_count=play_count, + last_try_time=last_try_time, + priority=priority, + player=player, + score_improvement=score_improvement, + rank_voting=rank_voting, + metadata=metadata, + offsets=offsets, + acc_left=acc_left, + acc_right=acc_right, + ) + + return score_response_with_acc diff --git a/src/clients/beatleader/models/score_response_with_my_score.py b/src/clients/beatleader/models/score_response_with_my_score.py new file mode 100644 index 0000000..48c911e --- /dev/null +++ b/src/clients/beatleader/models/score_response_with_my_score.py @@ -0,0 +1,625 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..models.controller_enum import ControllerEnum +from ..models.hmd import HMD +from ..models.leaderboard_contexts import LeaderboardContexts +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.compact_leaderboard_response import CompactLeaderboardResponse + from ..models.player_response import PlayerResponse + from ..models.rank_voting import RankVoting + from ..models.replay_offsets import ReplayOffsets + from ..models.score_improvement import ScoreImprovement + from ..models.score_metadata import ScoreMetadata + from ..models.score_response_with_acc import ScoreResponseWithAcc + + +T = TypeVar("T", bound="ScoreResponseWithMyScore") + + +@_attrs_define +class ScoreResponseWithMyScore: + """ + Attributes: + id (Union[None, Unset, int]): + base_score (Union[Unset, int]): + modified_score (Union[Unset, int]): + accuracy (Union[Unset, float]): + player_id (Union[None, Unset, str]): + pp (Union[Unset, float]): + bonus_pp (Union[Unset, float]): + pass_pp (Union[Unset, float]): + acc_pp (Union[Unset, float]): + tech_pp (Union[Unset, float]): + rank (Union[Unset, int]): + country (Union[None, Unset, str]): + fc_accuracy (Union[Unset, float]): + fc_pp (Union[Unset, float]): + weight (Union[Unset, float]): + replay (Union[None, Unset, str]): + modifiers (Union[None, Unset, str]): + bad_cuts (Union[Unset, int]): + missed_notes (Union[Unset, int]): + bomb_cuts (Union[Unset, int]): + walls_hit (Union[Unset, int]): + pauses (Union[Unset, int]): + full_combo (Union[Unset, bool]): + platform (Union[None, Unset, str]): + max_combo (Union[Unset, int]): + max_streak (Union[None, Unset, int]): + hmd (Union[Unset, HMD]): + controller (Union[Unset, ControllerEnum]): + leaderboard_id (Union[None, Unset, str]): + timeset (Union[None, Unset, str]): + timepost (Union[Unset, int]): + replays_watched (Union[Unset, int]): + play_count (Union[Unset, int]): + last_try_time (Union[Unset, int]): + priority (Union[Unset, int]): + player (Union[Unset, PlayerResponse]): + score_improvement (Union[Unset, ScoreImprovement]): + rank_voting (Union[Unset, RankVoting]): + metadata (Union[Unset, ScoreMetadata]): + offsets (Union[Unset, ReplayOffsets]): + acc_left (Union[Unset, float]): + acc_right (Union[Unset, float]): + my_score (Union[Unset, ScoreResponseWithAcc]): + valid_contexts (Union[Unset, LeaderboardContexts]): + leaderboard (Union[Unset, CompactLeaderboardResponse]): + """ + + id: Union[None, Unset, int] = UNSET + base_score: Union[Unset, int] = UNSET + modified_score: Union[Unset, int] = UNSET + accuracy: Union[Unset, float] = UNSET + player_id: Union[None, Unset, str] = UNSET + pp: Union[Unset, float] = UNSET + bonus_pp: Union[Unset, float] = UNSET + pass_pp: Union[Unset, float] = UNSET + acc_pp: Union[Unset, float] = UNSET + tech_pp: Union[Unset, float] = UNSET + rank: Union[Unset, int] = UNSET + country: Union[None, Unset, str] = UNSET + fc_accuracy: Union[Unset, float] = UNSET + fc_pp: Union[Unset, float] = UNSET + weight: Union[Unset, float] = UNSET + replay: Union[None, Unset, str] = UNSET + modifiers: Union[None, Unset, str] = UNSET + bad_cuts: Union[Unset, int] = UNSET + missed_notes: Union[Unset, int] = UNSET + bomb_cuts: Union[Unset, int] = UNSET + walls_hit: Union[Unset, int] = UNSET + pauses: Union[Unset, int] = UNSET + full_combo: Union[Unset, bool] = UNSET + platform: Union[None, Unset, str] = UNSET + max_combo: Union[Unset, int] = UNSET + max_streak: Union[None, Unset, int] = UNSET + hmd: Union[Unset, HMD] = UNSET + controller: Union[Unset, ControllerEnum] = UNSET + leaderboard_id: Union[None, Unset, str] = UNSET + timeset: Union[None, Unset, str] = UNSET + timepost: Union[Unset, int] = UNSET + replays_watched: Union[Unset, int] = UNSET + play_count: Union[Unset, int] = UNSET + last_try_time: Union[Unset, int] = UNSET + priority: Union[Unset, int] = UNSET + player: Union[Unset, "PlayerResponse"] = UNSET + score_improvement: Union[Unset, "ScoreImprovement"] = UNSET + rank_voting: Union[Unset, "RankVoting"] = UNSET + metadata: Union[Unset, "ScoreMetadata"] = UNSET + offsets: Union[Unset, "ReplayOffsets"] = UNSET + acc_left: Union[Unset, float] = UNSET + acc_right: Union[Unset, float] = UNSET + my_score: Union[Unset, "ScoreResponseWithAcc"] = UNSET + valid_contexts: Union[Unset, LeaderboardContexts] = UNSET + leaderboard: Union[Unset, "CompactLeaderboardResponse"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, int] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + base_score = self.base_score + + modified_score = self.modified_score + + accuracy = self.accuracy + + player_id: Union[None, Unset, str] + if isinstance(self.player_id, Unset): + player_id = UNSET + else: + player_id = self.player_id + + pp = self.pp + + bonus_pp = self.bonus_pp + + pass_pp = self.pass_pp + + acc_pp = self.acc_pp + + tech_pp = self.tech_pp + + rank = self.rank + + country: Union[None, Unset, str] + if isinstance(self.country, Unset): + country = UNSET + else: + country = self.country + + fc_accuracy = self.fc_accuracy + + fc_pp = self.fc_pp + + weight = self.weight + + replay: Union[None, Unset, str] + if isinstance(self.replay, Unset): + replay = UNSET + else: + replay = self.replay + + modifiers: Union[None, Unset, str] + if isinstance(self.modifiers, Unset): + modifiers = UNSET + else: + modifiers = self.modifiers + + bad_cuts = self.bad_cuts + + missed_notes = self.missed_notes + + bomb_cuts = self.bomb_cuts + + walls_hit = self.walls_hit + + pauses = self.pauses + + full_combo = self.full_combo + + platform: Union[None, Unset, str] + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + max_combo = self.max_combo + + max_streak: Union[None, Unset, int] + if isinstance(self.max_streak, Unset): + max_streak = UNSET + else: + max_streak = self.max_streak + + hmd: Union[Unset, str] = UNSET + if not isinstance(self.hmd, Unset): + hmd = self.hmd.value + + controller: Union[Unset, str] = UNSET + if not isinstance(self.controller, Unset): + controller = self.controller.value + + leaderboard_id: Union[None, Unset, str] + if isinstance(self.leaderboard_id, Unset): + leaderboard_id = UNSET + else: + leaderboard_id = self.leaderboard_id + + timeset: Union[None, Unset, str] + if isinstance(self.timeset, Unset): + timeset = UNSET + else: + timeset = self.timeset + + timepost = self.timepost + + replays_watched = self.replays_watched + + play_count = self.play_count + + last_try_time = self.last_try_time + + priority = self.priority + + player: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.player, Unset): + player = self.player.to_dict() + + score_improvement: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.score_improvement, Unset): + score_improvement = self.score_improvement.to_dict() + + rank_voting: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.rank_voting, Unset): + rank_voting = self.rank_voting.to_dict() + + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + offsets: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.offsets, Unset): + offsets = self.offsets.to_dict() + + acc_left = self.acc_left + + acc_right = self.acc_right + + my_score: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.my_score, Unset): + my_score = self.my_score.to_dict() + + valid_contexts: Union[Unset, str] = UNSET + if not isinstance(self.valid_contexts, Unset): + valid_contexts = self.valid_contexts.value + + leaderboard: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.leaderboard, Unset): + leaderboard = self.leaderboard.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if base_score is not UNSET: + field_dict["baseScore"] = base_score + if modified_score is not UNSET: + field_dict["modifiedScore"] = modified_score + if accuracy is not UNSET: + field_dict["accuracy"] = accuracy + if player_id is not UNSET: + field_dict["playerId"] = player_id + if pp is not UNSET: + field_dict["pp"] = pp + if bonus_pp is not UNSET: + field_dict["bonusPp"] = bonus_pp + if pass_pp is not UNSET: + field_dict["passPP"] = pass_pp + if acc_pp is not UNSET: + field_dict["accPP"] = acc_pp + if tech_pp is not UNSET: + field_dict["techPP"] = tech_pp + if rank is not UNSET: + field_dict["rank"] = rank + if country is not UNSET: + field_dict["country"] = country + if fc_accuracy is not UNSET: + field_dict["fcAccuracy"] = fc_accuracy + if fc_pp is not UNSET: + field_dict["fcPp"] = fc_pp + if weight is not UNSET: + field_dict["weight"] = weight + if replay is not UNSET: + field_dict["replay"] = replay + if modifiers is not UNSET: + field_dict["modifiers"] = modifiers + if bad_cuts is not UNSET: + field_dict["badCuts"] = bad_cuts + if missed_notes is not UNSET: + field_dict["missedNotes"] = missed_notes + if bomb_cuts is not UNSET: + field_dict["bombCuts"] = bomb_cuts + if walls_hit is not UNSET: + field_dict["wallsHit"] = walls_hit + if pauses is not UNSET: + field_dict["pauses"] = pauses + if full_combo is not UNSET: + field_dict["fullCombo"] = full_combo + if platform is not UNSET: + field_dict["platform"] = platform + if max_combo is not UNSET: + field_dict["maxCombo"] = max_combo + if max_streak is not UNSET: + field_dict["maxStreak"] = max_streak + if hmd is not UNSET: + field_dict["hmd"] = hmd + if controller is not UNSET: + field_dict["controller"] = controller + if leaderboard_id is not UNSET: + field_dict["leaderboardId"] = leaderboard_id + if timeset is not UNSET: + field_dict["timeset"] = timeset + if timepost is not UNSET: + field_dict["timepost"] = timepost + if replays_watched is not UNSET: + field_dict["replaysWatched"] = replays_watched + if play_count is not UNSET: + field_dict["playCount"] = play_count + if last_try_time is not UNSET: + field_dict["lastTryTime"] = last_try_time + if priority is not UNSET: + field_dict["priority"] = priority + if player is not UNSET: + field_dict["player"] = player + if score_improvement is not UNSET: + field_dict["scoreImprovement"] = score_improvement + if rank_voting is not UNSET: + field_dict["rankVoting"] = rank_voting + if metadata is not UNSET: + field_dict["metadata"] = metadata + if offsets is not UNSET: + field_dict["offsets"] = offsets + if acc_left is not UNSET: + field_dict["accLeft"] = acc_left + if acc_right is not UNSET: + field_dict["accRight"] = acc_right + if my_score is not UNSET: + field_dict["myScore"] = my_score + if valid_contexts is not UNSET: + field_dict["validContexts"] = valid_contexts + if leaderboard is not UNSET: + field_dict["leaderboard"] = leaderboard + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.compact_leaderboard_response import CompactLeaderboardResponse + from ..models.player_response import PlayerResponse + from ..models.rank_voting import RankVoting + from ..models.replay_offsets import ReplayOffsets + from ..models.score_improvement import ScoreImprovement + from ..models.score_metadata import ScoreMetadata + from ..models.score_response_with_acc import ScoreResponseWithAcc + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + id = _parse_id(d.pop("id", UNSET)) + + base_score = d.pop("baseScore", UNSET) + + modified_score = d.pop("modifiedScore", UNSET) + + accuracy = d.pop("accuracy", UNSET) + + def _parse_player_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + player_id = _parse_player_id(d.pop("playerId", UNSET)) + + pp = d.pop("pp", UNSET) + + bonus_pp = d.pop("bonusPp", UNSET) + + pass_pp = d.pop("passPP", UNSET) + + acc_pp = d.pop("accPP", UNSET) + + tech_pp = d.pop("techPP", UNSET) + + rank = d.pop("rank", UNSET) + + def _parse_country(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + country = _parse_country(d.pop("country", UNSET)) + + fc_accuracy = d.pop("fcAccuracy", UNSET) + + fc_pp = d.pop("fcPp", UNSET) + + weight = d.pop("weight", UNSET) + + def _parse_replay(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + replay = _parse_replay(d.pop("replay", UNSET)) + + def _parse_modifiers(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + modifiers = _parse_modifiers(d.pop("modifiers", UNSET)) + + bad_cuts = d.pop("badCuts", UNSET) + + missed_notes = d.pop("missedNotes", UNSET) + + bomb_cuts = d.pop("bombCuts", UNSET) + + walls_hit = d.pop("wallsHit", UNSET) + + pauses = d.pop("pauses", UNSET) + + full_combo = d.pop("fullCombo", UNSET) + + def _parse_platform(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + max_combo = d.pop("maxCombo", UNSET) + + def _parse_max_streak(data: object) -> Union[None, Unset, int]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, int], data) + + max_streak = _parse_max_streak(d.pop("maxStreak", UNSET)) + + _hmd = d.pop("hmd", UNSET) + hmd: Union[Unset, HMD] + if isinstance(_hmd, Unset): + hmd = UNSET + else: + hmd = HMD(_hmd) + + _controller = d.pop("controller", UNSET) + controller: Union[Unset, ControllerEnum] + if isinstance(_controller, Unset): + controller = UNSET + else: + controller = ControllerEnum(_controller) + + def _parse_leaderboard_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + leaderboard_id = _parse_leaderboard_id(d.pop("leaderboardId", UNSET)) + + def _parse_timeset(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + timeset = _parse_timeset(d.pop("timeset", UNSET)) + + timepost = d.pop("timepost", UNSET) + + replays_watched = d.pop("replaysWatched", UNSET) + + play_count = d.pop("playCount", UNSET) + + last_try_time = d.pop("lastTryTime", UNSET) + + priority = d.pop("priority", UNSET) + + _player = d.pop("player", UNSET) + player: Union[Unset, PlayerResponse] + if isinstance(_player, Unset): + player = UNSET + else: + player = PlayerResponse.from_dict(_player) + + _score_improvement = d.pop("scoreImprovement", UNSET) + score_improvement: Union[Unset, ScoreImprovement] + if isinstance(_score_improvement, Unset): + score_improvement = UNSET + else: + score_improvement = ScoreImprovement.from_dict(_score_improvement) + + _rank_voting = d.pop("rankVoting", UNSET) + rank_voting: Union[Unset, RankVoting] + if isinstance(_rank_voting, Unset): + rank_voting = UNSET + else: + rank_voting = RankVoting.from_dict(_rank_voting) + + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, ScoreMetadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = ScoreMetadata.from_dict(_metadata) + + _offsets = d.pop("offsets", UNSET) + offsets: Union[Unset, ReplayOffsets] + if isinstance(_offsets, Unset): + offsets = UNSET + else: + offsets = ReplayOffsets.from_dict(_offsets) + + acc_left = d.pop("accLeft", UNSET) + + acc_right = d.pop("accRight", UNSET) + + _my_score = d.pop("myScore", UNSET) + my_score: Union[Unset, ScoreResponseWithAcc] + if isinstance(_my_score, Unset): + my_score = UNSET + else: + my_score = ScoreResponseWithAcc.from_dict(_my_score) + + _valid_contexts = d.pop("validContexts", UNSET) + valid_contexts: Union[Unset, LeaderboardContexts] + if isinstance(_valid_contexts, Unset): + valid_contexts = UNSET + else: + valid_contexts = LeaderboardContexts(_valid_contexts) + + _leaderboard = d.pop("leaderboard", UNSET) + leaderboard: Union[Unset, CompactLeaderboardResponse] + if isinstance(_leaderboard, Unset): + leaderboard = UNSET + else: + leaderboard = CompactLeaderboardResponse.from_dict(_leaderboard) + + score_response_with_my_score = cls( + id=id, + base_score=base_score, + modified_score=modified_score, + accuracy=accuracy, + player_id=player_id, + pp=pp, + bonus_pp=bonus_pp, + pass_pp=pass_pp, + acc_pp=acc_pp, + tech_pp=tech_pp, + rank=rank, + country=country, + fc_accuracy=fc_accuracy, + fc_pp=fc_pp, + weight=weight, + replay=replay, + modifiers=modifiers, + bad_cuts=bad_cuts, + missed_notes=missed_notes, + bomb_cuts=bomb_cuts, + walls_hit=walls_hit, + pauses=pauses, + full_combo=full_combo, + platform=platform, + max_combo=max_combo, + max_streak=max_streak, + hmd=hmd, + controller=controller, + leaderboard_id=leaderboard_id, + timeset=timeset, + timepost=timepost, + replays_watched=replays_watched, + play_count=play_count, + last_try_time=last_try_time, + priority=priority, + player=player, + score_improvement=score_improvement, + rank_voting=rank_voting, + metadata=metadata, + offsets=offsets, + acc_left=acc_left, + acc_right=acc_right, + my_score=my_score, + valid_contexts=valid_contexts, + leaderboard=leaderboard, + ) + + return score_response_with_my_score diff --git a/src/clients/beatleader/models/score_response_with_my_score_response_with_metadata.py b/src/clients/beatleader/models/score_response_with_my_score_response_with_metadata.py new file mode 100644 index 0000000..97eac52 --- /dev/null +++ b/src/clients/beatleader/models/score_response_with_my_score_response_with_metadata.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.metadata import Metadata + from ..models.score_response_with_my_score import ScoreResponseWithMyScore + + +T = TypeVar("T", bound="ScoreResponseWithMyScoreResponseWithMetadata") + + +@_attrs_define +class ScoreResponseWithMyScoreResponseWithMetadata: + """ + Attributes: + metadata (Union[Unset, Metadata]): + data (Union[List['ScoreResponseWithMyScore'], None, Unset]): + """ + + metadata: Union[Unset, "Metadata"] = UNSET + data: Union[List["ScoreResponseWithMyScore"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + data: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.data, Unset): + data = UNSET + elif isinstance(self.data, list): + data = [] + for data_type_0_item_data in self.data: + data_type_0_item = data_type_0_item_data.to_dict() + data.append(data_type_0_item) + + else: + data = self.data + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + if data is not UNSET: + field_dict["data"] = data + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.metadata import Metadata + from ..models.score_response_with_my_score import ScoreResponseWithMyScore + + d = src_dict.copy() + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, Metadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = Metadata.from_dict(_metadata) + + def _parse_data(data: object) -> Union[List["ScoreResponseWithMyScore"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + data_type_0 = [] + _data_type_0 = data + for data_type_0_item_data in _data_type_0: + data_type_0_item = ScoreResponseWithMyScore.from_dict(data_type_0_item_data) + + data_type_0.append(data_type_0_item) + + return data_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ScoreResponseWithMyScore"], None, Unset], data) + + data = _parse_data(d.pop("data", UNSET)) + + score_response_with_my_score_response_with_metadata = cls( + metadata=metadata, + data=data, + ) + + return score_response_with_my_score_response_with_metadata diff --git a/src/clients/beatleader/models/scores_sort_by.py b/src/clients/beatleader/models/scores_sort_by.py new file mode 100644 index 0000000..b833808 --- /dev/null +++ b/src/clients/beatleader/models/scores_sort_by.py @@ -0,0 +1,22 @@ +from enum import Enum + + +class ScoresSortBy(str, Enum): + ACC = "acc" + ACCPP = "accPP" + DATE = "date" + LASTTRYTIME = "lastTryTime" + MAXSTREAK = "maxStreak" + MISTAKES = "mistakes" + PASSPP = "passPP" + PAUSES = "pauses" + PLAYCOUNT = "playCount" + PP = "pp" + RANK = "rank" + REPLAYSWATCHED = "replaysWatched" + STARS = "stars" + TECHPP = "techPP" + TIMING = "timing" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/song.py b/src/clients/beatleader/models/song.py new file mode 100644 index 0000000..4f0ca69 --- /dev/null +++ b/src/clients/beatleader/models/song.py @@ -0,0 +1,454 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.difficulty_description import DifficultyDescription + from ..models.external_status import ExternalStatus + from ..models.leaderboard import Leaderboard + from ..models.mapper import Mapper + + +T = TypeVar("T", bound="Song") + + +@_attrs_define +class Song: + """ + Attributes: + id (Union[None, Unset, str]): + hash_ (Union[None, Unset, str]): + name (Union[None, Unset, str]): + sub_name (Union[None, Unset, str]): + author (Union[None, Unset, str]): + mapper (Union[None, Unset, str]): + mappers (Union[List['Mapper'], None, Unset]): + mapper_id (Union[Unset, int]): + collaborator_ids (Union[None, Unset, str]): + cover_image (Union[None, Unset, str]): + full_cover_image (Union[None, Unset, str]): + download_url (Union[None, Unset, str]): + bpm (Union[Unset, float]): + duration (Union[Unset, float]): + tags (Union[None, Unset, str]): + upload_time (Union[Unset, int]): + difficulties (Union[List['DifficultyDescription'], None, Unset]): + leaderboards (Union[List['Leaderboard'], None, Unset]): + external_statuses (Union[List['ExternalStatus'], None, Unset]): + """ + + id: Union[None, Unset, str] = UNSET + hash_: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + sub_name: Union[None, Unset, str] = UNSET + author: Union[None, Unset, str] = UNSET + mapper: Union[None, Unset, str] = UNSET + mappers: Union[List["Mapper"], None, Unset] = UNSET + mapper_id: Union[Unset, int] = UNSET + collaborator_ids: Union[None, Unset, str] = UNSET + cover_image: Union[None, Unset, str] = UNSET + full_cover_image: Union[None, Unset, str] = UNSET + download_url: Union[None, Unset, str] = UNSET + bpm: Union[Unset, float] = UNSET + duration: Union[Unset, float] = UNSET + tags: Union[None, Unset, str] = UNSET + upload_time: Union[Unset, int] = UNSET + difficulties: Union[List["DifficultyDescription"], None, Unset] = UNSET + leaderboards: Union[List["Leaderboard"], None, Unset] = UNSET + external_statuses: Union[List["ExternalStatus"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + hash_: Union[None, Unset, str] + if isinstance(self.hash_, Unset): + hash_ = UNSET + else: + hash_ = self.hash_ + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + sub_name: Union[None, Unset, str] + if isinstance(self.sub_name, Unset): + sub_name = UNSET + else: + sub_name = self.sub_name + + author: Union[None, Unset, str] + if isinstance(self.author, Unset): + author = UNSET + else: + author = self.author + + mapper: Union[None, Unset, str] + if isinstance(self.mapper, Unset): + mapper = UNSET + else: + mapper = self.mapper + + mappers: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.mappers, Unset): + mappers = UNSET + elif isinstance(self.mappers, list): + mappers = [] + for mappers_type_0_item_data in self.mappers: + mappers_type_0_item = mappers_type_0_item_data.to_dict() + mappers.append(mappers_type_0_item) + + else: + mappers = self.mappers + + mapper_id = self.mapper_id + + collaborator_ids: Union[None, Unset, str] + if isinstance(self.collaborator_ids, Unset): + collaborator_ids = UNSET + else: + collaborator_ids = self.collaborator_ids + + cover_image: Union[None, Unset, str] + if isinstance(self.cover_image, Unset): + cover_image = UNSET + else: + cover_image = self.cover_image + + full_cover_image: Union[None, Unset, str] + if isinstance(self.full_cover_image, Unset): + full_cover_image = UNSET + else: + full_cover_image = self.full_cover_image + + download_url: Union[None, Unset, str] + if isinstance(self.download_url, Unset): + download_url = UNSET + else: + download_url = self.download_url + + bpm = self.bpm + + duration = self.duration + + tags: Union[None, Unset, str] + if isinstance(self.tags, Unset): + tags = UNSET + else: + tags = self.tags + + upload_time = self.upload_time + + difficulties: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.difficulties, Unset): + difficulties = UNSET + elif isinstance(self.difficulties, list): + difficulties = [] + for difficulties_type_0_item_data in self.difficulties: + difficulties_type_0_item = difficulties_type_0_item_data.to_dict() + difficulties.append(difficulties_type_0_item) + + else: + difficulties = self.difficulties + + leaderboards: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.leaderboards, Unset): + leaderboards = UNSET + elif isinstance(self.leaderboards, list): + leaderboards = [] + for leaderboards_type_0_item_data in self.leaderboards: + leaderboards_type_0_item = leaderboards_type_0_item_data.to_dict() + leaderboards.append(leaderboards_type_0_item) + + else: + leaderboards = self.leaderboards + + external_statuses: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.external_statuses, Unset): + external_statuses = UNSET + elif isinstance(self.external_statuses, list): + external_statuses = [] + for external_statuses_type_0_item_data in self.external_statuses: + external_statuses_type_0_item = external_statuses_type_0_item_data.to_dict() + external_statuses.append(external_statuses_type_0_item) + + else: + external_statuses = self.external_statuses + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if name is not UNSET: + field_dict["name"] = name + if sub_name is not UNSET: + field_dict["subName"] = sub_name + if author is not UNSET: + field_dict["author"] = author + if mapper is not UNSET: + field_dict["mapper"] = mapper + if mappers is not UNSET: + field_dict["mappers"] = mappers + if mapper_id is not UNSET: + field_dict["mapperId"] = mapper_id + if collaborator_ids is not UNSET: + field_dict["collaboratorIds"] = collaborator_ids + if cover_image is not UNSET: + field_dict["coverImage"] = cover_image + if full_cover_image is not UNSET: + field_dict["fullCoverImage"] = full_cover_image + if download_url is not UNSET: + field_dict["downloadUrl"] = download_url + if bpm is not UNSET: + field_dict["bpm"] = bpm + if duration is not UNSET: + field_dict["duration"] = duration + if tags is not UNSET: + field_dict["tags"] = tags + if upload_time is not UNSET: + field_dict["uploadTime"] = upload_time + if difficulties is not UNSET: + field_dict["difficulties"] = difficulties + if leaderboards is not UNSET: + field_dict["leaderboards"] = leaderboards + if external_statuses is not UNSET: + field_dict["externalStatuses"] = external_statuses + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.difficulty_description import DifficultyDescription + from ..models.external_status import ExternalStatus + from ..models.leaderboard import Leaderboard + from ..models.mapper import Mapper + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_hash_(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + hash_ = _parse_hash_(d.pop("hash", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_sub_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + sub_name = _parse_sub_name(d.pop("subName", UNSET)) + + def _parse_author(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + author = _parse_author(d.pop("author", UNSET)) + + def _parse_mapper(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mapper = _parse_mapper(d.pop("mapper", UNSET)) + + def _parse_mappers(data: object) -> Union[List["Mapper"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + mappers_type_0 = [] + _mappers_type_0 = data + for mappers_type_0_item_data in _mappers_type_0: + mappers_type_0_item = Mapper.from_dict(mappers_type_0_item_data) + + mappers_type_0.append(mappers_type_0_item) + + return mappers_type_0 + except: # noqa: E722 + pass + return cast(Union[List["Mapper"], None, Unset], data) + + mappers = _parse_mappers(d.pop("mappers", UNSET)) + + mapper_id = d.pop("mapperId", UNSET) + + def _parse_collaborator_ids(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + collaborator_ids = _parse_collaborator_ids(d.pop("collaboratorIds", UNSET)) + + def _parse_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover_image = _parse_cover_image(d.pop("coverImage", UNSET)) + + def _parse_full_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + full_cover_image = _parse_full_cover_image(d.pop("fullCoverImage", UNSET)) + + def _parse_download_url(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + download_url = _parse_download_url(d.pop("downloadUrl", UNSET)) + + bpm = d.pop("bpm", UNSET) + + duration = d.pop("duration", UNSET) + + def _parse_tags(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + tags = _parse_tags(d.pop("tags", UNSET)) + + upload_time = d.pop("uploadTime", UNSET) + + def _parse_difficulties(data: object) -> Union[List["DifficultyDescription"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + difficulties_type_0 = [] + _difficulties_type_0 = data + for difficulties_type_0_item_data in _difficulties_type_0: + difficulties_type_0_item = DifficultyDescription.from_dict(difficulties_type_0_item_data) + + difficulties_type_0.append(difficulties_type_0_item) + + return difficulties_type_0 + except: # noqa: E722 + pass + return cast(Union[List["DifficultyDescription"], None, Unset], data) + + difficulties = _parse_difficulties(d.pop("difficulties", UNSET)) + + def _parse_leaderboards(data: object) -> Union[List["Leaderboard"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + leaderboards_type_0 = [] + _leaderboards_type_0 = data + for leaderboards_type_0_item_data in _leaderboards_type_0: + leaderboards_type_0_item = Leaderboard.from_dict(leaderboards_type_0_item_data) + + leaderboards_type_0.append(leaderboards_type_0_item) + + return leaderboards_type_0 + except: # noqa: E722 + pass + return cast(Union[List["Leaderboard"], None, Unset], data) + + leaderboards = _parse_leaderboards(d.pop("leaderboards", UNSET)) + + def _parse_external_statuses(data: object) -> Union[List["ExternalStatus"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + external_statuses_type_0 = [] + _external_statuses_type_0 = data + for external_statuses_type_0_item_data in _external_statuses_type_0: + external_statuses_type_0_item = ExternalStatus.from_dict(external_statuses_type_0_item_data) + + external_statuses_type_0.append(external_statuses_type_0_item) + + return external_statuses_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ExternalStatus"], None, Unset], data) + + external_statuses = _parse_external_statuses(d.pop("externalStatuses", UNSET)) + + song = cls( + id=id, + hash_=hash_, + name=name, + sub_name=sub_name, + author=author, + mapper=mapper, + mappers=mappers, + mapper_id=mapper_id, + collaborator_ids=collaborator_ids, + cover_image=cover_image, + full_cover_image=full_cover_image, + download_url=download_url, + bpm=bpm, + duration=duration, + tags=tags, + upload_time=upload_time, + difficulties=difficulties, + leaderboards=leaderboards, + external_statuses=external_statuses, + ) + + return song diff --git a/src/clients/beatleader/models/song_response.py b/src/clients/beatleader/models/song_response.py new file mode 100644 index 0000000..5c70e66 --- /dev/null +++ b/src/clients/beatleader/models/song_response.py @@ -0,0 +1,373 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.difficulty_description import DifficultyDescription + from ..models.external_status import ExternalStatus + from ..models.mapper_response import MapperResponse + + +T = TypeVar("T", bound="SongResponse") + + +@_attrs_define +class SongResponse: + """ + Attributes: + id (Union[None, Unset, str]): + hash_ (Union[None, Unset, str]): + name (Union[None, Unset, str]): + sub_name (Union[None, Unset, str]): + author (Union[None, Unset, str]): + mapper (Union[None, Unset, str]): + mappers (Union[List['MapperResponse'], None, Unset]): + mapper_id (Union[Unset, int]): + cover_image (Union[None, Unset, str]): + full_cover_image (Union[None, Unset, str]): + download_url (Union[None, Unset, str]): + bpm (Union[Unset, float]): + duration (Union[Unset, float]): + upload_time (Union[Unset, int]): + difficulties (Union[List['DifficultyDescription'], None, Unset]): + external_statuses (Union[List['ExternalStatus'], None, Unset]): + """ + + id: Union[None, Unset, str] = UNSET + hash_: Union[None, Unset, str] = UNSET + name: Union[None, Unset, str] = UNSET + sub_name: Union[None, Unset, str] = UNSET + author: Union[None, Unset, str] = UNSET + mapper: Union[None, Unset, str] = UNSET + mappers: Union[List["MapperResponse"], None, Unset] = UNSET + mapper_id: Union[Unset, int] = UNSET + cover_image: Union[None, Unset, str] = UNSET + full_cover_image: Union[None, Unset, str] = UNSET + download_url: Union[None, Unset, str] = UNSET + bpm: Union[Unset, float] = UNSET + duration: Union[Unset, float] = UNSET + upload_time: Union[Unset, int] = UNSET + difficulties: Union[List["DifficultyDescription"], None, Unset] = UNSET + external_statuses: Union[List["ExternalStatus"], None, Unset] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id: Union[None, Unset, str] + if isinstance(self.id, Unset): + id = UNSET + else: + id = self.id + + hash_: Union[None, Unset, str] + if isinstance(self.hash_, Unset): + hash_ = UNSET + else: + hash_ = self.hash_ + + name: Union[None, Unset, str] + if isinstance(self.name, Unset): + name = UNSET + else: + name = self.name + + sub_name: Union[None, Unset, str] + if isinstance(self.sub_name, Unset): + sub_name = UNSET + else: + sub_name = self.sub_name + + author: Union[None, Unset, str] + if isinstance(self.author, Unset): + author = UNSET + else: + author = self.author + + mapper: Union[None, Unset, str] + if isinstance(self.mapper, Unset): + mapper = UNSET + else: + mapper = self.mapper + + mappers: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.mappers, Unset): + mappers = UNSET + elif isinstance(self.mappers, list): + mappers = [] + for mappers_type_0_item_data in self.mappers: + mappers_type_0_item = mappers_type_0_item_data.to_dict() + mappers.append(mappers_type_0_item) + + else: + mappers = self.mappers + + mapper_id = self.mapper_id + + cover_image: Union[None, Unset, str] + if isinstance(self.cover_image, Unset): + cover_image = UNSET + else: + cover_image = self.cover_image + + full_cover_image: Union[None, Unset, str] + if isinstance(self.full_cover_image, Unset): + full_cover_image = UNSET + else: + full_cover_image = self.full_cover_image + + download_url: Union[None, Unset, str] + if isinstance(self.download_url, Unset): + download_url = UNSET + else: + download_url = self.download_url + + bpm = self.bpm + + duration = self.duration + + upload_time = self.upload_time + + difficulties: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.difficulties, Unset): + difficulties = UNSET + elif isinstance(self.difficulties, list): + difficulties = [] + for difficulties_type_0_item_data in self.difficulties: + difficulties_type_0_item = difficulties_type_0_item_data.to_dict() + difficulties.append(difficulties_type_0_item) + + else: + difficulties = self.difficulties + + external_statuses: Union[List[Dict[str, Any]], None, Unset] + if isinstance(self.external_statuses, Unset): + external_statuses = UNSET + elif isinstance(self.external_statuses, list): + external_statuses = [] + for external_statuses_type_0_item_data in self.external_statuses: + external_statuses_type_0_item = external_statuses_type_0_item_data.to_dict() + external_statuses.append(external_statuses_type_0_item) + + else: + external_statuses = self.external_statuses + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if name is not UNSET: + field_dict["name"] = name + if sub_name is not UNSET: + field_dict["subName"] = sub_name + if author is not UNSET: + field_dict["author"] = author + if mapper is not UNSET: + field_dict["mapper"] = mapper + if mappers is not UNSET: + field_dict["mappers"] = mappers + if mapper_id is not UNSET: + field_dict["mapperId"] = mapper_id + if cover_image is not UNSET: + field_dict["coverImage"] = cover_image + if full_cover_image is not UNSET: + field_dict["fullCoverImage"] = full_cover_image + if download_url is not UNSET: + field_dict["downloadUrl"] = download_url + if bpm is not UNSET: + field_dict["bpm"] = bpm + if duration is not UNSET: + field_dict["duration"] = duration + if upload_time is not UNSET: + field_dict["uploadTime"] = upload_time + if difficulties is not UNSET: + field_dict["difficulties"] = difficulties + if external_statuses is not UNSET: + field_dict["externalStatuses"] = external_statuses + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.difficulty_description import DifficultyDescription + from ..models.external_status import ExternalStatus + from ..models.mapper_response import MapperResponse + + d = src_dict.copy() + + def _parse_id(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + id = _parse_id(d.pop("id", UNSET)) + + def _parse_hash_(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + hash_ = _parse_hash_(d.pop("hash", UNSET)) + + def _parse_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + name = _parse_name(d.pop("name", UNSET)) + + def _parse_sub_name(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + sub_name = _parse_sub_name(d.pop("subName", UNSET)) + + def _parse_author(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + author = _parse_author(d.pop("author", UNSET)) + + def _parse_mapper(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + mapper = _parse_mapper(d.pop("mapper", UNSET)) + + def _parse_mappers(data: object) -> Union[List["MapperResponse"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + mappers_type_0 = [] + _mappers_type_0 = data + for mappers_type_0_item_data in _mappers_type_0: + mappers_type_0_item = MapperResponse.from_dict(mappers_type_0_item_data) + + mappers_type_0.append(mappers_type_0_item) + + return mappers_type_0 + except: # noqa: E722 + pass + return cast(Union[List["MapperResponse"], None, Unset], data) + + mappers = _parse_mappers(d.pop("mappers", UNSET)) + + mapper_id = d.pop("mapperId", UNSET) + + def _parse_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + cover_image = _parse_cover_image(d.pop("coverImage", UNSET)) + + def _parse_full_cover_image(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + full_cover_image = _parse_full_cover_image(d.pop("fullCoverImage", UNSET)) + + def _parse_download_url(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + download_url = _parse_download_url(d.pop("downloadUrl", UNSET)) + + bpm = d.pop("bpm", UNSET) + + duration = d.pop("duration", UNSET) + + upload_time = d.pop("uploadTime", UNSET) + + def _parse_difficulties(data: object) -> Union[List["DifficultyDescription"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + difficulties_type_0 = [] + _difficulties_type_0 = data + for difficulties_type_0_item_data in _difficulties_type_0: + difficulties_type_0_item = DifficultyDescription.from_dict(difficulties_type_0_item_data) + + difficulties_type_0.append(difficulties_type_0_item) + + return difficulties_type_0 + except: # noqa: E722 + pass + return cast(Union[List["DifficultyDescription"], None, Unset], data) + + difficulties = _parse_difficulties(d.pop("difficulties", UNSET)) + + def _parse_external_statuses(data: object) -> Union[List["ExternalStatus"], None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + external_statuses_type_0 = [] + _external_statuses_type_0 = data + for external_statuses_type_0_item_data in _external_statuses_type_0: + external_statuses_type_0_item = ExternalStatus.from_dict(external_statuses_type_0_item_data) + + external_statuses_type_0.append(external_statuses_type_0_item) + + return external_statuses_type_0 + except: # noqa: E722 + pass + return cast(Union[List["ExternalStatus"], None, Unset], data) + + external_statuses = _parse_external_statuses(d.pop("externalStatuses", UNSET)) + + song_response = cls( + id=id, + hash_=hash_, + name=name, + sub_name=sub_name, + author=author, + mapper=mapper, + mappers=mappers, + mapper_id=mapper_id, + cover_image=cover_image, + full_cover_image=full_cover_image, + download_url=download_url, + bpm=bpm, + duration=duration, + upload_time=upload_time, + difficulties=difficulties, + external_statuses=external_statuses, + ) + + return song_response diff --git a/src/clients/beatleader/models/song_status.py b/src/clients/beatleader/models/song_status.py new file mode 100644 index 0000000..141fb0b --- /dev/null +++ b/src/clients/beatleader/models/song_status.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class SongStatus(str, Enum): + BEASTSABERAWARDED = "beastSaberAwarded" + CURATED = "curated" + FEATUREDONCC = "featuredOnCC" + MAPOFTHEWEEK = "mapOfTheWeek" + NONE = "none" + NOODLEMONDAY = "noodleMonday" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/type.py b/src/clients/beatleader/models/type.py new file mode 100644 index 0000000..f183656 --- /dev/null +++ b/src/clients/beatleader/models/type.py @@ -0,0 +1,17 @@ +from enum import Enum + + +class Type(str, Enum): + ALL = "all" + NOMINATED = "nominated" + OST = "ost" + QUALIFIED = "qualified" + RANKED = "ranked" + RANKING = "ranking" + REWEIGHTED = "reweighted" + REWEIGHTING = "reweighting" + STAFF = "staff" + UNRANKED = "unranked" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatleader/models/voter_feedback.py b/src/clients/beatleader/models/voter_feedback.py new file mode 100644 index 0000000..aeb9aaa --- /dev/null +++ b/src/clients/beatleader/models/voter_feedback.py @@ -0,0 +1,67 @@ +from typing import Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="VoterFeedback") + + +@_attrs_define +class VoterFeedback: + """ + Attributes: + id (Union[Unset, int]): + rt_member (Union[None, Unset, str]): + value (Union[Unset, float]): + """ + + id: Union[Unset, int] = UNSET + rt_member: Union[None, Unset, str] = UNSET + value: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + rt_member: Union[None, Unset, str] + if isinstance(self.rt_member, Unset): + rt_member = UNSET + else: + rt_member = self.rt_member + + value = self.value + + field_dict: Dict[str, Any] = {} + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if rt_member is not UNSET: + field_dict["rtMember"] = rt_member + if value is not UNSET: + field_dict["value"] = value + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id", UNSET) + + def _parse_rt_member(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + rt_member = _parse_rt_member(d.pop("rtMember", UNSET)) + + value = d.pop("value", UNSET) + + voter_feedback = cls( + id=id, + rt_member=rt_member, + value=value, + ) + + return voter_feedback diff --git a/src/clients/beatleader/py.typed b/src/clients/beatleader/py.typed new file mode 100644 index 0000000..1aad327 --- /dev/null +++ b/src/clients/beatleader/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/src/clients/beatleader/types.py b/src/clients/beatleader/types.py new file mode 100644 index 0000000..21fac10 --- /dev/null +++ b/src/clients/beatleader/types.py @@ -0,0 +1,45 @@ +"""Contains some shared types for properties""" + +from http import HTTPStatus +from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] + + +@define +class File: + """Contains information for file uploads""" + + payload: BinaryIO + file_name: Optional[str] = None + mime_type: Optional[str] = None + + def to_tuple(self) -> FileJsonType: + """Return a tuple representation that httpx will accept for multipart/form-data""" + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """A response from an endpoint""" + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: Optional[T] + + +__all__ = ["File", "Response", "FileJsonType", "Unset", "UNSET"] diff --git a/src/clients/beatsaver/__init__.py b/src/clients/beatsaver/__init__.py new file mode 100644 index 0000000..b98c2c0 --- /dev/null +++ b/src/clients/beatsaver/__init__.py @@ -0,0 +1,8 @@ +"""A client library for accessing BeatSaver API""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/src/clients/beatsaver/api/__init__.py b/src/clients/beatsaver/api/__init__.py new file mode 100644 index 0000000..81f9fa2 --- /dev/null +++ b/src/clients/beatsaver/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/src/clients/beatsaver/api/maps/__init__.py b/src/clients/beatsaver/api/maps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatsaver/api/maps/get_maps_collaborations_id.py b/src/clients/beatsaver/api/maps/get_maps_collaborations_id.py new file mode 100644 index 0000000..2871f26 --- /dev/null +++ b/src/clients/beatsaver/api/maps/get_maps_collaborations_id.py @@ -0,0 +1,190 @@ +import datetime +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.search_response import SearchResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: int, + *, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_before: Union[Unset, str] = UNSET + if not isinstance(before, Unset): + json_before = before.isoformat() + params["before"] = json_before + + params["pageSize"] = page_size + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/maps/collaborations/{id}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[SearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = SearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[SearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, +) -> Response[SearchResponse]: + """Get maps by a user, including collaborations + + Args: + id (int): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + id=id, + before=before, + page_size=page_size, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: Union[AuthenticatedClient, Client], + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, +) -> Optional[SearchResponse]: + """Get maps by a user, including collaborations + + Args: + id (int): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return sync_detailed( + id=id, + client=client, + before=before, + page_size=page_size, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, +) -> Response[SearchResponse]: + """Get maps by a user, including collaborations + + Args: + id (int): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + id=id, + before=before, + page_size=page_size, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + *, + client: Union[AuthenticatedClient, Client], + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, +) -> Optional[SearchResponse]: + """Get maps by a user, including collaborations + + Args: + id (int): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + before=before, + page_size=page_size, + ) + ).parsed diff --git a/src/clients/beatsaver/api/maps/get_maps_hash_hash.py b/src/clients/beatsaver/api/maps/get_maps_hash_hash.py new file mode 100644 index 0000000..5edb050 --- /dev/null +++ b/src/clients/beatsaver/api/maps/get_maps_hash_hash.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.map_detail import MapDetail +from ...types import Response + + +def _get_kwargs( + hash_: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/maps/hash/{hash_}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, MapDetail]]: + if response.status_code == HTTPStatus.OK: + response_200 = MapDetail.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, MapDetail]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, MapDetail]]: + """Get map(s) for a map hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapDetail]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, MapDetail]]: + """Get map(s) for a map hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapDetail] + """ + + return sync_detailed( + hash_=hash_, + client=client, + ).parsed + + +async def asyncio_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, MapDetail]]: + """Get map(s) for a map hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapDetail]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, MapDetail]]: + """Get map(s) for a map hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapDetail] + """ + + return ( + await asyncio_detailed( + hash_=hash_, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/maps/get_maps_id_id.py b/src/clients/beatsaver/api/maps/get_maps_id_id.py new file mode 100644 index 0000000..11d971a --- /dev/null +++ b/src/clients/beatsaver/api/maps/get_maps_id_id.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.map_detail import MapDetail +from ...types import Response + + +def _get_kwargs( + id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/maps/id/{id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, MapDetail]]: + if response.status_code == HTTPStatus.OK: + response_200 = MapDetail.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, MapDetail]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, MapDetail]]: + """Get map information + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapDetail]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, MapDetail]]: + """Get map information + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapDetail] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, MapDetail]]: + """Get map information + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapDetail]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, MapDetail]]: + """Get map information + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapDetail] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/maps/get_maps_ids_ids.py b/src/clients/beatsaver/api/maps/get_maps_ids_ids.py new file mode 100644 index 0000000..4fd8f5f --- /dev/null +++ b/src/clients/beatsaver/api/maps/get_maps_ids_ids.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.map_detail import MapDetail +from ...types import Response + + +def _get_kwargs( + ids: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/maps/ids/{ids}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, MapDetail]]: + if response.status_code == HTTPStatus.OK: + response_200 = MapDetail.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, MapDetail]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, MapDetail]]: + """Get maps for mapIds + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapDetail]] + """ + + kwargs = _get_kwargs( + ids=ids, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, MapDetail]]: + """Get maps for mapIds + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapDetail] + """ + + return sync_detailed( + ids=ids, + client=client, + ).parsed + + +async def asyncio_detailed( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, MapDetail]]: + """Get maps for mapIds + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, MapDetail]] + """ + + kwargs = _get_kwargs( + ids=ids, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, MapDetail]]: + """Get maps for mapIds + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, MapDetail] + """ + + return ( + await asyncio_detailed( + ids=ids, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/maps/get_maps_latest.py b/src/clients/beatsaver/api/maps/get_maps_latest.py new file mode 100644 index 0000000..736eddd --- /dev/null +++ b/src/clients/beatsaver/api/maps/get_maps_latest.py @@ -0,0 +1,249 @@ +import datetime +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_maps_latest_sort import GetMapsLatestSort +from ...models.search_response import SearchResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + after: Union[Unset, datetime.datetime] = UNSET, + automapper: Union[Unset, bool] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetMapsLatestSort] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_after: Union[Unset, str] = UNSET + if not isinstance(after, Unset): + json_after = after.isoformat() + params["after"] = json_after + + params["automapper"] = automapper + + json_before: Union[Unset, str] = UNSET + if not isinstance(before, Unset): + json_before = before.isoformat() + params["before"] = json_before + + params["pageSize"] = page_size + + json_sort: Union[Unset, str] = UNSET + if not isinstance(sort, Unset): + json_sort = sort.value + + params["sort"] = json_sort + + params["verified"] = verified + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/maps/latest", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[SearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = SearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[SearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + automapper: Union[Unset, bool] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetMapsLatestSort] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Response[SearchResponse]: + """Get maps ordered by upload/publish/updated. If you're going to scrape the data and make 100s of + requests make this this endpoint you use. + + Args: + after (Union[Unset, datetime.datetime]): + automapper (Union[Unset, bool]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetMapsLatestSort]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + after=after, + automapper=automapper, + before=before, + page_size=page_size, + sort=sort, + verified=verified, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + automapper: Union[Unset, bool] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetMapsLatestSort] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Optional[SearchResponse]: + """Get maps ordered by upload/publish/updated. If you're going to scrape the data and make 100s of + requests make this this endpoint you use. + + Args: + after (Union[Unset, datetime.datetime]): + automapper (Union[Unset, bool]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetMapsLatestSort]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return sync_detailed( + client=client, + after=after, + automapper=automapper, + before=before, + page_size=page_size, + sort=sort, + verified=verified, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + automapper: Union[Unset, bool] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetMapsLatestSort] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Response[SearchResponse]: + """Get maps ordered by upload/publish/updated. If you're going to scrape the data and make 100s of + requests make this this endpoint you use. + + Args: + after (Union[Unset, datetime.datetime]): + automapper (Union[Unset, bool]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetMapsLatestSort]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + after=after, + automapper=automapper, + before=before, + page_size=page_size, + sort=sort, + verified=verified, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + automapper: Union[Unset, bool] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetMapsLatestSort] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Optional[SearchResponse]: + """Get maps ordered by upload/publish/updated. If you're going to scrape the data and make 100s of + requests make this this endpoint you use. + + Args: + after (Union[Unset, datetime.datetime]): + automapper (Union[Unset, bool]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetMapsLatestSort]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return ( + await asyncio_detailed( + client=client, + after=after, + automapper=automapper, + before=before, + page_size=page_size, + sort=sort, + verified=verified, + ) + ).parsed diff --git a/src/clients/beatsaver/api/maps/get_maps_plays_page.py b/src/clients/beatsaver/api/maps/get_maps_plays_page.py new file mode 100644 index 0000000..464e818 --- /dev/null +++ b/src/clients/beatsaver/api/maps/get_maps_plays_page.py @@ -0,0 +1,150 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.search_response import SearchResponse +from ...types import Response + + +def _get_kwargs( + page: int = 0, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/maps/plays/{page}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[SearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = SearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[SearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[SearchResponse]: + """Get maps ordered by play count (Not currently tracked) + + Args: + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + page=page, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[SearchResponse]: + """Get maps ordered by play count (Not currently tracked) + + Args: + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return sync_detailed( + page=page, + client=client, + ).parsed + + +async def asyncio_detailed( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[SearchResponse]: + """Get maps ordered by play count (Not currently tracked) + + Args: + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + page=page, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[SearchResponse]: + """Get maps ordered by play count (Not currently tracked) + + Args: + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return ( + await asyncio_detailed( + page=page, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/maps/get_maps_uploader_id_page.py b/src/clients/beatsaver/api/maps/get_maps_uploader_id_page.py new file mode 100644 index 0000000..ce605bd --- /dev/null +++ b/src/clients/beatsaver/api/maps/get_maps_uploader_id_page.py @@ -0,0 +1,163 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.search_response import SearchResponse +from ...types import Response + + +def _get_kwargs( + id: int, + page: int = 0, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/maps/uploader/{id}/{page}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[SearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = SearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[SearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[SearchResponse]: + """Get maps by a user + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[SearchResponse]: + """Get maps by a user + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return sync_detailed( + id=id, + page=page, + client=client, + ).parsed + + +async def asyncio_detailed( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[SearchResponse]: + """Get maps by a user + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[SearchResponse]: + """Get maps by a user + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return ( + await asyncio_detailed( + id=id, + page=page, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/playlists/__init__.py b/src/clients/beatsaver/api/playlists/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatsaver/api/playlists/get_playlists_id_id_page.py b/src/clients/beatsaver/api/playlists/get_playlists_id_id_page.py new file mode 100644 index 0000000..91d1571 --- /dev/null +++ b/src/clients/beatsaver/api/playlists/get_playlists_id_id_page.py @@ -0,0 +1,166 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.playlist_page import PlaylistPage +from ...types import Response + + +def _get_kwargs( + id: int, + page: int = 0, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/playlists/id/{id}/{page}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlaylistPage]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlaylistPage.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlaylistPage]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlaylistPage]]: + """Get playlist detail + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlaylistPage]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlaylistPage]]: + """Get playlist detail + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlaylistPage] + """ + + return sync_detailed( + id=id, + page=page, + client=client, + ).parsed + + +async def asyncio_detailed( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, PlaylistPage]]: + """Get playlist detail + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlaylistPage]] + """ + + kwargs = _get_kwargs( + id=id, + page=page, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, PlaylistPage]]: + """Get playlist detail + + Args: + id (int): + page (int): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlaylistPage] + """ + + return ( + await asyncio_detailed( + id=id, + page=page, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/playlists/get_playlists_latest.py b/src/clients/beatsaver/api/playlists/get_playlists_latest.py new file mode 100644 index 0000000..b4de37b --- /dev/null +++ b/src/clients/beatsaver/api/playlists/get_playlists_latest.py @@ -0,0 +1,215 @@ +import datetime +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_playlists_latest_sort import GetPlaylistsLatestSort +from ...models.playlist_search_response import PlaylistSearchResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + after: Union[Unset, datetime.datetime] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetPlaylistsLatestSort] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_after: Union[Unset, str] = UNSET + if not isinstance(after, Unset): + json_after = after.isoformat() + params["after"] = json_after + + json_before: Union[Unset, str] = UNSET + if not isinstance(before, Unset): + json_before = before.isoformat() + params["before"] = json_before + + params["pageSize"] = page_size + + json_sort: Union[Unset, str] = UNSET + if not isinstance(sort, Unset): + json_sort = sort.value + + params["sort"] = json_sort + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/playlists/latest", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PlaylistSearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = PlaylistSearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PlaylistSearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetPlaylistsLatestSort] = UNSET, +) -> Response[PlaylistSearchResponse]: + """Get playlists ordered by created/updated + + Args: + after (Union[Unset, datetime.datetime]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetPlaylistsLatestSort]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PlaylistSearchResponse] + """ + + kwargs = _get_kwargs( + after=after, + before=before, + page_size=page_size, + sort=sort, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetPlaylistsLatestSort] = UNSET, +) -> Optional[PlaylistSearchResponse]: + """Get playlists ordered by created/updated + + Args: + after (Union[Unset, datetime.datetime]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetPlaylistsLatestSort]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PlaylistSearchResponse + """ + + return sync_detailed( + client=client, + after=after, + before=before, + page_size=page_size, + sort=sort, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetPlaylistsLatestSort] = UNSET, +) -> Response[PlaylistSearchResponse]: + """Get playlists ordered by created/updated + + Args: + after (Union[Unset, datetime.datetime]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetPlaylistsLatestSort]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PlaylistSearchResponse] + """ + + kwargs = _get_kwargs( + after=after, + before=before, + page_size=page_size, + sort=sort, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + after: Union[Unset, datetime.datetime] = UNSET, + before: Union[Unset, datetime.datetime] = UNSET, + page_size: Union[Unset, int] = 20, + sort: Union[Unset, GetPlaylistsLatestSort] = UNSET, +) -> Optional[PlaylistSearchResponse]: + """Get playlists ordered by created/updated + + Args: + after (Union[Unset, datetime.datetime]): + before (Union[Unset, datetime.datetime]): + page_size (Union[Unset, int]): Default: 20. + sort (Union[Unset, GetPlaylistsLatestSort]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PlaylistSearchResponse + """ + + return ( + await asyncio_detailed( + client=client, + after=after, + before=before, + page_size=page_size, + sort=sort, + ) + ).parsed diff --git a/src/clients/beatsaver/api/playlists/get_playlists_search_page.py b/src/clients/beatsaver/api/playlists/get_playlists_search_page.py new file mode 100644 index 0000000..3e62c40 --- /dev/null +++ b/src/clients/beatsaver/api/playlists/get_playlists_search_page.py @@ -0,0 +1,300 @@ +import datetime +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_playlists_search_page_sort_order import GetPlaylistsSearchPageSortOrder +from ...models.playlist_search_response import PlaylistSearchResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + page: int = 0, + *, + curated: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + include_empty: Union[Unset, bool] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetPlaylistsSearchPageSortOrder, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["curated"] = curated + + json_from_: Union[Unset, str] = UNSET + if not isinstance(from_, Unset): + json_from_ = from_.isoformat() + params["from"] = json_from_ + + params["includeEmpty"] = include_empty + + params["maxNps"] = max_nps + + params["minNps"] = min_nps + + params["q"] = q + + json_sort_order = sort_order.value + params["sortOrder"] = json_sort_order + + json_to: Union[Unset, str] = UNSET + if not isinstance(to, Unset): + json_to = to.isoformat() + params["to"] = json_to + + params["verified"] = verified + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/playlists/search/{page}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PlaylistSearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = PlaylistSearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PlaylistSearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + curated: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + include_empty: Union[Unset, bool] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetPlaylistsSearchPageSortOrder, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Response[PlaylistSearchResponse]: + """Search for playlists + + Args: + page (int): Default: 0. + curated (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + include_empty (Union[Unset, bool]): + max_nps (Union[Unset, Any]): + min_nps (Union[Unset, Any]): + q (Union[Unset, str]): + sort_order (GetPlaylistsSearchPageSortOrder): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PlaylistSearchResponse] + """ + + kwargs = _get_kwargs( + page=page, + curated=curated, + from_=from_, + include_empty=include_empty, + max_nps=max_nps, + min_nps=min_nps, + q=q, + sort_order=sort_order, + to=to, + verified=verified, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + curated: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + include_empty: Union[Unset, bool] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetPlaylistsSearchPageSortOrder, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Optional[PlaylistSearchResponse]: + """Search for playlists + + Args: + page (int): Default: 0. + curated (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + include_empty (Union[Unset, bool]): + max_nps (Union[Unset, Any]): + min_nps (Union[Unset, Any]): + q (Union[Unset, str]): + sort_order (GetPlaylistsSearchPageSortOrder): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PlaylistSearchResponse + """ + + return sync_detailed( + page=page, + client=client, + curated=curated, + from_=from_, + include_empty=include_empty, + max_nps=max_nps, + min_nps=min_nps, + q=q, + sort_order=sort_order, + to=to, + verified=verified, + ).parsed + + +async def asyncio_detailed( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + curated: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + include_empty: Union[Unset, bool] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetPlaylistsSearchPageSortOrder, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Response[PlaylistSearchResponse]: + """Search for playlists + + Args: + page (int): Default: 0. + curated (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + include_empty (Union[Unset, bool]): + max_nps (Union[Unset, Any]): + min_nps (Union[Unset, Any]): + q (Union[Unset, str]): + sort_order (GetPlaylistsSearchPageSortOrder): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PlaylistSearchResponse] + """ + + kwargs = _get_kwargs( + page=page, + curated=curated, + from_=from_, + include_empty=include_empty, + max_nps=max_nps, + min_nps=min_nps, + q=q, + sort_order=sort_order, + to=to, + verified=verified, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + curated: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + include_empty: Union[Unset, bool] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetPlaylistsSearchPageSortOrder, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Optional[PlaylistSearchResponse]: + """Search for playlists + + Args: + page (int): Default: 0. + curated (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + include_empty (Union[Unset, bool]): + max_nps (Union[Unset, Any]): + min_nps (Union[Unset, Any]): + q (Union[Unset, str]): + sort_order (GetPlaylistsSearchPageSortOrder): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PlaylistSearchResponse + """ + + return ( + await asyncio_detailed( + page=page, + client=client, + curated=curated, + from_=from_, + include_empty=include_empty, + max_nps=max_nps, + min_nps=min_nps, + q=q, + sort_order=sort_order, + to=to, + verified=verified, + ) + ).parsed diff --git a/src/clients/beatsaver/api/playlists/get_playlists_user_user_id_page.py b/src/clients/beatsaver/api/playlists/get_playlists_user_user_id_page.py new file mode 100644 index 0000000..e4e35a3 --- /dev/null +++ b/src/clients/beatsaver/api/playlists/get_playlists_user_user_id_page.py @@ -0,0 +1,163 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.playlist_search_response import PlaylistSearchResponse +from ...types import Response + + +def _get_kwargs( + user_id: int, + page: int, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/playlists/user/{user_id}/{page}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PlaylistSearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = PlaylistSearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PlaylistSearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + user_id: int, + page: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[PlaylistSearchResponse]: + """Get playlists by user + + Args: + user_id (int): + page (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PlaylistSearchResponse] + """ + + kwargs = _get_kwargs( + user_id=user_id, + page=page, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + user_id: int, + page: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[PlaylistSearchResponse]: + """Get playlists by user + + Args: + user_id (int): + page (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PlaylistSearchResponse + """ + + return sync_detailed( + user_id=user_id, + page=page, + client=client, + ).parsed + + +async def asyncio_detailed( + user_id: int, + page: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[PlaylistSearchResponse]: + """Get playlists by user + + Args: + user_id (int): + page (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PlaylistSearchResponse] + """ + + kwargs = _get_kwargs( + user_id=user_id, + page=page, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + user_id: int, + page: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[PlaylistSearchResponse]: + """Get playlists by user + + Args: + user_id (int): + page (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PlaylistSearchResponse + """ + + return ( + await asyncio_detailed( + user_id=user_id, + page=page, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/playlists/post_playlists_id_id_batch.py b/src/clients/beatsaver/api/playlists/post_playlists_id_id_batch.py new file mode 100644 index 0000000..590c90c --- /dev/null +++ b/src/clients/beatsaver/api/playlists/post_playlists_id_id_batch.py @@ -0,0 +1,181 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.action_response import ActionResponse +from ...models.playlist_batch_request import PlaylistBatchRequest +from ...types import Response + + +def _get_kwargs( + id: int, + *, + body: PlaylistBatchRequest, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": f"/playlists/id/{id}/batch", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ActionResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = ActionResponse.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = ActionResponse.from_dict(response.json()) + + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = ActionResponse.from_dict(response.json()) + + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ActionResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + body: PlaylistBatchRequest, +) -> Response[ActionResponse]: + """Add or remove up to 100 maps to a playlist. Requires OAUTH + + Args: + id (int): + body (PlaylistBatchRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ActionResponse] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: Union[AuthenticatedClient, Client], + body: PlaylistBatchRequest, +) -> Optional[ActionResponse]: + """Add or remove up to 100 maps to a playlist. Requires OAUTH + + Args: + id (int): + body (PlaylistBatchRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ActionResponse + """ + + return sync_detailed( + id=id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], + body: PlaylistBatchRequest, +) -> Response[ActionResponse]: + """Add or remove up to 100 maps to a playlist. Requires OAUTH + + Args: + id (int): + body (PlaylistBatchRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ActionResponse] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + *, + client: Union[AuthenticatedClient, Client], + body: PlaylistBatchRequest, +) -> Optional[ActionResponse]: + """Add or remove up to 100 maps to a playlist. Requires OAUTH + + Args: + id (int): + body (PlaylistBatchRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ActionResponse + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + body=body, + ) + ).parsed diff --git a/src/clients/beatsaver/api/search/__init__.py b/src/clients/beatsaver/api/search/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatsaver/api/search/get_search_text_page.py b/src/clients/beatsaver/api/search/get_search_text_page.py new file mode 100644 index 0000000..762a512 --- /dev/null +++ b/src/clients/beatsaver/api/search/get_search_text_page.py @@ -0,0 +1,512 @@ +import datetime +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_search_text_page_leaderboard import GetSearchTextPageLeaderboard +from ...models.get_search_text_page_sort_order import GetSearchTextPageSortOrder +from ...models.search_response import SearchResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + page: int = 0, + *, + automapper: Union[Unset, bool] = UNSET, + chroma: Union[Unset, bool] = UNSET, + cinema: Union[Unset, bool] = UNSET, + curated: Union[Unset, bool] = UNSET, + followed: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + full_spread: Union[Unset, bool] = UNSET, + leaderboard: GetSearchTextPageLeaderboard, + max_bpm: Union[Unset, Any] = UNSET, + max_duration: Union[Unset, int] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + max_rating: Union[Unset, Any] = UNSET, + me: Union[Unset, bool] = UNSET, + min_bpm: Union[Unset, Any] = UNSET, + min_duration: Union[Unset, int] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + min_rating: Union[Unset, Any] = UNSET, + noodle: Union[Unset, bool] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetSearchTextPageSortOrder, + tags: Union[Unset, str] = UNSET, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["automapper"] = automapper + + params["chroma"] = chroma + + params["cinema"] = cinema + + params["curated"] = curated + + params["followed"] = followed + + json_from_: Union[Unset, str] = UNSET + if not isinstance(from_, Unset): + json_from_ = from_.isoformat() + params["from"] = json_from_ + + params["fullSpread"] = full_spread + + json_leaderboard = leaderboard.value + params["leaderboard"] = json_leaderboard + + params["maxBpm"] = max_bpm + + params["maxDuration"] = max_duration + + params["maxNps"] = max_nps + + params["maxRating"] = max_rating + + params["me"] = me + + params["minBpm"] = min_bpm + + params["minDuration"] = min_duration + + params["minNps"] = min_nps + + params["minRating"] = min_rating + + params["noodle"] = noodle + + params["q"] = q + + json_sort_order = sort_order.value + params["sortOrder"] = json_sort_order + + params["tags"] = tags + + json_to: Union[Unset, str] = UNSET + if not isinstance(to, Unset): + json_to = to.isoformat() + params["to"] = json_to + + params["verified"] = verified + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/search/text/{page}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[SearchResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = SearchResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[SearchResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + automapper: Union[Unset, bool] = UNSET, + chroma: Union[Unset, bool] = UNSET, + cinema: Union[Unset, bool] = UNSET, + curated: Union[Unset, bool] = UNSET, + followed: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + full_spread: Union[Unset, bool] = UNSET, + leaderboard: GetSearchTextPageLeaderboard, + max_bpm: Union[Unset, Any] = UNSET, + max_duration: Union[Unset, int] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + max_rating: Union[Unset, Any] = UNSET, + me: Union[Unset, bool] = UNSET, + min_bpm: Union[Unset, Any] = UNSET, + min_duration: Union[Unset, int] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + min_rating: Union[Unset, Any] = UNSET, + noodle: Union[Unset, bool] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetSearchTextPageSortOrder, + tags: Union[Unset, str] = UNSET, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Response[SearchResponse]: + """Search for maps + + Args: + page (int): Default: 0. + automapper (Union[Unset, bool]): + chroma (Union[Unset, bool]): + cinema (Union[Unset, bool]): + curated (Union[Unset, bool]): + followed (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + full_spread (Union[Unset, bool]): + leaderboard (GetSearchTextPageLeaderboard): + max_bpm (Union[Unset, Any]): + max_duration (Union[Unset, int]): + max_nps (Union[Unset, Any]): + max_rating (Union[Unset, Any]): + me (Union[Unset, bool]): + min_bpm (Union[Unset, Any]): + min_duration (Union[Unset, int]): + min_nps (Union[Unset, Any]): + min_rating (Union[Unset, Any]): + noodle (Union[Unset, bool]): + q (Union[Unset, str]): + sort_order (GetSearchTextPageSortOrder): + tags (Union[Unset, str]): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + page=page, + automapper=automapper, + chroma=chroma, + cinema=cinema, + curated=curated, + followed=followed, + from_=from_, + full_spread=full_spread, + leaderboard=leaderboard, + max_bpm=max_bpm, + max_duration=max_duration, + max_nps=max_nps, + max_rating=max_rating, + me=me, + min_bpm=min_bpm, + min_duration=min_duration, + min_nps=min_nps, + min_rating=min_rating, + noodle=noodle, + q=q, + sort_order=sort_order, + tags=tags, + to=to, + verified=verified, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + automapper: Union[Unset, bool] = UNSET, + chroma: Union[Unset, bool] = UNSET, + cinema: Union[Unset, bool] = UNSET, + curated: Union[Unset, bool] = UNSET, + followed: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + full_spread: Union[Unset, bool] = UNSET, + leaderboard: GetSearchTextPageLeaderboard, + max_bpm: Union[Unset, Any] = UNSET, + max_duration: Union[Unset, int] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + max_rating: Union[Unset, Any] = UNSET, + me: Union[Unset, bool] = UNSET, + min_bpm: Union[Unset, Any] = UNSET, + min_duration: Union[Unset, int] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + min_rating: Union[Unset, Any] = UNSET, + noodle: Union[Unset, bool] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetSearchTextPageSortOrder, + tags: Union[Unset, str] = UNSET, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Optional[SearchResponse]: + """Search for maps + + Args: + page (int): Default: 0. + automapper (Union[Unset, bool]): + chroma (Union[Unset, bool]): + cinema (Union[Unset, bool]): + curated (Union[Unset, bool]): + followed (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + full_spread (Union[Unset, bool]): + leaderboard (GetSearchTextPageLeaderboard): + max_bpm (Union[Unset, Any]): + max_duration (Union[Unset, int]): + max_nps (Union[Unset, Any]): + max_rating (Union[Unset, Any]): + me (Union[Unset, bool]): + min_bpm (Union[Unset, Any]): + min_duration (Union[Unset, int]): + min_nps (Union[Unset, Any]): + min_rating (Union[Unset, Any]): + noodle (Union[Unset, bool]): + q (Union[Unset, str]): + sort_order (GetSearchTextPageSortOrder): + tags (Union[Unset, str]): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return sync_detailed( + page=page, + client=client, + automapper=automapper, + chroma=chroma, + cinema=cinema, + curated=curated, + followed=followed, + from_=from_, + full_spread=full_spread, + leaderboard=leaderboard, + max_bpm=max_bpm, + max_duration=max_duration, + max_nps=max_nps, + max_rating=max_rating, + me=me, + min_bpm=min_bpm, + min_duration=min_duration, + min_nps=min_nps, + min_rating=min_rating, + noodle=noodle, + q=q, + sort_order=sort_order, + tags=tags, + to=to, + verified=verified, + ).parsed + + +async def asyncio_detailed( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + automapper: Union[Unset, bool] = UNSET, + chroma: Union[Unset, bool] = UNSET, + cinema: Union[Unset, bool] = UNSET, + curated: Union[Unset, bool] = UNSET, + followed: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + full_spread: Union[Unset, bool] = UNSET, + leaderboard: GetSearchTextPageLeaderboard, + max_bpm: Union[Unset, Any] = UNSET, + max_duration: Union[Unset, int] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + max_rating: Union[Unset, Any] = UNSET, + me: Union[Unset, bool] = UNSET, + min_bpm: Union[Unset, Any] = UNSET, + min_duration: Union[Unset, int] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + min_rating: Union[Unset, Any] = UNSET, + noodle: Union[Unset, bool] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetSearchTextPageSortOrder, + tags: Union[Unset, str] = UNSET, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Response[SearchResponse]: + """Search for maps + + Args: + page (int): Default: 0. + automapper (Union[Unset, bool]): + chroma (Union[Unset, bool]): + cinema (Union[Unset, bool]): + curated (Union[Unset, bool]): + followed (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + full_spread (Union[Unset, bool]): + leaderboard (GetSearchTextPageLeaderboard): + max_bpm (Union[Unset, Any]): + max_duration (Union[Unset, int]): + max_nps (Union[Unset, Any]): + max_rating (Union[Unset, Any]): + me (Union[Unset, bool]): + min_bpm (Union[Unset, Any]): + min_duration (Union[Unset, int]): + min_nps (Union[Unset, Any]): + min_rating (Union[Unset, Any]): + noodle (Union[Unset, bool]): + q (Union[Unset, str]): + sort_order (GetSearchTextPageSortOrder): + tags (Union[Unset, str]): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[SearchResponse] + """ + + kwargs = _get_kwargs( + page=page, + automapper=automapper, + chroma=chroma, + cinema=cinema, + curated=curated, + followed=followed, + from_=from_, + full_spread=full_spread, + leaderboard=leaderboard, + max_bpm=max_bpm, + max_duration=max_duration, + max_nps=max_nps, + max_rating=max_rating, + me=me, + min_bpm=min_bpm, + min_duration=min_duration, + min_nps=min_nps, + min_rating=min_rating, + noodle=noodle, + q=q, + sort_order=sort_order, + tags=tags, + to=to, + verified=verified, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + page: int = 0, + *, + client: Union[AuthenticatedClient, Client], + automapper: Union[Unset, bool] = UNSET, + chroma: Union[Unset, bool] = UNSET, + cinema: Union[Unset, bool] = UNSET, + curated: Union[Unset, bool] = UNSET, + followed: Union[Unset, bool] = UNSET, + from_: Union[Unset, datetime.datetime] = UNSET, + full_spread: Union[Unset, bool] = UNSET, + leaderboard: GetSearchTextPageLeaderboard, + max_bpm: Union[Unset, Any] = UNSET, + max_duration: Union[Unset, int] = UNSET, + max_nps: Union[Unset, Any] = UNSET, + max_rating: Union[Unset, Any] = UNSET, + me: Union[Unset, bool] = UNSET, + min_bpm: Union[Unset, Any] = UNSET, + min_duration: Union[Unset, int] = UNSET, + min_nps: Union[Unset, Any] = UNSET, + min_rating: Union[Unset, Any] = UNSET, + noodle: Union[Unset, bool] = UNSET, + q: Union[Unset, str] = UNSET, + sort_order: GetSearchTextPageSortOrder, + tags: Union[Unset, str] = UNSET, + to: Union[Unset, datetime.datetime] = UNSET, + verified: Union[Unset, bool] = UNSET, +) -> Optional[SearchResponse]: + """Search for maps + + Args: + page (int): Default: 0. + automapper (Union[Unset, bool]): + chroma (Union[Unset, bool]): + cinema (Union[Unset, bool]): + curated (Union[Unset, bool]): + followed (Union[Unset, bool]): + from_ (Union[Unset, datetime.datetime]): + full_spread (Union[Unset, bool]): + leaderboard (GetSearchTextPageLeaderboard): + max_bpm (Union[Unset, Any]): + max_duration (Union[Unset, int]): + max_nps (Union[Unset, Any]): + max_rating (Union[Unset, Any]): + me (Union[Unset, bool]): + min_bpm (Union[Unset, Any]): + min_duration (Union[Unset, int]): + min_nps (Union[Unset, Any]): + min_rating (Union[Unset, Any]): + noodle (Union[Unset, bool]): + q (Union[Unset, str]): + sort_order (GetSearchTextPageSortOrder): + tags (Union[Unset, str]): + to (Union[Unset, datetime.datetime]): + verified (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + SearchResponse + """ + + return ( + await asyncio_detailed( + page=page, + client=client, + automapper=automapper, + chroma=chroma, + cinema=cinema, + curated=curated, + followed=followed, + from_=from_, + full_spread=full_spread, + leaderboard=leaderboard, + max_bpm=max_bpm, + max_duration=max_duration, + max_nps=max_nps, + max_rating=max_rating, + me=me, + min_bpm=min_bpm, + min_duration=min_duration, + min_nps=min_nps, + min_rating=min_rating, + noodle=noodle, + q=q, + sort_order=sort_order, + tags=tags, + to=to, + verified=verified, + ) + ).parsed diff --git a/src/clients/beatsaver/api/users/__init__.py b/src/clients/beatsaver/api/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatsaver/api/users/get_users_id_id.py b/src/clients/beatsaver/api/users/get_users_id_id.py new file mode 100644 index 0000000..9967b72 --- /dev/null +++ b/src/clients/beatsaver/api/users/get_users_id_id.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.user_detail import UserDetail +from ...types import Response + + +def _get_kwargs( + id: int, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/users/id/{id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, UserDetail]]: + if response.status_code == HTTPStatus.OK: + response_200 = UserDetail.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, UserDetail]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserDetail]]: + """Get user info + + Args: + id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserDetail]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserDetail]]: + """Get user info + + Args: + id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserDetail] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserDetail]]: + """Get user info + + Args: + id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserDetail]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserDetail]]: + """Get user info + + Args: + id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserDetail] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/users/get_users_ids_ids.py b/src/clients/beatsaver/api/users/get_users_ids_ids.py new file mode 100644 index 0000000..8281f52 --- /dev/null +++ b/src/clients/beatsaver/api/users/get_users_ids_ids.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.user_detail import UserDetail +from ...types import Response + + +def _get_kwargs( + ids: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/users/ids/{ids}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, UserDetail]]: + if response.status_code == HTTPStatus.OK: + response_200 = UserDetail.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, UserDetail]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserDetail]]: + """Get user info + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserDetail]] + """ + + kwargs = _get_kwargs( + ids=ids, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserDetail]]: + """Get user info + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserDetail] + """ + + return sync_detailed( + ids=ids, + client=client, + ).parsed + + +async def asyncio_detailed( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserDetail]]: + """Get user info + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserDetail]] + """ + + kwargs = _get_kwargs( + ids=ids, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + ids: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserDetail]]: + """Get user info + + Args: + ids (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserDetail] + """ + + return ( + await asyncio_detailed( + ids=ids, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/users/get_users_name_name.py b/src/clients/beatsaver/api/users/get_users_name_name.py new file mode 100644 index 0000000..65463ac --- /dev/null +++ b/src/clients/beatsaver/api/users/get_users_name_name.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.user_detail import UserDetail +from ...types import Response + + +def _get_kwargs( + name: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/users/name/{name}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, UserDetail]]: + if response.status_code == HTTPStatus.OK: + response_200 = UserDetail.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, UserDetail]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + name: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserDetail]]: + """Get user info by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserDetail]] + """ + + kwargs = _get_kwargs( + name=name, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + name: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserDetail]]: + """Get user info by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserDetail] + """ + + return sync_detailed( + name=name, + client=client, + ).parsed + + +async def asyncio_detailed( + name: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserDetail]]: + """Get user info by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserDetail]] + """ + + kwargs = _get_kwargs( + name=name, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + name: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserDetail]]: + """Get user info by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserDetail] + """ + + return ( + await asyncio_detailed( + name=name, + client=client, + ) + ).parsed diff --git a/src/clients/beatsaver/api/users/post_users_verify.py b/src/clients/beatsaver/api/users/post_users_verify.py new file mode 100644 index 0000000..7c3ab78 --- /dev/null +++ b/src/clients/beatsaver/api/users/post_users_verify.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.action_response import ActionResponse +from ...models.auth_request import AuthRequest +from ...types import Response + + +def _get_kwargs( + *, + body: AuthRequest, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/users/verify", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ActionResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = ActionResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ActionResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AuthRequest, +) -> Response[ActionResponse]: + """Verify user tokens + + Args: + body (AuthRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ActionResponse] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: AuthRequest, +) -> Optional[ActionResponse]: + """Verify user tokens + + Args: + body (AuthRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ActionResponse + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AuthRequest, +) -> Response[ActionResponse]: + """Verify user tokens + + Args: + body (AuthRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ActionResponse] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: AuthRequest, +) -> Optional[ActionResponse]: + """Verify user tokens + + Args: + body (AuthRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ActionResponse + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/src/clients/beatsaver/api/vote/__init__.py b/src/clients/beatsaver/api/vote/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/beatsaver/api/vote/get_vote.py b/src/clients/beatsaver/api/vote/get_vote.py new file mode 100644 index 0000000..140e03d --- /dev/null +++ b/src/clients/beatsaver/api/vote/get_vote.py @@ -0,0 +1,170 @@ +import datetime +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.vote_summary import VoteSummary +from ...types import UNSET, Response + + +def _get_kwargs( + *, + since: datetime.datetime, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_since = since.isoformat() + params["since"] = json_since + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/vote", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["VoteSummary"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.json() + for componentsschemas_list_of_vote_summary_item_data in _response_200: + componentsschemas_list_of_vote_summary_item = VoteSummary.from_dict( + componentsschemas_list_of_vote_summary_item_data + ) + + response_200.append(componentsschemas_list_of_vote_summary_item) + + return response_200 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["VoteSummary"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + since: datetime.datetime, +) -> Response[Union[Any, List["VoteSummary"]]]: + """Get votes + + Args: + since (datetime.datetime): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['VoteSummary']]] + """ + + kwargs = _get_kwargs( + since=since, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + since: datetime.datetime, +) -> Optional[Union[Any, List["VoteSummary"]]]: + """Get votes + + Args: + since (datetime.datetime): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['VoteSummary']] + """ + + return sync_detailed( + client=client, + since=since, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + since: datetime.datetime, +) -> Response[Union[Any, List["VoteSummary"]]]: + """Get votes + + Args: + since (datetime.datetime): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['VoteSummary']]] + """ + + kwargs = _get_kwargs( + since=since, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + since: datetime.datetime, +) -> Optional[Union[Any, List["VoteSummary"]]]: + """Get votes + + Args: + since (datetime.datetime): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['VoteSummary']] + """ + + return ( + await asyncio_detailed( + client=client, + since=since, + ) + ).parsed diff --git a/src/clients/beatsaver/api/vote/post_vote.py b/src/clients/beatsaver/api/vote/post_vote.py new file mode 100644 index 0000000..4c845d5 --- /dev/null +++ b/src/clients/beatsaver/api/vote/post_vote.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.action_response import ActionResponse +from ...models.vote_request import VoteRequest +from ...types import Response + + +def _get_kwargs( + *, + body: VoteRequest, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/vote", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ActionResponse]: + if response.status_code == HTTPStatus.OK: + response_200 = ActionResponse.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ActionResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: VoteRequest, +) -> Response[ActionResponse]: + """Vote on a map + + Args: + body (VoteRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ActionResponse] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: VoteRequest, +) -> Optional[ActionResponse]: + """Vote on a map + + Args: + body (VoteRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ActionResponse + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: VoteRequest, +) -> Response[ActionResponse]: + """Vote on a map + + Args: + body (VoteRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ActionResponse] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: VoteRequest, +) -> Optional[ActionResponse]: + """Vote on a map + + Args: + body (VoteRequest): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ActionResponse + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/src/clients/beatsaver/client.py b/src/clients/beatsaver/client.py new file mode 100644 index 0000000..63a2493 --- /dev/null +++ b/src/clients/beatsaver/client.py @@ -0,0 +1,268 @@ +import ssl +from typing import Any, Dict, Optional, Union + +import httpx +from attrs import define, evolve, field + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + def with_headers(self, headers: Dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: Dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/src/clients/beatsaver/errors.py b/src/clients/beatsaver/errors.py new file mode 100644 index 0000000..5f92e76 --- /dev/null +++ b/src/clients/beatsaver/errors.py @@ -0,0 +1,16 @@ +"""Contains shared errors types that can be raised from API functions""" + + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + + +__all__ = ["UnexpectedStatus"] diff --git a/src/clients/beatsaver/models/__init__.py b/src/clients/beatsaver/models/__init__.py new file mode 100644 index 0000000..5016023 --- /dev/null +++ b/src/clients/beatsaver/models/__init__.py @@ -0,0 +1,77 @@ +"""Contains all the data models used in inputs/outputs""" + +from .action_response import ActionResponse +from .auth_request import AuthRequest +from .get_maps_latest_sort import GetMapsLatestSort +from .get_playlists_latest_sort import GetPlaylistsLatestSort +from .get_playlists_search_page_sort_order import GetPlaylistsSearchPageSortOrder +from .get_search_text_page_leaderboard import GetSearchTextPageLeaderboard +from .get_search_text_page_sort_order import GetSearchTextPageSortOrder +from .map_detail import MapDetail +from .map_detail_declared_ai import MapDetailDeclaredAi +from .map_detail_metadata import MapDetailMetadata +from .map_detail_tags_item import MapDetailTagsItem +from .map_detail_with_order import MapDetailWithOrder +from .map_difficulty import MapDifficulty +from .map_difficulty_characteristic import MapDifficultyCharacteristic +from .map_difficulty_difficulty import MapDifficultyDifficulty +from .map_parity_summary import MapParitySummary +from .map_stats import MapStats +from .map_stats_sentiment import MapStatsSentiment +from .map_testplay import MapTestplay +from .map_version import MapVersion +from .map_version_state import MapVersionState +from .playlist_batch_request import PlaylistBatchRequest +from .playlist_full import PlaylistFull +from .playlist_full_type import PlaylistFullType +from .playlist_page import PlaylistPage +from .playlist_search_response import PlaylistSearchResponse +from .playlist_stats import PlaylistStats +from .search_response import SearchResponse +from .user_detail import UserDetail +from .user_detail_patreon import UserDetailPatreon +from .user_detail_type import UserDetailType +from .user_diff_stats import UserDiffStats +from .user_follow_data import UserFollowData +from .user_stats import UserStats +from .vote_request import VoteRequest +from .vote_summary import VoteSummary + +__all__ = ( + "ActionResponse", + "AuthRequest", + "GetMapsLatestSort", + "GetPlaylistsLatestSort", + "GetPlaylistsSearchPageSortOrder", + "GetSearchTextPageLeaderboard", + "GetSearchTextPageSortOrder", + "MapDetail", + "MapDetailDeclaredAi", + "MapDetailMetadata", + "MapDetailTagsItem", + "MapDetailWithOrder", + "MapDifficulty", + "MapDifficultyCharacteristic", + "MapDifficultyDifficulty", + "MapParitySummary", + "MapStats", + "MapStatsSentiment", + "MapTestplay", + "MapVersion", + "MapVersionState", + "PlaylistBatchRequest", + "PlaylistFull", + "PlaylistFullType", + "PlaylistPage", + "PlaylistSearchResponse", + "PlaylistStats", + "SearchResponse", + "UserDetail", + "UserDetailPatreon", + "UserDetailType", + "UserDiffStats", + "UserFollowData", + "UserStats", + "VoteRequest", + "VoteSummary", +) diff --git a/src/clients/beatsaver/models/action_response.py b/src/clients/beatsaver/models/action_response.py new file mode 100644 index 0000000..ea528f0 --- /dev/null +++ b/src/clients/beatsaver/models/action_response.py @@ -0,0 +1,69 @@ +from typing import Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ActionResponse") + + +@_attrs_define +class ActionResponse: + """ + Attributes: + errors (Union[Unset, List[str]]): + success (Union[Unset, bool]): + """ + + errors: Union[Unset, List[str]] = UNSET + success: Union[Unset, bool] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + errors: Union[Unset, List[str]] = UNSET + if not isinstance(self.errors, Unset): + errors = self.errors + + success = self.success + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if errors is not UNSET: + field_dict["errors"] = errors + if success is not UNSET: + field_dict["success"] = success + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + errors = cast(List[str], d.pop("errors", UNSET)) + + success = d.pop("success", UNSET) + + action_response = cls( + errors=errors, + success=success, + ) + + action_response.additional_properties = d + return action_response + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/auth_request.py b/src/clients/beatsaver/models/auth_request.py new file mode 100644 index 0000000..56c2705 --- /dev/null +++ b/src/clients/beatsaver/models/auth_request.py @@ -0,0 +1,76 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AuthRequest") + + +@_attrs_define +class AuthRequest: + """ + Attributes: + oculus_id (Union[Unset, str]): + proof (Union[Unset, str]): + steam_id (Union[Unset, str]): + """ + + oculus_id: Union[Unset, str] = UNSET + proof: Union[Unset, str] = UNSET + steam_id: Union[Unset, str] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + oculus_id = self.oculus_id + + proof = self.proof + + steam_id = self.steam_id + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if oculus_id is not UNSET: + field_dict["oculusId"] = oculus_id + if proof is not UNSET: + field_dict["proof"] = proof + if steam_id is not UNSET: + field_dict["steamId"] = steam_id + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + oculus_id = d.pop("oculusId", UNSET) + + proof = d.pop("proof", UNSET) + + steam_id = d.pop("steamId", UNSET) + + auth_request = cls( + oculus_id=oculus_id, + proof=proof, + steam_id=steam_id, + ) + + auth_request.additional_properties = d + return auth_request + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/get_maps_latest_sort.py b/src/clients/beatsaver/models/get_maps_latest_sort.py new file mode 100644 index 0000000..91a78d2 --- /dev/null +++ b/src/clients/beatsaver/models/get_maps_latest_sort.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class GetMapsLatestSort(str, Enum): + CREATED = "CREATED" + CURATED = "CURATED" + FIRST_PUBLISHED = "FIRST_PUBLISHED" + LAST_PUBLISHED = "LAST_PUBLISHED" + UPDATED = "UPDATED" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/get_playlists_latest_sort.py b/src/clients/beatsaver/models/get_playlists_latest_sort.py new file mode 100644 index 0000000..1d9d1cf --- /dev/null +++ b/src/clients/beatsaver/models/get_playlists_latest_sort.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class GetPlaylistsLatestSort(str, Enum): + CREATED = "CREATED" + CURATED = "CURATED" + SONGS_UPDATED = "SONGS_UPDATED" + UPDATED = "UPDATED" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/get_playlists_search_page_sort_order.py b/src/clients/beatsaver/models/get_playlists_search_page_sort_order.py new file mode 100644 index 0000000..a33fab8 --- /dev/null +++ b/src/clients/beatsaver/models/get_playlists_search_page_sort_order.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class GetPlaylistsSearchPageSortOrder(str, Enum): + CURATED = "Curated" + LATEST = "Latest" + RATING = "Rating" + RELEVANCE = "Relevance" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/get_search_text_page_leaderboard.py b/src/clients/beatsaver/models/get_search_text_page_leaderboard.py new file mode 100644 index 0000000..cfa4369 --- /dev/null +++ b/src/clients/beatsaver/models/get_search_text_page_leaderboard.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class GetSearchTextPageLeaderboard(str, Enum): + ALL = "All" + BEATLEADER = "BeatLeader" + RANKED = "Ranked" + SCORESABER = "ScoreSaber" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/get_search_text_page_sort_order.py b/src/clients/beatsaver/models/get_search_text_page_sort_order.py new file mode 100644 index 0000000..7ae20c2 --- /dev/null +++ b/src/clients/beatsaver/models/get_search_text_page_sort_order.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class GetSearchTextPageSortOrder(str, Enum): + CURATED = "Curated" + LATEST = "Latest" + RATING = "Rating" + RELEVANCE = "Relevance" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/map_detail.py b/src/clients/beatsaver/models/map_detail.py new file mode 100644 index 0000000..9f7ef3d --- /dev/null +++ b/src/clients/beatsaver/models/map_detail.py @@ -0,0 +1,379 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.map_detail_declared_ai import MapDetailDeclaredAi +from ..models.map_detail_tags_item import MapDetailTagsItem +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.map_detail_metadata import MapDetailMetadata + from ..models.map_stats import MapStats + from ..models.map_version import MapVersion + from ..models.user_detail import UserDetail + + +T = TypeVar("T", bound="MapDetail") + + +@_attrs_define +class MapDetail: + """ + Attributes: + automapper (Union[Unset, bool]): + bl_qualified (Union[Unset, bool]): + bl_ranked (Union[Unset, bool]): + bookmarked (Union[Unset, bool]): + collaborators (Union[Unset, List['UserDetail']]): + created_at (Union[Unset, datetime.datetime]): + curated_at (Union[Unset, datetime.datetime]): + curator (Union[Unset, UserDetail]): + declared_ai (Union[Unset, MapDetailDeclaredAi]): + deleted_at (Union[Unset, datetime.datetime]): + description (Union[Unset, str]): + id (Union[Unset, str]): + last_published_at (Union[Unset, datetime.datetime]): + metadata (Union[Unset, MapDetailMetadata]): + name (Union[Unset, str]): + qualified (Union[Unset, bool]): + ranked (Union[Unset, bool]): + stats (Union[Unset, MapStats]): + tags (Union[Unset, List[MapDetailTagsItem]]): + updated_at (Union[Unset, datetime.datetime]): + uploaded (Union[Unset, datetime.datetime]): + uploader (Union[Unset, UserDetail]): + versions (Union[Unset, List['MapVersion']]): + """ + + automapper: Union[Unset, bool] = UNSET + bl_qualified: Union[Unset, bool] = UNSET + bl_ranked: Union[Unset, bool] = UNSET + bookmarked: Union[Unset, bool] = UNSET + collaborators: Union[Unset, List["UserDetail"]] = UNSET + created_at: Union[Unset, datetime.datetime] = UNSET + curated_at: Union[Unset, datetime.datetime] = UNSET + curator: Union[Unset, "UserDetail"] = UNSET + declared_ai: Union[Unset, MapDetailDeclaredAi] = UNSET + deleted_at: Union[Unset, datetime.datetime] = UNSET + description: Union[Unset, str] = UNSET + id: Union[Unset, str] = UNSET + last_published_at: Union[Unset, datetime.datetime] = UNSET + metadata: Union[Unset, "MapDetailMetadata"] = UNSET + name: Union[Unset, str] = UNSET + qualified: Union[Unset, bool] = UNSET + ranked: Union[Unset, bool] = UNSET + stats: Union[Unset, "MapStats"] = UNSET + tags: Union[Unset, List[MapDetailTagsItem]] = UNSET + updated_at: Union[Unset, datetime.datetime] = UNSET + uploaded: Union[Unset, datetime.datetime] = UNSET + uploader: Union[Unset, "UserDetail"] = UNSET + versions: Union[Unset, List["MapVersion"]] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + automapper = self.automapper + + bl_qualified = self.bl_qualified + + bl_ranked = self.bl_ranked + + bookmarked = self.bookmarked + + collaborators: Union[Unset, List[Dict[str, Any]]] = UNSET + if not isinstance(self.collaborators, Unset): + collaborators = [] + for collaborators_item_data in self.collaborators: + collaborators_item = collaborators_item_data.to_dict() + collaborators.append(collaborators_item) + + created_at: Union[Unset, str] = UNSET + if not isinstance(self.created_at, Unset): + created_at = self.created_at.isoformat() + + curated_at: Union[Unset, str] = UNSET + if not isinstance(self.curated_at, Unset): + curated_at = self.curated_at.isoformat() + + curator: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.curator, Unset): + curator = self.curator.to_dict() + + declared_ai: Union[Unset, str] = UNSET + if not isinstance(self.declared_ai, Unset): + declared_ai = self.declared_ai.value + + deleted_at: Union[Unset, str] = UNSET + if not isinstance(self.deleted_at, Unset): + deleted_at = self.deleted_at.isoformat() + + description = self.description + + id = self.id + + last_published_at: Union[Unset, str] = UNSET + if not isinstance(self.last_published_at, Unset): + last_published_at = self.last_published_at.isoformat() + + metadata: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + name = self.name + + qualified = self.qualified + + ranked = self.ranked + + stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.stats, Unset): + stats = self.stats.to_dict() + + tags: Union[Unset, List[str]] = UNSET + if not isinstance(self.tags, Unset): + tags = [] + for tags_item_data in self.tags: + tags_item = tags_item_data.value + tags.append(tags_item) + + updated_at: Union[Unset, str] = UNSET + if not isinstance(self.updated_at, Unset): + updated_at = self.updated_at.isoformat() + + uploaded: Union[Unset, str] = UNSET + if not isinstance(self.uploaded, Unset): + uploaded = self.uploaded.isoformat() + + uploader: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.uploader, Unset): + uploader = self.uploader.to_dict() + + versions: Union[Unset, List[Dict[str, Any]]] = UNSET + if not isinstance(self.versions, Unset): + versions = [] + for versions_item_data in self.versions: + versions_item = versions_item_data.to_dict() + versions.append(versions_item) + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if automapper is not UNSET: + field_dict["automapper"] = automapper + if bl_qualified is not UNSET: + field_dict["blQualified"] = bl_qualified + if bl_ranked is not UNSET: + field_dict["blRanked"] = bl_ranked + if bookmarked is not UNSET: + field_dict["bookmarked"] = bookmarked + if collaborators is not UNSET: + field_dict["collaborators"] = collaborators + if created_at is not UNSET: + field_dict["createdAt"] = created_at + if curated_at is not UNSET: + field_dict["curatedAt"] = curated_at + if curator is not UNSET: + field_dict["curator"] = curator + if declared_ai is not UNSET: + field_dict["declaredAi"] = declared_ai + if deleted_at is not UNSET: + field_dict["deletedAt"] = deleted_at + if description is not UNSET: + field_dict["description"] = description + if id is not UNSET: + field_dict["id"] = id + if last_published_at is not UNSET: + field_dict["lastPublishedAt"] = last_published_at + if metadata is not UNSET: + field_dict["metadata"] = metadata + if name is not UNSET: + field_dict["name"] = name + if qualified is not UNSET: + field_dict["qualified"] = qualified + if ranked is not UNSET: + field_dict["ranked"] = ranked + if stats is not UNSET: + field_dict["stats"] = stats + if tags is not UNSET: + field_dict["tags"] = tags + if updated_at is not UNSET: + field_dict["updatedAt"] = updated_at + if uploaded is not UNSET: + field_dict["uploaded"] = uploaded + if uploader is not UNSET: + field_dict["uploader"] = uploader + if versions is not UNSET: + field_dict["versions"] = versions + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.map_detail_metadata import MapDetailMetadata + from ..models.map_stats import MapStats + from ..models.map_version import MapVersion + from ..models.user_detail import UserDetail + + d = src_dict.copy() + automapper = d.pop("automapper", UNSET) + + bl_qualified = d.pop("blQualified", UNSET) + + bl_ranked = d.pop("blRanked", UNSET) + + bookmarked = d.pop("bookmarked", UNSET) + + collaborators = [] + _collaborators = d.pop("collaborators", UNSET) + for collaborators_item_data in _collaborators or []: + collaborators_item = UserDetail.from_dict(collaborators_item_data) + + collaborators.append(collaborators_item) + + _created_at = d.pop("createdAt", UNSET) + created_at: Union[Unset, datetime.datetime] + if isinstance(_created_at, Unset): + created_at = UNSET + else: + created_at = isoparse(_created_at) + + _curated_at = d.pop("curatedAt", UNSET) + curated_at: Union[Unset, datetime.datetime] + if isinstance(_curated_at, Unset): + curated_at = UNSET + else: + curated_at = isoparse(_curated_at) + + _curator = d.pop("curator", UNSET) + curator: Union[Unset, UserDetail] + if isinstance(_curator, Unset): + curator = UNSET + else: + curator = UserDetail.from_dict(_curator) + + _declared_ai = d.pop("declaredAi", UNSET) + declared_ai: Union[Unset, MapDetailDeclaredAi] + if isinstance(_declared_ai, Unset): + declared_ai = UNSET + else: + declared_ai = MapDetailDeclaredAi(_declared_ai) + + _deleted_at = d.pop("deletedAt", UNSET) + deleted_at: Union[Unset, datetime.datetime] + if isinstance(_deleted_at, Unset): + deleted_at = UNSET + else: + deleted_at = isoparse(_deleted_at) + + description = d.pop("description", UNSET) + + id = d.pop("id", UNSET) + + _last_published_at = d.pop("lastPublishedAt", UNSET) + last_published_at: Union[Unset, datetime.datetime] + if isinstance(_last_published_at, Unset): + last_published_at = UNSET + else: + last_published_at = isoparse(_last_published_at) + + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, MapDetailMetadata] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = MapDetailMetadata.from_dict(_metadata) + + name = d.pop("name", UNSET) + + qualified = d.pop("qualified", UNSET) + + ranked = d.pop("ranked", UNSET) + + _stats = d.pop("stats", UNSET) + stats: Union[Unset, MapStats] + if isinstance(_stats, Unset): + stats = UNSET + else: + stats = MapStats.from_dict(_stats) + + tags = [] + _tags = d.pop("tags", UNSET) + for tags_item_data in _tags or []: + tags_item = MapDetailTagsItem(tags_item_data) + + tags.append(tags_item) + + _updated_at = d.pop("updatedAt", UNSET) + updated_at: Union[Unset, datetime.datetime] + if isinstance(_updated_at, Unset): + updated_at = UNSET + else: + updated_at = isoparse(_updated_at) + + _uploaded = d.pop("uploaded", UNSET) + uploaded: Union[Unset, datetime.datetime] + if isinstance(_uploaded, Unset): + uploaded = UNSET + else: + uploaded = isoparse(_uploaded) + + _uploader = d.pop("uploader", UNSET) + uploader: Union[Unset, UserDetail] + if isinstance(_uploader, Unset): + uploader = UNSET + else: + uploader = UserDetail.from_dict(_uploader) + + versions = [] + _versions = d.pop("versions", UNSET) + for versions_item_data in _versions or []: + versions_item = MapVersion.from_dict(versions_item_data) + + versions.append(versions_item) + + map_detail = cls( + automapper=automapper, + bl_qualified=bl_qualified, + bl_ranked=bl_ranked, + bookmarked=bookmarked, + collaborators=collaborators, + created_at=created_at, + curated_at=curated_at, + curator=curator, + declared_ai=declared_ai, + deleted_at=deleted_at, + description=description, + id=id, + last_published_at=last_published_at, + metadata=metadata, + name=name, + qualified=qualified, + ranked=ranked, + stats=stats, + tags=tags, + updated_at=updated_at, + uploaded=uploaded, + uploader=uploader, + versions=versions, + ) + + map_detail.additional_properties = d + return map_detail + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_detail_declared_ai.py b/src/clients/beatsaver/models/map_detail_declared_ai.py new file mode 100644 index 0000000..6e9dd4d --- /dev/null +++ b/src/clients/beatsaver/models/map_detail_declared_ai.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class MapDetailDeclaredAi(str, Enum): + ADMIN = "Admin" + NONE = "None" + SAGESCORE = "SageScore" + UPLOADER = "Uploader" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/map_detail_metadata.py b/src/clients/beatsaver/models/map_detail_metadata.py new file mode 100644 index 0000000..ae29fba --- /dev/null +++ b/src/clients/beatsaver/models/map_detail_metadata.py @@ -0,0 +1,103 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MapDetailMetadata") + + +@_attrs_define +class MapDetailMetadata: + """ + Attributes: + bpm (Union[Unset, Any]): + duration (Union[Unset, int]): + level_author_name (Union[Unset, str]): + song_author_name (Union[Unset, str]): + song_name (Union[Unset, str]): + song_sub_name (Union[Unset, str]): + """ + + bpm: Union[Unset, Any] = UNSET + duration: Union[Unset, int] = UNSET + level_author_name: Union[Unset, str] = UNSET + song_author_name: Union[Unset, str] = UNSET + song_name: Union[Unset, str] = UNSET + song_sub_name: Union[Unset, str] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + bpm = self.bpm + + duration = self.duration + + level_author_name = self.level_author_name + + song_author_name = self.song_author_name + + song_name = self.song_name + + song_sub_name = self.song_sub_name + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if bpm is not UNSET: + field_dict["bpm"] = bpm + if duration is not UNSET: + field_dict["duration"] = duration + if level_author_name is not UNSET: + field_dict["levelAuthorName"] = level_author_name + if song_author_name is not UNSET: + field_dict["songAuthorName"] = song_author_name + if song_name is not UNSET: + field_dict["songName"] = song_name + if song_sub_name is not UNSET: + field_dict["songSubName"] = song_sub_name + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + bpm = d.pop("bpm", UNSET) + + duration = d.pop("duration", UNSET) + + level_author_name = d.pop("levelAuthorName", UNSET) + + song_author_name = d.pop("songAuthorName", UNSET) + + song_name = d.pop("songName", UNSET) + + song_sub_name = d.pop("songSubName", UNSET) + + map_detail_metadata = cls( + bpm=bpm, + duration=duration, + level_author_name=level_author_name, + song_author_name=song_author_name, + song_name=song_name, + song_sub_name=song_sub_name, + ) + + map_detail_metadata.additional_properties = d + return map_detail_metadata + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_detail_tags_item.py b/src/clients/beatsaver/models/map_detail_tags_item.py new file mode 100644 index 0000000..196b485 --- /dev/null +++ b/src/clients/beatsaver/models/map_detail_tags_item.py @@ -0,0 +1,51 @@ +from enum import Enum + + +class MapDetailTagsItem(str, Enum): + ACCURACY = "Accuracy" + ALT = "Alt" + AMBIENT = "Ambient" + ANIME = "Anime" + BALANCED = "Balanced" + CHALLENGE = "Challenge" + CLASSICAL = "Classical" + COMEDY = "Comedy" + DANCE = "Dance" + DANCESTYLE = "DanceStyle" + DRUMBASS = "DrumBass" + DUBSTEP = "Dubstep" + ELECTRONIC = "Electronic" + FAMILY = "Family" + FILM = "Film" + FITNESS = "Fitness" + FOLK = "Folk" + FUNK = "Funk" + GAME = "Game" + HARDCORE = "Hardcore" + HIPHOP = "HipHop" + HOLIDAY = "Holiday" + HOUSE = "House" + INDIE = "Indie" + INSTRUMENTAL = "Instrumental" + JAZZ = "Jazz" + JPOP = "JPop" + JROCK = "JRock" + KPOP = "KPop" + METAL = "Metal" + NIGHTCORE = "Nightcore" + NONE = "None" + POP = "Pop" + PUNK = "Punk" + RB = "RB" + ROCK = "Rock" + SOUL = "Soul" + SPEED = "Speed" + SPEEDCORE = "Speedcore" + SWING = "Swing" + TECH = "Tech" + TECHNO = "Techno" + TRANCE = "Trance" + VOCALOID = "Vocaloid" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/map_detail_with_order.py b/src/clients/beatsaver/models/map_detail_with_order.py new file mode 100644 index 0000000..de7e4a0 --- /dev/null +++ b/src/clients/beatsaver/models/map_detail_with_order.py @@ -0,0 +1,80 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.map_detail import MapDetail + + +T = TypeVar("T", bound="MapDetailWithOrder") + + +@_attrs_define +class MapDetailWithOrder: + """ + Attributes: + map_ (Union[Unset, MapDetail]): + order (Union[Unset, Any]): + """ + + map_: Union[Unset, "MapDetail"] = UNSET + order: Union[Unset, Any] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + map_: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.map_, Unset): + map_ = self.map_.to_dict() + + order = self.order + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if map_ is not UNSET: + field_dict["map"] = map_ + if order is not UNSET: + field_dict["order"] = order + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.map_detail import MapDetail + + d = src_dict.copy() + _map_ = d.pop("map", UNSET) + map_: Union[Unset, MapDetail] + if isinstance(_map_, Unset): + map_ = UNSET + else: + map_ = MapDetail.from_dict(_map_) + + order = d.pop("order", UNSET) + + map_detail_with_order = cls( + map_=map_, + order=order, + ) + + map_detail_with_order.additional_properties = d + return map_detail_with_order + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_difficulty.py b/src/clients/beatsaver/models/map_difficulty.py new file mode 100644 index 0000000..1a6a739 --- /dev/null +++ b/src/clients/beatsaver/models/map_difficulty.py @@ -0,0 +1,258 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.map_difficulty_characteristic import MapDifficultyCharacteristic +from ..models.map_difficulty_difficulty import MapDifficultyDifficulty +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.map_parity_summary import MapParitySummary + + +T = TypeVar("T", bound="MapDifficulty") + + +@_attrs_define +class MapDifficulty: + """ + Attributes: + bl_stars (Union[Unset, Any]): + bombs (Union[Unset, int]): + characteristic (Union[Unset, MapDifficultyCharacteristic]): + chroma (Union[Unset, bool]): + cinema (Union[Unset, bool]): + difficulty (Union[Unset, MapDifficultyDifficulty]): + events (Union[Unset, int]): + label (Union[Unset, str]): + length (Union[Unset, float]): + max_score (Union[Unset, int]): + me (Union[Unset, bool]): + ne (Union[Unset, bool]): + njs (Union[Unset, Any]): + notes (Union[Unset, int]): + nps (Union[Unset, float]): + obstacles (Union[Unset, int]): + offset (Union[Unset, Any]): + parity_summary (Union[Unset, MapParitySummary]): + seconds (Union[Unset, float]): + stars (Union[Unset, Any]): + """ + + bl_stars: Union[Unset, Any] = UNSET + bombs: Union[Unset, int] = UNSET + characteristic: Union[Unset, MapDifficultyCharacteristic] = UNSET + chroma: Union[Unset, bool] = UNSET + cinema: Union[Unset, bool] = UNSET + difficulty: Union[Unset, MapDifficultyDifficulty] = UNSET + events: Union[Unset, int] = UNSET + label: Union[Unset, str] = UNSET + length: Union[Unset, float] = UNSET + max_score: Union[Unset, int] = UNSET + me: Union[Unset, bool] = UNSET + ne: Union[Unset, bool] = UNSET + njs: Union[Unset, Any] = UNSET + notes: Union[Unset, int] = UNSET + nps: Union[Unset, float] = UNSET + obstacles: Union[Unset, int] = UNSET + offset: Union[Unset, Any] = UNSET + parity_summary: Union[Unset, "MapParitySummary"] = UNSET + seconds: Union[Unset, float] = UNSET + stars: Union[Unset, Any] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + bl_stars = self.bl_stars + + bombs = self.bombs + + characteristic: Union[Unset, str] = UNSET + if not isinstance(self.characteristic, Unset): + characteristic = self.characteristic.value + + chroma = self.chroma + + cinema = self.cinema + + difficulty: Union[Unset, str] = UNSET + if not isinstance(self.difficulty, Unset): + difficulty = self.difficulty.value + + events = self.events + + label = self.label + + length = self.length + + max_score = self.max_score + + me = self.me + + ne = self.ne + + njs = self.njs + + notes = self.notes + + nps = self.nps + + obstacles = self.obstacles + + offset = self.offset + + parity_summary: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.parity_summary, Unset): + parity_summary = self.parity_summary.to_dict() + + seconds = self.seconds + + stars = self.stars + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if bl_stars is not UNSET: + field_dict["blStars"] = bl_stars + if bombs is not UNSET: + field_dict["bombs"] = bombs + if characteristic is not UNSET: + field_dict["characteristic"] = characteristic + if chroma is not UNSET: + field_dict["chroma"] = chroma + if cinema is not UNSET: + field_dict["cinema"] = cinema + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + if events is not UNSET: + field_dict["events"] = events + if label is not UNSET: + field_dict["label"] = label + if length is not UNSET: + field_dict["length"] = length + if max_score is not UNSET: + field_dict["maxScore"] = max_score + if me is not UNSET: + field_dict["me"] = me + if ne is not UNSET: + field_dict["ne"] = ne + if njs is not UNSET: + field_dict["njs"] = njs + if notes is not UNSET: + field_dict["notes"] = notes + if nps is not UNSET: + field_dict["nps"] = nps + if obstacles is not UNSET: + field_dict["obstacles"] = obstacles + if offset is not UNSET: + field_dict["offset"] = offset + if parity_summary is not UNSET: + field_dict["paritySummary"] = parity_summary + if seconds is not UNSET: + field_dict["seconds"] = seconds + if stars is not UNSET: + field_dict["stars"] = stars + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.map_parity_summary import MapParitySummary + + d = src_dict.copy() + bl_stars = d.pop("blStars", UNSET) + + bombs = d.pop("bombs", UNSET) + + _characteristic = d.pop("characteristic", UNSET) + characteristic: Union[Unset, MapDifficultyCharacteristic] + if isinstance(_characteristic, Unset): + characteristic = UNSET + else: + characteristic = MapDifficultyCharacteristic(_characteristic) + + chroma = d.pop("chroma", UNSET) + + cinema = d.pop("cinema", UNSET) + + _difficulty = d.pop("difficulty", UNSET) + difficulty: Union[Unset, MapDifficultyDifficulty] + if isinstance(_difficulty, Unset): + difficulty = UNSET + else: + difficulty = MapDifficultyDifficulty(_difficulty) + + events = d.pop("events", UNSET) + + label = d.pop("label", UNSET) + + length = d.pop("length", UNSET) + + max_score = d.pop("maxScore", UNSET) + + me = d.pop("me", UNSET) + + ne = d.pop("ne", UNSET) + + njs = d.pop("njs", UNSET) + + notes = d.pop("notes", UNSET) + + nps = d.pop("nps", UNSET) + + obstacles = d.pop("obstacles", UNSET) + + offset = d.pop("offset", UNSET) + + _parity_summary = d.pop("paritySummary", UNSET) + parity_summary: Union[Unset, MapParitySummary] + if isinstance(_parity_summary, Unset): + parity_summary = UNSET + else: + parity_summary = MapParitySummary.from_dict(_parity_summary) + + seconds = d.pop("seconds", UNSET) + + stars = d.pop("stars", UNSET) + + map_difficulty = cls( + bl_stars=bl_stars, + bombs=bombs, + characteristic=characteristic, + chroma=chroma, + cinema=cinema, + difficulty=difficulty, + events=events, + label=label, + length=length, + max_score=max_score, + me=me, + ne=ne, + njs=njs, + notes=notes, + nps=nps, + obstacles=obstacles, + offset=offset, + parity_summary=parity_summary, + seconds=seconds, + stars=stars, + ) + + map_difficulty.additional_properties = d + return map_difficulty + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_difficulty_characteristic.py b/src/clients/beatsaver/models/map_difficulty_characteristic.py new file mode 100644 index 0000000..88077ce --- /dev/null +++ b/src/clients/beatsaver/models/map_difficulty_characteristic.py @@ -0,0 +1,15 @@ +from enum import Enum + + +class MapDifficultyCharacteristic(str, Enum): + LAWLESS = "Lawless" + LEGACY = "Legacy" + LIGHTSHOW = "Lightshow" + NOARROWS = "NoArrows" + ONESABER = "OneSaber" + STANDARD = "Standard" + VALUE_3 = "90Degree" + VALUE_4 = "360Degree" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/map_difficulty_difficulty.py b/src/clients/beatsaver/models/map_difficulty_difficulty.py new file mode 100644 index 0000000..13f6f99 --- /dev/null +++ b/src/clients/beatsaver/models/map_difficulty_difficulty.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class MapDifficultyDifficulty(str, Enum): + EASY = "Easy" + EXPERT = "Expert" + EXPERTPLUS = "ExpertPlus" + HARD = "Hard" + NORMAL = "Normal" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/map_parity_summary.py b/src/clients/beatsaver/models/map_parity_summary.py new file mode 100644 index 0000000..9a9cc0e --- /dev/null +++ b/src/clients/beatsaver/models/map_parity_summary.py @@ -0,0 +1,76 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MapParitySummary") + + +@_attrs_define +class MapParitySummary: + """ + Attributes: + errors (Union[Unset, int]): + resets (Union[Unset, int]): + warns (Union[Unset, int]): + """ + + errors: Union[Unset, int] = UNSET + resets: Union[Unset, int] = UNSET + warns: Union[Unset, int] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + errors = self.errors + + resets = self.resets + + warns = self.warns + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if errors is not UNSET: + field_dict["errors"] = errors + if resets is not UNSET: + field_dict["resets"] = resets + if warns is not UNSET: + field_dict["warns"] = warns + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + errors = d.pop("errors", UNSET) + + resets = d.pop("resets", UNSET) + + warns = d.pop("warns", UNSET) + + map_parity_summary = cls( + errors=errors, + resets=resets, + warns=warns, + ) + + map_parity_summary.additional_properties = d + return map_parity_summary + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_stats.py b/src/clients/beatsaver/models/map_stats.py new file mode 100644 index 0000000..d4331cb --- /dev/null +++ b/src/clients/beatsaver/models/map_stats.py @@ -0,0 +1,129 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.map_stats_sentiment import MapStatsSentiment +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MapStats") + + +@_attrs_define +class MapStats: + """ + Attributes: + downloads (Union[Unset, int]): + downvotes (Union[Unset, int]): + plays (Union[Unset, int]): + reviews (Union[Unset, int]): + score (Union[Unset, Any]): + score_one_dp (Union[Unset, Any]): + sentiment (Union[Unset, MapStatsSentiment]): + upvotes (Union[Unset, int]): + """ + + downloads: Union[Unset, int] = UNSET + downvotes: Union[Unset, int] = UNSET + plays: Union[Unset, int] = UNSET + reviews: Union[Unset, int] = UNSET + score: Union[Unset, Any] = UNSET + score_one_dp: Union[Unset, Any] = UNSET + sentiment: Union[Unset, MapStatsSentiment] = UNSET + upvotes: Union[Unset, int] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + downloads = self.downloads + + downvotes = self.downvotes + + plays = self.plays + + reviews = self.reviews + + score = self.score + + score_one_dp = self.score_one_dp + + sentiment: Union[Unset, str] = UNSET + if not isinstance(self.sentiment, Unset): + sentiment = self.sentiment.value + + upvotes = self.upvotes + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if downloads is not UNSET: + field_dict["downloads"] = downloads + if downvotes is not UNSET: + field_dict["downvotes"] = downvotes + if plays is not UNSET: + field_dict["plays"] = plays + if reviews is not UNSET: + field_dict["reviews"] = reviews + if score is not UNSET: + field_dict["score"] = score + if score_one_dp is not UNSET: + field_dict["scoreOneDP"] = score_one_dp + if sentiment is not UNSET: + field_dict["sentiment"] = sentiment + if upvotes is not UNSET: + field_dict["upvotes"] = upvotes + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + downloads = d.pop("downloads", UNSET) + + downvotes = d.pop("downvotes", UNSET) + + plays = d.pop("plays", UNSET) + + reviews = d.pop("reviews", UNSET) + + score = d.pop("score", UNSET) + + score_one_dp = d.pop("scoreOneDP", UNSET) + + _sentiment = d.pop("sentiment", UNSET) + sentiment: Union[Unset, MapStatsSentiment] + if isinstance(_sentiment, Unset): + sentiment = UNSET + else: + sentiment = MapStatsSentiment(_sentiment) + + upvotes = d.pop("upvotes", UNSET) + + map_stats = cls( + downloads=downloads, + downvotes=downvotes, + plays=plays, + reviews=reviews, + score=score, + score_one_dp=score_one_dp, + sentiment=sentiment, + upvotes=upvotes, + ) + + map_stats.additional_properties = d + return map_stats + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_stats_sentiment.py b/src/clients/beatsaver/models/map_stats_sentiment.py new file mode 100644 index 0000000..0ac1297 --- /dev/null +++ b/src/clients/beatsaver/models/map_stats_sentiment.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class MapStatsSentiment(str, Enum): + MIXED = "MIXED" + MOSTLY_NEGATIVE = "MOSTLY_NEGATIVE" + MOSTLY_POSITIVE = "MOSTLY_POSITIVE" + PENDING = "PENDING" + VERY_NEGATIVE = "VERY_NEGATIVE" + VERY_POSITIVE = "VERY_POSITIVE" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/map_testplay.py b/src/clients/beatsaver/models/map_testplay.py new file mode 100644 index 0000000..ae296b1 --- /dev/null +++ b/src/clients/beatsaver/models/map_testplay.py @@ -0,0 +1,123 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.user_detail import UserDetail + + +T = TypeVar("T", bound="MapTestplay") + + +@_attrs_define +class MapTestplay: + """ + Attributes: + created_at (Union[Unset, datetime.datetime]): + feedback (Union[Unset, str]): + feedback_at (Union[Unset, datetime.datetime]): + user (Union[Unset, UserDetail]): + video (Union[Unset, str]): + """ + + created_at: Union[Unset, datetime.datetime] = UNSET + feedback: Union[Unset, str] = UNSET + feedback_at: Union[Unset, datetime.datetime] = UNSET + user: Union[Unset, "UserDetail"] = UNSET + video: Union[Unset, str] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + created_at: Union[Unset, str] = UNSET + if not isinstance(self.created_at, Unset): + created_at = self.created_at.isoformat() + + feedback = self.feedback + + feedback_at: Union[Unset, str] = UNSET + if not isinstance(self.feedback_at, Unset): + feedback_at = self.feedback_at.isoformat() + + user: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.user, Unset): + user = self.user.to_dict() + + video = self.video + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if created_at is not UNSET: + field_dict["createdAt"] = created_at + if feedback is not UNSET: + field_dict["feedback"] = feedback + if feedback_at is not UNSET: + field_dict["feedbackAt"] = feedback_at + if user is not UNSET: + field_dict["user"] = user + if video is not UNSET: + field_dict["video"] = video + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.user_detail import UserDetail + + d = src_dict.copy() + _created_at = d.pop("createdAt", UNSET) + created_at: Union[Unset, datetime.datetime] + if isinstance(_created_at, Unset): + created_at = UNSET + else: + created_at = isoparse(_created_at) + + feedback = d.pop("feedback", UNSET) + + _feedback_at = d.pop("feedbackAt", UNSET) + feedback_at: Union[Unset, datetime.datetime] + if isinstance(_feedback_at, Unset): + feedback_at = UNSET + else: + feedback_at = isoparse(_feedback_at) + + _user = d.pop("user", UNSET) + user: Union[Unset, UserDetail] + if isinstance(_user, Unset): + user = UNSET + else: + user = UserDetail.from_dict(_user) + + video = d.pop("video", UNSET) + + map_testplay = cls( + created_at=created_at, + feedback=feedback, + feedback_at=feedback_at, + user=user, + video=video, + ) + + map_testplay.additional_properties = d + return map_testplay + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_version.py b/src/clients/beatsaver/models/map_version.py new file mode 100644 index 0000000..e043203 --- /dev/null +++ b/src/clients/beatsaver/models/map_version.py @@ -0,0 +1,225 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.map_version_state import MapVersionState +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.map_difficulty import MapDifficulty + from ..models.map_testplay import MapTestplay + + +T = TypeVar("T", bound="MapVersion") + + +@_attrs_define +class MapVersion: + """ + Attributes: + cover_url (Union[Unset, str]): + created_at (Union[Unset, datetime.datetime]): + diffs (Union[Unset, List['MapDifficulty']]): + download_url (Union[Unset, str]): + feedback (Union[Unset, str]): + hash_ (Union[Unset, str]): + key (Union[Unset, str]): + preview_url (Union[Unset, str]): + sage_score (Union[Unset, Any]): + scheduled_at (Union[Unset, datetime.datetime]): + state (Union[Unset, MapVersionState]): + testplay_at (Union[Unset, datetime.datetime]): + testplays (Union[Unset, List['MapTestplay']]): + """ + + cover_url: Union[Unset, str] = UNSET + created_at: Union[Unset, datetime.datetime] = UNSET + diffs: Union[Unset, List["MapDifficulty"]] = UNSET + download_url: Union[Unset, str] = UNSET + feedback: Union[Unset, str] = UNSET + hash_: Union[Unset, str] = UNSET + key: Union[Unset, str] = UNSET + preview_url: Union[Unset, str] = UNSET + sage_score: Union[Unset, Any] = UNSET + scheduled_at: Union[Unset, datetime.datetime] = UNSET + state: Union[Unset, MapVersionState] = UNSET + testplay_at: Union[Unset, datetime.datetime] = UNSET + testplays: Union[Unset, List["MapTestplay"]] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + cover_url = self.cover_url + + created_at: Union[Unset, str] = UNSET + if not isinstance(self.created_at, Unset): + created_at = self.created_at.isoformat() + + diffs: Union[Unset, List[Dict[str, Any]]] = UNSET + if not isinstance(self.diffs, Unset): + diffs = [] + for diffs_item_data in self.diffs: + diffs_item = diffs_item_data.to_dict() + diffs.append(diffs_item) + + download_url = self.download_url + + feedback = self.feedback + + hash_ = self.hash_ + + key = self.key + + preview_url = self.preview_url + + sage_score = self.sage_score + + scheduled_at: Union[Unset, str] = UNSET + if not isinstance(self.scheduled_at, Unset): + scheduled_at = self.scheduled_at.isoformat() + + state: Union[Unset, str] = UNSET + if not isinstance(self.state, Unset): + state = self.state.value + + testplay_at: Union[Unset, str] = UNSET + if not isinstance(self.testplay_at, Unset): + testplay_at = self.testplay_at.isoformat() + + testplays: Union[Unset, List[Dict[str, Any]]] = UNSET + if not isinstance(self.testplays, Unset): + testplays = [] + for testplays_item_data in self.testplays: + testplays_item = testplays_item_data.to_dict() + testplays.append(testplays_item) + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if cover_url is not UNSET: + field_dict["coverURL"] = cover_url + if created_at is not UNSET: + field_dict["createdAt"] = created_at + if diffs is not UNSET: + field_dict["diffs"] = diffs + if download_url is not UNSET: + field_dict["downloadURL"] = download_url + if feedback is not UNSET: + field_dict["feedback"] = feedback + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if key is not UNSET: + field_dict["key"] = key + if preview_url is not UNSET: + field_dict["previewURL"] = preview_url + if sage_score is not UNSET: + field_dict["sageScore"] = sage_score + if scheduled_at is not UNSET: + field_dict["scheduledAt"] = scheduled_at + if state is not UNSET: + field_dict["state"] = state + if testplay_at is not UNSET: + field_dict["testplayAt"] = testplay_at + if testplays is not UNSET: + field_dict["testplays"] = testplays + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.map_difficulty import MapDifficulty + from ..models.map_testplay import MapTestplay + + d = src_dict.copy() + cover_url = d.pop("coverURL", UNSET) + + _created_at = d.pop("createdAt", UNSET) + created_at: Union[Unset, datetime.datetime] + if isinstance(_created_at, Unset): + created_at = UNSET + else: + created_at = isoparse(_created_at) + + diffs = [] + _diffs = d.pop("diffs", UNSET) + for diffs_item_data in _diffs or []: + diffs_item = MapDifficulty.from_dict(diffs_item_data) + + diffs.append(diffs_item) + + download_url = d.pop("downloadURL", UNSET) + + feedback = d.pop("feedback", UNSET) + + hash_ = d.pop("hash", UNSET) + + key = d.pop("key", UNSET) + + preview_url = d.pop("previewURL", UNSET) + + sage_score = d.pop("sageScore", UNSET) + + _scheduled_at = d.pop("scheduledAt", UNSET) + scheduled_at: Union[Unset, datetime.datetime] + if isinstance(_scheduled_at, Unset): + scheduled_at = UNSET + else: + scheduled_at = isoparse(_scheduled_at) + + _state = d.pop("state", UNSET) + state: Union[Unset, MapVersionState] + if isinstance(_state, Unset): + state = UNSET + else: + state = MapVersionState(_state) + + _testplay_at = d.pop("testplayAt", UNSET) + testplay_at: Union[Unset, datetime.datetime] + if isinstance(_testplay_at, Unset): + testplay_at = UNSET + else: + testplay_at = isoparse(_testplay_at) + + testplays = [] + _testplays = d.pop("testplays", UNSET) + for testplays_item_data in _testplays or []: + testplays_item = MapTestplay.from_dict(testplays_item_data) + + testplays.append(testplays_item) + + map_version = cls( + cover_url=cover_url, + created_at=created_at, + diffs=diffs, + download_url=download_url, + feedback=feedback, + hash_=hash_, + key=key, + preview_url=preview_url, + sage_score=sage_score, + scheduled_at=scheduled_at, + state=state, + testplay_at=testplay_at, + testplays=testplays, + ) + + map_version.additional_properties = d + return map_version + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/map_version_state.py b/src/clients/beatsaver/models/map_version_state.py new file mode 100644 index 0000000..fd0ea69 --- /dev/null +++ b/src/clients/beatsaver/models/map_version_state.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class MapVersionState(str, Enum): + FEEDBACK = "Feedback" + PUBLISHED = "Published" + SCHEDULED = "Scheduled" + TESTPLAY = "Testplay" + UPLOADED = "Uploaded" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/playlist_batch_request.py b/src/clients/beatsaver/models/playlist_batch_request.py new file mode 100644 index 0000000..f1f26bf --- /dev/null +++ b/src/clients/beatsaver/models/playlist_batch_request.py @@ -0,0 +1,89 @@ +from typing import Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlaylistBatchRequest") + + +@_attrs_define +class PlaylistBatchRequest: + """ + Attributes: + hashes (Union[Unset, List[str]]): + ignore_unknown (Union[Unset, bool]): + in_playlist (Union[Unset, bool]): + keys (Union[Unset, List[str]]): + """ + + hashes: Union[Unset, List[str]] = UNSET + ignore_unknown: Union[Unset, bool] = UNSET + in_playlist: Union[Unset, bool] = UNSET + keys: Union[Unset, List[str]] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + hashes: Union[Unset, List[str]] = UNSET + if not isinstance(self.hashes, Unset): + hashes = self.hashes + + ignore_unknown = self.ignore_unknown + + in_playlist = self.in_playlist + + keys: Union[Unset, List[str]] = UNSET + if not isinstance(self.keys, Unset): + keys = self.keys + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if hashes is not UNSET: + field_dict["hashes"] = hashes + if ignore_unknown is not UNSET: + field_dict["ignoreUnknown"] = ignore_unknown + if in_playlist is not UNSET: + field_dict["inPlaylist"] = in_playlist + if keys is not UNSET: + field_dict["keys"] = keys + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + hashes = cast(List[str], d.pop("hashes", UNSET)) + + ignore_unknown = d.pop("ignoreUnknown", UNSET) + + in_playlist = d.pop("inPlaylist", UNSET) + + keys = cast(List[str], d.pop("keys", UNSET)) + + playlist_batch_request = cls( + hashes=hashes, + ignore_unknown=ignore_unknown, + in_playlist=in_playlist, + keys=keys, + ) + + playlist_batch_request.additional_properties = d + return playlist_batch_request + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/playlist_full.py b/src/clients/beatsaver/models/playlist_full.py new file mode 100644 index 0000000..a3f3edb --- /dev/null +++ b/src/clients/beatsaver/models/playlist_full.py @@ -0,0 +1,267 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.playlist_full_type import PlaylistFullType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.playlist_stats import PlaylistStats + from ..models.user_detail import UserDetail + + +T = TypeVar("T", bound="PlaylistFull") + + +@_attrs_define +class PlaylistFull: + """ + Attributes: + config (Union[Unset, Any]): + created_at (Union[Unset, datetime.datetime]): + curated_at (Union[Unset, datetime.datetime]): + curator (Union[Unset, UserDetail]): + deleted_at (Union[Unset, datetime.datetime]): + description (Union[Unset, str]): + download_url (Union[Unset, str]): + name (Union[Unset, str]): + owner (Union[Unset, UserDetail]): + playlist_id (Union[Unset, int]): + playlist_image (Union[Unset, str]): + playlist_image_512 (Union[Unset, str]): + songs_changed_at (Union[Unset, datetime.datetime]): + stats (Union[Unset, PlaylistStats]): + type (Union[Unset, PlaylistFullType]): + updated_at (Union[Unset, datetime.datetime]): + """ + + config: Union[Unset, Any] = UNSET + created_at: Union[Unset, datetime.datetime] = UNSET + curated_at: Union[Unset, datetime.datetime] = UNSET + curator: Union[Unset, "UserDetail"] = UNSET + deleted_at: Union[Unset, datetime.datetime] = UNSET + description: Union[Unset, str] = UNSET + download_url: Union[Unset, str] = UNSET + name: Union[Unset, str] = UNSET + owner: Union[Unset, "UserDetail"] = UNSET + playlist_id: Union[Unset, int] = UNSET + playlist_image: Union[Unset, str] = UNSET + playlist_image_512: Union[Unset, str] = UNSET + songs_changed_at: Union[Unset, datetime.datetime] = UNSET + stats: Union[Unset, "PlaylistStats"] = UNSET + type: Union[Unset, PlaylistFullType] = UNSET + updated_at: Union[Unset, datetime.datetime] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + config = self.config + + created_at: Union[Unset, str] = UNSET + if not isinstance(self.created_at, Unset): + created_at = self.created_at.isoformat() + + curated_at: Union[Unset, str] = UNSET + if not isinstance(self.curated_at, Unset): + curated_at = self.curated_at.isoformat() + + curator: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.curator, Unset): + curator = self.curator.to_dict() + + deleted_at: Union[Unset, str] = UNSET + if not isinstance(self.deleted_at, Unset): + deleted_at = self.deleted_at.isoformat() + + description = self.description + + download_url = self.download_url + + name = self.name + + owner: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.owner, Unset): + owner = self.owner.to_dict() + + playlist_id = self.playlist_id + + playlist_image = self.playlist_image + + playlist_image_512 = self.playlist_image_512 + + songs_changed_at: Union[Unset, str] = UNSET + if not isinstance(self.songs_changed_at, Unset): + songs_changed_at = self.songs_changed_at.isoformat() + + stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.stats, Unset): + stats = self.stats.to_dict() + + type: Union[Unset, str] = UNSET + if not isinstance(self.type, Unset): + type = self.type.value + + updated_at: Union[Unset, str] = UNSET + if not isinstance(self.updated_at, Unset): + updated_at = self.updated_at.isoformat() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if config is not UNSET: + field_dict["config"] = config + if created_at is not UNSET: + field_dict["createdAt"] = created_at + if curated_at is not UNSET: + field_dict["curatedAt"] = curated_at + if curator is not UNSET: + field_dict["curator"] = curator + if deleted_at is not UNSET: + field_dict["deletedAt"] = deleted_at + if description is not UNSET: + field_dict["description"] = description + if download_url is not UNSET: + field_dict["downloadURL"] = download_url + if name is not UNSET: + field_dict["name"] = name + if owner is not UNSET: + field_dict["owner"] = owner + if playlist_id is not UNSET: + field_dict["playlistId"] = playlist_id + if playlist_image is not UNSET: + field_dict["playlistImage"] = playlist_image + if playlist_image_512 is not UNSET: + field_dict["playlistImage512"] = playlist_image_512 + if songs_changed_at is not UNSET: + field_dict["songsChangedAt"] = songs_changed_at + if stats is not UNSET: + field_dict["stats"] = stats + if type is not UNSET: + field_dict["type"] = type + if updated_at is not UNSET: + field_dict["updatedAt"] = updated_at + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.playlist_stats import PlaylistStats + from ..models.user_detail import UserDetail + + d = src_dict.copy() + config = d.pop("config", UNSET) + + _created_at = d.pop("createdAt", UNSET) + created_at: Union[Unset, datetime.datetime] + if isinstance(_created_at, Unset): + created_at = UNSET + else: + created_at = isoparse(_created_at) + + _curated_at = d.pop("curatedAt", UNSET) + curated_at: Union[Unset, datetime.datetime] + if isinstance(_curated_at, Unset): + curated_at = UNSET + else: + curated_at = isoparse(_curated_at) + + _curator = d.pop("curator", UNSET) + curator: Union[Unset, UserDetail] + if isinstance(_curator, Unset): + curator = UNSET + else: + curator = UserDetail.from_dict(_curator) + + _deleted_at = d.pop("deletedAt", UNSET) + deleted_at: Union[Unset, datetime.datetime] + if isinstance(_deleted_at, Unset): + deleted_at = UNSET + else: + deleted_at = isoparse(_deleted_at) + + description = d.pop("description", UNSET) + + download_url = d.pop("downloadURL", UNSET) + + name = d.pop("name", UNSET) + + _owner = d.pop("owner", UNSET) + owner: Union[Unset, UserDetail] + if isinstance(_owner, Unset): + owner = UNSET + else: + owner = UserDetail.from_dict(_owner) + + playlist_id = d.pop("playlistId", UNSET) + + playlist_image = d.pop("playlistImage", UNSET) + + playlist_image_512 = d.pop("playlistImage512", UNSET) + + _songs_changed_at = d.pop("songsChangedAt", UNSET) + songs_changed_at: Union[Unset, datetime.datetime] + if isinstance(_songs_changed_at, Unset): + songs_changed_at = UNSET + else: + songs_changed_at = isoparse(_songs_changed_at) + + _stats = d.pop("stats", UNSET) + stats: Union[Unset, PlaylistStats] + if isinstance(_stats, Unset): + stats = UNSET + else: + stats = PlaylistStats.from_dict(_stats) + + _type = d.pop("type", UNSET) + type: Union[Unset, PlaylistFullType] + if isinstance(_type, Unset): + type = UNSET + else: + type = PlaylistFullType(_type) + + _updated_at = d.pop("updatedAt", UNSET) + updated_at: Union[Unset, datetime.datetime] + if isinstance(_updated_at, Unset): + updated_at = UNSET + else: + updated_at = isoparse(_updated_at) + + playlist_full = cls( + config=config, + created_at=created_at, + curated_at=curated_at, + curator=curator, + deleted_at=deleted_at, + description=description, + download_url=download_url, + name=name, + owner=owner, + playlist_id=playlist_id, + playlist_image=playlist_image, + playlist_image_512=playlist_image_512, + songs_changed_at=songs_changed_at, + stats=stats, + type=type, + updated_at=updated_at, + ) + + playlist_full.additional_properties = d + return playlist_full + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/playlist_full_type.py b/src/clients/beatsaver/models/playlist_full_type.py new file mode 100644 index 0000000..f62ef8a --- /dev/null +++ b/src/clients/beatsaver/models/playlist_full_type.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class PlaylistFullType(str, Enum): + PRIVATE = "Private" + PUBLIC = "Public" + SEARCH = "Search" + SYSTEM = "System" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/playlist_page.py b/src/clients/beatsaver/models/playlist_page.py new file mode 100644 index 0000000..806e0f6 --- /dev/null +++ b/src/clients/beatsaver/models/playlist_page.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.map_detail_with_order import MapDetailWithOrder + from ..models.playlist_full import PlaylistFull + + +T = TypeVar("T", bound="PlaylistPage") + + +@_attrs_define +class PlaylistPage: + """ + Attributes: + maps (Union[Unset, List['MapDetailWithOrder']]): + playlist (Union[Unset, PlaylistFull]): + """ + + maps: Union[Unset, List["MapDetailWithOrder"]] = UNSET + playlist: Union[Unset, "PlaylistFull"] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + maps: Union[Unset, List[Dict[str, Any]]] = UNSET + if not isinstance(self.maps, Unset): + maps = [] + for maps_item_data in self.maps: + maps_item = maps_item_data.to_dict() + maps.append(maps_item) + + playlist: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.playlist, Unset): + playlist = self.playlist.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if maps is not UNSET: + field_dict["maps"] = maps + if playlist is not UNSET: + field_dict["playlist"] = playlist + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.map_detail_with_order import MapDetailWithOrder + from ..models.playlist_full import PlaylistFull + + d = src_dict.copy() + maps = [] + _maps = d.pop("maps", UNSET) + for maps_item_data in _maps or []: + maps_item = MapDetailWithOrder.from_dict(maps_item_data) + + maps.append(maps_item) + + _playlist = d.pop("playlist", UNSET) + playlist: Union[Unset, PlaylistFull] + if isinstance(_playlist, Unset): + playlist = UNSET + else: + playlist = PlaylistFull.from_dict(_playlist) + + playlist_page = cls( + maps=maps, + playlist=playlist, + ) + + playlist_page.additional_properties = d + return playlist_page + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/playlist_search_response.py b/src/clients/beatsaver/models/playlist_search_response.py new file mode 100644 index 0000000..7d3219f --- /dev/null +++ b/src/clients/beatsaver/models/playlist_search_response.py @@ -0,0 +1,74 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.playlist_full import PlaylistFull + + +T = TypeVar("T", bound="PlaylistSearchResponse") + + +@_attrs_define +class PlaylistSearchResponse: + """ + Attributes: + docs (Union[Unset, List['PlaylistFull']]): + """ + + docs: Union[Unset, List["PlaylistFull"]] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + docs: Union[Unset, List[Dict[str, Any]]] = UNSET + if not isinstance(self.docs, Unset): + docs = [] + for docs_item_data in self.docs: + docs_item = docs_item_data.to_dict() + docs.append(docs_item) + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if docs is not UNSET: + field_dict["docs"] = docs + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.playlist_full import PlaylistFull + + d = src_dict.copy() + docs = [] + _docs = d.pop("docs", UNSET) + for docs_item_data in _docs or []: + docs_item = PlaylistFull.from_dict(docs_item_data) + + docs.append(docs_item) + + playlist_search_response = cls( + docs=docs, + ) + + playlist_search_response.additional_properties = d + return playlist_search_response + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/playlist_stats.py b/src/clients/beatsaver/models/playlist_stats.py new file mode 100644 index 0000000..07ff66d --- /dev/null +++ b/src/clients/beatsaver/models/playlist_stats.py @@ -0,0 +1,148 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PlaylistStats") + + +@_attrs_define +class PlaylistStats: + """ + Attributes: + avg_score (Union[Unset, Any]): + down_votes (Union[Unset, int]): + mapper_count (Union[Unset, int]): + max_nps (Union[Unset, float]): + max_nps_two_dp (Union[Unset, float]): + min_nps (Union[Unset, float]): + min_nps_two_dp (Union[Unset, float]): + score_one_dp (Union[Unset, Any]): + total_duration (Union[Unset, int]): + total_maps (Union[Unset, int]): + up_votes (Union[Unset, int]): + """ + + avg_score: Union[Unset, Any] = UNSET + down_votes: Union[Unset, int] = UNSET + mapper_count: Union[Unset, int] = UNSET + max_nps: Union[Unset, float] = UNSET + max_nps_two_dp: Union[Unset, float] = UNSET + min_nps: Union[Unset, float] = UNSET + min_nps_two_dp: Union[Unset, float] = UNSET + score_one_dp: Union[Unset, Any] = UNSET + total_duration: Union[Unset, int] = UNSET + total_maps: Union[Unset, int] = UNSET + up_votes: Union[Unset, int] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + avg_score = self.avg_score + + down_votes = self.down_votes + + mapper_count = self.mapper_count + + max_nps = self.max_nps + + max_nps_two_dp = self.max_nps_two_dp + + min_nps = self.min_nps + + min_nps_two_dp = self.min_nps_two_dp + + score_one_dp = self.score_one_dp + + total_duration = self.total_duration + + total_maps = self.total_maps + + up_votes = self.up_votes + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if avg_score is not UNSET: + field_dict["avgScore"] = avg_score + if down_votes is not UNSET: + field_dict["downVotes"] = down_votes + if mapper_count is not UNSET: + field_dict["mapperCount"] = mapper_count + if max_nps is not UNSET: + field_dict["maxNps"] = max_nps + if max_nps_two_dp is not UNSET: + field_dict["maxNpsTwoDP"] = max_nps_two_dp + if min_nps is not UNSET: + field_dict["minNps"] = min_nps + if min_nps_two_dp is not UNSET: + field_dict["minNpsTwoDP"] = min_nps_two_dp + if score_one_dp is not UNSET: + field_dict["scoreOneDP"] = score_one_dp + if total_duration is not UNSET: + field_dict["totalDuration"] = total_duration + if total_maps is not UNSET: + field_dict["totalMaps"] = total_maps + if up_votes is not UNSET: + field_dict["upVotes"] = up_votes + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + avg_score = d.pop("avgScore", UNSET) + + down_votes = d.pop("downVotes", UNSET) + + mapper_count = d.pop("mapperCount", UNSET) + + max_nps = d.pop("maxNps", UNSET) + + max_nps_two_dp = d.pop("maxNpsTwoDP", UNSET) + + min_nps = d.pop("minNps", UNSET) + + min_nps_two_dp = d.pop("minNpsTwoDP", UNSET) + + score_one_dp = d.pop("scoreOneDP", UNSET) + + total_duration = d.pop("totalDuration", UNSET) + + total_maps = d.pop("totalMaps", UNSET) + + up_votes = d.pop("upVotes", UNSET) + + playlist_stats = cls( + avg_score=avg_score, + down_votes=down_votes, + mapper_count=mapper_count, + max_nps=max_nps, + max_nps_two_dp=max_nps_two_dp, + min_nps=min_nps, + min_nps_two_dp=min_nps_two_dp, + score_one_dp=score_one_dp, + total_duration=total_duration, + total_maps=total_maps, + up_votes=up_votes, + ) + + playlist_stats.additional_properties = d + return playlist_stats + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/search_response.py b/src/clients/beatsaver/models/search_response.py new file mode 100644 index 0000000..62858e4 --- /dev/null +++ b/src/clients/beatsaver/models/search_response.py @@ -0,0 +1,83 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.map_detail import MapDetail + + +T = TypeVar("T", bound="SearchResponse") + + +@_attrs_define +class SearchResponse: + """ + Attributes: + docs (Union[Unset, List['MapDetail']]): + redirect (Union[Unset, str]): + """ + + docs: Union[Unset, List["MapDetail"]] = UNSET + redirect: Union[Unset, str] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + docs: Union[Unset, List[Dict[str, Any]]] = UNSET + if not isinstance(self.docs, Unset): + docs = [] + for docs_item_data in self.docs: + docs_item = docs_item_data.to_dict() + docs.append(docs_item) + + redirect = self.redirect + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if docs is not UNSET: + field_dict["docs"] = docs + if redirect is not UNSET: + field_dict["redirect"] = redirect + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.map_detail import MapDetail + + d = src_dict.copy() + docs = [] + _docs = d.pop("docs", UNSET) + for docs_item_data in _docs or []: + docs_item = MapDetail.from_dict(docs_item_data) + + docs.append(docs_item) + + redirect = d.pop("redirect", UNSET) + + search_response = cls( + docs=docs, + redirect=redirect, + ) + + search_response.additional_properties = d + return search_response + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/user_detail.py b/src/clients/beatsaver/models/user_detail.py new file mode 100644 index 0000000..722a4a7 --- /dev/null +++ b/src/clients/beatsaver/models/user_detail.py @@ -0,0 +1,276 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.user_detail_patreon import UserDetailPatreon +from ..models.user_detail_type import UserDetailType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.user_follow_data import UserFollowData + from ..models.user_stats import UserStats + + +T = TypeVar("T", bound="UserDetail") + + +@_attrs_define +class UserDetail: + """ + Attributes: + admin (Union[Unset, bool]): + avatar (Union[Unset, str]): + curator (Union[Unset, bool]): + curator_tab (Union[Unset, bool]): + description (Union[Unset, str]): + email (Union[Unset, str]): + follow_data (Union[Unset, UserFollowData]): + hash_ (Union[Unset, str]): + id (Union[Unset, int]): + name (Union[Unset, str]): + patreon (Union[Unset, UserDetailPatreon]): + playlist_url (Union[Unset, str]): + senior_curator (Union[Unset, bool]): + stats (Union[Unset, UserStats]): + suspended_at (Union[Unset, datetime.datetime]): + testplay (Union[Unset, bool]): + type (Union[Unset, UserDetailType]): + unique_set (Union[Unset, bool]): + upload_limit (Union[Unset, int]): + verified_mapper (Union[Unset, bool]): + """ + + admin: Union[Unset, bool] = UNSET + avatar: Union[Unset, str] = UNSET + curator: Union[Unset, bool] = UNSET + curator_tab: Union[Unset, bool] = UNSET + description: Union[Unset, str] = UNSET + email: Union[Unset, str] = UNSET + follow_data: Union[Unset, "UserFollowData"] = UNSET + hash_: Union[Unset, str] = UNSET + id: Union[Unset, int] = UNSET + name: Union[Unset, str] = UNSET + patreon: Union[Unset, UserDetailPatreon] = UNSET + playlist_url: Union[Unset, str] = UNSET + senior_curator: Union[Unset, bool] = UNSET + stats: Union[Unset, "UserStats"] = UNSET + suspended_at: Union[Unset, datetime.datetime] = UNSET + testplay: Union[Unset, bool] = UNSET + type: Union[Unset, UserDetailType] = UNSET + unique_set: Union[Unset, bool] = UNSET + upload_limit: Union[Unset, int] = UNSET + verified_mapper: Union[Unset, bool] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + admin = self.admin + + avatar = self.avatar + + curator = self.curator + + curator_tab = self.curator_tab + + description = self.description + + email = self.email + + follow_data: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.follow_data, Unset): + follow_data = self.follow_data.to_dict() + + hash_ = self.hash_ + + id = self.id + + name = self.name + + patreon: Union[Unset, str] = UNSET + if not isinstance(self.patreon, Unset): + patreon = self.patreon.value + + playlist_url = self.playlist_url + + senior_curator = self.senior_curator + + stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.stats, Unset): + stats = self.stats.to_dict() + + suspended_at: Union[Unset, str] = UNSET + if not isinstance(self.suspended_at, Unset): + suspended_at = self.suspended_at.isoformat() + + testplay = self.testplay + + type: Union[Unset, str] = UNSET + if not isinstance(self.type, Unset): + type = self.type.value + + unique_set = self.unique_set + + upload_limit = self.upload_limit + + verified_mapper = self.verified_mapper + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if admin is not UNSET: + field_dict["admin"] = admin + if avatar is not UNSET: + field_dict["avatar"] = avatar + if curator is not UNSET: + field_dict["curator"] = curator + if curator_tab is not UNSET: + field_dict["curatorTab"] = curator_tab + if description is not UNSET: + field_dict["description"] = description + if email is not UNSET: + field_dict["email"] = email + if follow_data is not UNSET: + field_dict["followData"] = follow_data + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if id is not UNSET: + field_dict["id"] = id + if name is not UNSET: + field_dict["name"] = name + if patreon is not UNSET: + field_dict["patreon"] = patreon + if playlist_url is not UNSET: + field_dict["playlistUrl"] = playlist_url + if senior_curator is not UNSET: + field_dict["seniorCurator"] = senior_curator + if stats is not UNSET: + field_dict["stats"] = stats + if suspended_at is not UNSET: + field_dict["suspendedAt"] = suspended_at + if testplay is not UNSET: + field_dict["testplay"] = testplay + if type is not UNSET: + field_dict["type"] = type + if unique_set is not UNSET: + field_dict["uniqueSet"] = unique_set + if upload_limit is not UNSET: + field_dict["uploadLimit"] = upload_limit + if verified_mapper is not UNSET: + field_dict["verifiedMapper"] = verified_mapper + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.user_follow_data import UserFollowData + from ..models.user_stats import UserStats + + d = src_dict.copy() + admin = d.pop("admin", UNSET) + + avatar = d.pop("avatar", UNSET) + + curator = d.pop("curator", UNSET) + + curator_tab = d.pop("curatorTab", UNSET) + + description = d.pop("description", UNSET) + + email = d.pop("email", UNSET) + + _follow_data = d.pop("followData", UNSET) + follow_data: Union[Unset, UserFollowData] + if isinstance(_follow_data, Unset): + follow_data = UNSET + else: + follow_data = UserFollowData.from_dict(_follow_data) + + hash_ = d.pop("hash", UNSET) + + id = d.pop("id", UNSET) + + name = d.pop("name", UNSET) + + _patreon = d.pop("patreon", UNSET) + patreon: Union[Unset, UserDetailPatreon] + if isinstance(_patreon, Unset): + patreon = UNSET + else: + patreon = UserDetailPatreon(_patreon) + + playlist_url = d.pop("playlistUrl", UNSET) + + senior_curator = d.pop("seniorCurator", UNSET) + + _stats = d.pop("stats", UNSET) + stats: Union[Unset, UserStats] + if isinstance(_stats, Unset): + stats = UNSET + else: + stats = UserStats.from_dict(_stats) + + _suspended_at = d.pop("suspendedAt", UNSET) + suspended_at: Union[Unset, datetime.datetime] + if isinstance(_suspended_at, Unset): + suspended_at = UNSET + else: + suspended_at = isoparse(_suspended_at) + + testplay = d.pop("testplay", UNSET) + + _type = d.pop("type", UNSET) + type: Union[Unset, UserDetailType] + if isinstance(_type, Unset): + type = UNSET + else: + type = UserDetailType(_type) + + unique_set = d.pop("uniqueSet", UNSET) + + upload_limit = d.pop("uploadLimit", UNSET) + + verified_mapper = d.pop("verifiedMapper", UNSET) + + user_detail = cls( + admin=admin, + avatar=avatar, + curator=curator, + curator_tab=curator_tab, + description=description, + email=email, + follow_data=follow_data, + hash_=hash_, + id=id, + name=name, + patreon=patreon, + playlist_url=playlist_url, + senior_curator=senior_curator, + stats=stats, + suspended_at=suspended_at, + testplay=testplay, + type=type, + unique_set=unique_set, + upload_limit=upload_limit, + verified_mapper=verified_mapper, + ) + + user_detail.additional_properties = d + return user_detail + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/user_detail_patreon.py b/src/clients/beatsaver/models/user_detail_patreon.py new file mode 100644 index 0000000..a07c7e8 --- /dev/null +++ b/src/clients/beatsaver/models/user_detail_patreon.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class UserDetailPatreon(str, Enum): + NONE = "None" + SUPPORTER = "Supporter" + SUPPORTERPLUS = "SupporterPlus" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/user_detail_type.py b/src/clients/beatsaver/models/user_detail_type.py new file mode 100644 index 0000000..5ddf689 --- /dev/null +++ b/src/clients/beatsaver/models/user_detail_type.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class UserDetailType(str, Enum): + DISCORD = "DISCORD" + DUAL = "DUAL" + SIMPLE = "SIMPLE" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/beatsaver/models/user_diff_stats.py b/src/clients/beatsaver/models/user_diff_stats.py new file mode 100644 index 0000000..c2ac005 --- /dev/null +++ b/src/clients/beatsaver/models/user_diff_stats.py @@ -0,0 +1,103 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="UserDiffStats") + + +@_attrs_define +class UserDiffStats: + """ + Attributes: + easy (Union[Unset, int]): + expert (Union[Unset, int]): + expert_plus (Union[Unset, int]): + hard (Union[Unset, int]): + normal (Union[Unset, int]): + total (Union[Unset, int]): + """ + + easy: Union[Unset, int] = UNSET + expert: Union[Unset, int] = UNSET + expert_plus: Union[Unset, int] = UNSET + hard: Union[Unset, int] = UNSET + normal: Union[Unset, int] = UNSET + total: Union[Unset, int] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + easy = self.easy + + expert = self.expert + + expert_plus = self.expert_plus + + hard = self.hard + + normal = self.normal + + total = self.total + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if easy is not UNSET: + field_dict["easy"] = easy + if expert is not UNSET: + field_dict["expert"] = expert + if expert_plus is not UNSET: + field_dict["expertPlus"] = expert_plus + if hard is not UNSET: + field_dict["hard"] = hard + if normal is not UNSET: + field_dict["normal"] = normal + if total is not UNSET: + field_dict["total"] = total + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + easy = d.pop("easy", UNSET) + + expert = d.pop("expert", UNSET) + + expert_plus = d.pop("expertPlus", UNSET) + + hard = d.pop("hard", UNSET) + + normal = d.pop("normal", UNSET) + + total = d.pop("total", UNSET) + + user_diff_stats = cls( + easy=easy, + expert=expert, + expert_plus=expert_plus, + hard=hard, + normal=normal, + total=total, + ) + + user_diff_stats.additional_properties = d + return user_diff_stats + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/user_follow_data.py b/src/clients/beatsaver/models/user_follow_data.py new file mode 100644 index 0000000..805e5b5 --- /dev/null +++ b/src/clients/beatsaver/models/user_follow_data.py @@ -0,0 +1,103 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="UserFollowData") + + +@_attrs_define +class UserFollowData: + """ + Attributes: + collab (Union[Unset, bool]): + curation (Union[Unset, bool]): + followers (Union[Unset, int]): + following (Union[Unset, bool]): + follows (Union[Unset, int]): + upload (Union[Unset, bool]): + """ + + collab: Union[Unset, bool] = UNSET + curation: Union[Unset, bool] = UNSET + followers: Union[Unset, int] = UNSET + following: Union[Unset, bool] = UNSET + follows: Union[Unset, int] = UNSET + upload: Union[Unset, bool] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + collab = self.collab + + curation = self.curation + + followers = self.followers + + following = self.following + + follows = self.follows + + upload = self.upload + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if collab is not UNSET: + field_dict["collab"] = collab + if curation is not UNSET: + field_dict["curation"] = curation + if followers is not UNSET: + field_dict["followers"] = followers + if following is not UNSET: + field_dict["following"] = following + if follows is not UNSET: + field_dict["follows"] = follows + if upload is not UNSET: + field_dict["upload"] = upload + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + collab = d.pop("collab", UNSET) + + curation = d.pop("curation", UNSET) + + followers = d.pop("followers", UNSET) + + following = d.pop("following", UNSET) + + follows = d.pop("follows", UNSET) + + upload = d.pop("upload", UNSET) + + user_follow_data = cls( + collab=collab, + curation=curation, + followers=followers, + following=following, + follows=follows, + upload=upload, + ) + + user_follow_data.additional_properties = d + return user_follow_data + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/user_stats.py b/src/clients/beatsaver/models/user_stats.py new file mode 100644 index 0000000..9646142 --- /dev/null +++ b/src/clients/beatsaver/models/user_stats.py @@ -0,0 +1,168 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.user_diff_stats import UserDiffStats + + +T = TypeVar("T", bound="UserStats") + + +@_attrs_define +class UserStats: + """ + Attributes: + avg_bpm (Union[Unset, Any]): + avg_duration (Union[Unset, Any]): + avg_score (Union[Unset, Any]): + diff_stats (Union[Unset, UserDiffStats]): + first_upload (Union[Unset, datetime.datetime]): + last_upload (Union[Unset, datetime.datetime]): + ranked_maps (Union[Unset, int]): + total_downvotes (Union[Unset, int]): + total_maps (Union[Unset, int]): + total_upvotes (Union[Unset, int]): + """ + + avg_bpm: Union[Unset, Any] = UNSET + avg_duration: Union[Unset, Any] = UNSET + avg_score: Union[Unset, Any] = UNSET + diff_stats: Union[Unset, "UserDiffStats"] = UNSET + first_upload: Union[Unset, datetime.datetime] = UNSET + last_upload: Union[Unset, datetime.datetime] = UNSET + ranked_maps: Union[Unset, int] = UNSET + total_downvotes: Union[Unset, int] = UNSET + total_maps: Union[Unset, int] = UNSET + total_upvotes: Union[Unset, int] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + avg_bpm = self.avg_bpm + + avg_duration = self.avg_duration + + avg_score = self.avg_score + + diff_stats: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.diff_stats, Unset): + diff_stats = self.diff_stats.to_dict() + + first_upload: Union[Unset, str] = UNSET + if not isinstance(self.first_upload, Unset): + first_upload = self.first_upload.isoformat() + + last_upload: Union[Unset, str] = UNSET + if not isinstance(self.last_upload, Unset): + last_upload = self.last_upload.isoformat() + + ranked_maps = self.ranked_maps + + total_downvotes = self.total_downvotes + + total_maps = self.total_maps + + total_upvotes = self.total_upvotes + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if avg_bpm is not UNSET: + field_dict["avgBpm"] = avg_bpm + if avg_duration is not UNSET: + field_dict["avgDuration"] = avg_duration + if avg_score is not UNSET: + field_dict["avgScore"] = avg_score + if diff_stats is not UNSET: + field_dict["diffStats"] = diff_stats + if first_upload is not UNSET: + field_dict["firstUpload"] = first_upload + if last_upload is not UNSET: + field_dict["lastUpload"] = last_upload + if ranked_maps is not UNSET: + field_dict["rankedMaps"] = ranked_maps + if total_downvotes is not UNSET: + field_dict["totalDownvotes"] = total_downvotes + if total_maps is not UNSET: + field_dict["totalMaps"] = total_maps + if total_upvotes is not UNSET: + field_dict["totalUpvotes"] = total_upvotes + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.user_diff_stats import UserDiffStats + + d = src_dict.copy() + avg_bpm = d.pop("avgBpm", UNSET) + + avg_duration = d.pop("avgDuration", UNSET) + + avg_score = d.pop("avgScore", UNSET) + + _diff_stats = d.pop("diffStats", UNSET) + diff_stats: Union[Unset, UserDiffStats] + if isinstance(_diff_stats, Unset): + diff_stats = UNSET + else: + diff_stats = UserDiffStats.from_dict(_diff_stats) + + _first_upload = d.pop("firstUpload", UNSET) + first_upload: Union[Unset, datetime.datetime] + if isinstance(_first_upload, Unset): + first_upload = UNSET + else: + first_upload = isoparse(_first_upload) + + _last_upload = d.pop("lastUpload", UNSET) + last_upload: Union[Unset, datetime.datetime] + if isinstance(_last_upload, Unset): + last_upload = UNSET + else: + last_upload = isoparse(_last_upload) + + ranked_maps = d.pop("rankedMaps", UNSET) + + total_downvotes = d.pop("totalDownvotes", UNSET) + + total_maps = d.pop("totalMaps", UNSET) + + total_upvotes = d.pop("totalUpvotes", UNSET) + + user_stats = cls( + avg_bpm=avg_bpm, + avg_duration=avg_duration, + avg_score=avg_score, + diff_stats=diff_stats, + first_upload=first_upload, + last_upload=last_upload, + ranked_maps=ranked_maps, + total_downvotes=total_downvotes, + total_maps=total_maps, + total_upvotes=total_upvotes, + ) + + user_stats.additional_properties = d + return user_stats + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/vote_request.py b/src/clients/beatsaver/models/vote_request.py new file mode 100644 index 0000000..98b2c65 --- /dev/null +++ b/src/clients/beatsaver/models/vote_request.py @@ -0,0 +1,89 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.auth_request import AuthRequest + + +T = TypeVar("T", bound="VoteRequest") + + +@_attrs_define +class VoteRequest: + """ + Attributes: + auth (Union[Unset, AuthRequest]): + direction (Union[Unset, bool]): + hash_ (Union[Unset, str]): + """ + + auth: Union[Unset, "AuthRequest"] = UNSET + direction: Union[Unset, bool] = UNSET + hash_: Union[Unset, str] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + auth: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.auth, Unset): + auth = self.auth.to_dict() + + direction = self.direction + + hash_ = self.hash_ + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if auth is not UNSET: + field_dict["auth"] = auth + if direction is not UNSET: + field_dict["direction"] = direction + if hash_ is not UNSET: + field_dict["hash"] = hash_ + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.auth_request import AuthRequest + + d = src_dict.copy() + _auth = d.pop("auth", UNSET) + auth: Union[Unset, AuthRequest] + if isinstance(_auth, Unset): + auth = UNSET + else: + auth = AuthRequest.from_dict(_auth) + + direction = d.pop("direction", UNSET) + + hash_ = d.pop("hash", UNSET) + + vote_request = cls( + auth=auth, + direction=direction, + hash_=hash_, + ) + + vote_request.additional_properties = d + return vote_request + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/models/vote_summary.py b/src/clients/beatsaver/models/vote_summary.py new file mode 100644 index 0000000..afd5ef9 --- /dev/null +++ b/src/clients/beatsaver/models/vote_summary.py @@ -0,0 +1,103 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="VoteSummary") + + +@_attrs_define +class VoteSummary: + """ + Attributes: + downvotes (Union[Unset, int]): + hash_ (Union[Unset, str]): + key64 (Union[Unset, str]): + map_id (Union[Unset, int]): + score (Union[Unset, float]): + upvotes (Union[Unset, int]): + """ + + downvotes: Union[Unset, int] = UNSET + hash_: Union[Unset, str] = UNSET + key64: Union[Unset, str] = UNSET + map_id: Union[Unset, int] = UNSET + score: Union[Unset, float] = UNSET + upvotes: Union[Unset, int] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + downvotes = self.downvotes + + hash_ = self.hash_ + + key64 = self.key64 + + map_id = self.map_id + + score = self.score + + upvotes = self.upvotes + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if downvotes is not UNSET: + field_dict["downvotes"] = downvotes + if hash_ is not UNSET: + field_dict["hash"] = hash_ + if key64 is not UNSET: + field_dict["key64"] = key64 + if map_id is not UNSET: + field_dict["mapId"] = map_id + if score is not UNSET: + field_dict["score"] = score + if upvotes is not UNSET: + field_dict["upvotes"] = upvotes + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + downvotes = d.pop("downvotes", UNSET) + + hash_ = d.pop("hash", UNSET) + + key64 = d.pop("key64", UNSET) + + map_id = d.pop("mapId", UNSET) + + score = d.pop("score", UNSET) + + upvotes = d.pop("upvotes", UNSET) + + vote_summary = cls( + downvotes=downvotes, + hash_=hash_, + key64=key64, + map_id=map_id, + score=score, + upvotes=upvotes, + ) + + vote_summary.additional_properties = d + return vote_summary + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/beatsaver/py.typed b/src/clients/beatsaver/py.typed new file mode 100644 index 0000000..1aad327 --- /dev/null +++ b/src/clients/beatsaver/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/src/clients/beatsaver/types.py b/src/clients/beatsaver/types.py new file mode 100644 index 0000000..21fac10 --- /dev/null +++ b/src/clients/beatsaver/types.py @@ -0,0 +1,45 @@ +"""Contains some shared types for properties""" + +from http import HTTPStatus +from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] + + +@define +class File: + """Contains information for file uploads""" + + payload: BinaryIO + file_name: Optional[str] = None + mime_type: Optional[str] = None + + def to_tuple(self) -> FileJsonType: + """Return a tuple representation that httpx will accept for multipart/form-data""" + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """A response from an endpoint""" + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: Optional[T] + + +__all__ = ["File", "Response", "FileJsonType", "Unset", "UNSET"] diff --git a/src/clients/scoresaber/__init__.py b/src/clients/scoresaber/__init__.py new file mode 100644 index 0000000..28d3067 --- /dev/null +++ b/src/clients/scoresaber/__init__.py @@ -0,0 +1,8 @@ +"""A client library for accessing ScoreSaber Public API""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/src/clients/scoresaber/api/__init__.py b/src/clients/scoresaber/api/__init__.py new file mode 100644 index 0000000..81f9fa2 --- /dev/null +++ b/src/clients/scoresaber/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/src/clients/scoresaber/api/leaderboards/__init__.py b/src/clients/scoresaber/api/leaderboards/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_hash_hash_info.py b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_hash_hash_info.py new file mode 100644 index 0000000..f4a2af0 --- /dev/null +++ b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_hash_hash_info.py @@ -0,0 +1,192 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_info import LeaderboardInfo +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + hash_: str, + *, + difficulty: int, + game_mode: Union[Unset, str] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["difficulty"] = difficulty + + params["gameMode"] = game_mode + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/leaderboard/by-hash/{hash_}/info", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, LeaderboardInfo]]: + if response.status_code == HTTPStatus.OK: + response_200 = LeaderboardInfo.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, LeaderboardInfo]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + game_mode: Union[Unset, str] = UNSET, +) -> Response[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by map hash + + Args: + hash_ (str): + difficulty (int): + game_mode (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfo]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + difficulty=difficulty, + game_mode=game_mode, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + game_mode: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by map hash + + Args: + hash_ (str): + difficulty (int): + game_mode (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfo] + """ + + return sync_detailed( + hash_=hash_, + client=client, + difficulty=difficulty, + game_mode=game_mode, + ).parsed + + +async def asyncio_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + game_mode: Union[Unset, str] = UNSET, +) -> Response[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by map hash + + Args: + hash_ (str): + difficulty (int): + game_mode (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfo]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + difficulty=difficulty, + game_mode=game_mode, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + game_mode: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by map hash + + Args: + hash_ (str): + difficulty (int): + game_mode (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfo] + """ + + return ( + await asyncio_detailed( + hash_=hash_, + client=client, + difficulty=difficulty, + game_mode=game_mode, + ) + ).parsed diff --git a/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_hash_hash_scores.py b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_hash_hash_scores.py new file mode 100644 index 0000000..8c7059f --- /dev/null +++ b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_hash_hash_scores.py @@ -0,0 +1,260 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.score_collection import ScoreCollection +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + hash_: str, + *, + difficulty: int, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + game_mode: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["difficulty"] = difficulty + + params["countries"] = countries + + params["search"] = search + + params["page"] = page + + params["gameMode"] = game_mode + + params["withMetadata"] = with_metadata + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/leaderboard/by-hash/{hash_}/scores", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["ScoreCollection"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = ScoreCollection.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = cast(Any, None) + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["ScoreCollection"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + game_mode: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, List["ScoreCollection"]]]: + """Gets leaderboard scores by map hash + + Args: + hash_ (str): + difficulty (int): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + game_mode (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['ScoreCollection']]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + difficulty=difficulty, + countries=countries, + search=search, + page=page, + game_mode=game_mode, + with_metadata=with_metadata, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + game_mode: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, List["ScoreCollection"]]]: + """Gets leaderboard scores by map hash + + Args: + hash_ (str): + difficulty (int): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + game_mode (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['ScoreCollection']] + """ + + return sync_detailed( + hash_=hash_, + client=client, + difficulty=difficulty, + countries=countries, + search=search, + page=page, + game_mode=game_mode, + with_metadata=with_metadata, + ).parsed + + +async def asyncio_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + game_mode: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, List["ScoreCollection"]]]: + """Gets leaderboard scores by map hash + + Args: + hash_ (str): + difficulty (int): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + game_mode (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['ScoreCollection']]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + difficulty=difficulty, + countries=countries, + search=search, + page=page, + game_mode=game_mode, + with_metadata=with_metadata, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], + difficulty: int, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + game_mode: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, List["ScoreCollection"]]]: + """Gets leaderboard scores by map hash + + Args: + hash_ (str): + difficulty (int): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + game_mode (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['ScoreCollection']] + """ + + return ( + await asyncio_detailed( + hash_=hash_, + client=client, + difficulty=difficulty, + countries=countries, + search=search, + page=page, + game_mode=game_mode, + with_metadata=with_metadata, + ) + ).parsed diff --git a/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_id_leaderboard_id_info.py b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_id_leaderboard_id_info.py new file mode 100644 index 0000000..17eac1c --- /dev/null +++ b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_id_leaderboard_id_info.py @@ -0,0 +1,156 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_info import LeaderboardInfo +from ...types import Response + + +def _get_kwargs( + leaderboard_id: float, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/leaderboard/by-id/{leaderboard_id}/info", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, LeaderboardInfo]]: + if response.status_code == HTTPStatus.OK: + response_200 = LeaderboardInfo.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, LeaderboardInfo]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfo]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfo] + """ + + return sync_detailed( + leaderboard_id=leaderboard_id, + client=client, + ).parsed + + +async def asyncio_detailed( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfo]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, LeaderboardInfo]]: + """Gets leaderboard information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfo] + """ + + return ( + await asyncio_detailed( + leaderboard_id=leaderboard_id, + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_id_leaderboard_id_scores.py b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_id_leaderboard_id_scores.py new file mode 100644 index 0000000..4c93a4c --- /dev/null +++ b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_by_id_leaderboard_id_scores.py @@ -0,0 +1,225 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.score_collection import ScoreCollection +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + leaderboard_id: float, + *, + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["countries"] = countries + + params["search"] = search + + params["page"] = page + + params["withMetadata"] = with_metadata + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/leaderboard/by-id/{leaderboard_id}/scores", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, ScoreCollection]]: + if response.status_code == HTTPStatus.OK: + response_200 = ScoreCollection.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = cast(Any, None) + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, ScoreCollection]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, ScoreCollection]]: + """Gets leaderboard scores by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ScoreCollection]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + countries=countries, + search=search, + page=page, + with_metadata=with_metadata, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, ScoreCollection]]: + """Gets leaderboard scores by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ScoreCollection] + """ + + return sync_detailed( + leaderboard_id=leaderboard_id, + client=client, + countries=countries, + search=search, + page=page, + with_metadata=with_metadata, + ).parsed + + +async def asyncio_detailed( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, ScoreCollection]]: + """Gets leaderboard scores by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, ScoreCollection]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + countries=countries, + search=search, + page=page, + with_metadata=with_metadata, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], + countries: Union[Unset, str] = UNSET, + search: Union[Unset, str] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, ScoreCollection]]: + """Gets leaderboard scores by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + countries (Union[Unset, str]): + search (Union[Unset, str]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, ScoreCollection] + """ + + return ( + await asyncio_detailed( + leaderboard_id=leaderboard_id, + client=client, + countries=countries, + search=search, + page=page, + with_metadata=with_metadata, + ) + ).parsed diff --git a/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_get_difficulties_hash.py b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_get_difficulties_hash.py new file mode 100644 index 0000000..0eda2c0 --- /dev/null +++ b/src/clients/scoresaber/api/leaderboards/get_api_leaderboard_get_difficulties_hash.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.difficulty import Difficulty +from ...types import Response + + +def _get_kwargs( + hash_: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/leaderboard/get-difficulties/{hash_}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["Difficulty"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = Difficulty.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["Difficulty"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, List["Difficulty"]]]: + """Gets a leaderboards difficulties by hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['Difficulty']]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, List["Difficulty"]]]: + """Gets a leaderboards difficulties by hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['Difficulty']] + """ + + return sync_detailed( + hash_=hash_, + client=client, + ).parsed + + +async def asyncio_detailed( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, List["Difficulty"]]]: + """Gets a leaderboards difficulties by hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['Difficulty']]] + """ + + kwargs = _get_kwargs( + hash_=hash_, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + hash_: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, List["Difficulty"]]]: + """Gets a leaderboards difficulties by hash + + Args: + hash_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['Difficulty']] + """ + + return ( + await asyncio_detailed( + hash_=hash_, + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/leaderboards/get_api_leaderboards.py b/src/clients/scoresaber/api/leaderboards/get_api_leaderboards.py new file mode 100644 index 0000000..763c301 --- /dev/null +++ b/src/clients/scoresaber/api/leaderboards/get_api_leaderboards.py @@ -0,0 +1,332 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.leaderboard_info_collection import LeaderboardInfoCollection +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + search: Union[Unset, str] = UNSET, + verified: Union[Unset, bool] = UNSET, + ranked: Union[Unset, bool] = UNSET, + qualified: Union[Unset, bool] = UNSET, + loved: Union[Unset, bool] = UNSET, + min_star: Union[Unset, float] = UNSET, + max_star: Union[Unset, float] = UNSET, + category: Union[Unset, float] = UNSET, + sort: Union[Unset, float] = UNSET, + unique: Union[Unset, bool] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["search"] = search + + params["verified"] = verified + + params["ranked"] = ranked + + params["qualified"] = qualified + + params["loved"] = loved + + params["minStar"] = min_star + + params["maxStar"] = max_star + + params["category"] = category + + params["sort"] = sort + + params["unique"] = unique + + params["page"] = page + + params["withMetadata"] = with_metadata + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/leaderboards", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, LeaderboardInfoCollection]]: + if response.status_code == HTTPStatus.OK: + response_200 = LeaderboardInfoCollection.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = cast(Any, None) + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, LeaderboardInfoCollection]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + verified: Union[Unset, bool] = UNSET, + ranked: Union[Unset, bool] = UNSET, + qualified: Union[Unset, bool] = UNSET, + loved: Union[Unset, bool] = UNSET, + min_star: Union[Unset, float] = UNSET, + max_star: Union[Unset, float] = UNSET, + category: Union[Unset, float] = UNSET, + sort: Union[Unset, float] = UNSET, + unique: Union[Unset, bool] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, LeaderboardInfoCollection]]: + """Get a list of leaderboards based on filters + + Args: + search (Union[Unset, str]): + verified (Union[Unset, bool]): + ranked (Union[Unset, bool]): + qualified (Union[Unset, bool]): + loved (Union[Unset, bool]): + min_star (Union[Unset, float]): + max_star (Union[Unset, float]): + category (Union[Unset, float]): + sort (Union[Unset, float]): + unique (Union[Unset, bool]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfoCollection]] + """ + + kwargs = _get_kwargs( + search=search, + verified=verified, + ranked=ranked, + qualified=qualified, + loved=loved, + min_star=min_star, + max_star=max_star, + category=category, + sort=sort, + unique=unique, + page=page, + with_metadata=with_metadata, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + verified: Union[Unset, bool] = UNSET, + ranked: Union[Unset, bool] = UNSET, + qualified: Union[Unset, bool] = UNSET, + loved: Union[Unset, bool] = UNSET, + min_star: Union[Unset, float] = UNSET, + max_star: Union[Unset, float] = UNSET, + category: Union[Unset, float] = UNSET, + sort: Union[Unset, float] = UNSET, + unique: Union[Unset, bool] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, LeaderboardInfoCollection]]: + """Get a list of leaderboards based on filters + + Args: + search (Union[Unset, str]): + verified (Union[Unset, bool]): + ranked (Union[Unset, bool]): + qualified (Union[Unset, bool]): + loved (Union[Unset, bool]): + min_star (Union[Unset, float]): + max_star (Union[Unset, float]): + category (Union[Unset, float]): + sort (Union[Unset, float]): + unique (Union[Unset, bool]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfoCollection] + """ + + return sync_detailed( + client=client, + search=search, + verified=verified, + ranked=ranked, + qualified=qualified, + loved=loved, + min_star=min_star, + max_star=max_star, + category=category, + sort=sort, + unique=unique, + page=page, + with_metadata=with_metadata, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + verified: Union[Unset, bool] = UNSET, + ranked: Union[Unset, bool] = UNSET, + qualified: Union[Unset, bool] = UNSET, + loved: Union[Unset, bool] = UNSET, + min_star: Union[Unset, float] = UNSET, + max_star: Union[Unset, float] = UNSET, + category: Union[Unset, float] = UNSET, + sort: Union[Unset, float] = UNSET, + unique: Union[Unset, bool] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, LeaderboardInfoCollection]]: + """Get a list of leaderboards based on filters + + Args: + search (Union[Unset, str]): + verified (Union[Unset, bool]): + ranked (Union[Unset, bool]): + qualified (Union[Unset, bool]): + loved (Union[Unset, bool]): + min_star (Union[Unset, float]): + max_star (Union[Unset, float]): + category (Union[Unset, float]): + sort (Union[Unset, float]): + unique (Union[Unset, bool]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, LeaderboardInfoCollection]] + """ + + kwargs = _get_kwargs( + search=search, + verified=verified, + ranked=ranked, + qualified=qualified, + loved=loved, + min_star=min_star, + max_star=max_star, + category=category, + sort=sort, + unique=unique, + page=page, + with_metadata=with_metadata, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + verified: Union[Unset, bool] = UNSET, + ranked: Union[Unset, bool] = UNSET, + qualified: Union[Unset, bool] = UNSET, + loved: Union[Unset, bool] = UNSET, + min_star: Union[Unset, float] = UNSET, + max_star: Union[Unset, float] = UNSET, + category: Union[Unset, float] = UNSET, + sort: Union[Unset, float] = UNSET, + unique: Union[Unset, bool] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, LeaderboardInfoCollection]]: + """Get a list of leaderboards based on filters + + Args: + search (Union[Unset, str]): + verified (Union[Unset, bool]): + ranked (Union[Unset, bool]): + qualified (Union[Unset, bool]): + loved (Union[Unset, bool]): + min_star (Union[Unset, float]): + max_star (Union[Unset, float]): + category (Union[Unset, float]): + sort (Union[Unset, float]): + unique (Union[Unset, bool]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, LeaderboardInfoCollection] + """ + + return ( + await asyncio_detailed( + client=client, + search=search, + verified=verified, + ranked=ranked, + qualified=qualified, + loved=loved, + min_star=min_star, + max_star=max_star, + category=category, + sort=sort, + unique=unique, + page=page, + with_metadata=with_metadata, + ) + ).parsed diff --git a/src/clients/scoresaber/api/nomination_assessment_team/__init__.py b/src/clients/scoresaber/api/nomination_assessment_team/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_deny.py b/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_deny.py new file mode 100644 index 0000000..646fb98 --- /dev/null +++ b/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_deny.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.nat_deny_body import NatDenyBody +from ...types import Response + + +def _get_kwargs( + *, + body: NatDenyBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/nat/deny", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.FORBIDDEN: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: NatDenyBody, +) -> Response[Any]: + """Denies a rank request + + Args: + body (NatDenyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: NatDenyBody, +) -> Response[Any]: + """Denies a rank request + + Args: + body (NatDenyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_qualify.py b/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_qualify.py new file mode 100644 index 0000000..6738c5d --- /dev/null +++ b/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_qualify.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.nat_qualify_body import NatQualifyBody +from ...types import Response + + +def _get_kwargs( + *, + body: NatQualifyBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/nat/qualify", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.FORBIDDEN: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: NatQualifyBody, +) -> Response[Any]: + """Qualifies a rank request + + Args: + body (NatQualifyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: NatQualifyBody, +) -> Response[Any]: + """Qualifies a rank request + + Args: + body (NatQualifyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_replace.py b/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_replace.py new file mode 100644 index 0000000..30c2ef6 --- /dev/null +++ b/src/clients/scoresaber/api/nomination_assessment_team/post_api_ranking_request_action_nat_replace.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.nat_replace_body import NatReplaceBody +from ...types import Response + + +def _get_kwargs( + *, + body: NatReplaceBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/nat/replace", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.FORBIDDEN: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: NatReplaceBody, +) -> Response[Any]: + """Replaces a rank requests leaderboardId + + Args: + body (NatReplaceBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: NatReplaceBody, +) -> Response[Any]: + """Replaces a rank requests leaderboardId + + Args: + body (NatReplaceBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/players/__init__.py b/src/clients/scoresaber/api/players/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/players/get_api_player_player_id_basic.py b/src/clients/scoresaber/api/players/get_api_player_player_id_basic.py new file mode 100644 index 0000000..7370b0e --- /dev/null +++ b/src/clients/scoresaber/api/players/get_api_player_player_id_basic.py @@ -0,0 +1,156 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.player import Player +from ...types import Response + + +def _get_kwargs( + player_id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/player/{player_id}/basic", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, Player]]: + if response.status_code == HTTPStatus.OK: + response_200 = Player.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, Player]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, Player]]: + """Gets a players basic information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, Player]] + """ + + kwargs = _get_kwargs( + player_id=player_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, Player]]: + """Gets a players basic information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, Player] + """ + + return sync_detailed( + player_id=player_id, + client=client, + ).parsed + + +async def asyncio_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, Player]]: + """Gets a players basic information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, Player]] + """ + + kwargs = _get_kwargs( + player_id=player_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, Player]]: + """Gets a players basic information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, Player] + """ + + return ( + await asyncio_detailed( + player_id=player_id, + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/players/get_api_player_player_id_full.py b/src/clients/scoresaber/api/players/get_api_player_player_id_full.py new file mode 100644 index 0000000..e6cba15 --- /dev/null +++ b/src/clients/scoresaber/api/players/get_api_player_player_id_full.py @@ -0,0 +1,156 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.player import Player +from ...types import Response + + +def _get_kwargs( + player_id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/player/{player_id}/full", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, Player]]: + if response.status_code == HTTPStatus.OK: + response_200 = Player.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, Player]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, Player]]: + """Gets all the players information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, Player]] + """ + + kwargs = _get_kwargs( + player_id=player_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, Player]]: + """Gets all the players information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, Player] + """ + + return sync_detailed( + player_id=player_id, + client=client, + ).parsed + + +async def asyncio_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, Player]]: + """Gets all the players information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, Player]] + """ + + kwargs = _get_kwargs( + player_id=player_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, Player]]: + """Gets all the players information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, Player] + """ + + return ( + await asyncio_detailed( + player_id=player_id, + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/players/get_api_player_player_id_scores.py b/src/clients/scoresaber/api/players/get_api_player_player_id_scores.py new file mode 100644 index 0000000..2e2e75d --- /dev/null +++ b/src/clients/scoresaber/api/players/get_api_player_player_id_scores.py @@ -0,0 +1,227 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_api_player_player_id_scores_sort import GetApiPlayerPlayerIdScoresSort +from ...models.player_score_collection import PlayerScoreCollection +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + player_id: str, + *, + limit: Union[Unset, int] = UNSET, + sort: Union[Unset, GetApiPlayerPlayerIdScoresSort] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["limit"] = limit + + json_sort: Union[Unset, str] = UNSET + if not isinstance(sort, Unset): + json_sort = sort.value + + params["sort"] = json_sort + + params["page"] = page + + params["withMetadata"] = with_metadata + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/player/{player_id}/scores", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, PlayerScoreCollection]]: + if response.status_code == HTTPStatus.OK: + response_200 = PlayerScoreCollection.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, PlayerScoreCollection]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], + limit: Union[Unset, int] = UNSET, + sort: Union[Unset, GetApiPlayerPlayerIdScoresSort] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, PlayerScoreCollection]]: + """Gets scores by playerId + + Args: + player_id (str): + limit (Union[Unset, int]): + sort (Union[Unset, GetApiPlayerPlayerIdScoresSort]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerScoreCollection]] + """ + + kwargs = _get_kwargs( + player_id=player_id, + limit=limit, + sort=sort, + page=page, + with_metadata=with_metadata, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], + limit: Union[Unset, int] = UNSET, + sort: Union[Unset, GetApiPlayerPlayerIdScoresSort] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, PlayerScoreCollection]]: + """Gets scores by playerId + + Args: + player_id (str): + limit (Union[Unset, int]): + sort (Union[Unset, GetApiPlayerPlayerIdScoresSort]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerScoreCollection] + """ + + return sync_detailed( + player_id=player_id, + client=client, + limit=limit, + sort=sort, + page=page, + with_metadata=with_metadata, + ).parsed + + +async def asyncio_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], + limit: Union[Unset, int] = UNSET, + sort: Union[Unset, GetApiPlayerPlayerIdScoresSort] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, PlayerScoreCollection]]: + """Gets scores by playerId + + Args: + player_id (str): + limit (Union[Unset, int]): + sort (Union[Unset, GetApiPlayerPlayerIdScoresSort]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, PlayerScoreCollection]] + """ + + kwargs = _get_kwargs( + player_id=player_id, + limit=limit, + sort=sort, + page=page, + with_metadata=with_metadata, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], + limit: Union[Unset, int] = UNSET, + sort: Union[Unset, GetApiPlayerPlayerIdScoresSort] = UNSET, + page: Union[Unset, int] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, PlayerScoreCollection]]: + """Gets scores by playerId + + Args: + player_id (str): + limit (Union[Unset, int]): + sort (Union[Unset, GetApiPlayerPlayerIdScoresSort]): + page (Union[Unset, int]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, PlayerScoreCollection] + """ + + return ( + await asyncio_detailed( + player_id=player_id, + client=client, + limit=limit, + sort=sort, + page=page, + with_metadata=with_metadata, + ) + ).parsed diff --git a/src/clients/scoresaber/api/players/get_api_players.py b/src/clients/scoresaber/api/players/get_api_players.py new file mode 100644 index 0000000..df9ee86 --- /dev/null +++ b/src/clients/scoresaber/api/players/get_api_players.py @@ -0,0 +1,217 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.player_collection import PlayerCollection +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + search: Union[Unset, str] = UNSET, + page: Union[Unset, float] = UNSET, + countries: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["search"] = search + + params["page"] = page + + params["countries"] = countries + + params["withMetadata"] = with_metadata + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/players", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, List["PlayerCollection"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = PlayerCollection.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = cast(Any, None) + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, List["PlayerCollection"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + page: Union[Unset, float] = UNSET, + countries: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, List["PlayerCollection"]]]: + """Get a list of players based on filters + + Args: + search (Union[Unset, str]): + page (Union[Unset, float]): + countries (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['PlayerCollection']]] + """ + + kwargs = _get_kwargs( + search=search, + page=page, + countries=countries, + with_metadata=with_metadata, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + page: Union[Unset, float] = UNSET, + countries: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, List["PlayerCollection"]]]: + """Get a list of players based on filters + + Args: + search (Union[Unset, str]): + page (Union[Unset, float]): + countries (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['PlayerCollection']] + """ + + return sync_detailed( + client=client, + search=search, + page=page, + countries=countries, + with_metadata=with_metadata, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + page: Union[Unset, float] = UNSET, + countries: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Response[Union[Any, List["PlayerCollection"]]]: + """Get a list of players based on filters + + Args: + search (Union[Unset, str]): + page (Union[Unset, float]): + countries (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, List['PlayerCollection']]] + """ + + kwargs = _get_kwargs( + search=search, + page=page, + countries=countries, + with_metadata=with_metadata, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + page: Union[Unset, float] = UNSET, + countries: Union[Unset, str] = UNSET, + with_metadata: Union[Unset, bool] = UNSET, +) -> Optional[Union[Any, List["PlayerCollection"]]]: + """Get a list of players based on filters + + Args: + search (Union[Unset, str]): + page (Union[Unset, float]): + countries (Union[Unset, str]): + with_metadata (Union[Unset, bool]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, List['PlayerCollection']] + """ + + return ( + await asyncio_detailed( + client=client, + search=search, + page=page, + countries=countries, + with_metadata=with_metadata, + ) + ).parsed diff --git a/src/clients/scoresaber/api/players/get_api_players_count.py b/src/clients/scoresaber/api/players/get_api_players_count.py new file mode 100644 index 0000000..d78dfe6 --- /dev/null +++ b/src/clients/scoresaber/api/players/get_api_players_count.py @@ -0,0 +1,180 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + search: Union[Unset, str] = UNSET, + countries: Union[Unset, str] = UNSET, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + params["search"] = search + + params["countries"] = countries + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/players/count", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, float]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(float, response.text) + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = cast(Any, None) + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, float]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + countries: Union[Unset, str] = UNSET, +) -> Response[Union[Any, float]]: + """Get a list of active players based on filters + + Args: + search (Union[Unset, str]): + countries (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, float]] + """ + + kwargs = _get_kwargs( + search=search, + countries=countries, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + countries: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, float]]: + """Get a list of active players based on filters + + Args: + search (Union[Unset, str]): + countries (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, float] + """ + + return sync_detailed( + client=client, + search=search, + countries=countries, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + countries: Union[Unset, str] = UNSET, +) -> Response[Union[Any, float]]: + """Get a list of active players based on filters + + Args: + search (Union[Unset, str]): + countries (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, float]] + """ + + kwargs = _get_kwargs( + search=search, + countries=countries, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + search: Union[Unset, str] = UNSET, + countries: Union[Unset, str] = UNSET, +) -> Optional[Union[Any, float]]: + """Get a list of active players based on filters + + Args: + search (Union[Unset, str]): + countries (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, float] + """ + + return ( + await asyncio_detailed( + client=client, + search=search, + countries=countries, + ) + ).parsed diff --git a/src/clients/scoresaber/api/public_ranking/__init__.py b/src/clients/scoresaber/api/public_ranking/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/public_ranking/get_api_ranking_request_by_id_leaderboard_id.py b/src/clients/scoresaber/api/public_ranking/get_api_ranking_request_by_id_leaderboard_id.py new file mode 100644 index 0000000..3d49e65 --- /dev/null +++ b/src/clients/scoresaber/api/public_ranking/get_api_ranking_request_by_id_leaderboard_id.py @@ -0,0 +1,156 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.rank_request_information import RankRequestInformation +from ...types import Response + + +def _get_kwargs( + leaderboard_id: float, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/ranking/request/by-id/{leaderboard_id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, RankRequestInformation]]: + if response.status_code == HTTPStatus.OK: + response_200 = RankRequestInformation.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, RankRequestInformation]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, RankRequestInformation]]: + """Gets rank request information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, RankRequestInformation]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, RankRequestInformation]]: + """Gets rank request information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, RankRequestInformation] + """ + + return sync_detailed( + leaderboard_id=leaderboard_id, + client=client, + ).parsed + + +async def asyncio_detailed( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, RankRequestInformation]]: + """Gets rank request information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, RankRequestInformation]] + """ + + kwargs = _get_kwargs( + leaderboard_id=leaderboard_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + leaderboard_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, RankRequestInformation]]: + """Gets rank request information by ScoreSaber leaderboardId + + Args: + leaderboard_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, RankRequestInformation] + """ + + return ( + await asyncio_detailed( + leaderboard_id=leaderboard_id, + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/public_ranking/get_api_ranking_request_request_id.py b/src/clients/scoresaber/api/public_ranking/get_api_ranking_request_request_id.py new file mode 100644 index 0000000..49967bb --- /dev/null +++ b/src/clients/scoresaber/api/public_ranking/get_api_ranking_request_request_id.py @@ -0,0 +1,156 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.rank_request_information import RankRequestInformation +from ...types import Response + + +def _get_kwargs( + request_id: float, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/ranking/request/{request_id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, RankRequestInformation]]: + if response.status_code == HTTPStatus.OK: + response_200 = RankRequestInformation.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.NOT_FOUND: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, RankRequestInformation]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + request_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, RankRequestInformation]]: + """Gets rank request information by requestId + + Args: + request_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, RankRequestInformation]] + """ + + kwargs = _get_kwargs( + request_id=request_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + request_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, RankRequestInformation]]: + """Gets rank request information by requestId + + Args: + request_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, RankRequestInformation] + """ + + return sync_detailed( + request_id=request_id, + client=client, + ).parsed + + +async def asyncio_detailed( + request_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, RankRequestInformation]]: + """Gets rank request information by requestId + + Args: + request_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, RankRequestInformation]] + """ + + kwargs = _get_kwargs( + request_id=request_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + request_id: float, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, RankRequestInformation]]: + """Gets rank request information by requestId + + Args: + request_id (float): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, RankRequestInformation] + """ + + return ( + await asyncio_detailed( + request_id=request_id, + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/public_ranking/get_api_ranking_requests_below_top.py b/src/clients/scoresaber/api/public_ranking/get_api_ranking_requests_below_top.py new file mode 100644 index 0000000..fe7ebc5 --- /dev/null +++ b/src/clients/scoresaber/api/public_ranking/get_api_ranking_requests_below_top.py @@ -0,0 +1,131 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.rank_request_listing import RankRequestListing +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/ranking/requests/belowTop", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[List["RankRequestListing"]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = RankRequestListing.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[List["RankRequestListing"]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[List["RankRequestListing"]]: + """Gets the rest of the ranking requests - ⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List['RankRequestListing']] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[List["RankRequestListing"]]: + """Gets the rest of the ranking requests - ⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + List['RankRequestListing'] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[List["RankRequestListing"]]: + """Gets the rest of the ranking requests - ⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List['RankRequestListing']] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[List["RankRequestListing"]]: + """Gets the rest of the ranking requests - ⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + List['RankRequestListing'] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/public_ranking/get_api_ranking_requests_top.py b/src/clients/scoresaber/api/public_ranking/get_api_ranking_requests_top.py new file mode 100644 index 0000000..34f7f2b --- /dev/null +++ b/src/clients/scoresaber/api/public_ranking/get_api_ranking_requests_top.py @@ -0,0 +1,131 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.rank_request_listing import RankRequestListing +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/ranking/requests/top", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[List["RankRequestListing"]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = RankRequestListing.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[List["RankRequestListing"]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[List["RankRequestListing"]]: + """Gets the top 6 rank requests -⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List['RankRequestListing']] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[List["RankRequestListing"]]: + """Gets the top 6 rank requests -⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + List['RankRequestListing'] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[List["RankRequestListing"]]: + """Gets the top 6 rank requests -⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[List['RankRequestListing']] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[List["RankRequestListing"]]: + """Gets the top 6 rank requests -⚠️deprecation notice + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + List['RankRequestListing'] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/quality_assurance_team/__init__.py b/src/clients/scoresaber/api/quality_assurance_team/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/quality_assurance_team/post_api_ranking_request_action_qat_comment.py b/src/clients/scoresaber/api/quality_assurance_team/post_api_ranking_request_action_qat_comment.py new file mode 100644 index 0000000..389f29d --- /dev/null +++ b/src/clients/scoresaber/api/quality_assurance_team/post_api_ranking_request_action_qat_comment.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.qat_comment_body import QatCommentBody +from ...types import Response + + +def _get_kwargs( + *, + body: QatCommentBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/qat/comment", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.FORBIDDEN: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: QatCommentBody, +) -> Response[Any]: + """Comments on a given rank request + + Args: + body (QatCommentBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: QatCommentBody, +) -> Response[Any]: + """Comments on a given rank request + + Args: + body (QatCommentBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/quality_assurance_team/post_api_ranking_request_action_qat_vote.py b/src/clients/scoresaber/api/quality_assurance_team/post_api_ranking_request_action_qat_vote.py new file mode 100644 index 0000000..933dc58 --- /dev/null +++ b/src/clients/scoresaber/api/quality_assurance_team/post_api_ranking_request_action_qat_vote.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.qat_vote_body import QatVoteBody +from ...types import Response + + +def _get_kwargs( + *, + body: QatVoteBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/qat/vote", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.FORBIDDEN: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: QatVoteBody, +) -> Response[Any]: + """Votes on a given rank request + + Args: + body (QatVoteBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: QatVoteBody, +) -> Response[Any]: + """Votes on a given rank request + + Args: + body (QatVoteBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/ranking_team/__init__.py b/src/clients/scoresaber/api/ranking_team/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_comment.py b/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_comment.py new file mode 100644 index 0000000..08e96d0 --- /dev/null +++ b/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_comment.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.rt_comment_body import RtCommentBody +from ...types import Response + + +def _get_kwargs( + *, + body: RtCommentBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/rt/comment", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.FORBIDDEN: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: RtCommentBody, +) -> Response[Any]: + """Comments on a given rank request + + Args: + body (RtCommentBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: RtCommentBody, +) -> Response[Any]: + """Comments on a given rank request + + Args: + body (RtCommentBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_create.py b/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_create.py new file mode 100644 index 0000000..8ce95d3 --- /dev/null +++ b/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_create.py @@ -0,0 +1,164 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.rt_create_body import RtCreateBody +from ...types import Response + + +def _get_kwargs( + *, + body: RtCreateBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/rt/create", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, float]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(float, response.text) + return response_200 + if response.status_code == HTTPStatus.BAD_REQUEST: + response_400 = cast(Any, None) + return response_400 + if response.status_code == HTTPStatus.FORBIDDEN: + response_403 = cast(Any, None) + return response_403 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, float]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: RtCreateBody, +) -> Response[Union[Any, float]]: + """Creates a rank request + + Args: + body (RtCreateBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, float]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: RtCreateBody, +) -> Optional[Union[Any, float]]: + """Creates a rank request + + Args: + body (RtCreateBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, float] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: RtCreateBody, +) -> Response[Union[Any, float]]: + """Creates a rank request + + Args: + body (RtCreateBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, float]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: RtCreateBody, +) -> Optional[Union[Any, float]]: + """Creates a rank request + + Args: + body (RtCreateBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, float] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_vote.py b/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_vote.py new file mode 100644 index 0000000..18f5b51 --- /dev/null +++ b/src/clients/scoresaber/api/ranking_team/post_api_ranking_request_action_rt_vote.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.rt_vote_body import RtVoteBody +from ...types import Response + + +def _get_kwargs( + *, + body: RtVoteBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/ranking/request/action/rt/vote", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if response.status_code == HTTPStatus.FORBIDDEN: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: RtVoteBody, +) -> Response[Any]: + """Votes on a given rank request + + Args: + body (RtVoteBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: RtVoteBody, +) -> Response[Any]: + """Votes on a given rank request + + Args: + body (RtVoteBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/website_auth/__init__.py b/src/clients/scoresaber/api/website_auth/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/website_auth/get_api_auth_get_token.py b/src/clients/scoresaber/api/website_auth/get_api_auth_get_token.py new file mode 100644 index 0000000..12cfe5b --- /dev/null +++ b/src/clients/scoresaber/api/website_auth/get_api_auth_get_token.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.i_get_token_response import IGetTokenResponse +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/auth/getToken", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, IGetTokenResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = IGetTokenResponse.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = cast(Any, None) + return response_401 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, IGetTokenResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, IGetTokenResponse]]: + """Gets logged in users auth token + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, IGetTokenResponse]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, IGetTokenResponse]]: + """Gets logged in users auth token + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, IGetTokenResponse] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, IGetTokenResponse]]: + """Gets logged in users auth token + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, IGetTokenResponse]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, IGetTokenResponse]]: + """Gets logged in users auth token + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, IGetTokenResponse] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/website_auth/get_api_auth_logout.py b/src/clients/scoresaber/api/website_auth/get_api_auth_logout.py new file mode 100644 index 0000000..134d923 --- /dev/null +++ b/src/clients/scoresaber/api/website_auth/get_api_auth_logout.py @@ -0,0 +1,79 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/auth/logout", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Logs out a logged in user + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Logs out a logged in user + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/website_auth/post_api_auth_check_token.py b/src/clients/scoresaber/api/website_auth/post_api_auth_check_token.py new file mode 100644 index 0000000..69dc7bf --- /dev/null +++ b/src/clients/scoresaber/api/website_auth/post_api_auth_check_token.py @@ -0,0 +1,105 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.check_token_body import CheckTokenBody +from ...types import Response + + +def _get_kwargs( + *, + body: CheckTokenBody, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/api/auth/checkToken", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.UNAUTHORIZED: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: CheckTokenBody, +) -> Response[Any]: + """Checks users auth token + + Args: + body (CheckTokenBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: CheckTokenBody, +) -> Response[Any]: + """Checks users auth token + + Args: + body (CheckTokenBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/website_user/__init__.py b/src/clients/scoresaber/api/website_user/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/clients/scoresaber/api/website_user/get_api_user_me.py b/src/clients/scoresaber/api/website_user/get_api_user_me.py new file mode 100644 index 0000000..ce5eeb1 --- /dev/null +++ b/src/clients/scoresaber/api/website_user/get_api_user_me.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.user_data import UserData +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/user/@me", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, UserData]]: + if response.status_code == HTTPStatus.OK: + response_200 = UserData.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = cast(Any, None) + return response_401 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, UserData]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserData]]: + """Get logged in user information + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserData]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserData]]: + """Get logged in user information + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserData] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, UserData]]: + """Get logged in user information + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, UserData]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, UserData]]: + """Get logged in user information + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, UserData] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/api/website_user/get_api_user_player_id_refresh.py b/src/clients/scoresaber/api/website_user/get_api_user_player_id_refresh.py new file mode 100644 index 0000000..7fb8a00 --- /dev/null +++ b/src/clients/scoresaber/api/website_user/get_api_user_player_id_refresh.py @@ -0,0 +1,95 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + player_id: str, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/api/user/{player_id}/refresh", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == HTTPStatus.OK: + return None + if response.status_code == HTTPStatus.BAD_REQUEST: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Get logged in user information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + player_id=player_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + player_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Get logged in user information + + Args: + player_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + player_id=player_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/clients/scoresaber/api/website_user/get_api_user_quest_key.py b/src/clients/scoresaber/api/website_user/get_api_user_quest_key.py new file mode 100644 index 0000000..b895e31 --- /dev/null +++ b/src/clients/scoresaber/api/website_user/get_api_user_quest_key.py @@ -0,0 +1,127 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": "/api/user/quest-key", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, str]]: + if response.status_code == HTTPStatus.OK: + response_200 = response.text + return response_200 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = cast(Any, None) + return response_401 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, str]]: + """Generates a new quest key if one doesn't exist + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, str]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, str]]: + """Generates a new quest key if one doesn't exist + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, str] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, str]]: + """Generates a new quest key if one doesn't exist + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, str]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, str]]: + """Generates a new quest key if one doesn't exist + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, str] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/clients/scoresaber/client.py b/src/clients/scoresaber/client.py new file mode 100644 index 0000000..63a2493 --- /dev/null +++ b/src/clients/scoresaber/client.py @@ -0,0 +1,268 @@ +import ssl +from typing import Any, Dict, Optional, Union + +import httpx +from attrs import define, evolve, field + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + def with_headers(self, headers: Dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: Dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/src/clients/scoresaber/errors.py b/src/clients/scoresaber/errors.py new file mode 100644 index 0000000..5f92e76 --- /dev/null +++ b/src/clients/scoresaber/errors.py @@ -0,0 +1,16 @@ +"""Contains shared errors types that can be raised from API functions""" + + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + + +__all__ = ["UnexpectedStatus"] diff --git a/src/clients/scoresaber/models/__init__.py b/src/clients/scoresaber/models/__init__.py new file mode 100644 index 0000000..5c3f1ef --- /dev/null +++ b/src/clients/scoresaber/models/__init__.py @@ -0,0 +1,69 @@ +"""Contains all the data models used in inputs/outputs""" + +from .badge import Badge +from .check_token_body import CheckTokenBody +from .comment import Comment +from .difficulty import Difficulty +from .get_api_player_player_id_scores_sort import GetApiPlayerPlayerIdScoresSort +from .i_get_token_response import IGetTokenResponse +from .leaderboard_info import LeaderboardInfo +from .leaderboard_info_collection import LeaderboardInfoCollection +from .leaderboard_player import LeaderboardPlayer +from .metadata import Metadata +from .nat_deny_body import NatDenyBody +from .nat_qualify_body import NatQualifyBody +from .nat_replace_body import NatReplaceBody +from .player import Player +from .player_badges_type_1 import PlayerBadgesType1 +from .player_collection import PlayerCollection +from .player_score import PlayerScore +from .player_score_collection import PlayerScoreCollection +from .qat_comment_body import QatCommentBody +from .qat_vote_body import QatVoteBody +from .rank_request_information import RankRequestInformation +from .rank_request_listing import RankRequestListing +from .ranking_difficulty import RankingDifficulty +from .rt_comment_body import RtCommentBody +from .rt_create_body import RtCreateBody +from .rt_vote_body import RtVoteBody +from .score import Score +from .score_collection import ScoreCollection +from .score_saber_error import ScoreSaberError +from .score_stats import ScoreStats +from .user_data import UserData +from .vote_group import VoteGroup + +__all__ = ( + "Badge", + "CheckTokenBody", + "Comment", + "Difficulty", + "GetApiPlayerPlayerIdScoresSort", + "IGetTokenResponse", + "LeaderboardInfo", + "LeaderboardInfoCollection", + "LeaderboardPlayer", + "Metadata", + "NatDenyBody", + "NatQualifyBody", + "NatReplaceBody", + "Player", + "PlayerBadgesType1", + "PlayerCollection", + "PlayerScore", + "PlayerScoreCollection", + "QatCommentBody", + "QatVoteBody", + "RankingDifficulty", + "RankRequestInformation", + "RankRequestListing", + "RtCommentBody", + "RtCreateBody", + "RtVoteBody", + "Score", + "ScoreCollection", + "ScoreSaberError", + "ScoreStats", + "UserData", + "VoteGroup", +) diff --git a/src/clients/scoresaber/models/badge.py b/src/clients/scoresaber/models/badge.py new file mode 100644 index 0000000..b196027 --- /dev/null +++ b/src/clients/scoresaber/models/badge.py @@ -0,0 +1,46 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="Badge") + + +@_attrs_define +class Badge: + """ + Attributes: + description (str): + image (str): + """ + + description: str + image: str + + def to_dict(self) -> Dict[str, Any]: + description = self.description + + image = self.image + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "description": description, + "image": image, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + description = d.pop("description") + + image = d.pop("image") + + badge = cls( + description=description, + image=image, + ) + + return badge diff --git a/src/clients/scoresaber/models/check_token_body.py b/src/clients/scoresaber/models/check_token_body.py new file mode 100644 index 0000000..6fd245b --- /dev/null +++ b/src/clients/scoresaber/models/check_token_body.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="CheckTokenBody") + + +@_attrs_define +class CheckTokenBody: + """ + Attributes: + token (str): + """ + + token: str + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + token = self.token + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "token": token, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + token = d.pop("token") + + check_token_body = cls( + token=token, + ) + + check_token_body.additional_properties = d + return check_token_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/comment.py b/src/clients/scoresaber/models/comment.py new file mode 100644 index 0000000..359ae7f --- /dev/null +++ b/src/clients/scoresaber/models/comment.py @@ -0,0 +1,62 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="Comment") + + +@_attrs_define +class Comment: + """ + Attributes: + username (str): + user_id (str): + comment (str): + time_stamp (str): + """ + + username: str + user_id: str + comment: str + time_stamp: str + + def to_dict(self) -> Dict[str, Any]: + username = self.username + + user_id = self.user_id + + comment = self.comment + + time_stamp = self.time_stamp + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "username": username, + "userId": user_id, + "comment": comment, + "timeStamp": time_stamp, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + username = d.pop("username") + + user_id = d.pop("userId") + + comment = d.pop("comment") + + time_stamp = d.pop("timeStamp") + + comment = cls( + username=username, + user_id=user_id, + comment=comment, + time_stamp=time_stamp, + ) + + return comment diff --git a/src/clients/scoresaber/models/difficulty.py b/src/clients/scoresaber/models/difficulty.py new file mode 100644 index 0000000..b705a6f --- /dev/null +++ b/src/clients/scoresaber/models/difficulty.py @@ -0,0 +1,62 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="Difficulty") + + +@_attrs_define +class Difficulty: + """ + Attributes: + leaderboard_id (float): + difficulty (float): + game_mode (str): + difficulty_raw (str): + """ + + leaderboard_id: float + difficulty: float + game_mode: str + difficulty_raw: str + + def to_dict(self) -> Dict[str, Any]: + leaderboard_id = self.leaderboard_id + + difficulty = self.difficulty + + game_mode = self.game_mode + + difficulty_raw = self.difficulty_raw + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "leaderboardId": leaderboard_id, + "difficulty": difficulty, + "gameMode": game_mode, + "difficultyRaw": difficulty_raw, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + leaderboard_id = d.pop("leaderboardId") + + difficulty = d.pop("difficulty") + + game_mode = d.pop("gameMode") + + difficulty_raw = d.pop("difficultyRaw") + + difficulty = cls( + leaderboard_id=leaderboard_id, + difficulty=difficulty, + game_mode=game_mode, + difficulty_raw=difficulty_raw, + ) + + return difficulty diff --git a/src/clients/scoresaber/models/get_api_player_player_id_scores_sort.py b/src/clients/scoresaber/models/get_api_player_player_id_scores_sort.py new file mode 100644 index 0000000..c6e5159 --- /dev/null +++ b/src/clients/scoresaber/models/get_api_player_player_id_scores_sort.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class GetApiPlayerPlayerIdScoresSort(str, Enum): + RECENT = "recent" + TOP = "top" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/clients/scoresaber/models/i_get_token_response.py b/src/clients/scoresaber/models/i_get_token_response.py new file mode 100644 index 0000000..9b5ac62 --- /dev/null +++ b/src/clients/scoresaber/models/i_get_token_response.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="IGetTokenResponse") + + +@_attrs_define +class IGetTokenResponse: + """ + Attributes: + token (str): + """ + + token: str + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + token = self.token + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "token": token, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + token = d.pop("token") + + i_get_token_response = cls( + token=token, + ) + + i_get_token_response.additional_properties = d + return i_get_token_response + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/leaderboard_info.py b/src/clients/scoresaber/models/leaderboard_info.py new file mode 100644 index 0000000..e8cd323 --- /dev/null +++ b/src/clients/scoresaber/models/leaderboard_info.py @@ -0,0 +1,324 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.difficulty import Difficulty + from ..models.score import Score + + +T = TypeVar("T", bound="LeaderboardInfo") + + +@_attrs_define +class LeaderboardInfo: + """ + Attributes: + id (float): + song_hash (str): + song_name (str): + song_sub_name (str): + song_author_name (str): + level_author_name (str): + difficulty (Difficulty): + max_score (float): + created_date (datetime.datetime): + ranked_date (Union[None, datetime.datetime]): + qualified_date (Union[None, datetime.datetime]): + loved_date (Union[None, datetime.datetime]): + ranked (bool): + qualified (bool): + loved (bool): + max_pp (float): + stars (float): + positive_modifiers (bool): + plays (float): + daily_plays (float): + cover_image (str): + player_score (Union['Score', None]): + difficulties (List['Difficulty']): + """ + + id: float + song_hash: str + song_name: str + song_sub_name: str + song_author_name: str + level_author_name: str + difficulty: "Difficulty" + max_score: float + created_date: datetime.datetime + ranked_date: Union[None, datetime.datetime] + qualified_date: Union[None, datetime.datetime] + loved_date: Union[None, datetime.datetime] + ranked: bool + qualified: bool + loved: bool + max_pp: float + stars: float + positive_modifiers: bool + plays: float + daily_plays: float + cover_image: str + player_score: Union["Score", None] + difficulties: List["Difficulty"] + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + from ..models.score import Score + + id = self.id + + song_hash = self.song_hash + + song_name = self.song_name + + song_sub_name = self.song_sub_name + + song_author_name = self.song_author_name + + level_author_name = self.level_author_name + + difficulty = self.difficulty.to_dict() + + max_score = self.max_score + + created_date = self.created_date.isoformat() + + ranked_date: Union[None, str] + if isinstance(self.ranked_date, datetime.datetime): + ranked_date = self.ranked_date.isoformat() + else: + ranked_date = self.ranked_date + + qualified_date: Union[None, str] + if isinstance(self.qualified_date, datetime.datetime): + qualified_date = self.qualified_date.isoformat() + else: + qualified_date = self.qualified_date + + loved_date: Union[None, str] + if isinstance(self.loved_date, datetime.datetime): + loved_date = self.loved_date.isoformat() + else: + loved_date = self.loved_date + + ranked = self.ranked + + qualified = self.qualified + + loved = self.loved + + max_pp = self.max_pp + + stars = self.stars + + positive_modifiers = self.positive_modifiers + + plays = self.plays + + daily_plays = self.daily_plays + + cover_image = self.cover_image + + player_score: Union[Dict[str, Any], None] + if isinstance(self.player_score, Score): + player_score = self.player_score.to_dict() + else: + player_score = self.player_score + + difficulties = [] + for difficulties_item_data in self.difficulties: + difficulties_item = difficulties_item_data.to_dict() + difficulties.append(difficulties_item) + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "songHash": song_hash, + "songName": song_name, + "songSubName": song_sub_name, + "songAuthorName": song_author_name, + "levelAuthorName": level_author_name, + "difficulty": difficulty, + "maxScore": max_score, + "createdDate": created_date, + "rankedDate": ranked_date, + "qualifiedDate": qualified_date, + "lovedDate": loved_date, + "ranked": ranked, + "qualified": qualified, + "loved": loved, + "maxPP": max_pp, + "stars": stars, + "positiveModifiers": positive_modifiers, + "plays": plays, + "dailyPlays": daily_plays, + "coverImage": cover_image, + "playerScore": player_score, + "difficulties": difficulties, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.difficulty import Difficulty + from ..models.score import Score + + d = src_dict.copy() + id = d.pop("id") + + song_hash = d.pop("songHash") + + song_name = d.pop("songName") + + song_sub_name = d.pop("songSubName") + + song_author_name = d.pop("songAuthorName") + + level_author_name = d.pop("levelAuthorName") + + difficulty = Difficulty.from_dict(d.pop("difficulty")) + + max_score = d.pop("maxScore") + + created_date = isoparse(d.pop("createdDate")) + + def _parse_ranked_date(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + ranked_date_type_0 = isoparse(data) + + return ranked_date_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + ranked_date = _parse_ranked_date(d.pop("rankedDate")) + + def _parse_qualified_date(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + qualified_date_type_0 = isoparse(data) + + return qualified_date_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + qualified_date = _parse_qualified_date(d.pop("qualifiedDate")) + + def _parse_loved_date(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + loved_date_type_0 = isoparse(data) + + return loved_date_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + loved_date = _parse_loved_date(d.pop("lovedDate")) + + ranked = d.pop("ranked") + + qualified = d.pop("qualified") + + loved = d.pop("loved") + + max_pp = d.pop("maxPP") + + stars = d.pop("stars") + + positive_modifiers = d.pop("positiveModifiers") + + plays = d.pop("plays") + + daily_plays = d.pop("dailyPlays") + + cover_image = d.pop("coverImage") + + def _parse_player_score(data: object) -> Union["Score", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + player_score_type_1 = Score.from_dict(data) + + return player_score_type_1 + except: # noqa: E722 + pass + return cast(Union["Score", None], data) + + player_score = _parse_player_score(d.pop("playerScore")) + + _difficulties = d.pop("difficulties", None) + difficulties = [] + if _difficulties is not None: + for difficulties_item_data in _difficulties: + difficulties_item = Difficulty.from_dict(difficulties_item_data) + difficulties.append(difficulties_item) + else: + difficulties = [] + + leaderboard_info = cls( + id=id, + song_hash=song_hash, + song_name=song_name, + song_sub_name=song_sub_name, + song_author_name=song_author_name, + level_author_name=level_author_name, + difficulty=difficulty, + max_score=max_score, + created_date=created_date, + ranked_date=ranked_date, + qualified_date=qualified_date, + loved_date=loved_date, + ranked=ranked, + qualified=qualified, + loved=loved, + max_pp=max_pp, + stars=stars, + positive_modifiers=positive_modifiers, + plays=plays, + daily_plays=daily_plays, + cover_image=cover_image, + player_score=player_score, + difficulties=difficulties, + ) + + leaderboard_info.additional_properties = d + return leaderboard_info + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/leaderboard_info_collection.py b/src/clients/scoresaber/models/leaderboard_info_collection.py new file mode 100644 index 0000000..b2fb604 --- /dev/null +++ b/src/clients/scoresaber/models/leaderboard_info_collection.py @@ -0,0 +1,62 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.leaderboard_info import LeaderboardInfo + from ..models.metadata import Metadata + + +T = TypeVar("T", bound="LeaderboardInfoCollection") + + +@_attrs_define +class LeaderboardInfoCollection: + """ + Attributes: + leaderboards (List['LeaderboardInfo']): + metadata (Metadata): + """ + + leaderboards: List["LeaderboardInfo"] + metadata: "Metadata" + + def to_dict(self) -> Dict[str, Any]: + leaderboards = [] + for leaderboards_item_data in self.leaderboards: + leaderboards_item = leaderboards_item_data.to_dict() + leaderboards.append(leaderboards_item) + + metadata = self.metadata.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "leaderboards": leaderboards, + "metadata": metadata, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.leaderboard_info import LeaderboardInfo + from ..models.metadata import Metadata + + d = src_dict.copy() + leaderboards = [] + _leaderboards = d.pop("leaderboards") + for leaderboards_item_data in _leaderboards: + leaderboards_item = LeaderboardInfo.from_dict(leaderboards_item_data) + + leaderboards.append(leaderboards_item) + + metadata = Metadata.from_dict(d.pop("metadata")) + + leaderboard_info_collection = cls( + leaderboards=leaderboards, + metadata=metadata, + ) + + return leaderboard_info_collection diff --git a/src/clients/scoresaber/models/leaderboard_player.py b/src/clients/scoresaber/models/leaderboard_player.py new file mode 100644 index 0000000..dae3ab0 --- /dev/null +++ b/src/clients/scoresaber/models/leaderboard_player.py @@ -0,0 +1,78 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="LeaderboardPlayer") + + +@_attrs_define +class LeaderboardPlayer: + """ + Attributes: + id (str): + name (str): + profile_picture (str): + country (str): + permissions (float): + role (str): + """ + + id: str + name: str + profile_picture: str + country: str + permissions: float + role: str + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + name = self.name + + profile_picture = self.profile_picture + + country = self.country + + permissions = self.permissions + + role = self.role + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "id": id, + "name": name, + "profilePicture": profile_picture, + "country": country, + "permissions": permissions, + "role": role, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + id = d.pop("id") + + name = d.pop("name") + + profile_picture = d.pop("profilePicture") + + country = d.pop("country") + + permissions = d.pop("permissions") + + role = d.pop("role") + + leaderboard_player = cls( + id=id, + name=name, + profile_picture=profile_picture, + country=country, + permissions=permissions, + role=role, + ) + + return leaderboard_player diff --git a/src/clients/scoresaber/models/metadata.py b/src/clients/scoresaber/models/metadata.py new file mode 100644 index 0000000..3eac24e --- /dev/null +++ b/src/clients/scoresaber/models/metadata.py @@ -0,0 +1,54 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="Metadata") + + +@_attrs_define +class Metadata: + """ + Attributes: + total (float): + page (float): + items_per_page (float): + """ + + total: float + page: float + items_per_page: float + + def to_dict(self) -> Dict[str, Any]: + total = self.total + + page = self.page + + items_per_page = self.items_per_page + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "total": total, + "page": page, + "itemsPerPage": items_per_page, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + total = d.pop("total") + + page = d.pop("page") + + items_per_page = d.pop("itemsPerPage") + + metadata = cls( + total=total, + page=page, + items_per_page=items_per_page, + ) + + return metadata diff --git a/src/clients/scoresaber/models/nat_deny_body.py b/src/clients/scoresaber/models/nat_deny_body.py new file mode 100644 index 0000000..e86bfb5 --- /dev/null +++ b/src/clients/scoresaber/models/nat_deny_body.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="NatDenyBody") + + +@_attrs_define +class NatDenyBody: + """ + Attributes: + request_id (float): + """ + + request_id: float + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + nat_deny_body = cls( + request_id=request_id, + ) + + nat_deny_body.additional_properties = d + return nat_deny_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/nat_qualify_body.py b/src/clients/scoresaber/models/nat_qualify_body.py new file mode 100644 index 0000000..5542f8f --- /dev/null +++ b/src/clients/scoresaber/models/nat_qualify_body.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="NatQualifyBody") + + +@_attrs_define +class NatQualifyBody: + """ + Attributes: + request_id (float): + """ + + request_id: float + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + nat_qualify_body = cls( + request_id=request_id, + ) + + nat_qualify_body.additional_properties = d + return nat_qualify_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/nat_replace_body.py b/src/clients/scoresaber/models/nat_replace_body.py new file mode 100644 index 0000000..dc2ce02 --- /dev/null +++ b/src/clients/scoresaber/models/nat_replace_body.py @@ -0,0 +1,74 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="NatReplaceBody") + + +@_attrs_define +class NatReplaceBody: + """ + Attributes: + request_id (float): The requestId affected + leaderboard_id (float): The leaderboardId to replace the current requests leaderboardId + description (str): An updated description + """ + + request_id: float + leaderboard_id: float + description: str + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + leaderboard_id = self.leaderboard_id + + description = self.description + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + "leaderboardId": leaderboard_id, + "description": description, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + leaderboard_id = d.pop("leaderboardId") + + description = d.pop("description") + + nat_replace_body = cls( + request_id=request_id, + leaderboard_id=leaderboard_id, + description=description, + ) + + nat_replace_body.additional_properties = d + return nat_replace_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/player.py b/src/clients/scoresaber/models/player.py new file mode 100644 index 0000000..a7a8657 --- /dev/null +++ b/src/clients/scoresaber/models/player.py @@ -0,0 +1,228 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.player_badges_type_1 import PlayerBadgesType1 + from ..models.score_stats import ScoreStats + + +T = TypeVar("T", bound="Player") + + +@_attrs_define +class Player: + """ + Attributes: + id (str): + name (str): + profile_picture (str): + bio (Union[None, str]): + country (str): + pp (float): + rank (float): + country_rank (float): + role (str): + badges (Union['PlayerBadgesType1', None]): + histories (str): + score_stats (Union['ScoreStats', None]): + permissions (float): + banned (bool): + inactive (bool): + first_seen (Union[None, datetime.datetime]): + """ + + id: str + name: str + profile_picture: str + bio: Union[None, str] + country: str + pp: float + rank: float + country_rank: float + role: str + badges: Union["PlayerBadgesType1", None] + histories: str + score_stats: Union["ScoreStats", None] + permissions: float + banned: bool + inactive: bool + first_seen: Union[None, datetime.datetime] + + def to_dict(self) -> Dict[str, Any]: + from ..models.player_badges_type_1 import PlayerBadgesType1 + from ..models.score_stats import ScoreStats + + id = self.id + + name = self.name + + profile_picture = self.profile_picture + + bio: Union[None, str] + bio = self.bio + + country = self.country + + pp = self.pp + + rank = self.rank + + country_rank = self.country_rank + + role = self.role + + badges: Union[Dict[str, Any], None] + if isinstance(self.badges, PlayerBadgesType1): + badges = self.badges.to_dict() + else: + badges = self.badges + + histories = self.histories + + score_stats: Union[Dict[str, Any], None] + if isinstance(self.score_stats, ScoreStats): + score_stats = self.score_stats.to_dict() + else: + score_stats = self.score_stats + + permissions = self.permissions + + banned = self.banned + + inactive = self.inactive + + first_seen: Union[None, str] + if isinstance(self.first_seen, datetime.datetime): + first_seen = self.first_seen.isoformat() + else: + first_seen = self.first_seen + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "id": id, + "name": name, + "profilePicture": profile_picture, + "bio": bio, + "country": country, + "pp": pp, + "rank": rank, + "countryRank": country_rank, + "role": role, + "badges": badges, + "histories": histories, + "scoreStats": score_stats, + "permissions": permissions, + "banned": banned, + "inactive": inactive, + "firstSeen": first_seen, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.player_badges_type_1 import PlayerBadgesType1 + from ..models.score_stats import ScoreStats + + d = src_dict.copy() + id = d.pop("id") + + name = d.pop("name") + + profile_picture = d.pop("profilePicture") + + def _parse_bio(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + bio = _parse_bio(d.pop("bio")) + + country = d.pop("country") + + pp = d.pop("pp") + + rank = d.pop("rank") + + country_rank = d.pop("countryRank") + + role = d.pop("role") + + def _parse_badges(data: object) -> Union["PlayerBadgesType1", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + badges_type_1 = PlayerBadgesType1.from_dict(data) + + return badges_type_1 + except: # noqa: E722 + pass + return cast(Union["PlayerBadgesType1", None], data) + + badges = _parse_badges(d.pop("badges")) + + histories = d.pop("histories") + + def _parse_score_stats(data: object) -> Union["ScoreStats", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + score_stats_type_1 = ScoreStats.from_dict(data) + + return score_stats_type_1 + except: # noqa: E722 + pass + return cast(Union["ScoreStats", None], data) + + score_stats = _parse_score_stats(d.pop("scoreStats")) + + permissions = d.pop("permissions") + + banned = d.pop("banned") + + inactive = d.pop("inactive") + + def _parse_first_seen(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + first_seen_type_0 = isoparse(data) + + return first_seen_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + first_seen = _parse_first_seen(d.pop("firstSeen")) + + player = cls( + id=id, + name=name, + profile_picture=profile_picture, + bio=bio, + country=country, + pp=pp, + rank=rank, + country_rank=country_rank, + role=role, + badges=badges, + histories=histories, + score_stats=score_stats, + permissions=permissions, + banned=banned, + inactive=inactive, + first_seen=first_seen, + ) + + return player diff --git a/src/clients/scoresaber/models/player_badges_type_1.py b/src/clients/scoresaber/models/player_badges_type_1.py new file mode 100644 index 0000000..6e0fa3e --- /dev/null +++ b/src/clients/scoresaber/models/player_badges_type_1.py @@ -0,0 +1,43 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="PlayerBadgesType1") + + +@_attrs_define +class PlayerBadgesType1: + """ """ + + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + player_badges_type_1 = cls() + + player_badges_type_1.additional_properties = d + return player_badges_type_1 + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/player_collection.py b/src/clients/scoresaber/models/player_collection.py new file mode 100644 index 0000000..b0e110b --- /dev/null +++ b/src/clients/scoresaber/models/player_collection.py @@ -0,0 +1,62 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.metadata import Metadata + from ..models.player import Player + + +T = TypeVar("T", bound="PlayerCollection") + + +@_attrs_define +class PlayerCollection: + """ + Attributes: + players (List['Player']): + metadata (Metadata): + """ + + players: List["Player"] + metadata: "Metadata" + + def to_dict(self) -> Dict[str, Any]: + players = [] + for players_item_data in self.players: + players_item = players_item_data.to_dict() + players.append(players_item) + + metadata = self.metadata.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "players": players, + "metadata": metadata, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.metadata import Metadata + from ..models.player import Player + + d = src_dict.copy() + players = [] + _players = d.pop("players") + for players_item_data in _players: + players_item = Player.from_dict(players_item_data) + + players.append(players_item) + + metadata = Metadata.from_dict(d.pop("metadata")) + + player_collection = cls( + players=players, + metadata=metadata, + ) + + return player_collection diff --git a/src/clients/scoresaber/models/player_score.py b/src/clients/scoresaber/models/player_score.py new file mode 100644 index 0000000..173852d --- /dev/null +++ b/src/clients/scoresaber/models/player_score.py @@ -0,0 +1,54 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.leaderboard_info import LeaderboardInfo + from ..models.score import Score + + +T = TypeVar("T", bound="PlayerScore") + + +@_attrs_define +class PlayerScore: + """ + Attributes: + score (Score): + leaderboard (LeaderboardInfo): + """ + + score: "Score" + leaderboard: "LeaderboardInfo" + + def to_dict(self) -> Dict[str, Any]: + score = self.score.to_dict() + + leaderboard = self.leaderboard.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "score": score, + "leaderboard": leaderboard, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.leaderboard_info import LeaderboardInfo + from ..models.score import Score + + d = src_dict.copy() + score = Score.from_dict(d.pop("score")) + + leaderboard = LeaderboardInfo.from_dict(d.pop("leaderboard")) + + player_score = cls( + score=score, + leaderboard=leaderboard, + ) + + return player_score diff --git a/src/clients/scoresaber/models/player_score_collection.py b/src/clients/scoresaber/models/player_score_collection.py new file mode 100644 index 0000000..ce93524 --- /dev/null +++ b/src/clients/scoresaber/models/player_score_collection.py @@ -0,0 +1,62 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.metadata import Metadata + from ..models.player_score import PlayerScore + + +T = TypeVar("T", bound="PlayerScoreCollection") + + +@_attrs_define +class PlayerScoreCollection: + """ + Attributes: + player_scores (List['PlayerScore']): + metadata (Metadata): + """ + + player_scores: List["PlayerScore"] + metadata: "Metadata" + + def to_dict(self) -> Dict[str, Any]: + player_scores = [] + for player_scores_item_data in self.player_scores: + player_scores_item = player_scores_item_data.to_dict() + player_scores.append(player_scores_item) + + metadata = self.metadata.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "playerScores": player_scores, + "metadata": metadata, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.metadata import Metadata + from ..models.player_score import PlayerScore + + d = src_dict.copy() + player_scores = [] + _player_scores = d.pop("playerScores") + for player_scores_item_data in _player_scores: + player_scores_item = PlayerScore.from_dict(player_scores_item_data) + + player_scores.append(player_scores_item) + + metadata = Metadata.from_dict(d.pop("metadata")) + + player_score_collection = cls( + player_scores=player_scores, + metadata=metadata, + ) + + return player_score_collection diff --git a/src/clients/scoresaber/models/qat_comment_body.py b/src/clients/scoresaber/models/qat_comment_body.py new file mode 100644 index 0000000..5949dc0 --- /dev/null +++ b/src/clients/scoresaber/models/qat_comment_body.py @@ -0,0 +1,69 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="QatCommentBody") + + +@_attrs_define +class QatCommentBody: + """ + Attributes: + request_id (str): + comment (Union[Unset, str]): + """ + + request_id: str + comment: Union[Unset, str] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + comment = self.comment + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + } + ) + if comment is not UNSET: + field_dict["comment"] = comment + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + comment = d.pop("comment", UNSET) + + qat_comment_body = cls( + request_id=request_id, + comment=comment, + ) + + qat_comment_body.additional_properties = d + return qat_comment_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/qat_vote_body.py b/src/clients/scoresaber/models/qat_vote_body.py new file mode 100644 index 0000000..016cfd0 --- /dev/null +++ b/src/clients/scoresaber/models/qat_vote_body.py @@ -0,0 +1,66 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="QatVoteBody") + + +@_attrs_define +class QatVoteBody: + """ + Attributes: + request_id (str): + vote (int): (0 = down, 1 up, 2 = neutral) + """ + + request_id: str + vote: int + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + vote = self.vote + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + "vote": vote, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + vote = d.pop("vote") + + qat_vote_body = cls( + request_id=request_id, + vote=vote, + ) + + qat_vote_body.additional_properties = d + return qat_vote_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/rank_request_information.py b/src/clients/scoresaber/models/rank_request_information.py new file mode 100644 index 0000000..ab7ebcf --- /dev/null +++ b/src/clients/scoresaber/models/rank_request_information.py @@ -0,0 +1,154 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.comment import Comment + from ..models.leaderboard_info import LeaderboardInfo + from ..models.ranking_difficulty import RankingDifficulty + from ..models.vote_group import VoteGroup + + +T = TypeVar("T", bound="RankRequestInformation") + + +@_attrs_define +class RankRequestInformation: + """ + Attributes: + request_id (float): + request_description (str): + leaderboard_info (LeaderboardInfo): + created_at (str): + rank_votes (VoteGroup): + qat_votes (VoteGroup): + rank_comments (List['Comment']): + qat_comments (List['Comment']): + request_type (float): + approved (float): + difficulties (List['RankingDifficulty']): + """ + + request_id: float + request_description: str + leaderboard_info: "LeaderboardInfo" + created_at: str + rank_votes: "VoteGroup" + qat_votes: "VoteGroup" + rank_comments: List["Comment"] + qat_comments: List["Comment"] + request_type: float + approved: float + difficulties: List["RankingDifficulty"] + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + request_description = self.request_description + + leaderboard_info = self.leaderboard_info.to_dict() + + created_at = self.created_at + + rank_votes = self.rank_votes.to_dict() + + qat_votes = self.qat_votes.to_dict() + + rank_comments = [] + for rank_comments_item_data in self.rank_comments: + rank_comments_item = rank_comments_item_data.to_dict() + rank_comments.append(rank_comments_item) + + qat_comments = [] + for qat_comments_item_data in self.qat_comments: + qat_comments_item = qat_comments_item_data.to_dict() + qat_comments.append(qat_comments_item) + + request_type = self.request_type + + approved = self.approved + + difficulties = [] + for difficulties_item_data in self.difficulties: + difficulties_item = difficulties_item_data.to_dict() + difficulties.append(difficulties_item) + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "requestId": request_id, + "requestDescription": request_description, + "leaderboardInfo": leaderboard_info, + "created_at": created_at, + "rankVotes": rank_votes, + "qatVotes": qat_votes, + "rankComments": rank_comments, + "qatComments": qat_comments, + "requestType": request_type, + "approved": approved, + "difficulties": difficulties, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.comment import Comment + from ..models.leaderboard_info import LeaderboardInfo + from ..models.ranking_difficulty import RankingDifficulty + from ..models.vote_group import VoteGroup + + d = src_dict.copy() + request_id = d.pop("requestId") + + request_description = d.pop("requestDescription") + + leaderboard_info = LeaderboardInfo.from_dict(d.pop("leaderboardInfo")) + + created_at = d.pop("created_at") + + rank_votes = VoteGroup.from_dict(d.pop("rankVotes")) + + qat_votes = VoteGroup.from_dict(d.pop("qatVotes")) + + rank_comments = [] + _rank_comments = d.pop("rankComments") + for rank_comments_item_data in _rank_comments: + rank_comments_item = Comment.from_dict(rank_comments_item_data) + + rank_comments.append(rank_comments_item) + + qat_comments = [] + _qat_comments = d.pop("qatComments") + for qat_comments_item_data in _qat_comments: + qat_comments_item = Comment.from_dict(qat_comments_item_data) + + qat_comments.append(qat_comments_item) + + request_type = d.pop("requestType") + + approved = d.pop("approved") + + difficulties = [] + _difficulties = d.pop("difficulties") + for difficulties_item_data in _difficulties: + difficulties_item = RankingDifficulty.from_dict(difficulties_item_data) + + difficulties.append(difficulties_item) + + rank_request_information = cls( + request_id=request_id, + request_description=request_description, + leaderboard_info=leaderboard_info, + created_at=created_at, + rank_votes=rank_votes, + qat_votes=qat_votes, + rank_comments=rank_comments, + qat_comments=qat_comments, + request_type=request_type, + approved=approved, + difficulties=difficulties, + ) + + return rank_request_information diff --git a/src/clients/scoresaber/models/rank_request_listing.py b/src/clients/scoresaber/models/rank_request_listing.py new file mode 100644 index 0000000..1a5a271 --- /dev/null +++ b/src/clients/scoresaber/models/rank_request_listing.py @@ -0,0 +1,94 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.leaderboard_info import LeaderboardInfo + from ..models.vote_group import VoteGroup + + +T = TypeVar("T", bound="RankRequestListing") + + +@_attrs_define +class RankRequestListing: + """ + Attributes: + request_id (float): + weight (float): + leaderboard_info (LeaderboardInfo): + created_at (str): + total_rank_votes (VoteGroup): + total_qat_votes (VoteGroup): + difficulty_count (float): + """ + + request_id: float + weight: float + leaderboard_info: "LeaderboardInfo" + created_at: str + total_rank_votes: "VoteGroup" + total_qat_votes: "VoteGroup" + difficulty_count: float + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + weight = self.weight + + leaderboard_info = self.leaderboard_info.to_dict() + + created_at = self.created_at + + total_rank_votes = self.total_rank_votes.to_dict() + + total_qat_votes = self.total_qat_votes.to_dict() + + difficulty_count = self.difficulty_count + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "requestId": request_id, + "weight": weight, + "leaderboardInfo": leaderboard_info, + "created_at": created_at, + "totalRankVotes": total_rank_votes, + "totalQATVotes": total_qat_votes, + "difficultyCount": difficulty_count, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.leaderboard_info import LeaderboardInfo + from ..models.vote_group import VoteGroup + + d = src_dict.copy() + request_id = d.pop("requestId") + + weight = d.pop("weight") + + leaderboard_info = LeaderboardInfo.from_dict(d.pop("leaderboardInfo")) + + created_at = d.pop("created_at") + + total_rank_votes = VoteGroup.from_dict(d.pop("totalRankVotes")) + + total_qat_votes = VoteGroup.from_dict(d.pop("totalQATVotes")) + + difficulty_count = d.pop("difficultyCount") + + rank_request_listing = cls( + request_id=request_id, + weight=weight, + leaderboard_info=leaderboard_info, + created_at=created_at, + total_rank_votes=total_rank_votes, + total_qat_votes=total_qat_votes, + difficulty_count=difficulty_count, + ) + + return rank_request_listing diff --git a/src/clients/scoresaber/models/ranking_difficulty.py b/src/clients/scoresaber/models/ranking_difficulty.py new file mode 100644 index 0000000..d544977 --- /dev/null +++ b/src/clients/scoresaber/models/ranking_difficulty.py @@ -0,0 +1,46 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="RankingDifficulty") + + +@_attrs_define +class RankingDifficulty: + """ + Attributes: + request_id (float): + difficulty (float): + """ + + request_id: float + difficulty: float + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + difficulty = self.difficulty + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "requestId": request_id, + "difficulty": difficulty, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + difficulty = d.pop("difficulty") + + ranking_difficulty = cls( + request_id=request_id, + difficulty=difficulty, + ) + + return ranking_difficulty diff --git a/src/clients/scoresaber/models/rt_comment_body.py b/src/clients/scoresaber/models/rt_comment_body.py new file mode 100644 index 0000000..e318416 --- /dev/null +++ b/src/clients/scoresaber/models/rt_comment_body.py @@ -0,0 +1,69 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="RtCommentBody") + + +@_attrs_define +class RtCommentBody: + """ + Attributes: + request_id (str): + comment (Union[Unset, str]): + """ + + request_id: str + comment: Union[Unset, str] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + comment = self.comment + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + } + ) + if comment is not UNSET: + field_dict["comment"] = comment + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + comment = d.pop("comment", UNSET) + + rt_comment_body = cls( + request_id=request_id, + comment=comment, + ) + + rt_comment_body.additional_properties = d + return rt_comment_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/rt_create_body.py b/src/clients/scoresaber/models/rt_create_body.py new file mode 100644 index 0000000..be57b74 --- /dev/null +++ b/src/clients/scoresaber/models/rt_create_body.py @@ -0,0 +1,74 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RtCreateBody") + + +@_attrs_define +class RtCreateBody: + """ + Attributes: + leaderboard_id (str): + request_type (int): (0 = unrank, 1 rank) + description (str): + """ + + leaderboard_id: str + request_type: int + description: str + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + leaderboard_id = self.leaderboard_id + + request_type = self.request_type + + description = self.description + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "leaderboardId": leaderboard_id, + "requestType": request_type, + "description": description, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + leaderboard_id = d.pop("leaderboardId") + + request_type = d.pop("requestType") + + description = d.pop("description") + + rt_create_body = cls( + leaderboard_id=leaderboard_id, + request_type=request_type, + description=description, + ) + + rt_create_body.additional_properties = d + return rt_create_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/rt_vote_body.py b/src/clients/scoresaber/models/rt_vote_body.py new file mode 100644 index 0000000..5c58245 --- /dev/null +++ b/src/clients/scoresaber/models/rt_vote_body.py @@ -0,0 +1,66 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RtVoteBody") + + +@_attrs_define +class RtVoteBody: + """ + Attributes: + request_id (str): + vote (int): (0 = down, 1 up) + """ + + request_id: str + vote: int + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + vote = self.vote + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + "vote": vote, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + request_id = d.pop("requestId") + + vote = d.pop("vote") + + rt_vote_body = cls( + request_id=request_id, + vote=vote, + ) + + rt_vote_body.additional_properties = d + return rt_vote_body + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/score.py b/src/clients/scoresaber/models/score.py new file mode 100644 index 0000000..877df58 --- /dev/null +++ b/src/clients/scoresaber/models/score.py @@ -0,0 +1,220 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union, cast + +from attrs import define as _attrs_define +from dateutil.parser import isoparse + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.leaderboard_player import LeaderboardPlayer + + +T = TypeVar("T", bound="Score") + + +@_attrs_define +class Score: + """ + Attributes: + id (float): + rank (float): + base_score (float): + modified_score (float): + pp (float): + weight (float): + modifiers (str): + multiplier (float): + bad_cuts (float): + missed_notes (float): + max_combo (float): + full_combo (bool): + hmd (float): + has_replay (bool): + time_set (datetime.datetime): + device_hmd (Union[None, str]): + device_controller_left (Union[None, str]): + device_controller_right (Union[None, str]): + leaderboard_player_info (Union[Unset, LeaderboardPlayer]): + """ + + id: float + rank: float + base_score: float + modified_score: float + pp: float + weight: float + modifiers: str + multiplier: float + bad_cuts: float + missed_notes: float + max_combo: float + full_combo: bool + hmd: float + has_replay: bool + time_set: datetime.datetime + device_hmd: Union[None, str] + device_controller_left: Union[None, str] + device_controller_right: Union[None, str] + leaderboard_player_info: Union[Unset, "LeaderboardPlayer"] = UNSET + + def to_dict(self) -> Dict[str, Any]: + id = self.id + + rank = self.rank + + base_score = self.base_score + + modified_score = self.modified_score + + pp = self.pp + + weight = self.weight + + modifiers = self.modifiers + + multiplier = self.multiplier + + bad_cuts = self.bad_cuts + + missed_notes = self.missed_notes + + max_combo = self.max_combo + + full_combo = self.full_combo + + hmd = self.hmd + + has_replay = self.has_replay + + time_set = self.time_set.isoformat() + + device_hmd: Union[None, str] + device_hmd = self.device_hmd + + device_controller_left: Union[None, str] + device_controller_left = self.device_controller_left + + device_controller_right: Union[None, str] + device_controller_right = self.device_controller_right + + leaderboard_player_info: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.leaderboard_player_info, Unset): + leaderboard_player_info = self.leaderboard_player_info.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "id": id, + "rank": rank, + "baseScore": base_score, + "modifiedScore": modified_score, + "pp": pp, + "weight": weight, + "modifiers": modifiers, + "multiplier": multiplier, + "badCuts": bad_cuts, + "missedNotes": missed_notes, + "maxCombo": max_combo, + "fullCombo": full_combo, + "hmd": hmd, + "hasReplay": has_replay, + "timeSet": time_set, + "deviceHmd": device_hmd, + "deviceControllerLeft": device_controller_left, + "deviceControllerRight": device_controller_right, + } + ) + if leaderboard_player_info is not UNSET: + field_dict["leaderboardPlayerInfo"] = leaderboard_player_info + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.leaderboard_player import LeaderboardPlayer + + d = src_dict.copy() + id = d.pop("id") + + rank = d.pop("rank") + + base_score = d.pop("baseScore") + + modified_score = d.pop("modifiedScore") + + pp = d.pop("pp") + + weight = d.pop("weight") + + modifiers = d.pop("modifiers") + + multiplier = d.pop("multiplier") + + bad_cuts = d.pop("badCuts") + + missed_notes = d.pop("missedNotes") + + max_combo = d.pop("maxCombo") + + full_combo = d.pop("fullCombo") + + hmd = d.pop("hmd") + + has_replay = d.pop("hasReplay") + + time_set = isoparse(d.pop("timeSet")) + + def _parse_device_hmd(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + device_hmd = _parse_device_hmd(d.pop("deviceHmd")) + + def _parse_device_controller_left(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + device_controller_left = _parse_device_controller_left(d.pop("deviceControllerLeft")) + + def _parse_device_controller_right(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + device_controller_right = _parse_device_controller_right(d.pop("deviceControllerRight")) + + _leaderboard_player_info = d.pop("leaderboardPlayerInfo", UNSET) + leaderboard_player_info: Union[Unset, LeaderboardPlayer] + if isinstance(_leaderboard_player_info, Unset): + leaderboard_player_info = UNSET + elif _leaderboard_player_info is None: + leaderboard_player_info = None # Handle None value here + else: + leaderboard_player_info = LeaderboardPlayer.from_dict(_leaderboard_player_info) + + score = cls( + id=id, + rank=rank, + base_score=base_score, + modified_score=modified_score, + pp=pp, + weight=weight, + modifiers=modifiers, + multiplier=multiplier, + bad_cuts=bad_cuts, + missed_notes=missed_notes, + max_combo=max_combo, + full_combo=full_combo, + hmd=hmd, + has_replay=has_replay, + time_set=time_set, + device_hmd=device_hmd, + device_controller_left=device_controller_left, + device_controller_right=device_controller_right, + leaderboard_player_info=leaderboard_player_info, + ) + + return score diff --git a/src/clients/scoresaber/models/score_collection.py b/src/clients/scoresaber/models/score_collection.py new file mode 100644 index 0000000..0f0c6e0 --- /dev/null +++ b/src/clients/scoresaber/models/score_collection.py @@ -0,0 +1,62 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.metadata import Metadata + from ..models.score import Score + + +T = TypeVar("T", bound="ScoreCollection") + + +@_attrs_define +class ScoreCollection: + """ + Attributes: + scores (List['Score']): + metadata (Metadata): + """ + + scores: List["Score"] + metadata: "Metadata" + + def to_dict(self) -> Dict[str, Any]: + scores = [] + for scores_item_data in self.scores: + scores_item = scores_item_data.to_dict() + scores.append(scores_item) + + metadata = self.metadata.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "scores": scores, + "metadata": metadata, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.metadata import Metadata + from ..models.score import Score + + d = src_dict.copy() + scores = [] + _scores = d.pop("scores") + for scores_item_data in _scores: + scores_item = Score.from_dict(scores_item_data) + + scores.append(scores_item) + + metadata = Metadata.from_dict(d.pop("metadata")) + + score_collection = cls( + scores=scores, + metadata=metadata, + ) + + return score_collection diff --git a/src/clients/scoresaber/models/score_saber_error.py b/src/clients/scoresaber/models/score_saber_error.py new file mode 100644 index 0000000..d26ea32 --- /dev/null +++ b/src/clients/scoresaber/models/score_saber_error.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ScoreSaberError") + + +@_attrs_define +class ScoreSaberError: + """ + Attributes: + error_message (str): + """ + + error_message: str + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + error_message = self.error_message + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "errorMessage": error_message, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + error_message = d.pop("errorMessage") + + score_saber_error = cls( + error_message=error_message, + ) + + score_saber_error.additional_properties = d + return score_saber_error + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/clients/scoresaber/models/score_stats.py b/src/clients/scoresaber/models/score_stats.py new file mode 100644 index 0000000..a816b28 --- /dev/null +++ b/src/clients/scoresaber/models/score_stats.py @@ -0,0 +1,78 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="ScoreStats") + + +@_attrs_define +class ScoreStats: + """ + Attributes: + total_score (float): + total_ranked_score (float): + average_ranked_accuracy (float): + total_play_count (float): + ranked_play_count (float): + replays_watched (float): + """ + + total_score: float + total_ranked_score: float + average_ranked_accuracy: float + total_play_count: float + ranked_play_count: float + replays_watched: float + + def to_dict(self) -> Dict[str, Any]: + total_score = self.total_score + + total_ranked_score = self.total_ranked_score + + average_ranked_accuracy = self.average_ranked_accuracy + + total_play_count = self.total_play_count + + ranked_play_count = self.ranked_play_count + + replays_watched = self.replays_watched + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "totalScore": total_score, + "totalRankedScore": total_ranked_score, + "averageRankedAccuracy": average_ranked_accuracy, + "totalPlayCount": total_play_count, + "rankedPlayCount": ranked_play_count, + "replaysWatched": replays_watched, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + total_score = d.pop("totalScore") + + total_ranked_score = d.pop("totalRankedScore") + + average_ranked_accuracy = d.pop("averageRankedAccuracy") + + total_play_count = d.pop("totalPlayCount") + + ranked_play_count = d.pop("rankedPlayCount") + + replays_watched = d.pop("replaysWatched") + + score_stats = cls( + total_score=total_score, + total_ranked_score=total_ranked_score, + average_ranked_accuracy=average_ranked_accuracy, + total_play_count=total_play_count, + ranked_play_count=ranked_play_count, + replays_watched=replays_watched, + ) + + return score_stats diff --git a/src/clients/scoresaber/models/user_data.py b/src/clients/scoresaber/models/user_data.py new file mode 100644 index 0000000..439b0b9 --- /dev/null +++ b/src/clients/scoresaber/models/user_data.py @@ -0,0 +1,54 @@ +from typing import Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="UserData") + + +@_attrs_define +class UserData: + """ + Attributes: + player_id (str): + permissions (float): + quest_key (str): + """ + + player_id: str + permissions: float + quest_key: str + + def to_dict(self) -> Dict[str, Any]: + player_id = self.player_id + + permissions = self.permissions + + quest_key = self.quest_key + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "playerId": player_id, + "permissions": permissions, + "questKey": quest_key, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + player_id = d.pop("playerId") + + permissions = d.pop("permissions") + + quest_key = d.pop("questKey") + + user_data = cls( + player_id=player_id, + permissions=permissions, + quest_key=quest_key, + ) + + return user_data diff --git a/src/clients/scoresaber/models/vote_group.py b/src/clients/scoresaber/models/vote_group.py new file mode 100644 index 0000000..89760b2 --- /dev/null +++ b/src/clients/scoresaber/models/vote_group.py @@ -0,0 +1,65 @@ +from typing import Any, Dict, Type, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="VoteGroup") + + +@_attrs_define +class VoteGroup: + """ + Attributes: + upvotes (float): + downvotes (float): + my_vote (bool): + neutral (Union[Unset, float]): + """ + + upvotes: float + downvotes: float + my_vote: bool + neutral: Union[Unset, float] = UNSET + + def to_dict(self) -> Dict[str, Any]: + upvotes = self.upvotes + + downvotes = self.downvotes + + my_vote = self.my_vote + + neutral = self.neutral + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "upvotes": upvotes, + "downvotes": downvotes, + "myVote": my_vote, + } + ) + if neutral is not UNSET: + field_dict["neutral"] = neutral + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + upvotes = d.pop("upvotes") + + downvotes = d.pop("downvotes") + + my_vote = d.pop("myVote") + + neutral = d.pop("neutral", UNSET) + + vote_group = cls( + upvotes=upvotes, + downvotes=downvotes, + my_vote=my_vote, + neutral=neutral, + ) + + return vote_group diff --git a/src/clients/scoresaber/py.typed b/src/clients/scoresaber/py.typed new file mode 100644 index 0000000..1aad327 --- /dev/null +++ b/src/clients/scoresaber/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/src/clients/scoresaber/types.py b/src/clients/scoresaber/types.py new file mode 100644 index 0000000..21fac10 --- /dev/null +++ b/src/clients/scoresaber/types.py @@ -0,0 +1,45 @@ +"""Contains some shared types for properties""" + +from http import HTTPStatus +from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] + + +@define +class File: + """Contains information for file uploads""" + + payload: BinaryIO + file_name: Optional[str] = None + mime_type: Optional[str] = None + + def to_tuple(self) -> FileJsonType: + """Return a tuple representation that httpx will accept for multipart/form-data""" + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """A response from an endpoint""" + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: Optional[T] + + +__all__ = ["File", "Response", "FileJsonType", "Unset", "UNSET"] diff --git a/src/helpers/PlaylistBuilder.py b/src/helpers/PlaylistBuilder.py new file mode 100644 index 0000000..f544095 --- /dev/null +++ b/src/helpers/PlaylistBuilder.py @@ -0,0 +1,129 @@ +import os +import json +import random +import base64 +from datetime import datetime +import logging +from typing import List, Optional, Dict +from dataclasses import dataclass, field, asdict + +@dataclass +class Difficulty: + name: str + characteristic: str + +@dataclass +class Song: + hash: str + difficulties: List[Difficulty] + key: Optional[str] = field(default=None, repr=False) + levelId: Optional[str] = field(default=None, repr=False) + songName: Optional[str] = field(default=None, repr=False) + + def __post_init__(self): + # Ensure missing fields don't appear in the final output + self.__dict__ = {k: v for k, v in self.__dict__.items() if v is not None} + +@dataclass +class CustomData: + syncURL: Optional[str] = None + owner: Optional[str] = None + id: Optional[str] = None + hash: Optional[str] = None + shared: Optional[bool] = None + +@dataclass +class Playlist: + playlistTitle: str + songs: List[Song] + playlistAuthor: Optional[str] = None + image: Optional[str] = None + coverImage: Optional[str] = None + description: Optional[str] = None + allowDuplicates: Optional[bool] = None + customData: Optional[CustomData] = None + +class PlaylistBuilder: + def __init__(self, covers_dir="./covers", history_file="./playlist_history.json", output_dir=None): + self.covers_dir = covers_dir + self.history_file = history_file + self.output_dir = output_dir or os.getcwd() + self._ensure_covers_directory() + self.history = self._load_history() + self._save_history() + + def _ensure_covers_directory(self): + if not os.path.exists(self.covers_dir): + os.makedirs(self.covers_dir) + logging.info(f"Created directory: {self.covers_dir}") + + def _load_history(self): + if os.path.exists(self.history_file): + with open(self.history_file, 'r') as f: + history = json.load(f) + history.setdefault('cover_history', []) + return history + return {"cover_history": []} + + def _save_history(self): + with open(self.history_file, 'w') as f: + json.dump(self.history, f) + + def _get_random_unused_cover(self): + available_covers = [f for f in os.listdir(self.covers_dir) + if f.endswith('.jpg') and f not in self.history['cover_history']] + + if not available_covers: + logging.warning("No unused cover images available. Using no cover.") + return None + + selected_cover = random.choice(available_covers) + self.history['cover_history'].append(selected_cover) + self._save_history() + return os.path.join(self.covers_dir, selected_cover) + + def _encode_image(self, image_path): + with open(image_path, "rb") as image_file: + return base64.b64encode(image_file.read()).decode('utf-8') + + def create_playlist(self, playlist_data: List[Dict], playlist_title: str = "playlist", playlist_author: str = "SaberList Tool") -> str: + """ + Create a playlist from standardized playlist data. + + :param playlist_data: A list of dictionaries, each containing song information + :param playlist_title: Title of the playlist + :param playlist_author: Author of the playlist + :return: Path to the created playlist file + """ + songs = [] + for song_data in playlist_data: + difficulties = [Difficulty(**diff) for diff in song_data.get('difficulties', [])] + songs.append(Song( + hash=song_data['hash'], + difficulties=difficulties, + key=song_data.get('key'), + levelId=song_data.get('levelId'), + songName=song_data.get('songName') + )) + + cover_path = self._get_random_unused_cover() + image = self._encode_image(cover_path) if cover_path else None + + playlist = Playlist( + playlistTitle=playlist_title, + playlistAuthor=playlist_author, + songs=songs, + image=f"data:image/png;base64,{image}" if image else None, + coverImage=cover_path, + description=f"Playlist created by SaberList Tool on {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", + allowDuplicates=False, + customData=CustomData() + ) + + playlist_dict = asdict(playlist) + filename = os.path.join(self.output_dir, f"{playlist_title.replace(' ', '_')}.bplist") + with open(filename, 'w') as f: + json.dump(playlist_dict, f, indent=2) + + logging.info(f"Playlist created: {filename}") + return filename diff --git a/src/helpers/ScoreSaberAPI.py b/src/helpers/ScoreSaberAPI.py new file mode 100644 index 0000000..694252f --- /dev/null +++ b/src/helpers/ScoreSaberAPI.py @@ -0,0 +1,122 @@ +import json +import os +import logging +from datetime import datetime, timedelta +from typing import Optional, Dict, Any + +from clients.scoresaber import client as scoresaber_client +from clients.scoresaber.api.players import get_api_player_player_id_scores +from clients.scoresaber.models import PlayerScoreCollection + +logging.basicConfig( + format='%(asctime)s %(levelname)s: %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + level=logging.DEBUG +) + +class ScoreSaberAPI: + BASE_URL = "https://scoresaber.com" + + def __init__(self, cache_expiry_days: int = 1, cache_dir: Optional[str] = None): + self.client = scoresaber_client.Client(base_url=self.BASE_URL) + self.cache_expiry_days = cache_expiry_days + self.CACHE_DIR = cache_dir or self._determine_cache_dir() + if not os.path.exists(self.CACHE_DIR): + os.makedirs(self.CACHE_DIR) + logging.info(f"Created cache directory: {self.CACHE_DIR}") + + def _determine_cache_dir(self) -> str: + home_cache = os.path.expanduser("~/.cache") + scoresaber_cache = os.path.join(home_cache, "scoresaber") + + if os.path.exists(home_cache): + if not os.path.exists(scoresaber_cache): + try: + os.makedirs(scoresaber_cache) + logging.info(f"Created cache directory: {scoresaber_cache}") + except OSError as e: + logging.warning(f"Failed to create {scoresaber_cache}: {e}") + return os.path.join(os.getcwd(), ".cache") + return scoresaber_cache + else: + logging.info("~/.cache doesn't exist, using local .cache directory") + return os.path.join(os.getcwd(), ".cache") + + def _get_cache_filename(self, player_id: str) -> str: + return os.path.join(self.CACHE_DIR, f"player_{player_id}_scores.json") + + def _is_cache_valid(self, cache_file: str) -> bool: + if not os.path.exists(cache_file): + return False + file_modified_time = datetime.fromtimestamp(os.path.getmtime(cache_file)) + return datetime.now() - file_modified_time < timedelta(days=self.cache_expiry_days) + + def get_player_scores( + self, + player_id: str, + use_cache: bool = True, + limit: int = 100, + sort: str = "recent", + max_pages: Optional[int] = None + ) -> Dict[str, Any]: + """ + Fetches all player scores for a given player ID, handling pagination and caching. + + :param player_id: The ScoreSaber player ID. + :param use_cache: Whether to use cached data if available. + :param limit: Number of scores per page. + :param sort: Sorting criteria. + :param max_pages: Maximum number of pages to fetch. Fetch all if None. + :return: A dictionary containing metadata and a list of player scores. + """ + cache_file = self._get_cache_filename(player_id) + + if use_cache and self._is_cache_valid(cache_file): + logging.debug(f"Using cached data for player {player_id}") + with open(cache_file, 'r') as f: + return json.load(f) + + logging.debug(f"Fetching fresh data for player {player_id}") + url_player_scores = f"/api/player/{player_id}/scores" + + all_scores = [] + page = 1 + total_items = None + + while max_pages is None or page <= max_pages: + try: + response: PlayerScoreCollection = get_api_player_player_id_scores.sync( + client=self.client, + player_id=player_id, + page=page, + limit=limit, + sort=sort + ) + except Exception as e: + logging.error(f"Error fetching page {page} for player {player_id}: {e}") + break + + all_scores.extend([score.dict() for score in response.player_scores]) + + if total_items is None: + total_items = response.metadata.total + logging.debug(f"Total scores to fetch: {total_items}") + + logging.debug(f"Fetched page {page}: {len(response.player_scores)} scores") + + if len(all_scores) >= total_items: + break + + page += 1 + + result = { + 'metadata': response.metadata.dict(), + 'playerScores': all_scores + } + + with open(cache_file, 'w') as f: + json.dump(result, f, default=str) # default=str to handle datetime serialization + + logging.info(f"Cached scores for player {player_id} at {cache_file}") + + return result diff --git a/src/saberlist/beatleader.py b/src/saberlist/beatleader.py index 4732653..2783d9a 100644 --- a/src/saberlist/beatleader.py +++ b/src/saberlist/beatleader.py @@ -1,6 +1,8 @@ +""" from collections import defaultdict from datetime import datetime -from saberlist.beatleaderAPI import BeatLeaderAPI +from saberlist.BeatLeaderAPI import BeatLeaderAPI +from archive.PlaylistBuilder import PlaylistBuilder import json import os @@ -11,22 +13,6 @@ logging.basicConfig( level=logging.DEBUG ) -HISTORY_FILE = "playlist_history.json" - -def load_history(): - if os.path.exists(HISTORY_FILE): - with open(HISTORY_FILE, 'r') as f: - history = json.load(f) - # Ensure 'used_covers' key exists - if 'used_covers' not in history: - history['used_covers'] = [] - return history - return {'used_covers': []} - -def save_history(history): - with open(HISTORY_FILE, 'w') as f: - json.dump(history, f, indent=2) - def prompt_for_player_id(default_id='76561199407393962'): prompt = f"Enter player ID (press Enter for default '{default_id}'): " user_input = input(prompt).strip() @@ -67,15 +53,6 @@ def build_difficulty_based_playlist(api, player_id, history, playlist_name, song playlist_scores.extend(sorted(unique_songs.values(), key=lambda x: x['timepost'])[:count]) - # Add 5 songs with no star value or zero stars - unique_no_stars_songs = {} - for score in no_stars_group: - song_id = score['leaderboard']['song']['id'] - if song_id not in unique_no_stars_songs or score['timepost'] < unique_no_stars_songs[song_id]['timepost']: - unique_no_stars_songs[song_id] = score - - playlist_scores.extend(sorted(unique_no_stars_songs.values(), key=lambda x: x['timepost'])[:5]) - # Update history for score in playlist_scores: song_id = score['leaderboard']['song']['id'] @@ -92,15 +69,14 @@ def build_difficulty_based_playlist(api, player_id, history, playlist_name, song 'difficulty': score['leaderboard']['difficulty'] }) - playlist_file, used_cover = api.create_player_playlist_with_random_cover( - player_id, + playlist_builder = PlaylistBuilder() + playlist_file, used_cover = playlist_builder.create_player_playlist_with_random_cover( + playlist_scores, playlist_name, - "SaberList Tool", - custom_playlist=playlist_scores, # Pass the playlist_scores directly - use_cache=True, + "SaberList Tool", used_covers=set(history['used_covers']) ) - + if used_cover: history['used_covers'].append(used_cover) @@ -116,20 +92,13 @@ def saberlist_replay_bl(): history = load_history() - # Generate a unique playlist name timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") playlist_name = f"star_ladder-{timestamp}" playlist_file, playlist_scores, used_cover = build_difficulty_based_playlist(api, player_id, history, playlist_name, song_count=10) save_history(history) - # Create the full path for the cover image - cover_image_path = os.path.join("covers", used_cover) if used_cover else None - - # Create the bplist file using create_bplist() - bplist_file = api.create_bplist(playlist_scores, playlist_name, "SaberList Tool", cover_image_path) - - print(f"Playlist created: {bplist_file}") + print(f"Playlist created: {playlist_file}") if used_cover: print(f"Cover image used: {used_cover}") print("Playlist contents:") @@ -139,4 +108,5 @@ def saberlist_replay_bl(): print(f"{i}. {song['name']} by {song['author']} (Mapper: {song['mapper']}) - {difficulty['stars']:.2f} stars - Last played: {datetime.fromtimestamp(score['timepost'])}") if __name__ == "__main__": - saberlist_replay_bl() \ No newline at end of file + saberlist_replay_bl() +""" \ No newline at end of file diff --git a/src/saberlist/beatleaderAPI.py b/src/saberlist/beatleaderAPI.py deleted file mode 100644 index ff6ba19..0000000 --- a/src/saberlist/beatleaderAPI.py +++ /dev/null @@ -1,268 +0,0 @@ -from datetime import datetime, timedelta -import base64 -import json -import os -import random -import requests -import time - -import logging -logging.basicConfig( - format='%(asctime)s %(levelname)s: %(message)s', - datefmt='%Y-%m-%d %H:%M:%S', - level=logging.DEBUG -) - -class BeatLeaderAPI: - BASE_URL = "https://api.beatleader.xyz" - - def __init__(self, cache_expiry_days=1): - self.session = requests.Session() - self.cache_expiry_days = cache_expiry_days - self.CACHE_DIR = self._determine_cache_dir() - if not os.path.exists(self.CACHE_DIR): - os.makedirs(self.CACHE_DIR) - - def _determine_cache_dir(self): - home_cache = os.path.expanduser("~/.cache") - saberlist_cache = os.path.join(home_cache, "saberlist") - - if os.path.exists(home_cache): - if not os.path.exists(saberlist_cache): - try: - os.makedirs(saberlist_cache) - logging.info(f"Created cache directory: {saberlist_cache}") - except OSError as e: - logging.warning(f"Failed to create {saberlist_cache}: {e}") - return os.path.join(os.getcwd(), ".cache") - return saberlist_cache - else: - logging.info("~/.cache doesn't exist, using local .cache directory") - return os.path.join(os.getcwd(), ".cache") - - def _get_cache_filename(self, player_id): - return os.path.join(self.CACHE_DIR, f"player_{player_id}_scores.json") - - def _is_cache_valid(self, cache_file): - if not os.path.exists(cache_file): - return False - file_modified_time = datetime.fromtimestamp(os.path.getmtime(cache_file)) - return datetime.now() - file_modified_time < timedelta(days=self.cache_expiry_days) - - def get_player_scores(self, player_id, use_cache=True, page_size=100, max_pages=None): - cache_file = self._get_cache_filename(player_id) - - if use_cache and self._is_cache_valid(cache_file): - logging.debug(f"Using cached data for player {player_id}") - with open(cache_file, 'r') as f: - return json.load(f) - - logging.debug(f"Fetching fresh data for player {player_id}") - url = f"{self.BASE_URL}/player/{player_id}/scores" - - all_scores = [] - page = 1 - total_items = None - - while max_pages is None or page <= max_pages: - params = { - "page": page, - "count": page_size - } - response = self.session.get(url, params=params) - response.raise_for_status() - data = response.json() - - all_scores.extend(data['data']) - - if total_items is None: - total_items = data['metadata']['total'] - - if len(all_scores) >= total_items: - break - - page += 1 - time.sleep(1) # Add a small delay to avoid rate limiting - - result = { - 'metadata': { - 'total': total_items, - 'itemsPerPage': page_size, - 'page': page - }, - 'data': all_scores - } - - with open(cache_file, 'w') as f: - json.dump(result, f) - - return result - - - def get_player_songs(self, player_id, page=1, count=100, use_cache=True): - scores = self.get_player_scores(player_id, page, count, use_cache) - songs = [] - song_ids = set() - - for score in scores['data']: - song = score['leaderboard']['song'] - if song['id'] not in song_ids: - songs.append(song) - song_ids.add(song['id']) - - return songs - - def get_player_songs_minimal(self, player_id, page=1, count=100, use_cache=True): - full_songs = self.get_player_songs(player_id, page, count, use_cache) - return [self._get_minimal_song_data(song) for song in full_songs] - - def _get_minimal_song_data(self, song): - return { - 'id': song['id'], - 'name': song['name'], - 'author': song['author'], - 'mapper': song['mapper'], - 'hash': song['hash'], - 'bpm': song['bpm'], - 'duration': song['duration'] - } - - def clear_cache(self, player_id=None): - if player_id: - cache_file = self._get_cache_filename(player_id) - if os.path.exists(cache_file): - os.remove(cache_file) - logging.debug(f"Cleared cache for player {player_id}") - else: - for file in os.listdir(self.CACHE_DIR): - os.remove(os.path.join(self.CACHE_DIR, file)) - logging.debug("Cleared all cache") - - def get_cache_dir(self): - return self.CACHE_DIR - - - def create_bplist(self, playlist_data, playlist_title="playlist", playlist_author="SaberList Tool", cover_path=None): - """ - Create a bplist (JSON) file in the current directory from the given playlist data. - - :param playlist_data: List of score data or custom playlist data - :param playlist_title: Title of the playlist (default: "playlist") - :param playlist_author: Author of the playlist (default: "SaberList Tool") - :param cover_path: Path to the cover image file (optional) - :return: Path to the created bplist file - """ - playlist = { - "playlistTitle": playlist_title, - "playlistAuthor": playlist_author, - "songs": [] - } - - if cover_path: - with open(cover_path, "rb") as image_file: - encoded_image = base64.b64encode(image_file.read()).decode('utf-8') - playlist["image"] = f"data:image/jpeg;base64,{encoded_image}" - - for item in playlist_data: - if 'leaderboard' in item: # It's a score object - song = item['leaderboard']['song'] - difficulty = item['leaderboard']['difficulty'] - else: # It's a custom playlist item - song = item['song'] - difficulty = item['difficulty'] - - song_entry = { - "hash": song['hash'], - "songName": song['name'], - "difficulties": [ - { - "name": difficulty['difficultyName'].lower(), - "characteristic": difficulty['modeName'].lower() - } - ], - "levelAuthorName": song['mapper'] - } - playlist["songs"].append(song_entry) - - # Generate a unique filename - timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") - filename = f"{playlist_title}_{timestamp}.bplist" - - # Write the playlist to a file - with open(filename, 'w') as file: - json.dump(playlist, file, indent=4) - - logging.info(f"Playlist written to {filename} with {len(playlist['songs'])} songs") - - return os.path.abspath(filename) - - def create_player_playlist(self, player_id, playlist_title="playlist", playlist_author="SaberList Tool", song_limit=0, use_cache=True): - """ - Create a bplist (JSON) file for a player's scores. - - :param player_id: ID of the player - :param playlist_title: Title of the playlist (default: "playlist") - :param playlist_author: Author of the playlist (default: "SaberList Tool") - :param song_limit: Maximum number of songs to include (0 for no limit) - :param use_cache: Whether to use cached scores data (default: True) - :return: Path to the created bplist file - """ - scores_data = self.get_player_scores(player_id, use_cache=use_cache) - return self.create_bplist(scores_data['data'], playlist_title, playlist_author, song_limit) - - def create_player_playlist_with_random_cover(self, player_id, playlist_title="playlist", playlist_author="SaberList Tool", custom_playlist=None, use_cache=True, used_covers=None): - """ - Create a bplist (JSON) file for a player's scores or a custom playlist with a random cover image. - - :param player_id: ID of the player - :param playlist_title: Title of the playlist (default: "playlist") - :param playlist_author: Author of the playlist (default: "SaberList Tool") - :param custom_playlist: Custom playlist data (optional) - :param use_cache: Whether to use cached scores data (default: True) - :param used_covers: Set of already used cover image filenames - :return: Path to the created bplist file, and the filename of the used cover - """ - if custom_playlist is None: - scores_data = self.get_player_scores(player_id, use_cache=use_cache) - playlist_data = scores_data['data'] - else: - playlist_data = custom_playlist - - covers_dir = "./covers" - - # Create the covers directory if it doesn't exist - if not os.path.exists(covers_dir): - os.makedirs(covers_dir) - logging.info(f"Created directory: {covers_dir}") - - available_covers = [f for f in os.listdir(covers_dir) if f.endswith('.jpg') and f not in (used_covers or set())] - - if not available_covers: - logging.warning("No unused cover images available. Using no cover.") - return self.create_bplist(playlist_data, playlist_title, playlist_author), None - - selected_cover = random.choice(available_covers) - cover_path = os.path.join(covers_dir, selected_cover) - - playlist_file = self.create_bplist(playlist_data, playlist_title, playlist_author, cover_path=cover_path) - - return playlist_file, selected_cover - - def get_player_info(self, player_id): - """ - Retrieve information for a specific player. - - :param player_id: ID of the player - :return: Dictionary containing player information - """ - url = f"{self.BASE_URL}/player/{player_id}" - - try: - response = self.session.get(url) - response.raise_for_status() - player_data = response.json() - - return player_data - except requests.exceptions.RequestException as e: - logging.error(f"Error fetching player info for ID {player_id}: {e}") - return None \ No newline at end of file diff --git a/src/saberlist/make.py b/src/saberlist/make.py new file mode 100644 index 0000000..982ee70 --- /dev/null +++ b/src/saberlist/make.py @@ -0,0 +1,251 @@ +import json +import os +import logging +from collections import defaultdict +from datetime import datetime, timedelta, timezone +from typing import Dict, Any, List + +from dotenv import load_dotenv +load_dotenv() +LOG_LEVEL = os.environ.get('LOG_LEVEL', 'INFO').upper() +HISTORY_FILE = os.environ.get('HISTORY_FILE', "playlist_history.json") +CACHE_EXPIRY_DAYS = int(os.environ.get('CACHE_EXPIRY_DAYS', 2)) + +import logging +logging.basicConfig( + format='%(asctime)s %(levelname)s: %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + level=LOG_LEVEL +) + +from helpers.PlaylistBuilder import PlaylistBuilder +from helpers.ScoreSaberAPI import ScoreSaberAPI + +def load_history() -> Dict[str, Any]: + """ + Load the playlist history from a JSON file. + + :return: A dictionary containing the history. + """ + if os.path.exists(HISTORY_FILE): + with open(HISTORY_FILE, 'r') as f: + return json.load(f) + return {} + +def save_history(history: Dict[str, Any]) -> None: + """ + Save the playlist history to a JSON file. + + :param history: The history dictionary to save. + """ + with open(HISTORY_FILE, 'w') as f: + json.dump(history, f, indent=2) + +def prompt_for_player_id(default_id: str = '76561199407393962') -> str: + """ + Prompt the user to enter a ScoreSaber player ID. + Uses a default ID if the user presses Enter without input. + + :param default_id: The default player ID to use. + :return: The player ID entered by the user or the default. + """ + prompt = f"Enter player ID (press Enter for default '{default_id}'): " + player_id = input(prompt).strip() or default_id + return player_id + +def format_time_ago(time_difference: timedelta) -> str: + """ + Format a timedelta object into a human-readable string. + + :param time_difference: The time difference to format. + :return: A string representing the time difference (e.g., '5d', '2w'). + """ + days = time_difference.days + + if days < 7: + return f"{days} days(s)" + elif days < 30: + weeks = days // 7 + return f"{weeks} week(s)" + elif days < 365: + months = days // 30 + return f"{months} month(s)" + else: + years = days // 365 + return f"{years} year(s)" + +def normalize_difficulty(difficulty_name): + # ScoreSaber difficulty naming convention + difficulty_map = { + '_ExpertPlus_SoloStandard': 'expertplus', + '_Expert_SoloStandard': 'expert', + '_Hard_SoloStandard': 'hard', + '_Normal_SoloStandard': 'normal', + '_Easy_SoloStandard': 'easy' + } + + return difficulty_map.get(difficulty_name, difficulty_name.lower().replace('_solostandard', '')) + +def playlist_strategy_oldscores( + api: ScoreSaberAPI, + song_count: int = 10 +) -> List[Dict[str, Any]]: + """Build and format a list of songs based on old scores, avoiding reusing the same song+difficulty.""" + + player_id = prompt_for_player_id() + history = load_history() + history.setdefault('oldscores', {}) + + scores_data = api.get_player_scores(player_id, use_cache=True) + all_scores = scores_data.get('playerScores', []) + if not all_scores: + logging.warning(f"No scores found for player ID {player_id}.") + return [] + logging.debug(f"Found {len(all_scores)} scores for player ID {player_id}.") + + # Sort scores by timeSet in ascending order (oldest first) + all_scores.sort(key=lambda x: x['score'].get('timeSet', '')) + + difficulty_groups = defaultdict(list) + no_stars_group = [] + current_time = datetime.now(timezone.utc) + + for score in all_scores: + leaderboard = score.get('leaderboard', {}) + stars = leaderboard.get('stars', 0) + song_id = leaderboard.get('songHash') + difficulty_raw = leaderboard.get('difficulty', {}).get('difficultyRaw', '') + + if not song_id or not difficulty_raw: + logging.debug(f"Skipping score due to missing song_id or difficulty_raw: {score}") + continue # Skip if essential data is missing + + # Calculate time ago + time_set_str = score['score'].get('timeSet') + if not time_set_str: + logging.debug(f"Skipping score due to missing timeSet: {score}") + continue # Skip if time_set is missing + try: + time_set = datetime.fromisoformat(time_set_str.replace('Z', '+00:00')) + except ValueError as e: + logging.error(f"Invalid time format for score ID {score['score'].get('id')}: {e}") + continue + time_difference = current_time - time_set + time_ago = format_time_ago(time_difference) + + # Normalize the difficulty name + difficulty = normalize_difficulty(difficulty_raw) + + # Check history to avoid reusing song+difficulty + if song_id in history['oldscores'] and difficulty in history['oldscores'][song_id]: + logging.debug(f"Skipping song {song_id} with difficulty {difficulty} as it's in history.") + continue # Skip if already used + + # Format the song data as expected by PlaylistBuilder + song_dict = { + 'hash': song_id, + 'songName': leaderboard.get('songName', 'Unknown'), + 'difficulties': [ + { + 'name': difficulty, + 'characteristic': leaderboard.get('difficulty', {}).get('gameMode', 'Standard') + } + ] + } + + # Group songs based on stars + if stars is None or stars == 0: + no_stars_group.append(song_dict) + elif 0 < stars <= 3: + difficulty_groups[0].append(song_dict) + elif 4 <= stars < 6: + difficulty_groups[1].append(song_dict) + elif 6 <= stars < 7: + difficulty_groups[2].append(song_dict) + elif stars >= 7: + difficulty_groups[3].append(song_dict) + + playlist_data = [] + + # Define the order and counts for each difficulty group + for difficulty_level, count in [(0, song_count), (1, song_count), (2, song_count), (3, song_count)]: + group = difficulty_groups.get(difficulty_level, []) + if not group: + logging.debug(f"No songs found for difficulty level {difficulty_level}.") + continue + # Sort by difficulty name to ensure consistent ordering + sorted_group = sorted(group, key=lambda x: x['difficulties'][0]['name']) + logging.debug(f"Sorted group for difficulty {difficulty_level}: {[song['songName'] for song in sorted_group]}") + # Select unique songs up to the desired count + unique_songs = {} + for song in sorted_group: + song_id = song['hash'] + if song_id not in unique_songs: + unique_songs[song_id] = song + logging.debug(f"Selected song for playlist: {song['songName']} ({song['difficulties'][0]['name']})") + if len(unique_songs) >= count: + break + playlist_data.extend(unique_songs.values()) + logging.debug(f"Added {len(unique_songs)} songs from difficulty level {difficulty_level} to playlist.") + + # Add no-stars songs separately + if no_stars_group: + unique_no_stars_songs = {} + sorted_no_stars = sorted(no_stars_group, key=lambda x: x['difficulties'][0]['name']) # Adjust sorting as needed + logging.debug(f"Sorted no_stars_group: {[song['songName'] for song in sorted_no_stars]}") + for song in sorted_no_stars: + song_id = song['hash'] + if song_id not in unique_no_stars_songs: + unique_no_stars_songs[song_id] = song + logging.debug(f"Selected no-star song for playlist: {song['songName']} ({song['difficulties'][0]['name']})") + if len(unique_no_stars_songs) >= 5: # Limit to 5 no-stars songs + break + playlist_data.extend(unique_no_stars_songs.values()) + logging.debug(f"Added {len(unique_no_stars_songs)} no-star songs to playlist.") + + # Log if no songs were added + if not playlist_data: + logging.info("No new songs found to add to the playlist based on history.") + else: + # Log details of each song added to the playlist + for song in playlist_data: + song_name = song['songName'] + mapper = "Unknown" # Since mapper info was used earlier but not included in the formatted data + # To include mapper, you may need to adjust the formatting in playlist_strategy_oldscores() + # For now, it's omitted or you need to include it differently + difficulty = song['difficulties'][0]['name'] + logging.info(f"Song added: {song_name} ({difficulty}), mapped by {mapper}. Last played {time_ago} ago.") + logging.info(f"Total songs added to playlist: {len(playlist_data)}") + + # Update history to avoid reusing the same song+difficulty + for song in playlist_data: + song_id = song['hash'] + difficulty_name = song['difficulties'][0]['name'] + history['oldscores'].setdefault(song_id, []).append(difficulty_name) + save_history(history) + + return playlist_data + +def create_playlist(strategy='oldscores') -> None: + """ + Generate a playlist of songs from a range of difficulties, all with scores previously set a long time ago. + The range of difficulties ensures that the first few songs are good for warming up. + Avoids reusing the same song+difficulty in a playlist based on history. + """ + api = ScoreSaberAPI(cache_expiry_days=CACHE_EXPIRY_DAYS) + + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + playlist_name = f"{strategy}-{timestamp}" + + if strategy == 'oldscores': + playlist_data = playlist_strategy_oldscores(api, song_count=10) + + if not playlist_data: + logging.info("No new scores found to add to the playlist.") + return + + PlaylistBuilder().create_playlist( + playlist_data, + playlist_title=playlist_name, + playlist_author="SaberList Tool" + ) diff --git a/src/saberlist/scoresaber.py b/src/saberlist/scoresaber.py deleted file mode 100644 index 9e9923a..0000000 --- a/src/saberlist/scoresaber.py +++ /dev/null @@ -1,228 +0,0 @@ -import json -import asyncio -from pyscoresaber import ScoreSaberAPI, ScoreSort - -import logging -logging.basicConfig( - format='%(asctime)s %(levelname)s: %(message)s', - datefmt='%Y-%m-%d %H:%M:%S', - level=logging.DEBUG -) -logger = logging.getLogger(__name__) - - -def filter_and_sort_scores_by_stars(scores, min_stars: float, max_stars: float): - # Exclude scores outside the specified star range - filtered_scores = [score for score in scores if min_stars <= score.leaderboard.stars < max_stars] - # Sort the remaining scores by stars - sorted_scores = sorted(filtered_scores, key=lambda x: x.leaderboard.stars) - return sorted_scores - -def filter_and_sort_scores_by_acc(scores, min_stars: float, max_stars: float): - # Exclude scores outside the specified star range - filtered_scores = [score for score in scores if min_stars <= score.leaderboard.stars < max_stars] - # Calculate the score percentage for sorting - sorted_scores = sorted(filtered_scores, key=lambda x: (x.score.base_score / x.leaderboard.max_score) * 100) - return sorted_scores - -# TODO: combine with scores_to_playlist() -def leaderboards_to_playlist(leaderboards: list, playlist_title: str, playlist_author: str = "SaberList Tool") -> str: - playlist = { - "playlistTitle": playlist_title, - "playlistAuthor": playlist_author, - "songs": [] - } - - for leaderboard in leaderboards: - song_entry = { - "hash": leaderboard.song_hash, - "songName": leaderboard.song_name, - "difficulties": [ - { - "name": leaderboard.difficulty.difficulty.name.lower(), - "characteristic": leaderboard.difficulty.game_mode.name.lower() - } - ], - "levelAuthorName": leaderboard.level_author_name, - "songSubName": leaderboard.song_sub_name, - "songAuthorName": leaderboard.song_author_name - } - playlist["songs"].append(song_entry) - - playlist_json = json.dumps(playlist, indent=4) - with open(f"{playlist_title}.bplist", 'w') as file: - file.write(playlist_json) - logging.info(f"Playlist written to {playlist_title}.bplist") - return playlist_json - -def scores_to_playlist(scores: list, playlist_title, playlist_author="SaberList Tool", song_limit=0): - playlist = { - "playlistTitle": playlist_title, - "playlistAuthor": playlist_author, - "songs": [] - } - - # Determine the number of songs to include - num_songs = len(scores) if song_limit == 0 else min(song_limit, len(scores)) - - for score in scores[:num_songs]: - song_entry = { - "hash": score.leaderboard.song_hash, - "songName": score.leaderboard.song_name, - "difficulties": [ - { - "name": score.leaderboard.difficulty.difficulty.name.lower(), - "characteristic": score.leaderboard.difficulty.game_mode.name.lower() - } - ], - "levelAuthorName": score.leaderboard.level_author_name - } - playlist["songs"].append(song_entry) - - playlist_json = json.dumps(playlist, indent=4) - with open(f"{playlist_title}.bplist", 'w') as file: - file.write(playlist_json) - logging.info(f"Playlist written to {playlist_title}.bplist with {num_songs} songs") - - return playlist_json - -async def async_replay_all_by_acc(): - """Generate playlists for each star level and sort by lowest accuracy.""" - - scoresaber = ExtendedScoreSaberAPI() - try: - await scoresaber.start() - score_sort = ScoreSort.TOP - scores = [] - default_title = "Replay SS" - default_player_id = '76561199407393962' - player_id = input(f"Enter the playerid (Default: {default_player_id}): ") or default_player_id - song_limit = input("Limit the playlist but number of songs (Default: 0, ie. no limit): ") or 0 - - async for player_scores in scoresaber.player_scores_all(player_id, score_sort): - scores.extend(player_scores) - - if scores: - max_stars = max(score.leaderboard.stars for score in scores) - - for stars in range(1, int(max_stars) + 1): - playlist_title = f"{default_title} {stars}★" - filtered_sorted_scores = filter_and_sort_scores_by_acc(scores, stars, stars + 1) - if filtered_sorted_scores: - scores_to_playlist(filtered_sorted_scores, playlist_title, song_limit=int(song_limit)) - else: - print(f"No scores found for {stars}★") - else: - print("No scores found for the given player.") - - finally: - await scoresaber._http_client.close() - -def replay_all_by_acc(): - try: - asyncio.run(async_replay_all_by_acc()) - except Exception as e: - print(f"An error occurred: {e}") - - -async def async_replay_ranked(): - scoresaber = ExtendedScoreSaberAPI() - try: - await scoresaber.start() - - score_sort = ScoreSort.TOP - scores = [] - default_player_id = '76561199407393962' - player_id = input(f"Enter the playerid (Default: {default_player_id}): ") or default_player_id - default_min_stars = 5 - min_stars = float(input(f"Enter the minimum starlevel to include on the playlist (Default: {default_min_stars}): ") or default_min_stars) - default_max_stars = min_stars + 1 - max_stars = float(input(f"Enter the maximum starlevel to include on the playlist (Default: {default_max_stars}): ") or default_max_stars) - default_title = f"Replay SS {min_stars}★" - playlist_title = input(f"Enter the filename for the playlist (Default: {default_title}): ") or default_title - - async for player_scores in scoresaber.player_scores_all(player_id, score_sort): - scores.extend(player_scores) - - # filtered_sorted_scores = filter_and_sort_scores_by_stars(scores, min_stars, max_stars) - filtered_sorted_scores = filter_and_sort_scores_by_acc(scores, min_stars, max_stars) - scores_to_playlist(filtered_sorted_scores, playlist_title) - finally: - await scoresaber._http_client.close() - -def replay_ranked(): - try: - asyncio.run(async_replay_ranked()) - except Exception as e: - print(f"An error occurred: {e}") - -def leaderboard_songs(): - - default_min_stars = 6.0 - min_stars = float(input(f"Enter the minimum starlevel to include on the playlist (Default: {default_min_stars}): ") or default_min_stars) - default_max_stars = min_stars + 0.10 - max_stars = float(input(f"Enter the maximum starlevel to include on the playlist (Default: {default_max_stars}): ") or default_max_stars) - default_title = f"SS{min_stars}★" - playlist_title = input(f"Enter the filename for the playlist (Default: {default_title}): ") or default_title - - try: - leaderboards = asyncio.run(async_leaderboards(min_stars, max_stars)) - except Exception as e: - print(f"An error occurred: {e}") - - leaderboards_to_playlist(leaderboards, playlist_title) - -async def async_leaderboards(min_stars: float, max_stars: float): - params = { - "category": 3, # sort by scores - "sort": 1, # sort ascending - "max_star": max_stars, - "min_star": min_stars, - "qualified": 0, # False - "ranked": 1 # True - } - scoresaber = ExtendedScoreSaberAPI() - await scoresaber.start() - all_leaderboards = [] - try: - async for leaderboard_page in scoresaber.leaderboards_all(**params): - all_leaderboards.extend(leaderboard_page) - except Exception as e: - print(f"An error occurred: {e}") - finally: - await scoresaber.close() - return all_leaderboards - -from math import ceil -from typing import AsyncIterable, List - -from pyscoresaber.models import LeaderboardInfo, PlayerScore -class ExtendedScoreSaberAPI(ScoreSaberAPI): - async def leaderboards_all(self, **params) -> AsyncIterable[List[LeaderboardInfo]]: - page = 1 - max_page = -1 - while page <= max_page or max_page == -1: - logging.info(f"Fetching page {page}/{max_page} of leaderboards") - leaderboards = await self.leaderboards(**params, page=page) - - if max_page == -1: - max_page = ceil(leaderboards.metadata.total / leaderboards.metadata.items_per_page) - logging.info(f"Got {len(leaderboards.leaderboards)} songs from leaderboard page {page}") - - yield leaderboards.leaderboards - page += 1 - - async def player_scores_all(self, player_id: int, score_sort: ScoreSort) -> AsyncIterable[List[PlayerScore]]: - page = 1 - max_page = -1 - - while page < max_page or max_page == -1: - logging.info(f"Fetching page {page}/{max_page} of player scores") - recent_scores = await self.player_scores(player_id, sort=score_sort, limit=100, page=page) - - if max_page == -1: - max_page = ceil(recent_scores.metadata.total / 100) + 1 - logging.info(f"Got {len(recent_scores.player_scores)} scores from page {page}") - - yield recent_scores.player_scores - page += 1 diff --git a/tests/api.beatleader.xyz.py b/tests/api.beatleader.xyz.py deleted file mode 100644 index 3224b8a..0000000 --- a/tests/api.beatleader.xyz.py +++ /dev/null @@ -1,80 +0,0 @@ -# This test hits the live api, and serves as a sanity check for the BeatLeaderAPI class. -# Run this sparingly! Ideally you should only need it just before tagging a release version. - -import pytest -import os -import logging -from saberlist.beatleaderAPI import BeatLeaderAPI - -# Set up logging -logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') - -# Test player ID (you may want to use a known player ID for consistent testing) -TEST_PLAYER_ID = '76561199407393962' - -@pytest.fixture(scope="module") -def api(): - return BeatLeaderAPI(cache_expiry_days=0) # Set to 0 to always get fresh data during tests - -def test_cache_directory(api): - cache_dir = api.get_cache_dir() - assert os.path.exists(cache_dir), f"Cache directory {cache_dir} does not exist" - assert cache_dir.endswith('saberlist'), f"Cache directory {cache_dir} does not end with 'saberlist'" - -def test_get_player_scores(api): - scores = api.get_player_scores(TEST_PLAYER_ID, use_cache=False) - assert isinstance(scores, dict), "get_player_scores should return a dictionary" - assert 'data' in scores, "Scores response should contain 'data' key" - assert len(scores['data']) > 0, "Player should have at least one score" - -def test_get_player_songs(api): - songs = api.get_player_songs(TEST_PLAYER_ID, use_cache=False) - assert isinstance(songs, list), "get_player_songs should return a list" - assert len(songs) > 0, "Player should have at least one song" - - # Check if all expected keys are present in the first song - expected_keys = ['id', 'name', 'author', 'mapper', 'hash', 'bpm', 'duration'] - assert all(key in songs[0] for key in expected_keys), f"Song is missing some expected keys. Got: {songs[0].keys()}" - -def test_get_player_songs_minimal(api): - songs = api.get_player_songs_minimal(TEST_PLAYER_ID, use_cache=False) - assert isinstance(songs, list), "get_player_songs_minimal should return a list" - assert len(songs) > 0, "Player should have at least one song" - - # Check if only the minimal keys are present in the first song - expected_keys = ['id', 'name', 'author', 'mapper', 'hash', 'bpm', 'duration'] - assert set(songs[0].keys()) == set(expected_keys), f"Minimal song data has unexpected keys. Got: {songs[0].keys()}" - -def test_caching(api): - # First call should hit the API - songs1 = api.get_player_songs(TEST_PLAYER_ID, use_cache=True) - - # Second call should use cache - songs2 = api.get_player_songs(TEST_PLAYER_ID, use_cache=True) - - assert songs1 == songs2, "Cached result should be the same as the initial API call" - - # Force a fresh API call - songs3 = api.get_player_songs(TEST_PLAYER_ID, use_cache=False) - - # The results might be different if the player has new scores, but the structure should be the same - assert type(songs1) == type(songs3), "Fresh API call should return the same data structure" - -def test_clear_cache(api): - # Ensure there's something in the cache - api.get_player_songs(TEST_PLAYER_ID, use_cache=True) - - # Clear cache for the test player - api.clear_cache(TEST_PLAYER_ID) - - cache_file = api._get_cache_filename(TEST_PLAYER_ID) - assert not os.path.exists(cache_file), f"Cache file for player {TEST_PLAYER_ID} should not exist after clearing" - - # Clear all cache - api.get_player_songs(TEST_PLAYER_ID, use_cache=True) # Recreate some cache - api.clear_cache() - - assert len(os.listdir(api.get_cache_dir())) == 0, "Cache directory should be empty after clearing all cache" - -if __name__ == "__main__": - pytest.main([__file__, "-v"]) \ No newline at end of file diff --git a/tests/assets/sample_cover.jpg b/tests/assets/sample_cover.jpg new file mode 100644 index 0000000..617ca8a Binary files /dev/null and b/tests/assets/sample_cover.jpg differ diff --git a/tests/playlist_builder.py b/tests/playlist_builder.py new file mode 100644 index 0000000..a739b08 --- /dev/null +++ b/tests/playlist_builder.py @@ -0,0 +1,259 @@ +import pytest +import shutil +import os +import json +from pathlib import Path +from unittest import mock +from saberlist.PlaylistBuilder import PlaylistBuilder + +@pytest.fixture +def temp_environment(tmp_path): + """ + Fixture to set up a temporary environment for testing. + Creates temporary directories for covers and output, + copies the sample cover image, and initializes PlaylistBuilder. + """ + # Define paths within the temporary directory + covers_dir = tmp_path / "covers" + history_file = tmp_path / "playlist_history.json" + output_dir = tmp_path / "output" + + # Create necessary directories + covers_dir.mkdir(parents=True, exist_ok=True) + output_dir.mkdir(parents=True, exist_ok=True) + + # Path to the sample cover image in the repository + sample_cover_src = Path(__file__).parent / 'assets' / 'sample_cover.jpg' + + # Ensure the sample cover exists + assert sample_cover_src.exists(), f"Sample cover not found at {sample_cover_src}" + + # Copy the sample cover to the covers directory + shutil.copy(sample_cover_src, covers_dir) + + # Initialize the PlaylistBuilder with the test paths + builder = PlaylistBuilder( + covers_dir=str(covers_dir), + history_file=str(history_file), + output_dir=str(output_dir) + ) + + # Sample song data + sample_song = { + "hash": "7c9e0a7c523395c7ef9d79006b9d42dc6ab8b44a", + "key": "2a44e", + "levelId": "custom_level_7c9e0a7c523395c7ef9d79006b9d42dc6ab8b44a", + "songName": "Gleodream", + "difficulties": [ + { + "name": "normal", + "characteristic": "Standard" + } + ] + } + + yield { + "builder": builder, + "covers_dir": covers_dir, + "history_file": history_file, + "output_dir": output_dir, + "sample_song": sample_song, + "sample_cover_src": sample_cover_src + } + + # Teardown is handled automatically by pytest's tmp_path fixture + +def test_create_playlist(temp_environment, caplog): + """ + Test the creation of a playlist with a sample song and cover. + """ + env = temp_environment + builder = env["builder"] + covers_dir = env["covers_dir"] + history_file = env["history_file"] + output_dir = env["output_dir"] + sample_song = env["sample_song"] + + # Create the playlist + playlist_title = "Test Playlist" + playlist_author = "Test Author" + playlist_path = builder.create_playlist( + playlist_data=[sample_song], + playlist_title=playlist_title, + playlist_author=playlist_author + ) + + # Verify that the playlist file exists + assert os.path.exists(playlist_path), "Playlist file was not created." + + # Load the playlist content + with open(playlist_path, 'r') as f: + playlist_content = json.load(f) + + # Check playlist metadata + assert playlist_content['playlistTitle'] == playlist_title + assert playlist_content['playlistAuthor'] == playlist_author + assert len(playlist_content['songs']) == 1 + + # Verify song details + song = playlist_content['songs'][0] + assert song['hash'] == sample_song['hash'] + assert song['key'] == sample_song['key'] + assert song['levelId'] == sample_song['levelId'] + assert song['songName'] == sample_song['songName'] + assert len(song['difficulties']) == 1 + assert song['difficulties'][0]['name'] == 'normal' + assert song['difficulties'][0]['characteristic'] == 'Standard' + + # Check that an image is encoded and included + assert 'image' in playlist_content + assert playlist_content['image'] is not None, "Image was not encoded in the playlist." + assert playlist_content['image'].startswith("data:image/png;base64,"), "Image encoding is incorrect." + + # Verify coverImage path + assert 'coverImage' in playlist_content + expected_cover_path = str(covers_dir / 'sample_cover.jpg') + assert playlist_content['coverImage'] == expected_cover_path + + # Verify description + assert 'description' in playlist_content + assert 'Playlist created by SaberList Tool on' in playlist_content['description'] + + # Check that duplicates are not allowed + assert not playlist_content['allowDuplicates'], "Duplicates should not be allowed." + + # Check customData fields are present but None + assert 'customData' in playlist_content + assert playlist_content['customData'] is not None + assert playlist_content['customData']['syncURL'] is None + assert playlist_content['customData']['owner'] is None + assert playlist_content['customData']['id'] is None + assert playlist_content['customData']['hash'] is None + assert playlist_content['customData']['shared'] is None + + # Verify that the cover was marked as used in history + with open(history_file, 'r') as f: + history = json.load(f) + assert 'sample_cover.jpg' in history['used_covers'], "Cover image was not marked as used in history." + +def test_no_available_covers(temp_environment, caplog): + """ + Test behavior when no unused cover images are available. + """ + env = temp_environment + builder = env["builder"] + covers_dir = env["covers_dir"] + history_file = env["history_file"] + output_dir = env["output_dir"] + sample_song = env["sample_song"] + + # Remove all covers to simulate no available covers + shutil.rmtree(covers_dir) + covers_dir.mkdir(parents=True, exist_ok=True) # Recreate covers directory without any covers + + # Attempt to create a playlist + playlist_path = builder.create_playlist( + playlist_data=[sample_song], + playlist_title="No Cover Playlist", + playlist_author="Test Author" + ) + + # Verify that the playlist file exists + assert os.path.exists(playlist_path), "Playlist file was not created when no covers are available." + + # Load the playlist content + with open(playlist_path, 'r') as f: + playlist_content = json.load(f) + + # Check that image and coverImage are None or not set + assert playlist_content['image'] is None, "Image should be None when no covers are available." + assert playlist_content['coverImage'] is None, "coverImage should be None when no covers are available." + + # Create another playlist to trigger logging + builder.create_playlist( + playlist_data=[sample_song], + playlist_title="Another No Cover Playlist", + playlist_author="Test Author" + ) + + # Verify that a warning was logged + assert any("No unused cover images available. Using no cover." in message for message in caplog.text.split('\n')), \ + "Expected warning was not logged." + +def test_history_persistence(temp_environment): + """ + Test that the history is persisted correctly across multiple playlist creations. + """ + env = temp_environment + builder = env["builder"] + covers_dir = env["covers_dir"] + history_file = env["history_file"] + sample_song = env["sample_song"] + + # Create first playlist + builder.create_playlist( + playlist_data=[sample_song], + playlist_title="First Playlist", + playlist_author="Author A" + ) + + # Attempt to create a second playlist; since there's only one cover, it should warn and not use any cover + playlist_path = builder.create_playlist( + playlist_data=[sample_song], + playlist_title="Second Playlist", + playlist_author="Author B" + ) + + # Load the second playlist + with open(playlist_path, 'r') as f: + playlist_content = json.load(f) + + # Check that no image is set since the cover was already used + assert playlist_content['image'] is None, "Image should be None when cover is already used." + assert playlist_content['coverImage'] is None, "coverImage should be None when cover is already used." + + # Verify history contains the cover + with open(history_file, 'r') as f: + history = json.load(f) + assert 'sample_cover.jpg' in history['used_covers'], "Cover image was not marked as used in history." + +@mock.patch('saberlist.PlaylistBuilder.random.choice') +def test_random_cover_selection(mock_choice, temp_environment): + """ + Test that a specific cover is selected when random.choice is mocked. + """ + env = temp_environment + builder = env["builder"] + covers_dir = env["covers_dir"] + history_file = env["history_file"] + sample_song = env["sample_song"] + sample_cover_src = env["sample_cover_src"] + + # Add another cover to the covers directory + additional_cover = covers_dir / 'additional_cover.jpg' + shutil.copy(sample_cover_src, additional_cover) + + # Mock random.choice to return 'additional_cover.jpg' + mock_choice.return_value = 'additional_cover.jpg' + + # Create the playlist + playlist_path = builder.create_playlist( + playlist_data=[sample_song], + playlist_title="Mocked Cover Playlist", + playlist_author="Mock Author" + ) + + # Verify that the mocked cover was used by checking 'coverImage' + expected_cover_path = str(covers_dir / 'additional_cover.jpg') + with open(playlist_path, 'r') as f: + playlist_content = json.load(f) + + assert playlist_content['coverImage'] == expected_cover_path, "The coverImage should point to 'additional_cover.jpg'." + + # Optionally, verify that 'image' is correctly encoded by checking the data URL prefix + assert playlist_content['image'].startswith("data:image/png;base64,"), "Image encoding is incorrect." + + # Verify that the history includes the mocked cover + with open(history_file, 'r') as f: + history = json.load(f) + assert 'additional_cover.jpg' in history['used_covers'], "Cover image was not marked as used in history." diff --git a/tests/test_beatleader.py b/tests/test_beatleader.py deleted file mode 100644 index b316226..0000000 --- a/tests/test_beatleader.py +++ /dev/null @@ -1,106 +0,0 @@ -# tests/test_beatleader.py - -import pytest -from unittest.mock import patch, Mock -from saberlist.beatleader import BeatLeaderAPI - -@pytest.fixture -def mock_response(): - mock = Mock() - mock.json.return_value = { - "metadata": {"itemsPerPage": 100, "page": 1, "total": 2}, - "data": [ - { - "leaderboard": { - "song": { - "id": "song1", - "name": "Test Song 1", - "author": "Test Author 1", - "mapper": "Test Mapper 1", - "hash": "testhash1", - "bpm": 120, - "duration": 180 - } - } - }, - { - "leaderboard": { - "song": { - "id": "song2", - "name": "Test Song 2", - "author": "Test Author 2", - "mapper": "Test Mapper 2", - "hash": "testhash2", - "bpm": 140, - "duration": 200 - } - } - } - ] - } - return mock - -@pytest.fixture -def beat_leader_api(): - return BeatLeaderAPI() - -@patch('requests.Session.get') -def test_get_player_scores(mock_get, beat_leader_api, mock_response): - mock_get.return_value = mock_response - player_id = '123456' - result = beat_leader_api.get_player_scores(player_id) - - assert result == mock_response.json.return_value - mock_get.assert_called_once_with( - f"{BeatLeaderAPI.BASE_URL}/player/{player_id}/scores", - params={"page": 1, "count": 100} - ) - -@patch('requests.Session.get') -def test_get_player_songs(mock_get, beat_leader_api, mock_response): - mock_get.return_value = mock_response - player_id = '123456' - result = beat_leader_api.get_player_songs(player_id) - - expected_songs = [ - { - 'id': 'song1', - 'name': 'Test Song 1', - 'author': 'Test Author 1', - 'mapper': 'Test Mapper 1', - 'hash': 'testhash1', - 'bpm': 120, - 'duration': 180 - }, - { - 'id': 'song2', - 'name': 'Test Song 2', - 'author': 'Test Author 2', - 'mapper': 'Test Mapper 2', - 'hash': 'testhash2', - 'bpm': 140, - 'duration': 200 - } - ] - - assert result == expected_songs - mock_get.assert_called_once_with( - f"{BeatLeaderAPI.BASE_URL}/player/{player_id}/scores", - params={"page": 1, "count": 100} - ) - -def test_get_player_songs_unique(beat_leader_api): - with patch.object(beat_leader_api, 'get_player_scores') as mock_get_scores: - mock_get_scores.return_value = { - "data": [ - {"leaderboard": {"song": {"id": "song1", "name": "Song 1", "author": "Author 1", "mapper": "Mapper 1", "hash": "hash1", "bpm": 120, "duration": 180}}}, - {"leaderboard": {"song": {"id": "song1", "name": "Song 1", "author": "Author 1", "mapper": "Mapper 1", "hash": "hash1", "bpm": 120, "duration": 180}}}, - {"leaderboard": {"song": {"id": "song2", "name": "Song 2", "author": "Author 2", "mapper": "Mapper 2", "hash": "hash2", "bpm": 140, "duration": 200}}} - ] - } - - result = beat_leader_api.get_player_songs('123456') - - assert len(result) == 2 - assert result[0]['id'] == 'song1' - assert result[1]['id'] == 'song2' \ No newline at end of file