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

feat: Add support for Contract Lines API #101

Merged
merged 2 commits into from
Nov 21, 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
2 changes: 2 additions & 0 deletions sageintacctsdk/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .departments import Departments
from .charge_card_accounts import ChargeCardAccounts
from .charge_card_transactions import ChargeCardTransactions
from .contract_lines import ContractLines
from .contracts import Contracts
from .customers import Customers
from .items import Items
Expand Down Expand Up @@ -44,6 +45,7 @@
'ApiBase',
'Contacts',
'Contracts',
'ContractLines',
'Locations',
'Employees',
'Accounts',
Expand Down
6 changes: 3 additions & 3 deletions sageintacctsdk/apis/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ def __post_request(self, dict_body: dict, api_url: str):
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)

Comment on lines +207 to +213
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid logging sensitive data at 'info' level

Logging the entire raw_response.text at the info level when a failure occurs may expose sensitive information in the logs. Consider logging only essential details or sanitizing the response before logging to prevent potential exposure of sensitive data.

if parsed_response['response']['control']['status'] == 'success':
api_response = parsed_response['response']['operation']

Expand Down Expand Up @@ -255,7 +255,7 @@ def __post_request(self, dict_body: dict, api_url: str):
if 'result' in parsed_response:
if 'errormessage' in parsed_response['result']:
parsed_response = parsed_response['result']['errormessage']

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the key used when checking for 'errormessage'

In the condition if 'errormessage' in parsed_response:, the code checks for 'errormessage' directly in parsed_response. However, 'errormessage' is likely within parsed_response['result']. Adjust the condition to properly access the error message.

Apply this diff to fix the issue:

-if 'errormessage' in parsed_response:
+if 'errormessage' in parsed_response['result']:

Committable suggestion skipped: line range outside the PR's diff.

if 'response' in parsed_response:
if 'errormessage' in parsed_response['response']:
parsed_response = parsed_response['response']['errormessage']
Expand Down
Loading