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 2 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
7 changes: 5 additions & 2 deletions odins_spear/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def delete(self, endpoint, data=None):

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a think about this and I've landed on just returning the status code. I think returning what is sent it pointless because the developer either has that already or it will be wiped from memory straight away in a loop. Lets other some more functionality but keep it light with the status code.

Change it to 'return response.status_code'


def _request(self, method, endpoint, data=None, params=None):


if self.rate_limit:
return self._rate_limited_request(method, endpoint, data, params)
else:
Expand All @@ -45,7 +43,10 @@ def _request(self, method, endpoint, data=None, params=None):
)
self.logger._log_request(endpoint=endpoint, response_code=response.status_code)
response.raise_for_status()
if isinstance(response.json(), list):
return response.request.body
return response.json()



@sleep_and_retry
Expand All @@ -59,5 +60,7 @@ def _rate_limited_request(self, method, endpoint, data=None, params=None):
)
self.logger._log_request(endpoint=endpoint, response_code=response.status_code)
response.raise_for_status()
if isinstance(response.json(), list):
return response.request.body
return response.json()