Modern ItryID SDK for Python apps with improved architecture, type safety, and error handling
Project description
ItryID SDK v2.0
Modern Python SDK for ItryID authentication and game progress management with improved architecture, type safety, and error handling.
Features
- 🔐 User Authentication - Register, login, logout with validation
- 🎮 Game Progress Management - Save/load progress with automatic sync
- 💾 Local Storage - Automatic local caching with fallback
- 🔄 Retry Logic - Automatic retry for failed network requests
- 🛡️ Type Safety - Full type hints and data models
- 📝 Comprehensive Logging - Detailed logging for debugging
- ⚡ Modern Architecture - Clean, maintainable code structure
Installation
```bash pip install itryid-sdk ```
Quick Start
```python from itryid import ItryIDClient, GameProgress
Initialize client
client = ItryIDClient( server_url="https://your-server.com/api.php", game_name="my_awesome_game" )
Register new user
try: response = client.register("username", "password123", "user@example.com") print("Registration successful!") except ValidationError as e: print(f"Validation error: {e}")
Login
try: response = client.login("username", "password123") print(f"Logged in as: {client.user.username}") except AuthenticationError as e: print(f"Login failed: {e}")
Update and save progress
client.update_progress(level=5, score=1500, achievements=["first_win"]) response = client.save_progress() print(f"Progress saved: {response.status}")
Load progress
progress = client.load_progress() print(f"Current level: {progress.level}, Score: {progress.score}") ```
Advanced Usage
Custom Progress Model
```python from itryid import GameProgress
Create custom progress
progress = GameProgress( level=10, score=5000, achievements=["speedrun", "perfectionist"], settings={"difficulty": "hard", "sound": True} )
Save custom progress
client.save_progress(progress) ```
Error Handling
```python from itryid import NetworkError, AuthenticationError, ValidationError
try: client.login("user", "pass") except NetworkError as e: print(f"Network issue: {e}") except AuthenticationError as e: print(f"Auth failed: {e}") except ValidationError as e: print(f"Invalid input: {e}") ```
Configuration
```python client = ItryIDClient( server_url="https://api.example.com", game_name="my_game", local_save_path="./saves/progress.json", # Custom save location timeout=15, # Request timeout in seconds retry_attempts=5 # Number of retry attempts ) ```
API Reference
ItryIDClient
Main client class for interacting with ItryID API.
Methods
register(username, password, email=None)- Register new userlogin(username, password)- Login userlogout()- Logout and clear local datais_logged_in()- Check login statussave_progress(progress=None)- Save game progressload_progress()- Load current progressupdate_progress(**kwargs)- Update progress fields
Models
User
user_id: Optional[int]- User ID from serverusername: str- Usernameemail: Optional[str]- Email addresscreated_at: Optional[str]- Account creation date
GameProgress
level: int- Current game levelscore: int- Player scoreachievements: List[str]- Unlocked achievementssettings: Dict[str, Any]- Game settingslast_played: Optional[str]- Last play timestamp
APIResponse
status: str- Response statusmessage: Optional[str]- Response messagedata: Optional[Dict]- Response datais_success: bool- Success indicator
Exceptions
ItryIDError- Base exceptionNetworkError- Network-related errorsAuthenticationError- Authentication failuresValidationError- Input validation errorsServerError- Server-side errors
Development
Setup Development Environment
```bash git clone https://github.com/IGBerko/itryid-sdk.git cd itryid-sdk pip install -e ".[dev]" ```
Run Tests
```bash pytest tests/ -v --cov=itryid ```
Code Formatting
```bash black itryid/ flake8 itryid/ mypy itryid/ ```
Changelog
v2.0.0
- Complete rewrite with modern architecture
- Added type safety and data models
- Improved error handling and validation
- Added comprehensive logging
- Better local storage management
- Retry logic for network requests
- Enhanced documentation
v1.0.1
- Initial release
- Basic authentication and progress saving
License
MIT License - see LICENSE file for details.
Support
- GitHub Issues: https://github.com/IGBerko/itryid-sdk/issues
- Email: support@ut.itrypro.ru
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file itryid_sdk-2.0.0.tar.gz.
File metadata
- Download URL: itryid_sdk-2.0.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83bd03bb8c92ff59f3853ca3bc7462e67cb8b759999e503ed92eaff78495922a
|
|
| MD5 |
767661e9ea8ba0a4f87772f5a8fbe7f4
|
|
| BLAKE2b-256 |
716fbed81bc8f15f00619d68c39d9a80e5df65ea3f3eacddde7418b6812c58e2
|
File details
Details for the file itryid_sdk-2.0.0-py3-none-any.whl.
File metadata
- Download URL: itryid_sdk-2.0.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83f55a57642f023ea543793094beba0b37d83a9a58cd17226b4da176c363c164
|
|
| MD5 |
20982426753a72866abc76fb79bcfc83
|
|
| BLAKE2b-256 |
9dfb36a623480e111c3307f2992a070be6fc64188f3ff1396f20eda5f0b9d875
|