Skip to content

Commit

Permalink
feat: Add active count api for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Sep 27, 2024
1 parent fffb9e3 commit 61453e0
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 2 deletions.
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']
4 changes: 2 additions & 2 deletions 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 All @@ -31,7 +31,7 @@ def count(self):
Returns:
Count in Int.
"""
"""
return self._query(Customers.COUNT_CUSTOMERS)['totalCount']

def get_inactive(self, last_updated_time: None):
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']
10 changes: 10 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,12 @@ 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']
10 changes: 10 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,12 @@ 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']

0 comments on commit 61453e0

Please sign in to comment.