Skip to content

Commit

Permalink
Merge pull request #258 from ej2/0.9.1
Browse files Browse the repository at this point in the history
0.9.1
  • Loading branch information
ej2 authored Nov 30, 2021
2 parents 2582c5b + e59931b commit 923f9e7
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 393 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

* 0.9.1 (July ??, 2021)
* Added response status code when raising unauthorized exceptions
* Added pending deprecation warnings to enable_global and disable_global

* 0.9.0 (July 20, 2021)
* Added missing TxnDate to Invoice
* Updated requirements
Expand Down
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ requests = ">=2.26.0"
simplejson = ">=3.17.0"
six = ">=1.14.0"
nose = "*"
authclient = "*"
coverage = "*"
twine = "*"

Expand Down
574 changes: 189 additions & 385 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ Void an invoice:
invoice.Id = 7
invoice.void(qb=client)

If your consumer_key never changes you can enable the client to stay running:
If your company_id never changes you can enable the client to stay running (deprecation warning: will be removed in next release):

QuickBooks.enable_global()

You can disable the global client like so:
You can disable the global client like so (deprecation warning: will be removed in next release):

QuickBooks.disable_global()

Expand Down
10 changes: 8 additions & 2 deletions quickbooks/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

try: # Python 3
import http.client as httplib
from urllib.parse import parse_qsl
Expand Down Expand Up @@ -114,6 +116,7 @@ def disable_global(cls):
"""
Disable use of singleton pattern.
"""
warnings.warn("disable_global deprecated", PendingDeprecationWarning)
QuickBooks.__use_global = False
QuickBooks.__instance = None

Expand All @@ -122,6 +125,7 @@ def enable_global(cls):
"""
Allow use of singleton pattern.
"""
warnings.warn("enable_global deprecated", PendingDeprecationWarning)
QuickBooks.__use_global = True

def _drop(self):
Expand Down Expand Up @@ -230,7 +234,8 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
req = self.process_request(request_type, url, headers=headers, params=params, data=request_body)

if req.status_code == httplib.UNAUTHORIZED:
raise exceptions.AuthorizationException("Application authentication failed", detail=req.text)
raise exceptions.AuthorizationException(
"Application authentication failed", error_code=req.status_code, detail=req.text)

try:
result = req.json()
Expand Down Expand Up @@ -363,7 +368,8 @@ def download_pdf(self, qbbo, item_id):

if response.status_code == httplib.UNAUTHORIZED:
# Note that auth errors have different result structure which can't be parsed by handle_exceptions()
raise exceptions.AuthorizationException("Application authentication failed", detail=response.text)
raise exceptions.AuthorizationException(
"Application authentication failed", error_code=response.status_code, detail=response.text)

try:
result = response.json()
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read(*parts):
return fp.read()


VERSION = (0, 9, 0)
VERSION = (0, 9, 1)
version = '.'.join(map(str, VERSION))

setup(
Expand All @@ -33,7 +33,6 @@ def read(*parts):
'setuptools',
'intuit-oauth==1.2.4',
'rauth>=0.7.3',
'authclient',
'requests>=2.26.0',
'simplejson>=3.17.0',
'six>=1.14.0',
Expand Down
19 changes: 18 additions & 1 deletion tests/integration/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import uuid

class InvoiceTest(QuickbooksTestCase):

def create_invoice(self, customer, request_id=None):
invoice = Invoice()

Expand All @@ -27,6 +26,24 @@ def create_invoice(self, customer, request_id=None):
invoice.CustomerMemo.value = "Customer Memo"
invoice.save(qb=self.qb_client, request_id=request_id)
return invoice

def test_query_by_customer_ref(self):
customer = Customer.all(max_results=1, qb=self.qb_client)[0]
invoice = Invoice.query(
"select * from Invoice where CustomerRef = '{0}'".format(customer.Id), qb=self.qb_client)

print(invoice[0].Line[0].LineNum)
print(invoice[0].Line[0].Amount)
self.assertEquals(invoice[0].CustomerRef.name, customer.DisplayName)

def test_where(self):
customer = Customer.all(max_results=1, qb=self.qb_client)[0]

invoice = Invoice.where(
"CustomerRef = '{0}'".format(customer.Id), qb=self.qb_client)

print(invoice[0])
self.assertEquals(invoice[0].CustomerRef.name, customer.DisplayName)

def test_create(self):
customer = Customer.all(max_results=1, qb=self.qb_client)[0]
Expand Down

0 comments on commit 923f9e7

Please sign in to comment.