Skip to content

Commit

Permalink
Add order by support for generator (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Jun 21, 2024
1 parent e44b350 commit 6d5ad45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion sageintacctsdk/apis/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def get_all(self, field: str = None, value: str = None, fields: list = None):

return complete_data

def get_all_generator(self, field: str = None, value: str = None, fields: list = None, updated_at: str = None):
def get_all_generator(self, field: str = None, value: str = None, fields: list = None, updated_at: str = None, order_by_field: str = None, order: str = None):
"""
Get all data from Sage Intacct
"""
Expand All @@ -453,12 +453,21 @@ def get_all_generator(self, field: str = None, value: str = None, fields: list =
'select': {
'field': fields if fields else dimensions_fields_mapping[self.__dimension]
},
'orderby': None,
'pagesize': pagesize,
'offset': offset,
'filter': None
}
}

if order_by_field and order:
data['query']['orderby'] = {
'order': {
'field': order_by_field,
order: None
}
}

if field and value:
data['query']['filter'] = {
'equalto': {
Expand Down Expand Up @@ -486,6 +495,9 @@ def get_all_generator(self, field: str = None, value: str = None, fields: list =
if not data['query']['filter']:
del data['query']['filter']

if not data['query']['orderby']:
del data['query']['orderby']

response = self.format_and_send_request(data)['data']
if self.__dimension in response:
yield self.format_and_send_request(data)['data'][self.__dimension]
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.19.2',
version='1.20.0',
author='Ashwin T',
author_email='[email protected]',
description='Python SDK for accessing Sage Intacct APIs',
Expand Down

0 comments on commit 6d5ad45

Please sign in to comment.