in pygenie/client.py [0:0]
def _call(url, *args, **kwargs):
"""
Wrap HTTP request _calls to the Genie server.
"""
if kwargs.get('data'):
kwargs['data'] = json.dumps(kwargs['data'])
header = {'Content-Type': 'application/json'}
resp = call(url, headers=header, *args, **kwargs)
if not hasattr(resp, 'content'):
return None
response = {}
content = resp.json() if resp.content else {}
# Genie nests the responses differently depending on whether the type is a
# list, dict, or string response type
if isinstance(content, list):
response['response'] = content
elif content.get('_embedded'):
response['response'] = content['_embedded']
else:
response['response'] = content
response['headers'] = resp.headers
if isinstance(content, dict):
response['page'] = content.get('page')
return response