fix(bring): properly extract items from BringItemsResponse
This commit is contained in:
@@ -137,20 +137,28 @@ class BringClientManager:
|
|||||||
list_uuid, canonical_name = await self.resolve_list(list_name)
|
list_uuid, canonical_name = await self.resolve_list(list_name)
|
||||||
list_details = await client.get_list(list_uuid)
|
list_details = await client.get_list(list_uuid)
|
||||||
|
|
||||||
|
items_container = getattr(list_details, "items", list_details)
|
||||||
|
raw_purchase = getattr(items_container, "purchase", []) or []
|
||||||
|
raw_recently = getattr(items_container, "recently", []) or []
|
||||||
|
|
||||||
# Purchase items (active to-buy)
|
# Purchase items (active to-buy)
|
||||||
purchase_items = []
|
purchase_items = []
|
||||||
for item in getattr(list_details, "purchase", []):
|
for item in raw_purchase:
|
||||||
|
name = getattr(item, "itemId", getattr(item, "name", str(item)))
|
||||||
|
spec = getattr(item, "specification", "") or ""
|
||||||
purchase_items.append({
|
purchase_items.append({
|
||||||
"name": getattr(item, "name", item.get("name") if isinstance(item, dict) else str(item)),
|
"name": name,
|
||||||
"specification": getattr(item, "specification", item.get("specification", "") if isinstance(item, dict) else ""),
|
"specification": spec or None,
|
||||||
})
|
})
|
||||||
|
|
||||||
# Recently bought items
|
# Recently bought items
|
||||||
recently_items = []
|
recently_items = []
|
||||||
for item in getattr(list_details, "recently", []):
|
for item in raw_recently:
|
||||||
|
name = getattr(item, "itemId", getattr(item, "name", str(item)))
|
||||||
|
spec = getattr(item, "specification", "") or ""
|
||||||
recently_items.append({
|
recently_items.append({
|
||||||
"name": getattr(item, "name", item.get("name") if isinstance(item, dict) else str(item)),
|
"name": name,
|
||||||
"specification": getattr(item, "specification", item.get("specification", "") if isinstance(item, dict) else ""),
|
"specification": spec or None,
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user