diff --git a/.pylintrc b/.pylintrc index 8f24533..22c463a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -153,7 +153,8 @@ disable=print-statement, redefined-outer-name, wildcard-import, no-value-for-parameter, - unused-wildcard-import + unused-wildcard-import, + super-with-arguments # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/qbosdk/apis/__init__.py b/qbosdk/apis/__init__.py index 9871d09..7a0c35d 100644 --- a/qbosdk/apis/__init__.py +++ b/qbosdk/apis/__init__.py @@ -14,6 +14,7 @@ from .bills import Bills from .attachments import Attachments from .customers import Customers +from .bill_payments import BillPayments __all_ = [ 'Accounts', @@ -28,5 +29,6 @@ 'Bills', 'JournalEntries', 'Attachments', - 'Customers' + 'Customers', + 'BillPayments' ] diff --git a/qbosdk/apis/bill_payments.py b/qbosdk/apis/bill_payments.py new file mode 100644 index 0000000..6e817ba --- /dev/null +++ b/qbosdk/apis/bill_payments.py @@ -0,0 +1,40 @@ +""" +Quickbooks Online Bill Payments +""" +from typing import Dict +from .api_base import ApiBase + + +class BillPayments(ApiBase): + """Class for Bill Payments API.""" + + GET_BILLS = '/query?query=select * from billpayment STARTPOSITION {0} MAXRESULTS 1000' + POST_BILL_PAYMENT = '/billpayment?minorversion=38' + DELETE_BILL = '/billpayment?operation=delete' + + def get(self): + """ + Get all Bill Payments + :return: List of Dicts in Bill Payment Schema + """ + return self._query_get_all('BillPayment', BillPayments.GET_BILLS) + + def post(self, data: Dict): + """ + Post Bill Payment to Quickbooks Online + :param data: Dict in Bill Payment schema + :return: + """ + return self._post_request(data, BillPayments.POST_BILL_PAYMENT) + + def delete(self, bill_payment_id: str): + """ + Delete Bill Payment from Quickbooks Online + :param bill_payment_id: Bill Payment Id to remove + :return: Dict response + """ + data = { + 'SyncToken': '1', + 'Id': bill_payment_id + } + return self._post_request(data, BillPayments.DELETE_BILL) diff --git a/qbosdk/apis/bills.py b/qbosdk/apis/bills.py index b340e45..d9e94e3 100644 --- a/qbosdk/apis/bills.py +++ b/qbosdk/apis/bills.py @@ -11,6 +11,7 @@ class Bills(ApiBase): GET_BILLS = '/query?query=select * from Bill STARTPOSITION {0} MAXRESULTS 1000' POST_BILL = '/bill?minorversion=38' DELETE_BILL = '/bill?operation=delete' + GET_BILL_BY_ID = '/bill/{0}' def get(self): """ @@ -38,3 +39,11 @@ def delete(self, bill_id: str): 'SyncToken': '1' } return self._post_request(data, Bills.DELETE_BILL) + + def get_by_id(self, bill_id): + """ + Get Bill from Quickbooks Online + :param bill_id: Bill Id + :return: Dict Response + """ + return self._get_request('Bill', Bills.GET_BILL_BY_ID.format(bill_id)) diff --git a/qbosdk/qbosdk.py b/qbosdk/qbosdk.py index 46eace9..8f1c926 100644 --- a/qbosdk/qbosdk.py +++ b/qbosdk/qbosdk.py @@ -56,6 +56,7 @@ def __init__(self, client_id: str, client_secret: str, self.purchases = Purchases() self.journal_entries = JournalEntries() self.attachments = Attachments() + self.bill_payments = BillPayments() self.update_server_url() self.update_access_token() @@ -79,6 +80,7 @@ def update_server_url(self): self.journal_entries.set_server_url(base_url) self.customers.set_server_url(base_url) self.attachments.set_server_url(base_url) + self.bill_payments.set_server_url(base_url) def update_access_token(self): """ @@ -100,6 +102,7 @@ def update_access_token(self): self.journal_entries.change_access_token(access_token) self.customers.change_access_token(access_token) self.attachments.change_access_token(access_token) + self.bill_payments.change_access_token(access_token) def __get_access_token(self): """Get the access token using a HTTP post. diff --git a/setup.py b/setup.py index dda621c..763c174 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='qbosdk', - version='0.6.1', + version='0.7.0', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Python SDK for accessing Quickbooks Online APIs',