Skip to content

Commit

Permalink
Updates to SendMixin and readme. Removed send_invoice from Invoice ob…
Browse files Browse the repository at this point in the history
…ject.
  • Loading branch information
ej2 committed Mar 27, 2018
1 parent 752ac39 commit 157daf2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
========

* 0.7.4 (March 26th, 2018)
* Fixed bug in SendMixin send method.
* Added support for send_to email to SendMixin.
* Removed send_invoice from Invoice object.
* Removed sandbox from Session Managers.

* 0.7.3 (November 28th, 2017)
* Fixed bug in ListMixin count method.

Expand Down
8 changes: 1 addition & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Manually connecting with OAuth version 1.0
from quickbooks import Oauth1SessionManager
session_manager = Oauth1SessionManager(
sandbox=True,
consumer_key=QUICKBOOKS_CLIENT_KEY,
consumer_secret=QUICKBOOKS_CLIENT_SECRET,
)
Expand All @@ -58,7 +57,6 @@ for use in the Callback method.
.. code-block:: python
session_manager = Oauth1SessionManager(
sandbox=True,
consumer_key=QUICKBOOKS_CLIENT_KEY,
consumer_secret=QUICKBOOKS_CLIENT_SECRET
)
Expand Down Expand Up @@ -86,7 +84,6 @@ Manually connecting with OAuth version 2.0
from quickbooks import Oauth2SessionManager
session_manager = Oauth2SessionManager(
sandbox=True,
client_id=QUICKBOOKS_CLIENT_ID,
client_secret=QUICKBOOKS_CLIENT_SECRET,
base_url='http://localhost:8000',
Expand All @@ -102,7 +99,6 @@ Manually connecting with OAuth version 2.0
.. code-block:: python
session_manager = Oauth2SessionManager(
sandbox=True,
client_id=QUICKBOOKS_CLIENT_ID,
client_secret=QUICKBOOKS_CLIENT_SECRET,
base_url='http://localhost:8000',
Expand All @@ -123,7 +119,6 @@ OAuth version 1.0 - Setup the session manager using the stored ``access_token``
.. code-block:: python
session_manager = Oauth1SessionManager(
sandbox=True,
consumer_key=CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET,
access_token=ACCESS_TOKEN,
Expand All @@ -134,8 +129,7 @@ OAuth version 2.0 - Setup the session manager using the stored ``access_token``

.. code-block:: python
self.session_manager = Oauth2SessionManager(
sandbox=True,
session_manager = Oauth2SessionManager(
client_id=realm_id,
client_secret=CLIENT_SECRET,
access_token=AUTH2_ACCESS_TOKEN,
Expand Down
7 changes: 0 additions & 7 deletions quickbooks/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

class AuthSessionManager(object):
oauth_version = None
sandbox = False
session = None
started = False

Expand Down Expand Up @@ -70,9 +69,6 @@ def __init__(self, **kwargs):
if 'access_token_secret' in kwargs:
self.access_token_secret = kwargs['access_token_secret']

if 'sandbox' in kwargs:
self.sandbox = kwargs['sandbox']

def start_session(self):
if not self.started:
if self.consumer_key == '':
Expand Down Expand Up @@ -176,9 +172,6 @@ def __init__(self, **kwargs):
if 'base_url' in kwargs:
self.base_url = kwargs['base_url']

if 'sandbox' in kwargs:
self.sandbox = kwargs['sandbox']

def start_session(self):
if not self.started:
if self.client_id == '':
Expand Down
8 changes: 6 additions & 2 deletions quickbooks/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,16 @@ def get(cls, id, qb=None):


class SendMixin(object):
def send(self, qb=None):
def send(self, qb=None, send_to=None):
if not qb:
qb = QuickBooks()

end_point = "{0}/{1}/send".format(self.qbo_object_name, self.Id)
results = qb.misc_operation(end_point)

if send_to:
end_point = "{0}?sendTo={1}".format(end_point, send_to)

results = qb.misc_operation(end_point, None)

return results

Expand Down
6 changes: 0 additions & 6 deletions quickbooks/objects/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,3 @@ def email_sent(self):
return True

return False

def send_invoice(self, send_to=None):
url = self.api_url + "/company/{0}/invoice/{1}/send".format(self.company_id, self.Id)
results = self.make_request("POST", url)

return results
10 changes: 9 additions & 1 deletion tests/unit/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,12 @@ def test_send(self, mock_misc_op):
invoice.Id = 2
invoice.send(qb=self.qb_client)

mock_misc_op.assert_called_with("Invoice/2/send")
mock_misc_op.assert_called_with("Invoice/2/send", None)

@patch('quickbooks.mixins.QuickBooks.misc_operation')
def test_send_with_send_to_email(self, mock_misc_op):
invoice = Invoice()
invoice.Id = 2
invoice.send(qb=self.qb_client, send_to="[email protected]")

mock_misc_op.assert_called_with("Invoice/2/[email protected]", None)

0 comments on commit 157daf2

Please sign in to comment.