## status
BETA - this client implements v1_0 of SWU API and is functional and tested
[![Build Status](https://travis-ci.org/sendwithus/sendwithus_python.png)](https://travis-ci.org/sendwithus/sendwithus_python)
## requirements
python requests library
- ## installation
- pip install sendwithus
- ## to run tests
- python setup.py test
## usage
For all examples, assume:
`python
import sendwithus
api = sendwithus.api(api_key='YOUR-API-KEY')
`
### Call with REQUIRED parameters only
The email_data field is optional, but highly recommended!
```python
r = api.send(
System Message: WARNING/2 (<string>, line 29); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 29); backlink
Inline interpreted text or phrase reference start-string without end-string.
System Message: ERROR/3 (<string>, line 31)
Unexpected indentation.
email_id='YOUR-EMAIL-ID',
recipient={'address': 'us@sendwithus.com'})
System Message: WARNING/2 (<string>, line 33)
Block quote ends without a blank line; unexpected unindent.
print r.status_code
# 200
```
System Message: WARNING/2 (<string>, line 33); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 33); backlink
Inline interpreted text or phrase reference start-string without end-string.
### Call with REQUIRED parameters and email_data
```python
r = api.send(
System Message: WARNING/2 (<string>, line 37); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 37); backlink
Inline interpreted text or phrase reference start-string without end-string.
System Message: ERROR/3 (<string>, line 40)
Unexpected indentation.
email_id='YOUR-EMAIL-ID',
recipient={'address': 'us@sendwithus.com'},
email_data={ 'first_name': 'Matt' })
System Message: WARNING/2 (<string>, line 43)
Block quote ends without a blank line; unexpected unindent.
print r.status_code
# 200
```
System Message: WARNING/2 (<string>, line 43); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 43); backlink
Inline interpreted text or phrase reference start-string without end-string.
### Optional Sender
The sender['address'] is a required sender field
```python
r = api.send(
System Message: WARNING/2 (<string>, line 50); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 50); backlink
Inline interpreted text or phrase reference start-string without end-string.
System Message: ERROR/3 (<string>, line 52)
Unexpected indentation.
email_id='YOUR-EMAIL-ID',
recipient={ 'name': 'Matt',
System Message: ERROR/3 (<string>, line 54)
Unexpected indentation.
'address': 'us@sendwithus.com'},
System Message: WARNING/2 (<string>, line 55)
Block quote ends without a blank line; unexpected unindent.
email_data={ 'first_name': 'Matt' },
sender={ 'address':'company@company.com' })
System Message: WARNING/2 (<string>, line 57)
Block quote ends without a blank line; unexpected unindent.
print r.status_code
# 200
```
System Message: WARNING/2 (<string>, line 57); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 57); backlink
Inline interpreted text or phrase reference start-string without end-string.
### Optional Sender with reply_to address
sender['name'] and sender['reply_to'] are both optional
```python
r = api.send(
System Message: WARNING/2 (<string>, line 64); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 64); backlink
Inline interpreted text or phrase reference start-string without end-string.
System Message: ERROR/3 (<string>, line 66)
Unexpected indentation.
email_id='YOUR-EMAIL-ID',
recipient={ 'name': 'Matt',
System Message: ERROR/3 (<string>, line 68)
Unexpected indentation.
'address': 'us@sendwithus.com'},
System Message: WARNING/2 (<string>, line 69)
Block quote ends without a blank line; unexpected unindent.
email_data={ 'first_name': 'Matt' },
sender={ 'name': 'Company',
System Message: ERROR/3 (<string>, line 71)
Unexpected indentation.
'address':'company@company.com',
'reply_to':'info@company.com'})
System Message: WARNING/2 (<string>, line 73)
Block quote ends without a blank line; unexpected unindent.
print r.status_code
# 200
```
System Message: WARNING/2 (<string>, line 73); backlink
Inline literal start-string without end-string.
System Message: WARNING/2 (<string>, line 73); backlink
Inline interpreted text or phrase reference start-string without end-string.
## expected response
- ### Success
>>> r.status_code
200
>>> r.json().get('success')
True
>>> r.json().get('status')
u'OK'
>>> r.json().get('receipt_id')
u'numeric-receipt-id'
### Error cases
* malformed request
>>> r.status_code
400
bad api key
>>> r.status_code
System Message: WARNING/2 (<string>, line 101)
Block quote ends without a blank line; unexpected unindent.
403
email_id not found
>>> r.status_code
404
- ### packaging (internal)
- python setup.py sdist upload