Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
JamessenLiu committed Aug 10, 2020
0 parents commit 05c2d31
Show file tree
Hide file tree
Showing 11 changed files with 501 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
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 added pybigcommerce/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions pybigcommerce/bigcommerce.py
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)






56 changes: 56 additions & 0 deletions pybigcommerce/connector.py
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.
Loading

0 comments on commit 05c2d31

Please sign in to comment.