-
Notifications
You must be signed in to change notification settings - Fork 13
Description
The "_make_get_request" returns a dictionary of status_code and response.text, which doesn't allow the developer to leverage the information-rich HTTP response.
Returning the full response object allows further programmability. (Current state and suggestion below)
Current state:
def __make_get_request(self, url, auth_header, url_params):
"""
Make the get request
:param url: The base url of the request
:param auth_header: The auth header
:param url_params: The params from the url
:return: A dictionary of the status_code and response
"""
try:
r = requests.get(url=url, headers={"Authorization": auth_header}, params=url_params)
return {"status_code": r.status_code, "response": r.text}
except Exception as e:
return {"status_code": 0, "response": "An error occurred, check your URL"}
Suggested:
def __make_get_request(self, url, auth_header, url_params):
"""
Make the get request
:param url: The base url of the request
:param auth_header: The auth header
:param url_params: The params from the url
:return: HTTP response
"""
try:
return requests.get(url=url, headers={"Authorization": auth_header}, params=url_params)
except Exception as e:
return {"status_code": 0, "response": "An error occurred, check your URL"}