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

feat: Add active count api for attributes #28

Merged
merged 3 commits into from
Oct 3, 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
9 changes: 9 additions & 0 deletions qbosdk/apis/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Accounts(ApiBase):
"""Class for Categories APIs."""

GET_ACCOUNTS = '/query?query=select * from Account STARTPOSITION {0} MAXRESULTS 1000'
ACCOUNT_COUNT = '/query?query=select count(*) from Account where Active = True'

def get(self):
"""Get a list of the existing Accounts in the Organization.
Expand Down Expand Up @@ -39,3 +40,11 @@ def get_inactive(self, last_updated_time: None):
QUERY += " STARTPOSITION {0} MAXRESULTS 1000"

return self._query_get_all_generator('Account', QUERY)

def count(self):
"""Get count of Accounts in the Organization.

Returns:
Count in Int.
"""
return self._query(Accounts.ACCOUNT_COUNT)['totalCount']
10 changes: 10 additions & 0 deletions qbosdk/apis/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Classes(ApiBase):
"""Class for Categories APIs."""

GET_CLASSES = '/query?query=select * from Class STARTPOSITION {0} MAXRESULTS 1000'
COUNT_CLASSES = '/query?query=select count(*) from Class where Active = True'

def get(self):
"""Get a list of the existing Classes in the Organization.
Expand All @@ -24,3 +25,12 @@ def get_all_generator(self):
Generator with dicts in Classes schema.
"""
return self._query_get_all_generator('Class', Classes.GET_CLASSES)


def count(self):
"""Get count of Classes in the Organization.

Returns:
Count in Int.
"""
return self._query(Classes.COUNT_CLASSES)['totalCount']
2 changes: 1 addition & 1 deletion qbosdk/apis/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Customers(ApiBase):
"""Class for Customer APIs."""

GET_CUSTOMERS = '/query?query=select * from Customer STARTPOSITION {0} MAXRESULTS 1000'
COUNT_CUSTOMERS = '/query?query=select count(*) from Customer'
COUNT_CUSTOMERS = '/query?query=select count(*) from Customer where Active = True'

def get(self):
"""Get a list of the existing Customers in the Organization.
Expand Down
9 changes: 9 additions & 0 deletions qbosdk/apis/departments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Departments(ApiBase):
"""Class for Categories APIs."""

GET_DEPARTMENTS = '/query?query=select * from Department STARTPOSITION {0} MAXRESULTS 1000'
COUNT_DEPARTMENT = '/query?query=select count(*) from Department where Active = True'

def get(self):
"""Get a list of the existing Departments in the Organization.
Expand All @@ -24,3 +25,11 @@ def get_all_generator(self):
Generator with dicts in Departments schema.
"""
return self._query_get_all_generator('Department', Departments.GET_DEPARTMENTS)

def count(self):
"""Get count of Departments in the Organization.

Returns:
Count in Int.
"""
return self._query(Departments.COUNT_DEPARTMENT)['totalCount']
9 changes: 9 additions & 0 deletions qbosdk/apis/employees.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Employees(ApiBase):

GET_EMPLOYEES = '/query?query=select * from Employee STARTPOSITION {0} MAXRESULTS 1000'
POST_EMPLOYEE = '/employee?minorversion=38'
COUNT_EMPLOYEES = '/query?query=select count(*) from Employee where Active = True'

def get(self):
"""Get a list of the existing Employees in the Organization.
Expand All @@ -35,3 +36,11 @@ def post(self, data: Dict):
:return:
"""
return self._post_request(data, Employees.POST_EMPLOYEE)

def count(self):
"""Get count of Employees in the Organization.

Returns:
Count in Int.
"""
return self._query(Employees.COUNT_EMPLOYEES)['totalCount']
9 changes: 9 additions & 0 deletions qbosdk/apis/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Items(ApiBase):
"""Class for Items APIs."""

GET_ITEMS = '/query?query=select * from Item STARTPOSITION {0} MAXRESULTS 1000'
COUNT_ITEMS = '/query?query=select count(*) from Item where Active = True'

def get(self):
"""Get a list of the existing items in the Organization.
Expand Down Expand Up @@ -40,3 +41,11 @@ def get_inactive(self, last_updated_time: None):
QUERY += " STARTPOSITION {0} MAXRESULTS 1000"

return self._query_get_all_generator('Item', QUERY)

def count(self):
"""Get count of Items in the Organization.

Returns:
Count in Int.
"""
return self._query(Items.COUNT_ITEMS)['totalCount']
9 changes: 9 additions & 0 deletions qbosdk/apis/tax_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TaxCodes(ApiBase):
"""Class for TaxCode APIs."""

GET_TAX_CODES = '/query?query=select * from TaxCode STARTPOSITION {0} MAXRESULTS 1000'
COUNT_TAX_CODES = '/query?query=select count(*) from TaxCode where Active = True'

def get(self):
"""Get a list of the existing Tax Code in the Organization.
Expand All @@ -24,3 +25,11 @@ def get_all_generator(self):
Generator with dicts in TaxCode schema.
"""
return self._query_get_all_generator('TaxCode', TaxCodes.GET_TAX_CODES)

def count(self):
"""Get count of Tax codes in the Organization.

Returns:
Count in Int.
"""
return self._query(TaxCodes.COUNT_TAX_CODES)['totalCount']
9 changes: 9 additions & 0 deletions qbosdk/apis/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Vendors(ApiBase):
GET_VENDORS = '/query?query=select * from Vendor STARTPOSITION {0} MAXRESULTS 1000'
POST_VENDOR = '/vendor?minorversion=38'
SEARCH_VENDOR = "/query?query=select * from Vendor where DisplayName = '{0}'"
COUNT_VENDORS = '/query?query=select count(*) from Vendor where Active = True'

def get(self):
"""Get a list of the existing Vendors in the Organization.
Expand Down Expand Up @@ -61,3 +62,11 @@ def get_inactive(self, last_updated_time: None):
QUERY += " STARTPOSITION {0} MAXRESULTS 1000"

return self._query_get_all_generator('Vendor', QUERY)

def count(self):
"""Get count of Vendors in the Organization.

Returns:
Count in Int.
"""
return self._query(Vendors.COUNT_VENDORS)['totalCount']
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.17.3',
version='0.18.0',
author='Shwetabh Kumar',
author_email='[email protected]',
description='Python SDK for accessing Quickbooks Online APIs',
Expand Down