From 0089ce85560997f82b10ed599242ff845338286d Mon Sep 17 00:00:00 2001 From: C <0xicl33n@gmail.com> Date: Sun, 4 Jan 2026 12:41:28 -0800 Subject: [PATCH] fdsadsa --- src/asquare.py | 96 ++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/src/asquare.py b/src/asquare.py index 1afa8fa..fb0bb5e 100644 --- a/src/asquare.py +++ b/src/asquare.py @@ -249,59 +249,61 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None): variations = fresh_item.get("variations", []) - if not variations: - print( - f"[@WARNING] Item {item_id} has no variations, creating new variation" - ) - variation_id = None - variation_version = None - else: - variation_id = variations[0]["id"] - variation_version = variations[0].get("version") + if not variations: + print( + f"[@WARNING] Item {item_id} has no variations, creating new variation" + ) + variation_id = None + variation_version = None + else: + variation_id = variations[0]["id"] + variation_version = variations[0].get("version") - # Get current version for version control - current_version = fresh_item.get("version") + # Get current version for version control + current_version = fresh_item.get("version") - print(f"[@DEBUG] Fresh item version: {current_version}") - print(f"[@DEBUG] Fresh variation version: {variation_version}") + print(f"[@DEBUG] Fresh item version: {current_version}") + print(f"[@DEBUG] Fresh variation version: {variation_version}") - # Build upsert body - upsert_body = { - "idempotency_key": str(uuid.uuid4()), - "object": { - "type": "ITEM", - "id": item_id, - "version": current_version, # Include version for conflict prevention - "item_data": { - "name": pw_name, - "description": f"{set_name} - {set_theme}", - "variations": [ - { - "type": "ITEM_VARIATION", - "id": ( - variation_id if variation_id else "#TEMP_VARIATION_ID" - ), - "item_variation_data": { - "item_id": item_id, - "name": "Regular", - "pricing_type": "FIXED_PRICING", - "price_money": { - "amount": price_in_cents, - "currency": "USD", + # Build upsert body + upsert_body = { + "idempotency_key": str(uuid.uuid4()), + "object": { + "type": "ITEM", + "id": item_id, + "version": current_version, # Include version for conflict prevention + "item_data": { + "name": pw_name, + "description": f"{set_name} - {set_theme}", + "variations": [ + { + "type": "ITEM_VARIATION", + "id": ( + variation_id + if variation_id + else "#TEMP_VARIATION_ID" + ), + "item_variation_data": { + "item_id": item_id, + "name": "Regular", + "pricing_type": "FIXED_PRICING", + "price_money": { + "amount": price_in_cents, + "currency": "USD", + }, + "sku": set_upc if set_upc else None, }, - "sku": set_upc if set_upc else None, - }, - } - ], + } + ], + }, }, - }, - } + } - # Remove None values - if not set_upc: - del upsert_body["object"]["item_data"]["variations"][0][ - "item_variation_data" - ]["sku"] + # Remove None values + if not set_upc: + del upsert_body["object"]["item_data"]["variations"][0][ + "item_variation_data" + ]["sku"] print(f"[@DEBUG] Upserting item {item_id} with name: {pw_name}")