[2ff88f42] 1. Analyse der Änderungen:
1. Analyse der Änderungen:
* superoffice_client.py: Implementierung der Methoden create_contact (Standardfelder) und create_person (inkl. Firmenverknüpfung).
* auth_handler.py: Härtung der Authentifizierung durch Priorisierung von SO_CLIENT_ID und Unterstützung für load_dotenv(override=True).
* main.py: Erweiterung des Test-Workflows für den vollständigen Lese- und Schreib-Durchstich (Erstellung von Demo-Firmen und Personen).
* README.md: Aktualisierung des Status Quo und der verfügbaren Client-Methoden.
This commit is contained in:
@@ -13,7 +13,12 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
def main():
|
||||
# Load .env from the root directory
|
||||
load_dotenv(dotenv_path="../.env")
|
||||
# If running from /app, .env is in the same directory.
|
||||
# If running from /app/connector-superoffice, it's in ../.env
|
||||
if os.path.exists(".env"):
|
||||
load_dotenv(".env", override=True)
|
||||
elif os.path.exists("../.env"):
|
||||
load_dotenv("../.env", override=True)
|
||||
|
||||
logger.info("Starting SuperOffice Connector S2S POC...")
|
||||
|
||||
@@ -33,24 +38,51 @@ def main():
|
||||
logger.error("Connection test failed.")
|
||||
return
|
||||
|
||||
# 2. Search for a test contact
|
||||
test_company = "Wackler Holding"
|
||||
logger.info(f"Step 2: Searching for company '{test_company}'...")
|
||||
contact = client.find_contact_by_criteria(name=test_company)
|
||||
# 2. Search for our demo company
|
||||
demo_company_name = "Gemini Test Company [2ff88f42]"
|
||||
logger.info(f"Step 2: Searching for company '{demo_company_name}'...")
|
||||
contact = client.find_contact_by_criteria(name=demo_company_name)
|
||||
|
||||
target_contact_id = None
|
||||
|
||||
if contact:
|
||||
logger.info(f"Found contact: {contact.get('Name')} (ID: {contact.get('ContactId')})")
|
||||
|
||||
# 3. Try to update UDFs (Warning: technical names might be wrong)
|
||||
# logger.info("Step 3: Attempting UDF update (experimental)...")
|
||||
# ai_test_data = {
|
||||
# "potential": "High",
|
||||
# "industry": "Facility Management",
|
||||
# "summary": "KI-Analyse erfolgreich durchgeführt."
|
||||
# }
|
||||
# client.update_udfs(contact.get('ContactId'), ai_test_data)
|
||||
target_contact_id = contact.get('ContactId')
|
||||
logger.info(f"Found existing demo company: {contact.get('Name')} (ID: {target_contact_id})")
|
||||
else:
|
||||
logger.info(f"Contact '{test_company}' not found.")
|
||||
logger.info(f"Demo company not found. Creating new one...")
|
||||
demo_company_url = "https://www.gemini-test-company.com"
|
||||
demo_company_orgnr = "DE123456789"
|
||||
|
||||
new_contact = client.create_contact(
|
||||
name=demo_company_name,
|
||||
url=demo_company_url,
|
||||
org_nr=demo_company_orgnr
|
||||
)
|
||||
if new_contact:
|
||||
target_contact_id = new_contact.get('ContactId')
|
||||
logger.info(f"Created new demo company with ID: {target_contact_id}")
|
||||
|
||||
# 3. Create a Person linked to this company
|
||||
if target_contact_id:
|
||||
logger.info(f"Step 3: Creating Person for Contact ID {target_contact_id}...")
|
||||
|
||||
# Create Max Mustermann
|
||||
person = client.create_person(
|
||||
first_name="Max",
|
||||
last_name="Mustermann",
|
||||
contact_id=target_contact_id,
|
||||
email="max.mustermann@gemini-test.com"
|
||||
)
|
||||
|
||||
if person:
|
||||
logger.info("SUCCESS: Person created!")
|
||||
logger.info(f"Name: {person.get('Firstname')} {person.get('Lastname')}")
|
||||
logger.info(f"Person ID: {person.get('PersonId')}")
|
||||
logger.info(f"Linked to Contact ID: {person.get('Contact').get('ContactId')}")
|
||||
else:
|
||||
logger.error("Failed to create person.")
|
||||
else:
|
||||
logger.error("Skipping person creation because company could not be found or created.")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}", exc_info=True)
|
||||
|
||||
Reference in New Issue
Block a user