[2ff88f42] refactor(connector-superoffice): finalize production readiness cleanup

- Integrated centralized logging system in all modules.
- Extracted all IDs and ProgIds into a separate .
- Refactored  and  for cleaner dependency management.
- Included updated discovery and inspection utilities.
- Verified end-to-end workflow stability.
This commit is contained in:
2026-02-10 12:43:26 +00:00
parent 42f1679377
commit 8e863b259e
9 changed files with 185 additions and 255 deletions

View File

@@ -1,25 +1,15 @@
import os
import logging
from dotenv import load_dotenv
from auth_handler import AuthHandler
from superoffice_client import SuperOfficeClient
from explorer_client import CompanyExplorerClient
from logging_config import setup_logging
# Setup logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
# Use the centralized logging configuration
logger = setup_logging(__name__)
def main():
# Load .env from the root directory
# 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)
# Note: Environment loading is now handled by config.py/helpers implicitly when clients are initialized
logger.info("Starting SuperOffice Connector S2S POC...")
@@ -55,11 +45,9 @@ def main():
contact = client.find_contact_by_criteria(name=demo_company_name)
target_contact_id = None
contact_obj = None # Store the full contact object
if contact:
target_contact_id = contact.get('ContactId')
contact_obj = contact
logger.info(f"Found existing demo company: {contact.get('Name')} (ID: {target_contact_id})")
else:
logger.info(f"Demo company not found. Creating new one...")
@@ -73,12 +61,8 @@ def main():
)
if new_contact:
target_contact_id = new_contact.get('ContactId')
contact_obj = new_contact
logger.info(f"Created new demo company with ID: {target_contact_id}")
# ... (Steps 3-7 remain the same, I will insert the sync step at the end) ...
# 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}...")
@@ -181,4 +165,4 @@ def main():
logger.error(f"An error occurred: {e}", exc_info=True)
if __name__ == "__main__":
main()
main()