WE ARE SO CLOSE
This commit is contained in:
1 parent
3e21b904a2
commit
cff03d5eee
2 files changed
+8
-3
No files matched your search
+7
-2
@@ -202,7 +202,7 @@ async def get_item_by_variation_id(variation_id: str) -> dict:
|
|||||||
raise
|
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.
|
Asynchronously updates an item in the Square catalog based on the provided LEGO set information.
|
||||||
Args:
|
Args:
|
||||||
@@ -215,6 +215,7 @@ async def update_itm(item_id: str, lego_set: dict):
|
|||||||
- "set_image": Thumbnail URL
|
- "set_image": Thumbnail URL
|
||||||
- "pw_name": Formatted name for Square inventory (e.g., "75192 - STAR WARS UCS Millennium Falcon")
|
- "pw_name": Formatted name for Square inventory (e.g., "75192 - STAR WARS UCS Millennium Falcon")
|
||||||
- "set_adjustredprice": Retail price with 10% markup applied
|
- "set_adjustredprice": Retail price with 10% markup applied
|
||||||
|
item_data (dict): Optional pre-fetched item data to avoid redundant API call
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if the update operation was successful.
|
bool: True if the update operation was successful.
|
||||||
Raises:
|
Raises:
|
||||||
@@ -233,8 +234,12 @@ async def update_itm(item_id: str, lego_set: dict):
|
|||||||
# Convert price to cents for Square API
|
# Convert price to cents for Square API
|
||||||
price_in_cents = int(set_adjustedprice * 100)
|
price_in_cents = int(set_adjustedprice * 100)
|
||||||
|
|
||||||
# Get current item to retrieve variation 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)
|
item = await get_item_by_id(item_id)
|
||||||
|
else:
|
||||||
|
item = item_data
|
||||||
|
|
||||||
variations = item.get("variations", [])
|
variations = item.get("variations", [])
|
||||||
|
|
||||||
if not variations:
|
if not variations:
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ async def enrich_single_item(item_id: str, item_data: dict = None, logger=None)
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Update Square item with enriched data
|
# 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 success:
|
||||||
if logger:
|
if logger:
|
||||||
|
|||||||
Reference in new issue
Block a user