Skip to content

Commit

Permalink
Added method for fetching inactive records
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrishabh17 committed Mar 5, 2024
1 parent b983f55 commit 6084c45
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
15 changes: 15 additions & 0 deletions qbosdk/apis/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,18 @@ def get_all_generator(self):
Generator with dicts in Accounts schema.
"""
return self._query_get_all_generator('Account', Accounts.GET_ACCOUNTS)

def get_inactive(self, last_updated_time):
"""
Retrieves a list of inactive accounts from the QuickBooks Online API.
:param last_updated_time: The last updated time to filter the accounts.
:return: A list of inactive accounts.
"""

QUERY = "/query?query=select * from Account where Active=false"
if last_updated_time:
QUERY += f" and Metadata.LastUpdatedTime >= '{last_updated_time}'"
QUERY += " STARTPOSITION {0} MAXRESULTS 1000"

return self._query_get_all_generator('Account', QUERY)
15 changes: 15 additions & 0 deletions qbosdk/apis/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@ def count(self):
Count in Int.
"""
return self._query(Customers.COUNT_CUSTOMERS)['totalCount']

def get_inactive(self, last_updated_time):
"""
Retrieves a list of inactive customers from the QuickBooks Online API.
:param last_updated_time: The last updated time to filter the customers.
:return: A list of inactive customers.
"""

QUERY = "/query?query=select * from Customer where Active=false"
if last_updated_time:
QUERY += f" and Metadata.LastUpdatedTime >= '{last_updated_time}'"
QUERY += " STARTPOSITION {0} MAXRESULTS 1000"

return self._query_get_all_generator('Customer', QUERY)
15 changes: 15 additions & 0 deletions qbosdk/apis/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ def get_all_generator(self):
Generator with dicts in Items schema.
"""
return self._query_get_all_generator('Item', Items.GET_ITEMS)

def get_inactive(self, last_updated_time):
"""
Retrieves a list of inactive items from the QuickBooks Online API.
:param last_updated_time: The last updated time to filter the items.
:return: A list of inactive items.
"""

QUERY = "/query?query=select * from Item where Active=false"
if last_updated_time:
QUERY += f" and Metadata.LastUpdatedTime >= '{last_updated_time}'"
QUERY += " STARTPOSITION {0} MAXRESULTS 1000"

return self._query_get_all_generator('Item', QUERY)
15 changes: 15 additions & 0 deletions qbosdk/apis/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,18 @@ def search_vendor_by_display_name(self, display_name=None):
response = self._get_request('QueryResponse', Vendors.SEARCH_VENDOR.format(display_name))

return response['Vendor'][0] if 'Vendor' in response else None

def get_inactive(self, last_updated_time):
"""
Retrieves a list of inactive vendors from the QuickBooks Online API.
:param last_updated_time: The last updated time to filter the vendors.
:return: A list of inactive vendors.
"""

QUERY = "/query?query=select * from Vendor where Active=false"
if last_updated_time:
QUERY += f" and Metadata.LastUpdatedTime >= '{last_updated_time}'"
QUERY += " STARTPOSITION {0} MAXRESULTS 1000"

return self._query_get_all_generator('Vendor', QUERY)

0 comments on commit 6084c45

Please sign in to comment.