Skip to content

Commit

Permalink
Merge pull request #375 from ej2/minor-version-deprecation
Browse files Browse the repository at this point in the history
Add warning for unsupported minorversion
  • Loading branch information
ej2 authored Feb 10, 2025
2 parents 045cded + a639f26 commit 8d38c63
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 8 additions & 0 deletions quickbooks/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import hashlib
import hmac
import decimal
import warnings

from . import exceptions
from requests_oauthlib import OAuth2Session
Expand All @@ -19,6 +20,7 @@ class Environments(object):


class QuickBooks(object):
MINIMUM_MINOR_VERSION = 75
company_id = 0
session = None
auth_client = None
Expand Down Expand Up @@ -77,6 +79,12 @@ def __new__(cls, **kwargs):
if 'minorversion' in kwargs:
instance.minorversion = kwargs['minorversion']

if instance.minorversion < instance.MINIMUM_MINOR_VERSION:
warnings.warn(
'Minor Version no longer supported.'
'See: https://blogs.intuit.com/2025/01/21/changes-to-our-accounting-api-that-may-impact-your-application/',
DeprecationWarning)

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

if 'verifier_token' in kwargs:
Expand Down
21 changes: 19 additions & 2 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import warnings
from tests.integration.test_base import QuickbooksUnitTestCase

try:
Expand Down Expand Up @@ -31,12 +32,28 @@ def test_client_new(self):
self.qb_client = client.QuickBooks(
company_id="company_id",
verbose=True,
minorversion=4,
minorversion=75,
verifier_token=TEST_VERIFIER_TOKEN,
)

self.assertEqual(self.qb_client.company_id, "company_id")
self.assertEqual(self.qb_client.minorversion, 4)
self.assertEqual(self.qb_client.minorversion, 75)

def test_client_with_deprecated_minor_version(self):
with warnings.catch_warnings(record=True) as w:
self.qb_client = client.QuickBooks(
company_id="company_id",
verbose=True,
minorversion=74,
verifier_token=TEST_VERIFIER_TOKEN,
)

warnings.simplefilter("always")
self.assertEqual(self.qb_client.company_id, "company_id")
self.assertEqual(self.qb_client.minorversion, 74)
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
self.assertTrue("Minor Version no longer supported." in str(w[-1].message))

def test_api_url(self):
qb_client = client.QuickBooks(sandbox=False)
Expand Down

0 comments on commit 8d38c63

Please sign in to comment.