Skip to content

Commit

Permalink
fix: get_by_query() and get_all() for empty response (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Oct 8, 2024
1 parent c254d56 commit 8ebebf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions sageintacctsdk/apis/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,12 @@ def get_all(self, field: str = None, value: str = None, fields: list = None):
}
}

paginated_data = self.format_and_send_request(data)['data'][self.__dimension]
complete_data.extend(paginated_data)
response = self.format_and_send_request(data)['data']
if self.__dimension in response:
paginated_data = response[self.__dimension]
complete_data.extend(paginated_data)

break

return complete_data

Expand Down Expand Up @@ -584,7 +588,8 @@ def get_by_query(self, fields: List[str] = None,
for offset in range(0, count, pagesize):
data['query']['offset'] = offset
paginated_data = self.format_and_send_request(data)['data']
complete_data.extend(paginated_data[self.__dimension])
if self.__dimension in paginated_data:
complete_data.extend(paginated_data[self.__dimension])
filtered_total = int(paginated_data['@totalcount'])
if paginated_data['@numremaining'] == '0':
break
Expand Down
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='sageintacctsdk',
version='1.23.1',
version='1.23.2',
author='Ashwin T',
author_email='[email protected]',
description='Python SDK for accessing Sage Intacct APIs',
Expand Down

0 comments on commit 8ebebf0

Please sign in to comment.