Skip to content

Commit 2dffeb9

Browse files
authored
Fix for bug where >12 and < 50 vehicles would error (#6)
* Fix for API error where >12 and <50 vehicles are found * Documenting TODO in HTTP helper library
1 parent 7f12f61 commit 2dffeb9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/libs/http.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ async def get(
9595
# If the length of the results list is 1, this is likely the results of a single
9696
# HTTP request. So returning just that one result, not a list containing one item.
9797
# If the length is > 1, return the list containing the httpx.Responses.
98+
# TODO: Return all results as a list. Will need to refactor all manufacturer
99+
# routers.
98100
if len(results) == 1:
99101
return results[0]
100102
else:

src/routers/ford.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ async def main(
160160

161161
remainder = await http.get(uri=urls_to_fetch)
162162

163+
# If we only have the initial API call and one additional API call, the response
164+
# back from the http helper library is a httpx.Response object. If we have multiple
165+
# additional API calls, the response back is a list. Catching this situation and
166+
# throwing that single httpx.Response object into a list for further processing.
167+
if type(remainder) != list:
168+
remainder = [remainder]
169+
163170
# Loop through the inventory results list
164171
for api_result in remainder:
165172
result = api_result.json()

0 commit comments

Comments
 (0)