Metadata-Version: 2.4
Name: merit-api
Version: 0.5.5
Summary: Python client for Merit Aktiva API
Project-URL: Homepage, https://github.com/jaakla/merit_api
Project-URL: Repository, https://github.com/jaakla/merit_api
Project-URL: Issues, https://github.com/jaakla/merit_api/issues
Project-URL: Changelog, https://github.com/jaakla/merit_api/blob/main/CHANGELOG.md
Author-email: Jaak Laineste <jaak.laineste@gmail.com>
License: MIT
Keywords: accounting,aktiva,api,estonia,invoicing,merit
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.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.10
Requires-Dist: requests>=2.31.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: python-dotenv>=1.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# merit-api

Python SDK for the Merit Aktiva API.

## Installation

```bash
pip install merit-api
```

## Usage

```python
from merit_api import MeritAPI

client = MeritAPI(api_id="YOUR_API_ID", api_key="YOUR_API_KEY")

customers = client.customers.get_list()
invoices = client.sales.get_invoices(
    PeriodStart="2024-01-01",
    PeriodEnd="2024-01-31",
)
```

## Features

- deterministic request-body serialization for signing
- configurable timeout and retry handling — retries apply only to idempotent requests;
  mutating writes (create invoice, create payment, …) are **never** retried automatically,
  because Merit does not deduplicate a POST that timed out after the server already
  committed it, so a replay would create a duplicate. This holds even when an
  `Idempotency-Key` is supplied, since Merit does not honor the header.
- request and response logging hooks with secret redaction
- optional idempotency header generation. **Note:** Merit's API does not deduplicate on
  this header, so it is not a duplicate-prevention guarantee — it only prepares for servers
  that honor it. Real protection comes from the duplicate guards below.
- duplicate-write guards for purchase invoices and payments: by default
  `purchases.send_invoice` refuses a second invoice with the same vendor + `BillNo`, and
  `financial.create_payment` refuses a second payment referencing the same `BillNo` and
  amount. Pass `allow_duplicate=True` to override.
- API-level business error parsing from HTTP 200 responses

## Testing and method coverage report

Run tests:

```bash
pytest -q
```

Regenerate the method-level read/write coverage report:

```bash
python scripts_report_method_test_coverage.py
```

The report is written to `reports/method_test_coverage.md` and CI checks that this file stays up to date.
