From 6d5ad45269942273d6c28df69a0e1bb5f7d516a6 Mon Sep 17 00:00:00 2001 From: Ashwin Thanaraj <37061471+ashwin1111@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:45:58 +0530 Subject: [PATCH] Add order by support for generator (#71) --- sageintacctsdk/apis/api_base.py | 14 +++++++++++++- setup.py | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sageintacctsdk/apis/api_base.py b/sageintacctsdk/apis/api_base.py index 3ade332..e8572fc 100644 --- a/sageintacctsdk/apis/api_base.py +++ b/sageintacctsdk/apis/api_base.py @@ -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 """ @@ -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': { @@ -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] diff --git a/setup.py b/setup.py index c0a6b82..e7ae3b4 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='sageintacctsdk', - version='1.19.2', + version='1.20.0', author='Ashwin T', author_email='ashwin.t@fyle.in', description='Python SDK for accessing Sage Intacct APIs',