Skip to content

Commit

Permalink
Added support for get_by_id for resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartikey authored and Kartikey committed Jun 23, 2021
1 parent 08f5716 commit c52a30a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fyle/platform/internals/get_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ def __init__(self, version, role, endpoint):

self.api = ApiBase(self.version, self.role)

def get(self, id_: str = None, query_params=None) -> Dict:
def get_by_id(self, id_: str) -> Dict:
"""
Get Single Resource object by ID
:param id_: Resource object ID
:param query_params:
:return: Resource Object
"""
query_params = {} if query_params is None else query_params
query_params = {}
api_url = self.endpoint

if id_:
query_params['id'] = 'eq.{}'.format(id_)
if not id_:
raise exceptions.WrongParamsError('Invalid Parameters')

query_params['id'] = 'eq.{}'.format(id_)
response = self.api.make_get_request(
api_url=api_url,
query_params=query_params,
Expand All @@ -40,4 +40,6 @@ def get(self, id_: str = None, query_params=None) -> Dict:
elif id_ and response['count'] > 1:
raise exceptions.MultipleObjectReturned('Multiple Objects returned')

return response
return {
'data': response.get('data')[0]
}

0 comments on commit c52a30a

Please sign in to comment.