Skip to content

Commit 4d14ee7

Browse files
committed
Made first successful call to shipstation API
1 parent fbb3284 commit 4d14ee7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

shipstation.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from django.conf import settings
12
import requests
23

3-
44
class ShipStation:
55
"""
66
Handles the details of connecting to and querying a ShipStation account.
@@ -14,16 +14,20 @@ def __init__(self, key=None, secret=None):
1414
self.url = 'https://ssapi.shipstation.com'
1515

1616
if key is None:
17-
raise AttributeError('Key must be supplied.')
17+
self.key = settings.SHIPSTATION_SETTINGS.get('key')
18+
if self.key is None:
19+
raise AttributeError('Key must be supplied.')
1820
else:
1921
self.key = key
2022

2123
if secret is None:
22-
raise AttributeError('Secret must be supplied.')
24+
self.secret = settings.SHIPSTATION_SETTINGS.get('secret')
25+
if self.key is None:
26+
raise AttributeError('Key must be supplied.')
2327
else:
2428
self.secret = secret
2529

2630
def get(self, endpoint):
27-
url = '{}/{}'.format(self.url, endpoint)
28-
r = requests.get(url, auth=(self.secret, self.key))
29-
print r
31+
url = '{}{}'.format(self.url, endpoint)
32+
r = requests.get(url, auth=(self.key, self.secret))
33+
print r.json()

0 commit comments

Comments
 (0)