You've already forked akaunting-py
Added exception for AccountNotFound
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from importlib.metadata import version, PackageNotFoundError
|
||||
from unittest.mock import seal
|
||||
import requests
|
||||
import json
|
||||
from requests.auth import HTTPBasicAuth
|
||||
@@ -75,6 +76,14 @@ class Client(object):
|
||||
def get_accounts(self, **params):
|
||||
data = self.call(endpoint="accounts", **params)
|
||||
|
||||
if params.get('search', False):
|
||||
# Check if there is an account returned
|
||||
if data['meta']['pagination'].get('count') == 0:
|
||||
# No account found
|
||||
raise exceptions.AccountNotFound("Sorry, account not found matching search parameters: %s".format(
|
||||
params.get('search')
|
||||
))
|
||||
|
||||
return data['data']
|
||||
|
||||
def create_transaction(self,
|
||||
|
||||
@@ -18,3 +18,11 @@ class InvalidData(Error):
|
||||
Args:
|
||||
Error (_type_): _description_
|
||||
"""
|
||||
|
||||
class AccountNotFound(Error):
|
||||
"""
|
||||
Account not found
|
||||
|
||||
Args:
|
||||
Error (_type_): _description_
|
||||
"""
|
||||
Reference in New Issue
Block a user