Skip to content

Commit

Permalink
add json_options to be passed to json.loads()
Browse files Browse the repository at this point in the history
  • Loading branch information
tavin committed Feb 15, 2018
1 parent 6097d60 commit d88fc51
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions krakenex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,19 @@ def __init__(self, key='', secret=''):
'User-Agent': 'krakenex/' + version.__version__ + ' (+' + version.__url__ + ')'
})
self.response = None
self._json_options = {}
return

def json_options(self, **kwargs):
""" Set keyword arguments to be passed to JSON deserialization.
:param kwargs: passed to :py:meth:`requests.Response.json`
:returns: this instance for chaining
"""
self._json_options = kwargs
return self

def close(self):
""" Close this session.
Expand Down Expand Up @@ -120,13 +131,13 @@ def _query(self, urlpath, data, headers=None, timeout=None):

url = self.uri + urlpath

self.response = self.session.post(url, data = data, headers = headers,
self.response = self.session.post(url, data = data, headers = headers,
timeout = timeout)

if self.response.status_code not in (200, 201, 202):
self.response.raise_for_status()

return self.response.json()
return self.response.json(**self._json_options)


def query_public(self, method, data=None, timeout=None):
Expand Down

0 comments on commit d88fc51

Please sign in to comment.