from __future__ import annotations

from typing import Any, Dict

from magento.magento_api import MagentoRestClient


def rename_product_sku(api: MagentoRestClient, old_sku: str, new_sku: str) -> Dict[str, Any]:
    """Rename a Magento product SKU via REST (no other attribute changes)."""
    old_sku = str(old_sku or "").strip()
    new_sku = str(new_sku or "").strip()
    if not old_sku or not new_sku:
        raise ValueError("old_sku and new_sku are required")
    if old_sku == new_sku:
        return {"old_sku": old_sku, "new_sku": new_sku, "changed": False}
    body = api.update_product(old_sku, {"sku": new_sku})
    return {"old_sku": old_sku, "new_sku": new_sku, "changed": True, "response": body}
