Metadata-Version: 2.4
Name: eyesoft-api-client
Version: 0.1.0
Summary: 
Author: Arnaud-Marie Gallardo
Author-email: arnaud.g@eyesoft.fr
Requires-Python: >=3.13
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: httpx (>=0.28.1,<0.29.0)
Description-Content-Type: text/markdown

# Eyesoft API Client

Python client for the Eyesoft API.

## Installation

```bash
pip install eyesoft-api-client
```

## Quick start

```python
from eyesoft_api_client import Client

with Client(
    base_url="https://api.example.com",
    username="user",
    password="pass",
    client_id="client_id",
    client_secret="client_secret",
) as client:
    patients = client.list_patients()
    print(patients[0].id)
```

## Authentication

The client authenticates with the API using OAuth2 (username/password + client credentials). Tokens are managed automatically by the HTTP session.

| Parameter | Description |
|---|---|
| `base_url` | Root URL of the API (no trailing slash) |
| `username` | User account login |
| `password` | User account password |
| `client_id` | OAuth2 client ID |
| `client_secret` | OAuth2 client secret |

## Usage

### Patients

```python
# List all patients
patients = client.list_patients()

# Fetch a single patient by UUID
patient = client.get_patient("550e8400-e29b-41d4-a716-446655440000")

# Access patient fields directly as attributes
print(patient.id, patient.name)
```

### Exercises

```python
# List all exercises for a patient
exercises = patient.list_exercises()

# Fetch a single exercise for a patient
exercise = patient.get_exercise("550e8400-e29b-41d4-a716-446655440001")

# Fetch raw exercise data (parsed JSON)
data = exercise.get_data()

# Or fetch exercise data directly from the client
data = client.get_exercise_data("550e8400-e29b-41d4-a716-446655440001")
```

### Resource objects

`Patient` and `Exercise` objects proxy attribute access to the underlying API response, so any field returned by the API is accessible directly:

```python
patient = client.get_patient("550e8400-e29b-41d4-a716-446655440000")
patient.id        # any field in the JSON response
patient["name"]   # dict-style access also works
```

### Lifecycle

Use the client as a context manager (recommended) to ensure the underlying HTTP session is closed:

```python
with Client(...) as client:
    ...
```

Or manage it manually:

```python
client = Client(...)
try:
    ...
finally:
    client.close()
```

## Development

### Publishing

This project uses [python-semantic-release](https://python-semantic-release.readthedocs.io/) with [Conventional Commits](https://www.conventionalcommits.org/) for automated versioning and publishing to PyPI via GitLab CI.

Releases are triggered automatically on every push to the default branch when the commit history contains releasable changes:

| Commit prefix | Version bump |
|---|---|
| `fix: ...` | Patch (0.1.0 → 0.1.1) |
| `feat: ...` | Minor (0.1.0 → 0.2.0) |
| `feat!: ...` / `BREAKING CHANGE:` | Major (0.1.0 → 1.0.0) |

