From cff03d5eee4ecda32cb2a60d25294b8f4d49928c Mon Sep 17 00:00:00 2001 From: C <0xicl33n@gmail.com> Date: Sun, 4 Jan 2026 12:17:19 -0800 Subject: [PATCH] WE ARE SO CLOSE --- src/asquare.py | 11 ++++++++--- src/glue.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/asquare.py b/src/asquare.py index ce79d1d..c5bdcf0 100644 --- a/src/asquare.py +++ b/src/asquare.py @@ -202,7 +202,7 @@ async def get_item_by_variation_id(variation_id: str) -> dict: raise -async def update_itm(item_id: str, lego_set: dict): +async def update_itm(item_id: str, lego_set: dict, item_data: dict = None): """ Asynchronously updates an item in the Square catalog based on the provided LEGO set information. Args: @@ -215,6 +215,7 @@ async def update_itm(item_id: str, lego_set: dict): - "set_image": Thumbnail URL - "pw_name": Formatted name for Square inventory (e.g., "75192 - STAR WARS UCS Millennium Falcon") - "set_adjustredprice": Retail price with 10% markup applied + item_data (dict): Optional pre-fetched item data to avoid redundant API call Returns: bool: True if the update operation was successful. Raises: @@ -233,8 +234,12 @@ async def update_itm(item_id: str, lego_set: dict): # Convert price to cents for Square API price_in_cents = int(set_adjustedprice * 100) - # Get current item to retrieve variation ID - item = await get_item_by_id(item_id) + # Get current item to retrieve variation ID (only if not provided) + if item_data is None: + item = await get_item_by_id(item_id) + else: + item = item_data + variations = item.get("variations", []) if not variations: diff --git a/src/glue.py b/src/glue.py index c5f79a1..b6a8f66 100644 --- a/src/glue.py +++ b/src/glue.py @@ -111,7 +111,7 @@ async def enrich_single_item(item_id: str, item_data: dict = None, logger=None) ) # Update Square item with enriched data - success = await asquare.update_itm(item_id, lego_set) + success = await asquare.update_itm(item_id, lego_set, item_data=item) if success: if logger: