Permalink
Browse files

Grouped imports into package

  • Loading branch information...
bc-jackiehuynh committed Dec 4, 2013
1 parent 1f3953d commit b48394fe3be0fccbd10b79114c418982d9e17ae1
Showing with 18 additions and 10 deletions.
  1. +1 −1 LICENSE
  2. +7 −1 README.md
  3. +4 −1 bigcommerce/__init__.py
  4. +3 −3 bigcommerce/connection.py
  5. +2 −0 example/script.py
  6. +1 −4 tests/test.py
View
@@ -1,4 +1,4 @@
-Copyright (C) BigCommerce, 2011.
+Copyright (C) BigCommerce, 2013.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
View
@@ -25,13 +25,19 @@ See http://developer.bigcommerce.com/docs/api/v2/resources for all resources.
The options/filters for some requests can be passed in as a dictionary (see 'Retrieving').
#### Setup
+Modules
```
-# import everything
+from bigcommerce import *
+
+# the above is equivalent to:
from bigcommerce.connection import Connection
from bigcommerce.httpexception import *
from bigcommerce.resource import *
from bigcommerce.subresource import *
+```
+Set-up connection:
+```
Connection.host = YOUR_STORE # eg. 'mystore.bigcommerce.com
Connection.user = USER # eg. 'admin'
Connection.api_key = API_KEY # eg. 'a2e777fbb2d98fd04461d700463a8ed71782e475'
View
@@ -1 +1,4 @@
-# Initialize bigcommerce.api
+from bigcommerce.connection import Connection
+from bigcommerce.httpexception import *
+from bigcommerce.resource import *
+from bigcommerce.subresource import *
@@ -48,7 +48,7 @@ class Connection(object):
api_key = API_KEY
proxies = None
- json_headers = {'Content-type':'application/json'}
+ req_headers = {'Content-type':'application/json'}
# TODO: let user close the session
@@ -86,7 +86,7 @@ def delete(self, req_path, options=None):
def post(self, req_path, data, options=None):
if options: req_path = self._join_options(req_path, options)
- r = requests.post(self.full_path(req_path), auth=self.auth_pair, headers=self.json_headers, data=data)
+ r = requests.post(self.full_path(req_path), auth=self.auth_pair, headers=self.req_headers, data=data)
ex = self._check_response(r)
if ex:
ex.message = "POST request failed:" + ex.message
@@ -96,7 +96,7 @@ def post(self, req_path, data, options=None):
def put(self, req_path, data, options=None):
if options: req_path = self._join_options(req_path, options)
- r = requests.put(self.full_path(req_path), auth=self.auth_pair, headers=self.json_headers, data=data)
+ r = requests.put(self.full_path(req_path), auth=self.auth_pair, headers=self.req_headers, data=data)
ex = self._check_response(r)
if ex:
ex.message = "PUT request failed:" + ex.message
View
@@ -1,3 +1,5 @@
+from bigcommerce import *
+
HOST = 'somestore.bigcommerce.com'
USER = 'admin'
KEY = 'asdfhahahahauehauheau'
View
@@ -1,7 +1,4 @@
-from bigcommerce.connection import Connection
-from bigcommerce.httpexception import *
-from bigcommerce.resource import *
-from bigcommerce.subresource import *
+from bigcommerce import *
import unittest
import vcr

0 comments on commit b48394f

Please sign in to comment.