Metadata-Version: 2.4
Name: trimis-python
Version: 1.0.0
Summary: Official Trimis SDK for Python - Send emails, push notifications, and chat messages
Home-page: https://github.com/trimis-ro/trimis-python
Author: Trimis.ro
Author-email: support@trimis.ro
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Communications :: Email
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28.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

# Trimis Python SDK

Official Python SDK for [Trimis.ro](https://trimis.ro) - Send emails, push notifications, and chat messages.

## Installation

```bash
pip install trimis-python
```

## Quick Start

```python
from trimis import TrimisClient

client = TrimisClient("YOUR_API_KEY")

# Send an email
result = client.send_email(
    to="recipient@example.com",
    from_email="sender@yourdomain.com",
    subject="Hello!",
    html="<h1>Hello World</h1>",
    text="Hello World"
)

if result["success"]:
    print("Email sent!", result["data"])
else:
    print("Error:", result["error"])
```

## Email API

```python
# Send email
result = client.send_email(
    to="user@example.com",
    from_email="noreply@yourdomain.com",
    subject="Welcome!",
    html="<h1>Welcome</h1>",
    text="Welcome",
    track_opens=True,
    track_clicks=True
)
```

## Notification Hub API

```python
# Send notification with template
result = client.send_notification(
    to="user@example.com",
    from_email="noreply@yourdomain.com",
    template="welcome_email",
    variables={
        "name": "John Doe",
        "activation_link": "https://app.com/activate?token=abc123"
    }
)

# Get notification status
notification = client.get_notification("notif_123")
```

## Push Notifications API

```python
# Get VAPID key
vapid = client.get_vapid_key()

# Subscribe user
client.subscribe_push(
    user_id="user123",
    platform="web",
    subscription={
        "endpoint": "https://fcm.googleapis.com/...",
        "keys": {
            "p256dh": "...",
            "auth": "..."
        }
    }
)

# Send push notification
client.send_push(
    user_ids=["user123", "user456"],
    title="New Message",
    body="You have a new message",
    url="https://app.com/messages"
)
```

## Chat API

```python
# Create conversation
conversation = client.create_conversation(
    conversation_type="direct",
    participants=[
        {"user_id": "user1", "name": "Alice"},
        {"user_id": "user2", "name": "Bob"}
    ]
)

# Send message
client.send_message(
    conversation_id=conversation["data"]["conversation_id"],
    sender_id="user1",
    content="Hello!"
)

# Get messages
messages = client.get_messages(conversation["data"]["conversation_id"])

# Mark as read
client.mark_message_read("msg_123", "user2")
```

## Django Integration

```python
# settings.py
TRIMIS_API_KEY = os.getenv("TRIMIS_API_KEY")

# In your views or tasks
from trimis import TrimisClient

client = TrimisClient(settings.TRIMIS_API_KEY)
client.send_email(...)
```

## Flask Integration

```python
from flask import Flask
from trimis import TrimisClient

app = Flask(__name__)
app.config["TRIMIS_API_KEY"] = os.getenv("TRIMIS_API_KEY")

client = TrimisClient(app.config["TRIMIS_API_KEY"])
```

## Error Handling

```python
result = client.send_email(...)

if not result["success"]:
    print(f"Error: {result['error']}")
    print(f"Status: {result.get('status')}")
```

## License

MIT

## Links

- [Documentation](https://trimis.ro/docs)
- [GitHub Repository](https://github.com/trimis-ro/trimis-python)
- [Website](https://trimis.ro)
