@@ -53,6 +53,10 @@ def _run_method(self, method, url, data=None, query=None, headers=None):
5353 if headers is None :
5454 headers = {}
5555
56+ # Support v3
57+ if self .api_path and 'v3' in self .api_path :
58+ url = 'catalog/{}' .format (url )
59+
5660 # make full path if not given
5761 if url and url [:4 ] != "http" :
5862 if url [0 ] == '/' : # can call with /resource if you want
@@ -156,6 +160,9 @@ def _handle_response(self, url, res, suppress_empty=True):
156160 if res .status_code in (200 , 201 , 202 ):
157161 try :
158162 result = res .json ()
163+ # Support v3
164+ if self .api_path and 'v3' in self .api_path :
165+ result = result ['data' ] #TODO ignore meta field for now
159166 except Exception as e : # json might be invalid, or store might be down
160167 e .message += " (_handle_response failed to decode JSON: " + str (res .content ) + ")"
161168 raise # TODO better exception
@@ -187,11 +194,11 @@ class OAuthConnection(Connection):
187194 """
188195
189196 def __init__ (self , client_id , store_hash , access_token = None , host = 'api.bigcommerce.com' ,
190- api_path = '/stores/{}/v2/{}' , rate_limiting_management = None ):
197+ api_path = None , rate_limiting_management = None ):
191198 self .client_id = client_id
192199 self .store_hash = store_hash
193200 self .host = host
194- self .api_path = api_path
201+ self .api_path = api_path if api_path else "/stores/{}/v2/{}"
195202 self .timeout = 7.0 # can attach to session?
196203 self .rate_limiting_management = rate_limiting_management
197204
0 commit comments