feat: implement backend API clients for multi-marketplace integration and frontend service layer

This commit is contained in:
2026-05-12 13:16:14 +03:00
parent 6974af486a
commit ee39a3d83b
65 changed files with 2501 additions and 33 deletions

View File

@@ -0,0 +1,45 @@
import os
import sys
from dotenv import load_dotenv
# Add parent dir to path so we can import backend packages
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from backend.lamoda_api import LamodaAPI
from backend.lamoda_api.exceptions import LamodaAPIError
def test_lamoda_api():
# Load environment variables
env_path = os.path.join(os.path.dirname(__file__), '.env')
load_dotenv(env_path)
# Check if key is loaded
api_key = os.getenv('LAMODA_API_KEY')
if not api_key:
print("Error: LAMODA_API_KEY must be in backend/.env")
return
print("Initializing LamodaAPI...")
api = LamodaAPI()
try:
# Test 1: Get Products
print("\n--- Testing Products API ---")
products_response = api.products.get_list(limit=5)
print("Success! Response keys:", products_response.keys())
# Depending on Lamoda's response wrapper, it might be in 'data' or 'items'
items = products_response.get("data", [])
if not items:
items = products_response.get("items", [])
print(f"Found {len(items)} products in catalog.")
except LamodaAPIError as e:
print(f"API Error: {e}")
except Exception as e:
print(f"Unexpected Error: {e}")
if __name__ == '__main__':
test_lamoda_api()