Skip to main content

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 user
  • login(username, password) - Login user
  • logout() - Logout and clear local data
  • is_logged_in() - Check login status
  • save_progress(progress=None) - Save game progress
  • load_progress() - Load current progress
  • update_progress(**kwargs) - Update progress fields

Models

User

  • user_id: Optional[int] - User ID from server
  • username: str - Username
  • email: Optional[str] - Email address
  • created_at: Optional[str] - Account creation date

GameProgress

  • level: int - Current game level
  • score: int - Player score
  • achievements: List[str] - Unlocked achievements
  • settings: Dict[str, Any] - Game settings
  • last_played: Optional[str] - Last play timestamp

APIResponse

  • status: str - Response status
  • message: Optional[str] - Response message
  • data: Optional[Dict] - Response data
  • is_success: bool - Success indicator

Exceptions

  • ItryIDError - Base exception
  • NetworkError - Network-related errors
  • AuthenticationError - Authentication failures
  • ValidationError - Input validation errors
  • ServerError - 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itryid_sdk-2.0.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itryid_sdk-2.0.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

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

Hashes for itryid_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 83bd03bb8c92ff59f3853ca3bc7462e67cb8b759999e503ed92eaff78495922a
MD5 767661e9ea8ba0a4f87772f5a8fbe7f4
BLAKE2b-256 716fbed81bc8f15f00619d68c39d9a80e5df65ea3f3eacddde7418b6812c58e2

See more details on using hashes here.

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

Hashes for itryid_sdk-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 83f55a57642f023ea543793094beba0b37d83a9a58cd17226b4da176c363c164
MD5 20982426753a72866abc76fb79bcfc83
BLAKE2b-256 9dfb36a623480e111c3307f2992a070be6fc64188f3ff1396f20eda5f0b9d875

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page