Skip to content

Commit

Permalink
Project formatted to python package.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Karpitsky committed Jul 25, 2013
1 parent 75ab3dc commit 1634212
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*~
*.pyc
build/*
dist/*
*/dist/*
*.egg
*.egg-info
src/*.egg-info/*
24 changes: 24 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2013 Marco Londero <marco.londero@linux.it>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
3 changes: 0 additions & 3 deletions README

This file was deleted.

63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
nexmomessage
============


A Python wrapper for the [Nexmo API](https://www.nexmo.com/documentation/api/index.html).


Installation
------------

$ pip install -e git+https://github.com/marcuz/libpynexmo.git#egg=nexmomessage


Quick start (sending a message)
-------------------------------

First you need to load up the package and construct a dictionary
with your API credentials and message, like this:

```python
from nexmomessage import NexmoMessage

msg = {
'reqtype': 'json',
'api_key': YOUR_API_KEY,
'api_secret': YOUR_API_SECRET_KEY,
'from': YOUR_PHONE_NUMBER,
'to': DESTINATION_PHONE_NUMBER,
'text': 'Hello world!'
}
sms = NexmoMessage(msg)
sms.set_text_info(msg['text'])
```

Then you have a choice. For a "fire and forget" approach to sending a message,
use the `send_message` method, like this:

```python
sms.send_request()
```

This method call returns the message data if the message was sent successfully,
or return Flase if there was an error.

```python
response = sms.send_request()

if response:
# do something with response data
else:
# handle the error
```


Troubleshooting
---------------

Remember that phone numbers should be specified in international format.

The Nexmo documentation contains a [list of error codes](http://nexmo.com/documentation/index.html#response_code)
which may be useful if you have problems sending a message.

Please report all bugs/issues via the GitHub issue tracker.
File renamed without changes.
1 change: 1 addition & 0 deletions nexmomessage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from nexmo import NexmoMessage
2 changes: 2 additions & 0 deletions nexmomessage.py → nexmomessage/nexmo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 Marco Londero <marco.londero@linux.it>
# All rights reserved.
Expand Down
20 changes: 20 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python

try:
from setuptools import setup
except ImportError:
from distutils.core import setup

VERSION = '0.1.0'

setup(
name='nexmomessage',
version=VERSION,
description='A Python wrapper for the Nexmo API',
author='Marco Londero',
author_email='marco.londero@linux.it',
license='BSD',
url='https://github.com/marcuz/libpynexmo',
keywords=['Nexmo', 'Python'],
packages=['nexmomessage'],
)

0 comments on commit 1634212

Please sign in to comment.