SQUARE THESE NUTS
This commit is contained in:
1 parent
8a1856448d
commit
5cbbed1992
1 file changed
+8
-8
+8
-8
@@ -289,22 +289,22 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None):
|
|||||||
|
|
||||||
print(f"[@DEBUG] Upserting item {item_id} with name: {pw_name}")
|
print(f"[@DEBUG] Upserting item {item_id} with name: {pw_name}")
|
||||||
|
|
||||||
# Perform upsert using batch_upsert_catalog_objects (async version)
|
# Perform upsert using catalog.object.upsert
|
||||||
result = await client.catalog.batch_upsert_catalog_objects(
|
result = await client.catalog.object.upsert(
|
||||||
body={
|
idempotency_key=upsert_body["idempotency_key"],
|
||||||
"idempotency_key": upsert_body["idempotency_key"],
|
object=upsert_body["object"],
|
||||||
"batches": [{"objects": [upsert_body["object"]]}],
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
result_json = json.loads(result.model_dump_json())
|
result_json = json.loads(result.model_dump_json())
|
||||||
|
|
||||||
if result_json.get("objects"):
|
if result_json.get("catalog_object"):
|
||||||
print(f"[@DEBUG] ✓ Successfully updated item {item_id}")
|
print(f"[@DEBUG] ✓ Successfully updated item {item_id}")
|
||||||
# TODO: Handle image upload separately (Square Images API)
|
# TODO: Handle image upload separately (Square Images API)
|
||||||
# This requires multipart/form-data upload
|
# This requires multipart/form-data upload
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print(f"[@ERROR] Failed to update item {item_id}: No objects in response")
|
print(
|
||||||
|
f"[@ERROR] Failed to update item {item_id}: No catalog_object in response"
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in new issue
Block a user