Metadata-Version: 2.5
Name: brivio
Version: 0.1.0
Summary: Official Brivio SDK — invoicing, e-Factura, contacts and more for the Romanian market
Project-URL: Homepage, https://brivio.ro
Project-URL: Documentation, https://brivio.ro/developers/docs
Project-URL: Source, https://github.com/brivio-ro/brivio-sdk-python
Project-URL: Issues, https://github.com/brivio-ro/brivio-sdk-python/issues
Author-email: Brivio <dev@brivio.ro>
License: MIT
Keywords: anaf,brivio,e-factura,efactura,invoicing,romania
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Accounting
Requires-Python: >=3.9
Requires-Dist: pydantic<3,>=2
Requires-Dist: python-dateutil>=2.8
Requires-Dist: typing-extensions>=4.7
Requires-Dist: urllib3<3,>=2.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# Brivio SDK for Python

Official Python client for the [Brivio](https://brivio.ro) API — invoicing,
e-Factura, contacts, articles and more, for the Romanian market.

```bash
pip install brivio
```

## Quick start

```python
from brivio import Brivio

client = Brivio(api_key="brivio_sk_live_…")

# Verify the key and see which organization it belongs to.
print(client.me())

# One page, with pagination metadata.
page = client.contacts.list(search="srl")
print(f"{len(page)} of {page.total} contacts")

# Or walk every page lazily — no manual page arithmetic.
for contact in client.contacts.iterate(search="srl"):
    print(contact["name"])
```

## Invoicing

```python
invoice = client.invoices.create(
    {
        "contactId": "ct_123",
        "currency": "RON",
        "lines": [{"description": "Consultanță", "quantity": 1, "unitPrice": 1000, "vatRate": 21}],
    },
    # Safe to retry: the same key never creates a second invoice.
    idempotency_key="order-42",
)

client.invoices.send(invoice["id"])
client.invoices.submit_efactura(invoice["id"])
print(client.invoices.efactura_status(invoice["id"]))
```

## Errors

Every failure raises `BrivioError`:

```python
from brivio import Brivio, BrivioError

try:
    client.contacts.create({})
except BrivioError as err:
    print(err.code)     # "VALIDATION_ERROR"
    print(err.status)   # 422
    print(err.details)  # {"name": ["required"]}
```

`status == 0` means the request never reached the API (DNS, connection reset,
timeout) rather than the API rejecting it.

## Retries and timeouts

Transient failures (`429`, `502`, `503`, `504`, network errors) are retried
automatically — twice by default — with exponential backoff plus jitter, and
`Retry-After` is honoured on `429`. Other 4xx responses are **not** retried:
they fail identically every time.

```python
client = Brivio(
    api_key="…",
    max_retries=5,   # 0 disables
    timeout=10.0,    # seconds; 0 disables
    base_url="https://api.brivio.ro/v1",
)
```

## Endpoints without a helper

The typed resources cover the common surface. Anything else is one call away
and still gets retries, error mapping and envelope unwrapping:

```python
zones = client.request("GET", "/dns/zones")
```

## Typed models

Generated Pydantic models for every schema in the API live under
`brivio._generated.models`:

```python
from brivio._generated.models.contact import Contact

contact = Contact.from_dict(client.contacts.get("ct_123"))
print(contact.name)
```

## How this SDK is built

Models and operation signatures are generated from the published OpenAPI
spec; the transport (retries, errors, pagination, idempotency) is
hand-written so every official Brivio SDK behaves identically. See
[`SDK_CONTRACT.md`](https://github.com/dragoscv/brivio/blob/main/docs/SDK_CONTRACT.md).

## Links

- API reference — <https://brivio.ro/developers/docs>
- Other SDKs — [TypeScript](https://www.npmjs.com/package/@brivio/sdk), [PHP](https://packagist.org/packages/brivio/sdk)

MIT © Brivio
