Skip to content

API endpoint methods should return response objects #12

Description

@Quantra

Issue:

Endpoint methods currently return the JSON result from the API as a python object.

This means all other information regarding the response is lost, such as the status code. It also means the return type is unknown as it can sometimes be a list and other times a dict.

This leads to the issue that the only way to determine if a response was a 400 or 200 is by inspecting the returned result.

Proposed solution:

Return response objects with either the content attribute decoded and replaced in place or with another attribute result with the decoded JSON. the decoded json content is available with response.json()

I am happy to make a PR for this but it's a backwards incompatible change!

Perhaps there is a way to make it backwards compatible by returning an object of a custom class that behaves as the list/dict but with extra attributes for the response object. But this sounds complicated =]

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions