Skip to content

Commit

Permalink
Adding BillPayment API Support (#6)
Browse files Browse the repository at this point in the history
Adding support to BillPayment API
  • Loading branch information
Sravanksk authored Jan 19, 2021
1 parent 136b4a5 commit c5e8cf0
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion qbosdk/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .bills import Bills
from .attachments import Attachments
from .customers import Customers
from .bill_payments import BillPayments

__all_ = [
'Accounts',
Expand All @@ -28,5 +29,6 @@
'Bills',
'JournalEntries',
'Attachments',
'Customers'
'Customers',
'BillPayments'
]
40 changes: 40 additions & 0 deletions qbosdk/apis/bill_payments.py
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions qbosdk/apis/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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))
3 changes: 3 additions & 0 deletions qbosdk/qbosdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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):
"""
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='qbosdk',
version='0.6.1',
version='0.7.0',
author='Shwetabh Kumar',
author_email='[email protected]',
description='Python SDK for accessing Quickbooks Online APIs',
Expand Down

0 comments on commit c5e8cf0

Please sign in to comment.