Metadata-Version: 2.4
Name: msgly-sdk
Version: 0.1.0
Summary: Python SDK for Msgly API
Home-page: https://github.com/yourusername/msgly-sdk-python
Author: Your Name
Author-email: your.email@example.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.20.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Msgly Python SDK

Official Python SDK for the [Msgly API](https://msgly.id). Provides simple OAuth2 authentication and WhatsApp OTP / Single messaging capabilities for Python 3.7+.

## Installation

```bash
pip install msgly-sdk
```

## Quick Start

```python
from msgly import MsglyClient

# Inisialisasi Client
client = MsglyClient(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    base_url="https://api.msgly.id" # Opsional, default https://api.msgly.id
)

# ------------------------------------------------------------
# 1. Send OTP (Mode 1: OTP Rotation Aktif)
# Server otomatis merotasi template WhatsApp. Cukup kirim code.
# ------------------------------------------------------------
try:
    response = client.message.send_otp(
        xid="otp_001",
        to="6281234567890",
        code="482910"
    )
    print("OTP Sent (Rotation):", response)
except Exception as e:
    print("Error sending OTP:", e)

# ------------------------------------------------------------
# 2. Send OTP (Mode 2: Manual Template Selection)
# Wajib sertakan template_id dan params jika Rotation nonaktif.
# ------------------------------------------------------------
try:
    response = client.message.send_otp(
        xid="otp_manual_001",
        to="6281234567890",
        template_id="c8f7a1b2-3c4d-5e6f-7a8b-9c0d1e2f3a4b",
        params=["482910"]
    )
    print("OTP Sent (Manual):", response)
except Exception as e:
    print("Error sending OTP:", e)

# ------------------------------------------------------------
# 3. Manage Templates (List & Get Detail)
# ------------------------------------------------------------
try:
    templates = client.template.list(search="OTP", page=1, per_page=10)
    print("Templates:", templates)

    if templates.get("data", {}).get("data"):
        template_id = templates["data"]["data"][0]["id"]
        detail = client.template.get_by_id(template_id)
        print("Template Detail:", detail)
except Exception as e:
    print("Error fetching templates:", e)
```

## License

ISC

