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

fix: get_by_query() and get_all() for empty response #96

Merged
merged 1 commit into from
Oct 8, 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
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