[31188f42] Fix: Default-Umgebung auf 'online3' gesetzt & Test-Suite hinzugefügt.

- config.py: Standard-Environment auf 'online3' geändert, um Auth-Fehler ohne .env zu beheben.
- tools/create_company.py: Skript zum Anlegen von Test-Accounts in Prod.
- tools/get_enriched_company_data.py: Diagnose-Tool für API-Antworten.
- tools/verify_enrichment.py: Verifikations-Skript (zeigt aktuelles UDF-Problem).
This commit is contained in:
2026-03-04 16:30:57 +00:00
parent 4f3ff619d7
commit 50764c4490
5 changed files with 250 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
import sys
import os
import json
from dotenv import load_dotenv
# Explicitly load .env from the project root
dotenv_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '.env'))
load_dotenv(dotenv_path=dotenv_path, override=True)
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from superoffice_client import SuperOfficeClient
from config import settings
def verify_enrichment(contact_id: int):
print(f"🚀 Verifying enrichment for ContactId: {contact_id}")
try:
client = SuperOfficeClient()
if not client.access_token:
print("❌ Authentication failed.")
return
contact_data = client.get_contact(
contact_id,
select=[
"Name", "UrlAddress", "Urls", "OrgNr", "Address", "UserDefinedFields"
]
)
if not contact_data:
print(f"❌ Contact {contact_id} not found.")
return
print("\n--- 🏢 Company Profile (SuperOffice) ---")
print(f"Name: {contact_data.get('Name')}")
print(f"Website: {contact_data.get('UrlAddress')}")
print(f"VAT/OrgNr: {contact_data.get('OrgNr')}")
udfs = contact_data.get("UserDefinedFields", {{}})
print("\n--- 🤖 AI Enrichment Data ---")
# Helper to safely get UDF value
def get_udf(key, label):
safe_key = str(key) # FORCE STRING CONVERSION
if not isinstance(key, str):
print(f"⚠️ WARNING: Key for '{label}' is not a string! Type: {type(key)} Value: {key}")
if safe_key in udfs:
val = udfs[safe_key]
print(f"{label:<25}: {val}")
else:
print(f"{label:<25}: [Not Set] (Key: {safe_key})")
get_udf(settings.UDF_VERTICAL, "Vertical (Branche)")
get_udf(settings.UDF_SUMMARY, "AI Summary")
get_udf(settings.UDF_OPENER, "AI Opener Primary")
get_udf(settings.UDF_OPENER_SECONDARY, "AI Opener Secondary")
get_udf(settings.UDF_LAST_UPDATE, "AI Last Update")
get_udf(settings.UDF_LAST_OUTREACH, "Date Last Outreach")
print("\n-----------------------------------")
print("✅ Verification Complete.")
except Exception as e:
print(f"❌ Error during verification: {e}")
if __name__ == "__main__":
target_contact_id = 171185
verify_enrichment(target_contact_id)