Metadata-Version: 2.4
Name: hackbou-push-notification
Version: 0.1.0
Summary: Client Python / Django pour l'API Push Notification
Author-email: hackbou <hackbou@users.noreply.github.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/hardhacklife/push-notification-python-sdk
Project-URL: Documentation, https://github.com/hardhacklife/push-notification-python-sdk#readme
Project-URL: Repository, https://github.com/hardhacklife/push-notification-python-sdk
Project-URL: Issues, https://github.com/hardhacklife/push-notification-python-sdk/issues
Keywords: push-notification,push,notifications,django,fcm,apns
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Classifier: Topic :: Communications
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27
Requires-Dist: typing_extensions>=4.5; python_version < "3.11"
Provides-Extra: django
Requires-Dist: Django>=4.2; extra == "django"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

# hackbou-push-notification

Client Python / Django pour l’API **Push Notification**.

Typage : PEP 561 (`py.typed`) + `TypedDict` pour les réponses.

**Import :** `push_notification`  
**Package PyPI :** `hackbou-push-notification`

## Installation

```bash
pip install hackbou-push-notification

# avec helpers Django
pip install "hackbou-push-notification[django]"
```

## Usage Python

```python
from push_notification import PushNotificationClient, Device, NotificationCreateResult

with PushNotificationClient(
    api_key="pf_live_…",
    base_url="https://push.example.com",
) as push:
    result: NotificationCreateResult = push.send_notification(
        title="Nouveau cours",
        body="Le support est disponible.",
        user_ids=["student_123"],
        data={"screen": "course"},
    )
    devices: list[Device] = push.list_devices(limit=50)
    page = push.list_devices_page(q="expo", limit=25, offset=0)
```

## Usage Django

`settings.py` :

```python
PUSH_NOTIFICATION_API_KEY = env("PUSH_NOTIFICATION_API_KEY")
PUSH_NOTIFICATION_BASE_URL = env("PUSH_NOTIFICATION_BASE_URL", default="http://127.0.0.1:8787")
PUSH_NOTIFICATION_TIMEOUT = 15
```

```python
from push_notification.django import send_to_user, get_client

send_to_user(
    "student_123",
    title="Nouveau cours",
    body="Un support vient d’être publié.",
    data={"course_id": "math_101"},
)

client = get_client()
client.login_user("student_123", device_ids=["…"])
client.set_user_tags("student_123", {"language": "fr"})
```

## API du client

| Méthode | Endpoint |
|---------|----------|
| `register_device(platform=, token=)` | `POST /v1/devices` |
| `list_devices(q=, limit=, offset=)` | `GET /v1/devices` → `list[Device]` |
| `list_devices_page(…)` | idem → `{items,total,limit,offset,has_more}` |
| `delete_device(id)` | `DELETE /v1/devices/{id}` |
| `login` / `login_user` | `POST /v1/users/…/login` |
| `set_tags` / `set_user_tags` | `PUT /v1/users/…/tags` |
| `list_users` / `list_users_page` | `GET /v1/users` |
| `send_notification(…)` | `POST /v1/notifications` |
| `get_notification(id)` | `GET /v1/notifications/{id}` |
| `list_notifications` / `_page` | `GET /v1/notifications` |
| `health_live()` / `health_ready()` | healthchecks |

Les listes acceptent l’enveloppe paginée **et** un ancien tableau brut (compat).

## Tests

```bash
pip install -e ".[dev]"
pytest
```

## Licence

Apache-2.0
