Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method for fetching inactive records #24

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: None):
"""
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: None):
"""
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: None):
"""
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: None):
"""
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)