From b99cca58c317ae245ffc499b8dba59ebe438534b Mon Sep 17 00:00:00 2001 From: Hugh Topping Date: Sun, 20 Aug 2017 17:01:07 +0100 Subject: [PATCH] Change the way credentials are passed in and bump version --- .gitignore | 3 ++- README.md | 12 +++++++----- setup.py | 4 ++-- spektrixpython.ini.sample | 4 ---- spektrixpython/spektrixpython.py | 13 ++++--------- 5 files changed, 15 insertions(+), 21 deletions(-) delete mode 100644 spektrixpython.ini.sample diff --git a/.gitignore b/.gitignore index 663c775..b64f1fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -spektrixpython.ini dist/* +*.pyc +.idea/* \ No newline at end of file diff --git a/README.md b/README.md index 521d0ba..6967031 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,21 @@ replacing `` 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) @@ -31,7 +33,7 @@ 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 diff --git a/setup.py b/setup.py index 0010046..bfec545 100644 --- a/setup.py +++ b/setup.py @@ -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 = 'hugh@hugh.io', 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 = [] diff --git a/spektrixpython.ini.sample b/spektrixpython.ini.sample deleted file mode 100644 index a8cfdb8..0000000 --- a/spektrixpython.ini.sample +++ /dev/null @@ -1,4 +0,0 @@ -[spektrix] -spektrix_system = XXXXXX -spektrix_api_user = XXXXXX -spektrix_api_key = XXXXXX diff --git a/spektrixpython/spektrixpython.py b/spektrixpython/spektrixpython.py index b72108f..28fbfc9 100644 --- a/spektrixpython/spektrixpython.py +++ b/spektrixpython/spektrixpython.py @@ -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