Skip to content

Commit 1dc7f68

Browse files
committed
cleanup version number default
1 parent c769b19 commit 1dc7f68

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

quickbooks/client.py

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,19 @@ def __new__(cls, **kwargs):
7676
if 'company_id' in kwargs:
7777
instance.company_id = kwargs['company_id']
7878

79-
if 'minorversion' in kwargs:
80-
instance.minorversion = kwargs['minorversion']
81-
82-
if instance.minorversion < instance.MINIMUM_MINOR_VERSION:
83-
warnings.warn(
84-
'Minor Version no longer supported.'
85-
'See: https://blogs.intuit.com/2025/01/21/changes-to-our-accounting-api-that-may-impact-your-application/',
86-
DeprecationWarning)
79+
# Handle minorversion with default
80+
instance.minorversion = kwargs.get('minorversion', instance.MINIMUM_MINOR_VERSION)
81+
if 'minorversion' not in kwargs:
82+
warnings.warn(
83+
'No minor version specified. Defaulting to minimum supported version (75). '
84+
'Please specify minorversion explicitly when initializing QuickBooks. '
85+
'See: https://blogs.intuit.com/2025/01/21/changes-to-our-accounting-api-that-may-impact-your-application/',
86+
DeprecationWarning)
87+
elif instance.minorversion < instance.MINIMUM_MINOR_VERSION:
88+
warnings.warn(
89+
f'Minor Version {instance.minorversion} is no longer supported. Minimum supported version is {instance.MINIMUM_MINOR_VERSION}. '
90+
'See: https://blogs.intuit.com/2025/01/21/changes-to-our-accounting-api-that-may-impact-your-application/',
91+
DeprecationWarning)
8792

8893
instance.invoice_link = kwargs.get('invoice_link', False)
8994

@@ -157,15 +162,7 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
157162
if not params:
158163
params = {}
159164

160-
if self.minorversion is None:
161-
warnings.warn(
162-
'No minor version specified. Defaulting to minimum supported version (75). '
163-
'Please specify minorversion explicitly when initializing QuickBooks. '
164-
'See: https://blogs.intuit.com/2025/01/21/changes-to-our-accounting-api-that-may-impact-your-application/',
165-
DeprecationWarning)
166-
params['minorversion'] = self.MINIMUM_MINOR_VERSION
167-
else:
168-
params['minorversion'] = self.minorversion
165+
params['minorversion'] = self.minorversion
169166

170167
if request_id:
171168
params['requestid'] = request_id
@@ -240,10 +237,18 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
240237
return result
241238

242239
def get(self, *args, **kwargs):
243-
return self.make_request("GET", *args, **kwargs)
240+
if 'params' not in kwargs:
241+
kwargs['params'] = {}
242+
if 'minorversion' not in kwargs['params']:
243+
kwargs['params']['minorversion'] = self.MINIMUM_MINOR_VERSION
244+
return self.make_request('GET', *args, **kwargs)
244245

245246
def post(self, *args, **kwargs):
246-
return self.make_request("POST", *args, **kwargs)
247+
if 'params' not in kwargs:
248+
kwargs['params'] = {}
249+
if 'minorversion' not in kwargs['params']:
250+
kwargs['params']['minorversion'] = self.MINIMUM_MINOR_VERSION
251+
return self.make_request('POST', *args, **kwargs)
247252

248253
def process_request(self, request_type, url, headers="", params="", data=""):
249254
if self.session is None:
@@ -256,9 +261,9 @@ def process_request(self, request_type, url, headers="", params="", data=""):
256261

257262
def get_single_object(self, qbbo, pk, params=None):
258263
url = "{0}/company/{1}/{2}/{3}/".format(self.api_url, self.company_id, qbbo.lower(), pk)
259-
result = self.get(url, {}, params=params)
260-
261-
return result
264+
if params is None:
265+
params = {}
266+
return self.get(url, {}, params=params)
262267

263268
@staticmethod
264269
def handle_exceptions(results):
@@ -316,9 +321,9 @@ def isvalid_object_name(self, object_name):
316321

317322
def update_object(self, qbbo, request_body, _file_path=None, request_id=None, params=None):
318323
url = "{0}/company/{1}/{2}".format(self.api_url, self.company_id, qbbo.lower())
319-
result = self.post(url, request_body, file_path=_file_path, request_id=request_id, params=params)
320-
321-
return result
324+
if params is None:
325+
params = {}
326+
return self.post(url, request_body, file_path=_file_path, request_id=request_id, params=params)
322327

323328
def delete_object(self, qbbo, request_body, _file_path=None, request_id=None):
324329
url = "{0}/company/{1}/{2}".format(self.api_url, self.company_id, qbbo.lower())

0 commit comments

Comments
 (0)