Metadata-Version: 2.5
Name: ens_sdk
Version: 0.2.2
Summary: An SDK to simplify connectivity to ENS Services
Project-URL: Homepage, https://github.com/enciphertz/encipher-notification-service-python-sdk
Project-URL: Bug Tracker, https://github.com/enciphertz/encipher-notification-service-python-sdk/issues
Author-email: Joseph Daudi <joseph@encipher.dev>
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Requires-Dist: esr-sdk
Requires-Dist: pydantic
Requires-Dist: python-decouple
Requires-Dist: pytz
Requires-Dist: redis
Requires-Dist: requests
Requires-Dist: sentry-sdk
Description-Content-Type: text/markdown

# ENS Python SDK

One client for every product that sends through the Encipher Notification
Service. Credentials and tenant come from the environment (or explicit
constructor arguments); every send goes through OAuth client-credentials,
idempotency keys, and honest errors.

Email and WhatsApp travel by carrier v2 (metered, attributed). SMS travels
by legacy v1 (carrier has no SMS channel).

## Install

```bash
pip install ens_sdk
```

## Configure

```bash
ENS_SERVER_URL=https://ens.encipher.co.tz
ENS_CLIENT_ID=<oauth application client id>
ENS_CLIENT_SECRET=<oauth application client secret>
ENS_TENANT=<carrier tenant external id>   # email/WhatsApp only
ENS_TIMEOUT=10
```

## Use

```python
from ens_sdk import ENS

ens = ENS()  # reads the environment above

ens.send_email("a@example.com", "Shift closed", "Shift 7 closed.")
ens.send_whatsapp_template("+255700000000", "otp_login", "en", ["482916"])
ens.send_sms("+255700000000", "Your code is 482916")
```

Constructor arguments override the environment with the same names
(`ENS(server_url=..., client_id=..., client_secret=..., tenant=...,
timeout=...`).

## Errors

- `ENSUnreachable` -- transport failure talking to ENS.
- `ENSRefused` -- bad credentials, unknown tenant, missing tenant, bad payload.
- `ENSQuotaExceeded` -- the client's daily quota is reached (HTTP 429).
