From 61453e044e6511d9ec8a46b19acc2b2dc3c67985 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Fri, 27 Sep 2024 17:58:07 +0530 Subject: [PATCH 1/3] feat: Add active count api for attributes --- qbosdk/apis/accounts.py | 9 +++++++++ qbosdk/apis/classes.py | 10 ++++++++++ qbosdk/apis/customers.py | 4 ++-- qbosdk/apis/departments.py | 9 +++++++++ qbosdk/apis/employees.py | 10 ++++++++++ qbosdk/apis/items.py | 9 +++++++++ qbosdk/apis/tax_codes.py | 9 +++++++++ qbosdk/apis/vendors.py | 10 ++++++++++ 8 files changed, 68 insertions(+), 2 deletions(-) diff --git a/qbosdk/apis/accounts.py b/qbosdk/apis/accounts.py index 5c80814..f8bb78d 100644 --- a/qbosdk/apis/accounts.py +++ b/qbosdk/apis/accounts.py @@ -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. @@ -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'] diff --git a/qbosdk/apis/classes.py b/qbosdk/apis/classes.py index 5c62d2d..603419e 100644 --- a/qbosdk/apis/classes.py +++ b/qbosdk/apis/classes.py @@ -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. @@ -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'] diff --git a/qbosdk/apis/customers.py b/qbosdk/apis/customers.py index 5e6d69c..4b6ca82 100644 --- a/qbosdk/apis/customers.py +++ b/qbosdk/apis/customers.py @@ -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. @@ -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): diff --git a/qbosdk/apis/departments.py b/qbosdk/apis/departments.py index 2f09daf..07b0fe3 100644 --- a/qbosdk/apis/departments.py +++ b/qbosdk/apis/departments.py @@ -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. @@ -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'] diff --git a/qbosdk/apis/employees.py b/qbosdk/apis/employees.py index deb9a2d..cbfc71a 100644 --- a/qbosdk/apis/employees.py +++ b/qbosdk/apis/employees.py @@ -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. @@ -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'] + diff --git a/qbosdk/apis/items.py b/qbosdk/apis/items.py index 01adc6b..7eba259 100644 --- a/qbosdk/apis/items.py +++ b/qbosdk/apis/items.py @@ -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. @@ -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'] diff --git a/qbosdk/apis/tax_codes.py b/qbosdk/apis/tax_codes.py index c0b0d80..2cbcce0 100644 --- a/qbosdk/apis/tax_codes.py +++ b/qbosdk/apis/tax_codes.py @@ -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. @@ -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'] diff --git a/qbosdk/apis/vendors.py b/qbosdk/apis/vendors.py index 04ced97..802471e 100644 --- a/qbosdk/apis/vendors.py +++ b/qbosdk/apis/vendors.py @@ -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. @@ -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'] + From cb0ac3e8e1fce8c3c5c0baa998c485791a9a5c3d Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Tue, 1 Oct 2024 17:16:58 +0530 Subject: [PATCH 2/3] resolving pylint --- qbosdk/apis/classes.py | 2 +- qbosdk/apis/customers.py | 2 +- qbosdk/apis/employees.py | 1 - qbosdk/apis/vendors.py | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/qbosdk/apis/classes.py b/qbosdk/apis/classes.py index 603419e..135e616 100644 --- a/qbosdk/apis/classes.py +++ b/qbosdk/apis/classes.py @@ -32,5 +32,5 @@ def count(self): Returns: Count in Int. - """ + """ return self._query(Classes.COUNT_CLASSES)['totalCount'] diff --git a/qbosdk/apis/customers.py b/qbosdk/apis/customers.py index 4b6ca82..bf145f1 100644 --- a/qbosdk/apis/customers.py +++ b/qbosdk/apis/customers.py @@ -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): diff --git a/qbosdk/apis/employees.py b/qbosdk/apis/employees.py index cbfc71a..d3b5018 100644 --- a/qbosdk/apis/employees.py +++ b/qbosdk/apis/employees.py @@ -44,4 +44,3 @@ def count(self): Count in Int. """ return self._query(Employees.COUNT_EMPLOYEES)['totalCount'] - diff --git a/qbosdk/apis/vendors.py b/qbosdk/apis/vendors.py index 802471e..72be0b9 100644 --- a/qbosdk/apis/vendors.py +++ b/qbosdk/apis/vendors.py @@ -70,4 +70,3 @@ def count(self): Count in Int. """ return self._query(Vendors.COUNT_VENDORS)['totalCount'] - From b3c26a5cb06c0198a2215e28522d334c26e759cb Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Thu, 3 Oct 2024 14:20:52 +0530 Subject: [PATCH 3/3] bump up version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 284c18d..b3beec5 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='qbosdk', - version='0.17.3', + version='0.18.0', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Python SDK for accessing Quickbooks Online APIs',