@@ -53,6 +53,10 @@ def _run_method(self, method, url, data=None, query=None, headers=None):
53
53
if headers is None :
54
54
headers = {}
55
55
56
+ # Support v3
57
+ if self .api_path and 'v3' in self .api_path :
58
+ url = 'catalog/{}' .format (url )
59
+
56
60
# make full path if not given
57
61
if url and url [:4 ] != "http" :
58
62
if url [0 ] == '/' : # can call with /resource if you want
@@ -156,6 +160,9 @@ def _handle_response(self, url, res, suppress_empty=True):
156
160
if res .status_code in (200 , 201 , 202 ):
157
161
try :
158
162
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
159
166
except Exception as e : # json might be invalid, or store might be down
160
167
e .message += " (_handle_response failed to decode JSON: " + str (res .content ) + ")"
161
168
raise # TODO better exception
@@ -187,11 +194,11 @@ class OAuthConnection(Connection):
187
194
"""
188
195
189
196
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 ):
191
198
self .client_id = client_id
192
199
self .store_hash = store_hash
193
200
self .host = host
194
- self .api_path = api_path
201
+ self .api_path = api_path if api_path else "/stores/{}/v2/{}"
195
202
self .timeout = 7.0 # can attach to session?
196
203
self .rate_limiting_management = rate_limiting_management
197
204
0 commit comments