Metadata-Version: 2.4
Name: weezy-sdk
Version: 0.2.1
Summary: Typed synchronous and asynchronous Weezy SMS and WhatsApp SDK
License-Expression: MIT
Project-URL: Homepage, https://github.com/pekenio/weezy-sdk
Project-URL: Repository, https://github.com/pekenio/weezy-sdk
Project-URL: Issues, https://github.com/pekenio/weezy-sdk/issues
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx<1,>=0.27
Dynamic: license-file

# weezy-sdk

Typed SMS and WhatsApp clients for Python 3.11+.

## Installation

```sh
pip install weezy-sdk
```

The package is named `weezy-sdk`; import clients from `weezy`.

For local development, install from this repository with `pip install ./python`.

## Synchronous client

```python
import os
from weezy import Weezy, WeezyError

with Weezy(
    client_id=os.environ['WEEZY_CLIENT_ID'],
    client_secret=os.environ['WEEZY_CLIENT_SECRET'],
) as client:
    wallet = client.sms.balance()
    print(f"Balance: {wallet['balance']:.3f} points")  # 1 point = 1 EUR
    message = client.sms.send(body={
        'to': '+2250700000000', 'body': 'Bonjour !', 'sender_name': 'WEEZY',
    })
    print(f"Cost: {message['cost']} points")
    status = client.sms.status(message_x_id=message['x_id'])
    result = client.whatsapp(os.environ['WEEZY_INSTANCE_ID']).messages.send_text_message(body={
        'phone': '2250700000000', 'message': 'Bonjour !',
    })
```

## Asynchronous client

```python
import asyncio
import os
from weezy import AsyncWeezy

async def main():
    async with AsyncWeezy(
        client_id=os.environ['WEEZY_CLIENT_ID'],
        client_secret=os.environ['WEEZY_CLIENT_SECRET'],
    ) as client:
        wallet = await client.sms.balance()
        print(f"Balance: {wallet['balance']:.3f} points")

asyncio.run(main())
```

Send methods create real messages with live credentials. Use a dedicated test account and recipient when testing.

SMS methods: `balance()`, `senders()`, `send(body=...)`, `send_bulk(body=...)`, `status(message_x_id=...)`, `opt_outs(body=...)`. All arguments are keyword-only. WhatsApp resource methods match the backend handler names; see [the full reference](API.md).

`WeezyError` exposes `status`, `details` and `request_id`. A timeout or transport failure has status `0`. Close clients with `close()` / `await aclose()` or use the context managers above. Options include `base_url` (full client API prefix), `timeout` in seconds and an injectable `httpx` transport. No automatic retries.

SMS amounts (`balance`, `cost`, `unit_price`, `amount_reserved`, ...) are `float` values in **points** (1 point = 1 EUR, up to 3 decimals), with `unit == 'point'` on the object.

TypedDict request and response contracts are exported from `weezy.types`. They support editor/type-checker assistance; runtime validation remains on the API.

## WhatsApp account access

WhatsApp is disabled by default for every customer account. An administrator must enable it for that customer before WhatsApp API credentials and methods can be used. Existing credentials do not bypass this account setting. The API returns HTTP 404 when WhatsApp access is unavailable; a 404 can also mean a missing resource. The SDK preserves this error and does not retry or enable access. SMS access is independent. Enabled accounts still need valid credential scopes, a subscription and a connected instance.

The SDK only covers the public client API: account activation and Google OAuth login belong to the dashboard and are not SDK methods.
