Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the body of user request as output #109

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions odins_spear/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _request(self, method, endpoint, data=None, params=None):
data=json.dumps(data if data is not None else {}),
params=(params if params is not None else {})
)

# if logger used log request
if self.logger:
self.logger._log_request(endpoint=endpoint, response_code=response.status_code)
Expand All @@ -76,7 +76,10 @@ def _request(self, method, endpoint, data=None, params=None):
except requests.exceptions.RequestException:
raise OSApiResponseError(response)
else:
return response.json()
# for methods where call is a success but returns no useful data
if response.text == '[]':
return response.status_code
return response.json()n


@sleep_and_retry
Expand All @@ -102,7 +105,8 @@ def _rate_limited_request(self, method, endpoint, data=None, params=None):
except requests.exceptions.RequestException:
raise OSApiResponseError(response)
else:
# for methods where call is a success but returns no useful data
if response.text == '[]':
return response.status_code
return response.json()