Move body of Client._get to State
This commit is contained in:
@@ -108,19 +108,8 @@ class Client(object):
|
|||||||
INTERNAL REQUEST METHODS
|
INTERNAL REQUEST METHODS
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _get(self, url, params, error_retries=3):
|
def _get(self, url, params):
|
||||||
params.update(self._state.get_params())
|
return self._state._get(url, params)
|
||||||
r = self._state._session.get(prefix_url(url), params=params)
|
|
||||||
content = check_request(r)
|
|
||||||
j = to_json(content)
|
|
||||||
try:
|
|
||||||
handle_payload_error(j)
|
|
||||||
except FBchatPleaseRefresh:
|
|
||||||
if error_retries > 0:
|
|
||||||
self._state._do_refresh()
|
|
||||||
return self._get(url, params, error_retries=error_retries - 1)
|
|
||||||
raise
|
|
||||||
return j
|
|
||||||
|
|
||||||
def _post(self, url, data, files=None, as_graphql=False, error_retries=3):
|
def _post(self, url, data, files=None, as_graphql=False, error_retries=3):
|
||||||
data.update(self._state.get_params())
|
data.update(self._state.get_params())
|
||||||
|
@@ -201,3 +201,17 @@ class State(object):
|
|||||||
self._revision = new._revision
|
self._revision = new._revision
|
||||||
self._counter = new._counter
|
self._counter = new._counter
|
||||||
self._logout_h = new._logout_h or self._logout_h
|
self._logout_h = new._logout_h or self._logout_h
|
||||||
|
|
||||||
|
def _get(self, url, params, error_retries=3):
|
||||||
|
params.update(self.get_params())
|
||||||
|
r = self._session.get(_util.prefix_url(url), params=params)
|
||||||
|
content = _util.check_request(r)
|
||||||
|
j = _util.to_json(content)
|
||||||
|
try:
|
||||||
|
_util.handle_payload_error(j)
|
||||||
|
except _exception.FBchatPleaseRefresh:
|
||||||
|
if error_retries > 0:
|
||||||
|
self._do_refresh()
|
||||||
|
return self._get(url, params, error_retries=error_retries - 1)
|
||||||
|
raise
|
||||||
|
return j
|
||||||
|
Reference in New Issue
Block a user