From 7dc9acf27f8c187f76251799acab93fd04a77a9d Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Thu, 3 Oct 2024 17:56:57 +0530 Subject: [PATCH 1/6] feat: Added Extensive Loggers --- sageintacctsdk/apis/api_base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sageintacctsdk/apis/api_base.py b/sageintacctsdk/apis/api_base.py index aa9a177..10073d1 100644 --- a/sageintacctsdk/apis/api_base.py +++ b/sageintacctsdk/apis/api_base.py @@ -2,6 +2,7 @@ API Base class with util functions """ import json +import logging import datetime import uuid from warnings import warn @@ -17,6 +18,9 @@ from .constants import dimensions_fields_mapping +logger = logging.getLogger(__name__) +logger.level = logging.WARNING + class ApiBase: """The base class for all API classes.""" @@ -186,6 +190,7 @@ def __post_request(self, dict_body: dict, api_url: str): A response from the request (dict). """ + logger.debug('Payload for post request: %s', dict_body) raw_response = self.__post_request_for_raw_response(dict_body, api_url) try: parsed_xml = xmltodict.parse(raw_response.text, force_list={self.__dimension}) @@ -195,6 +200,8 @@ def __post_request(self, dict_body: dict, api_url: str): parsed_xml = xmltodict.parse(raw_response, force_list={self.__dimension})['root'] parsed_response = json.loads(json.dumps(parsed_xml)) + + logger.debug('Response for post request: %s', raw_response.text) if raw_response.status_code == 200: if parsed_response['response']['control']['status'] == 'success': api_response = parsed_response['response']['operation'] From b67eb29d26475495817df70ac5d7eb50254e9cab Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Tue, 8 Oct 2024 17:46:03 +0530 Subject: [PATCH 2/6] better logging --- sageintacctsdk/apis/api_base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sageintacctsdk/apis/api_base.py b/sageintacctsdk/apis/api_base.py index 10073d1..d00187f 100644 --- a/sageintacctsdk/apis/api_base.py +++ b/sageintacctsdk/apis/api_base.py @@ -200,9 +200,8 @@ def __post_request(self, dict_body: dict, api_url: str): parsed_xml = xmltodict.parse(raw_response, force_list={self.__dimension})['root'] parsed_response = json.loads(json.dumps(parsed_xml)) - - logger.debug('Response for post request: %s', raw_response.text) if raw_response.status_code == 200: + logger.debug('Response for post request: %s', raw_response.text) if parsed_response['response']['control']['status'] == 'success': api_response = parsed_response['response']['operation'] @@ -242,6 +241,8 @@ def __post_request(self, dict_body: dict, api_url: str): } raise WrongParamsError('Something went wrong', custom_response) + + logger.info('Response for post request: %s', raw_response.text) if 'result' in parsed_response: if 'errormessage' in parsed_response['result']: parsed_response = parsed_response['result']['errormessage'] From f8343fe3e92367f3e22f326ae2bfe45bc01c200c Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Sun, 13 Oct 2024 22:16:33 +0530 Subject: [PATCH 3/6] comment resolved --- sageintacctsdk/apis/api_base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sageintacctsdk/apis/api_base.py b/sageintacctsdk/apis/api_base.py index d00187f..8a30c07 100644 --- a/sageintacctsdk/apis/api_base.py +++ b/sageintacctsdk/apis/api_base.py @@ -201,7 +201,12 @@ def __post_request(self, dict_body: dict, api_url: str): parsed_response = json.loads(json.dumps(parsed_xml)) if raw_response.status_code == 200: - logger.debug('Response for post request: %s', raw_response.text) + if (parsed_response['response']['control']['status'] == 'failure' or parsed_response['response']['operation']['authentication']['status'] == 'failure' or \ + parsed_response['response']['operation']['result']['status'] == 'failure'): + logger.info('Response for post request: %s', raw_response.text) + else: + logger.debug('Response for post request: %s', raw_response.text) + if parsed_response['response']['control']['status'] == 'success': api_response = parsed_response['response']['operation'] From 1ee9134fa54fad4d953c20394573a71aba8b8dba Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Sun, 13 Oct 2024 22:16:59 +0530 Subject: [PATCH 4/6] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7b3f4c1..b1a808c 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='sageintacctsdk', - version='1.23.0', + version='1.23.1', author='Ashwin T', author_email='ashwin.t@fyle.in', description='Python SDK for accessing Sage Intacct APIs', From d078f5e4a36740685d1b156724197ed7dd7e799b Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Mon, 14 Oct 2024 21:19:13 +0530 Subject: [PATCH 5/6] comment resolved --- sageintacctsdk/apis/api_base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sageintacctsdk/apis/api_base.py b/sageintacctsdk/apis/api_base.py index 8a30c07..ad061aa 100644 --- a/sageintacctsdk/apis/api_base.py +++ b/sageintacctsdk/apis/api_base.py @@ -201,12 +201,17 @@ def __post_request(self, dict_body: dict, api_url: str): parsed_response = json.loads(json.dumps(parsed_xml)) if raw_response.status_code == 200: - if (parsed_response['response']['control']['status'] == 'failure' or parsed_response['response']['operation']['authentication']['status'] == 'failure' or \ - parsed_response['response']['operation']['result']['status'] == 'failure'): + response = parsed_response.get('response', {}) + control_status = response.get('control', {}).get('status', '') + auth_status = response.get('operation', {}).get('authentication', {}).get('status', '') + result_status = response.get('operation', {}).get('result', {}).get('status', '') + + + if control_status == 'failure' or auth_status == 'failure' or result_status == 'failure': logger.info('Response for post request: %s', raw_response.text) else: logger.debug('Response for post request: %s', raw_response.text) - + if parsed_response['response']['control']['status'] == 'success': api_response = parsed_response['response']['operation'] From 758f507b155709c7db2d111710af1a1e611ce716 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Mon, 14 Oct 2024 22:30:16 +0530 Subject: [PATCH 6/6] removed level --- sageintacctsdk/apis/api_base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sageintacctsdk/apis/api_base.py b/sageintacctsdk/apis/api_base.py index d7d9f1a..5b2c47c 100644 --- a/sageintacctsdk/apis/api_base.py +++ b/sageintacctsdk/apis/api_base.py @@ -19,7 +19,6 @@ logger = logging.getLogger(__name__) -logger.level = logging.WARNING class ApiBase: """The base class for all API classes."""