-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05c2d31
Showing
11 changed files
with
501 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
__pycache__ | ||
__pycache__/ | ||
__pycache__/* | ||
*/__pycache__ | ||
*/__pycache__/ | ||
*/__pycache__/* | ||
*.pyc | ||
MYVENV | ||
MYVENV/ | ||
MYVENV/* | ||
.idea | ||
.idea/ | ||
.idea/* | ||
venv | ||
venv/ | ||
venv/* |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pybigcommerce.modules.customers import Customers | ||
from pybigcommerce.modules.store_info import StoreInfo | ||
|
||
|
||
class BigCommerceModel: | ||
|
||
def __init__(self, store_hash, access_token): | ||
self.customer = Customers(store_hash, access_token) | ||
self.store_info = StoreInfo(store_hash, access_token) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import requests | ||
|
||
|
||
class Connection: | ||
|
||
def __init__(self, store_hash, access_token): | ||
self.endpoint = 'https://api.bigcommerce.com/stores' | ||
self.session = requests.session() | ||
self.store_hash = store_hash | ||
self.headers = { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json", | ||
"X-Auth-Client": access_token, | ||
"X-Auth-Token": access_token | ||
} | ||
|
||
def get_method(self, uri, params=None, version='v2'): | ||
url = "{0}/{1}/{2}".format(self.endpoint, self.store_hash, version) + uri | ||
resp = self.session.get(url, headers=self.headers, params=params) | ||
if resp.status_code == 200: | ||
result = resp.json() | ||
else: | ||
result = False | ||
return result | ||
|
||
def delete_method(self, uri, params=None, version='v2'): | ||
url = "{0}/{1}/{2}".format(self.endpoint, self.store_hash, version) + uri | ||
resp = self.session.delete( | ||
url, headers=self.headers, params=params) | ||
if resp.status_code == 200: | ||
result = resp.json() | ||
else: | ||
result = False | ||
return result | ||
|
||
def post_method(self, uri, data, version='v2'): | ||
|
||
url = "{0}/{1}/{2}".format(self.endpoint, self.store_hash, version) + uri | ||
resp = self.session.post( | ||
url, headers=self.headers, data=data) | ||
if resp.status_code == 200 or resp.status_code == 201: | ||
result = resp.json() | ||
else: | ||
result = False | ||
return result | ||
|
||
def put_method(self, uri, data, version='v2'): | ||
|
||
url = "{0}/{1}/{2}".format(self.endpoint, self.store_hash, version) + uri | ||
resp = self.session.put( | ||
url, headers=self.headers, data=data) | ||
if resp.status_code == 200 or resp.status_code == 201: | ||
result = resp.json() | ||
else: | ||
result = False | ||
return result |
Empty file.
Oops, something went wrong.