test
This commit is contained in:
1 parent
187bf1c111
commit
8c11958d95
1 file changed
+9
-9
+9
-9
@@ -64,15 +64,15 @@ async def get_item_by_id(item_id: str) -> dict:
|
||||
Exception: If item not found or API error
|
||||
"""
|
||||
try:
|
||||
result = await client.catalog.retrieve_catalog_object(
|
||||
object_id=item_id, include_related_objects=True
|
||||
result = await client.catalog.batch_retrieve_catalog_objects(
|
||||
body={"object_ids": [item_id], "include_related_objects": True}
|
||||
)
|
||||
result_json = json.loads(result.model_dump_json())
|
||||
|
||||
if not result_json.get("object"):
|
||||
if not result_json.get("objects"):
|
||||
raise ValueError(f"Item {item_id} not found")
|
||||
|
||||
obj = result_json["object"]
|
||||
obj = result_json["objects"][0]
|
||||
item_data = obj.get("item_data", {})
|
||||
|
||||
return {
|
||||
@@ -107,16 +107,16 @@ async def get_item_by_variation_id(variation_id: str) -> dict:
|
||||
Exception: If variation/item not found or API error
|
||||
"""
|
||||
try:
|
||||
# Get variation object
|
||||
result = await client.catalog.retrieve_catalog_object(
|
||||
object_id=variation_id, include_related_objects=True
|
||||
# Get variation object using batch_retrieve
|
||||
result = await client.catalog.batch_retrieve_catalog_objects(
|
||||
body={"object_ids": [variation_id], "include_related_objects": True}
|
||||
)
|
||||
result_json = json.loads(result.model_dump_json())
|
||||
|
||||
if not result_json.get("object"):
|
||||
if not result_json.get("objects"):
|
||||
raise ValueError(f"Variation {variation_id} not found")
|
||||
|
||||
variation_obj = result_json["object"]
|
||||
variation_obj = result_json["objects"][0]
|
||||
|
||||
# Get parent item ID from variation
|
||||
item_id = variation_obj.get("item_variation_data", {}).get("item_id")
|
||||
|
||||
Reference in new issue
Block a user