Metadata-Version: 2.4
Name: chamapay
Version: 1.0.0
Summary: Official Python SDK for ChamaPay API — Financial Infrastructure for African Savings Groups
Author-email: ChamaPay <api-support@chamapay.co.ke>
License: MIT
Project-URL: Homepage, https://chamapay.co.ke
Project-URL: Documentation, https://api.chamapay.co.ke/docs
Project-URL: Source, https://github.com/chamapay/chamapay-python
Keywords: chamapay,sacco,savings,mpesa,africa,fintech
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25.0

# ChamaPay Python SDK

Official Python SDK for the ChamaPay API.

## Installation

```bash
pip install chamapay
```

## Usage

```python
from chamapay import ChamaPay

api = ChamaPay('cpk_live_your_api_key', 'your_api_secret')

# List members
members = api.members.list(status='Active', page=1, limit=20)

# Create a contribution (idempotent)
contribution = api.contributions.create(
    {'member_id': 'MFT001', 'amount': 5000},
    idempotency_key='550e8400-e29b-41d4-a716-446655440000'
)

# Get loan details
loan = api.loans.get('LN001')
```

## API Reference

| Resource           | Methods                                    |
|--------------------|--------------------------------------------|
| members            | list, get, create, update, delete          |
| contributions      | list, get, create (with idempotency key)   |
| loans              | list, get, create                          |
| fines              | list, create                               |
| meetings           | list, create                               |
| projects           | list, create                               |
| accounts           | list, get                                  |
| welfare            | list                                       |
| dividends          | list                                       |
| documents          | list                                       |
| election_notices   | list                                       |
| document_reminders | list                                       |
| audit              | list                                       |
| liabilities        | list, create                               |
| reports            | get                                        |

## Error Handling

```python
from chamapay import ChamaPayError, ValidationError, RateLimitError

try:
    api.members.create({...})
except ValidationError as e:
    print(f"Validation failed: {e.details}")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except ChamaPayError as e:
    print(f"API Error [{e.code}]: {e.message}")
```

## Publishing

```bash
pip install build twine
python -m build
twine upload dist/*
```

Requires a PyPI account with access to the `chamapay` package.
