Skip to content

Suggestion, return full response object from "_make_get_request" #1

Description

@michaelmernin

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"}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions