Skip to content

Commit

Permalink
Change the way credentials are passed in and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
hughtopping committed Aug 20, 2017
1 parent 73dcabe commit b99cca5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spektrixpython.ini
dist/*
*.pyc
.idea/*
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,29 @@ replacing `<clientname>` with your Spektrix system name.

`pip install spektrixpython`

Create a `spektrixpython.ini` config file from the `spektrixpython.ini.sample` template and fill in the details for your Spektrix system.

### Example

```python
from spektrixpython import SpektrixRequest

clientname = 'SPEKTRIX CLIENT NAME'
username = 'API USERNAME'
key = 'API KEY'

# Get a list of events
events = SpektrixRequest('events').get()
events = SpektrixRequest('events', clientname, username, key).get()
print events

# Create a new basket
basket = SpektrixRequest('baskets').post()['id']
basket = SpektrixRequest('baskets', clientname, username, key).post()['id']

# Add a merchandise item to the newly created basket
endpoint = 'baskets/{}/merchandise'.format(basket)

# Replace this stockItem Id with one from your Spektrix system.
payload = {'stockItem':'1AHGJDSMMPLMPPGNLJBQVLBRSKVDLQRPP'}

SpektrixRequest(endpoint).post(payload)
SpektrixRequest(endpoint, clientname, username, key).post(payload)
```

## License
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
name = 'spektrixpython',
packages = ['spektrixpython'],
install_requires = ['requests'],
version = '0.1.7',
version = '0.2.0',
description = 'A python module for interacting with Spektrix API v3.',
author = 'Hugh Topping',
author_email = '[email protected]',
url = 'https://github.com/hughtopping/spektrixpython',
download_url = 'https://github.com/hughtopping/spektrixpython/tarball/0.1.7',
download_url = 'https://github.com/hughtopping/spektrixpython/tarball/0.2.0',
keywords = ['spektrix','api','v3'],
license='MIT',
classifiers = []
Expand Down
4 changes: 0 additions & 4 deletions spektrixpython.ini.sample

This file was deleted.

13 changes: 4 additions & 9 deletions spektrixpython/spektrixpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
from hashlib import sha1, md5
import hmac
from base64 import b64encode, b64decode
from ConfigParser import SafeConfigParser

class SpektrixRequest(object):
def __init__(self, endpoint):

config = SafeConfigParser()
config.read('spektrixpython.ini')

spektrix_system = config.get('spektrix','spektrix_system')
class SpektrixRequest(object):
def __init__(self, endpoint, spektrix_system, spektrix_api_user, spektrix_api_key):

self.spektrix_api_user = config.get('spektrix', 'spektrix_api_user')
self.spektrix_api_key = config.get('spektrix', 'spektrix_api_key')
self.spektrix_api_user = spektrix_api_user
self.spektrix_api_key = spektrix_api_key

base_url = 'https://system.spektrix.com/' + spektrix_system + '/api/v3/'
self.url = base_url + endpoint
Expand Down

0 comments on commit b99cca5

Please sign in to comment.