Metadata-Version: 2.4
Name: isend-ai
Version: 1.0.0
Summary: Python SDK for isend.ai - Send emails easily using email connectors like SES, SendGrid, and more
Home-page: https://github.com/isend-ai/python-sdk
Author: isend.ai
Author-email: "isend.ai" <support@isend.ai>
License: MIT
Project-URL: Homepage, https://github.com/isend-ai/python-sdk
Project-URL: Repository, https://github.com/isend-ai/python-sdk
Project-URL: Documentation, https://github.com/isend-ai/python-sdk#readme
Project-URL: Bug Tracker, https://github.com/isend-ai/python-sdk/issues
Keywords: isend,email,sdk,ses,sendgrid,mailgun,postmark
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
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
Classifier: Topic :: Communications :: Email
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0.0; extra == "dev"
Requires-Dist: pytest-cov>=2.10.0; extra == "dev"
Requires-Dist: black>=21.0.0; extra == "dev"
Requires-Dist: flake8>=3.8.0; extra == "dev"
Requires-Dist: mypy>=0.800; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# isend.ai Python SDK

A simple Python SDK for sending emails through isend.ai using various email connectors like AWS SES, SendGrid, Mailgun, and more.

## Installation

### Using pip

```bash
pip install isend-ai
```

### From source

```bash
git clone https://github.com/isend-ai/python-sdk.git
cd python-sdk
pip install -e .
```

## Quick Start

```python
from isend import ISendClient

# Initialize the client
client = ISendClient('your-api-key-here')

# Send email using template
email_data = {
    'template_id': 124,
    'to': 'hi@isend.ai',
    'dataMapping': {
        'name': 'ISend'
    }
}

response = client.send_email(email_data)
print(response)
```

## Usage

### Send Email Using Template

```python
from isend import ISendClient

client = ISendClient('your-api-key-here')

email_data = {
    'template_id': 124,
    'to': 'hi@isend.ai',
    'dataMapping': {
        'name': 'ISend'
    }
}

response = client.send_email(email_data)
```

### Custom Configuration

```python
from isend import ISendClient

# Initialize with custom timeout
client = ISendClient('your-api-key-here', config={'timeout': 60})

email_data = {
    'template_id': 124,
    'to': 'hi@isend.ai',
    'dataMapping': {
        'name': 'ISend'
    }
}

response = client.send_email(email_data)
```

## API Reference

### ISendClient

#### Constructor
```python
ISendClient(api_key: str, config: Optional[Dict[str, Any]] = None)
```

**Parameters:**
- `api_key` (str): Your isend.ai API key
- `config` (dict, optional): Additional configuration options
  - `timeout` (int): Request timeout in seconds (default: 30)

#### Methods

##### send_email(email_data: Dict[str, Any]) -> Dict[str, Any]
Sends an email using the provided template and data.

**Parameters:**
- `email_data` (dict): Email data including:
  - `template_id` (int): The template ID to use
  - `to` (str): Recipient email address
  - `dataMapping` (dict): Data mapping for template variables

**Returns:**
- `dict`: Response from the API

## Error Handling

The SDK raises exceptions for any errors:

```python
from isend import ISendClient
import requests

try:
    client = ISendClient('your-api-key-here')
    response = client.send_email({
        'template_id': 124,
        'to': 'hi@isend.ai',
        'dataMapping': {
            'name': 'ISend'
        }
    })
    print("Email sent successfully!")
    print(response)
except ValueError as e:
    print(f"Validation error: {e}")
except requests.RequestException as e:
    print(f"Network error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")
```

## Examples

See the `examples/` directory for complete usage examples.

## Development

### Setup Development Environment

```bash
git clone https://github.com/isend-ai/python-sdk.git
cd python-sdk
pip install -r requirements-dev.txt
```

### Running Tests

```bash
# Run all tests
pytest

# Run tests with coverage
pytest --cov=isend

# Run tests with verbose output
pytest -v
```

### Code Formatting

```bash
# Format code with black
black .

# Check code style with flake8
flake8 .

# Type checking with mypy
mypy .
```

## Requirements

- Python 3.6 or higher
- requests library

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for your changes
5. Run the test suite
6. Submit a pull request

## Support

For support, email support@isend.ai or create an issue on GitHub.
