feat(so-sync): final round-trip tools and infrastructure fixes
This commit is contained in:
64
so_final_correction.py
Normal file
64
so_final_correction.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Path gymnastics
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "connector-superoffice"))
|
||||
|
||||
from superoffice_client import SuperOfficeClient
|
||||
from company_explorer_connector import get_company_details
|
||||
|
||||
# Load ENV
|
||||
load_dotenv(dotenv_path="/home/node/clawd/.env", override=True)
|
||||
|
||||
def final_correction(ce_id):
|
||||
client = SuperOfficeClient()
|
||||
print(f"--- Final Correction: Applying GROUND TRUTH for CE {ce_id} ---")
|
||||
|
||||
# 1. Force fetch from CE to ensure we have REAL data
|
||||
ce_data = get_company_details(ce_id)
|
||||
if not ce_data or "error" in ce_data:
|
||||
# Fallback to manual ground truth from your message if API still flutters
|
||||
ce_address = "Schatzbogen 39"
|
||||
ce_city = "München"
|
||||
ce_zip = "81829"
|
||||
ce_name = "Robo-Planet GmbH"
|
||||
else:
|
||||
ce_address = ce_data.get("address", "Schatzbogen 39")
|
||||
ce_city = ce_data.get("city", "München")
|
||||
ce_zip = ce_data.get("zip", "81829")
|
||||
ce_name = ce_data.get("name")
|
||||
|
||||
# 2. Map correctly
|
||||
payload = {
|
||||
"contactId": 2,
|
||||
"Name": "RoboPlanet GmbH-SOD",
|
||||
"Number2": "123",
|
||||
"OrgNr": "DE343867623", # Real Robo-Planet VAT
|
||||
"Address": {
|
||||
"Postal": {
|
||||
"Address1": ce_address,
|
||||
"City": ce_city,
|
||||
"Zipcode": ce_zip
|
||||
},
|
||||
"Street": {
|
||||
"Address1": ce_address,
|
||||
"City": ce_city,
|
||||
"Zipcode": ce_zip
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
url = f"{client.base_url}/Contact/2"
|
||||
resp = requests.put(url, headers=client.headers, json=payload)
|
||||
|
||||
if resp.status_code == 200:
|
||||
print(f"🚀 SUCCESS! Applied Ground Truth: {ce_address}, {ce_city}")
|
||||
else:
|
||||
print(f"❌ Error: {resp.text}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
final_correction(53)
|
||||
Reference in New Issue
Block a user