Skip to content

Commit

Permalink
Add get_by_id support for Journal Entry
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 committed Nov 25, 2024
1 parent 147f951 commit e197765
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ venv.bak/
.mypy_cache/
.dmypy.json
dmypy.json
private/

# Pyre type checker
.pyre/
2 changes: 1 addition & 1 deletion qbosdk/apis/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _query(self, url: str) -> List[Dict]:
if response.status_code == 200:
logger.debug('Response for get request for url: %s, %s', url, response.text)
data = json.loads(response.text)
return data['QueryResponse']
return data['QueryResponse'] if 'QueryResponse' in data else data

logger.info('Response for get request for url: %s, %s', url, response.text)
if response.status_code == 400:
Expand Down
9 changes: 9 additions & 0 deletions qbosdk/apis/journal_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class JournalEntries(ApiBase):
GET_JOURNAL_ENTRIES = '/query?query=select * from JournalEntry STARTPOSITION {0} MAXRESULTS 1000'
POST_JOURNAL_ENTRY = '/journalentry?minorversion=53'
DELETE_JOURNAL_ENTRY = '/journalentry?operation=delete'
GET_JOURNAL_ENTRY_BY_ID = '/journalentry/{0}'

def get(self):
"""
Expand All @@ -34,6 +35,14 @@ def post(self, data: Dict):
"""
return self._post_request(data, JournalEntries.POST_JOURNAL_ENTRY)

def get_by_id(self, journal_entry_id):
"""
Get JournalEntry by Id
:param journal_entry_id: Journal Entry Id
:return: Dict in JournalEntry schema
"""
return self._get_request('JournalEntry', JournalEntries.GET_JOURNAL_ENTRY_BY_ID.format(journal_entry_id))

def delete(self, journal_entry_id: str):
"""
Delete JournalEntry from Quickbooks Online
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='qbosdk',
version='0.19.0',
version='0.20.0',
author='Shwetabh Kumar',
author_email='[email protected]',
description='Python SDK for accessing Quickbooks Online APIs',
Expand Down

0 comments on commit e197765

Please sign in to comment.