Skip to content

Commit

Permalink
Fixed nested API list response (#11)
Browse files Browse the repository at this point in the history
* Fixed nested API list response

* Bumped patch to 0.5.2
  • Loading branch information
nicholas-ramsey authored Aug 30, 2021
1 parent d003a94 commit 84b4a2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [0.5.2] - 2021-08-30

- Fixed `list` and `all` methods for certain collections wherein the Ordway API results are nested under the collection name. As an example API response, `{"usages": [], "total": 0}` would've previously been `[]`.

## [0.4.0] - 2020-09-22

- Added support for updating following entities:
Expand Down
2 changes: 1 addition & 1 deletion ordway/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.1" # pragma: no cover
__version__ = "0.5.2" # pragma: no cover
12 changes: 11 additions & 1 deletion ordway/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,17 @@ def list( # pylint: disable=too-many-arguments
)

if isinstance(response_json, dict):
response_json = [response_json]
# For some endpoints, Ordway nests the results
# under the collection name so as to include
# additional metadata
# For example,
# { "usages": [], "total": 0 }
results = response_json.get(self.collection.lower())

if isinstance(results, list):
response_json = results
else:
response_json = [response_json]

# Mostly for consistency's sake.
for result in response_json:
Expand Down

0 comments on commit 84b4a2d

Please sign in to comment.