Skip to content

Commit

Permalink
Grouped imports into package
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-jackiehuynh committed Dec 4, 2013
1 parent 1f3953d commit b48394f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (C) BigCommerce, 2011. Copyright (C) BigCommerce, 2013.
All rights reserved. All rights reserved.


Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -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'). The options/filters for some requests can be passed in as a dictionary (see 'Retrieving').


#### Setup #### Setup
Modules
``` ```
# import everything from bigcommerce import *
# the above is equivalent to:
from bigcommerce.connection import Connection from bigcommerce.connection import Connection
from bigcommerce.httpexception import * from bigcommerce.httpexception import *
from bigcommerce.resource import * from bigcommerce.resource import *
from bigcommerce.subresource import * from bigcommerce.subresource import *
```


Set-up connection:
```
Connection.host = YOUR_STORE # eg. 'mystore.bigcommerce.com Connection.host = YOUR_STORE # eg. 'mystore.bigcommerce.com
Connection.user = USER # eg. 'admin' Connection.user = USER # eg. 'admin'
Connection.api_key = API_KEY # eg. 'a2e777fbb2d98fd04461d700463a8ed71782e475' Connection.api_key = API_KEY # eg. 'a2e777fbb2d98fd04461d700463a8ed71782e475'
Expand Down
5 changes: 4 additions & 1 deletion bigcommerce/__init__.py
@@ -1 +1,4 @@
# Initialize bigcommerce.api from bigcommerce.connection import Connection
from bigcommerce.httpexception import *
from bigcommerce.resource import *
from bigcommerce.subresource import *
6 changes: 3 additions & 3 deletions bigcommerce/connection.py
Expand Up @@ -48,7 +48,7 @@ class Connection(object):
api_key = API_KEY api_key = API_KEY
proxies = None proxies = None


json_headers = {'Content-type':'application/json'} req_headers = {'Content-type':'application/json'}


# TODO: let user close the session # TODO: let user close the session


Expand Down Expand Up @@ -86,7 +86,7 @@ def delete(self, req_path, options=None):


def post(self, req_path, data, options=None): def post(self, req_path, data, options=None):
if options: req_path = self._join_options(req_path, options) 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) ex = self._check_response(r)
if ex: if ex:
ex.message = "POST request failed:" + ex.message ex.message = "POST request failed:" + ex.message
Expand All @@ -96,7 +96,7 @@ def post(self, req_path, data, options=None):


def put(self, req_path, data, options=None): def put(self, req_path, data, options=None):
if options: req_path = self._join_options(req_path, options) 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) ex = self._check_response(r)
if ex: if ex:
ex.message = "PUT request failed:" + ex.message ex.message = "PUT request failed:" + ex.message
Expand Down
2 changes: 2 additions & 0 deletions example/script.py
@@ -1,3 +1,5 @@
from bigcommerce import *

HOST = 'somestore.bigcommerce.com' HOST = 'somestore.bigcommerce.com'
USER = 'admin' USER = 'admin'
KEY = 'asdfhahahahauehauheau' KEY = 'asdfhahahahauehauheau'
Expand Down
5 changes: 1 addition & 4 deletions tests/test.py
@@ -1,7 +1,4 @@
from bigcommerce.connection import Connection from bigcommerce import *
from bigcommerce.httpexception import *
from bigcommerce.resource import *
from bigcommerce.subresource import *


import unittest import unittest
import vcr import vcr
Expand Down

0 comments on commit b48394f

Please sign in to comment.