Files
Brancheneinstufung2/connector-superoffice/discover_fields.py
Floke 8e863b259e [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.
2026-02-10 12:43:26 +00:00

50 lines
1.9 KiB
Python

import os
from config import Config
from logging_config import setup_logging
from auth_handler import AuthHandler
from superoffice_client import SuperOfficeClient
logger = setup_logging("discovery")
def get_list_items_by_prog_id(client, prog_id, entity_name):
"""Fetches and prints list items for a specific ProgId."""
logger.info(f"--- Fetching list items for {entity_name} ProgId: {prog_id} ---")
list_url = client._get_url(f"v1/List/UserDefinedField/{prog_id}")
try:
list_resp = client.session.get(list_url, headers=client._get_headers())
list_resp.raise_for_status()
list_items = list_resp.json()
if list_items.get("value"):
print(f" --- List Items Found for {prog_id} ---")
for item in list_items["value"]:
print(f" ID: {item.get('Id'):<5} | Name: {item.get('Name')}")
return {item.get('Name'): item.get('Id') for item in list_items["value"]}
except Exception as e:
logger.error(f"Failed to fetch list items for {prog_id}: {e}")
return None
def get_activity_types(client):
"""Fetches available activity types."""
logger.info("--- Fetching Activity Types ---")
url = client._get_url("v1/ActivityType")
try:
resp = client.session.get(url, headers=client._get_headers())
resp.raise_for_status()
activity_types = resp.json()
if activity_types:
print(" --- Activity Types Found ---")
for atype in activity_types:
print(f" ID: {atype.get('Id'):<5} | Name: {atype.get('Name')}")
return {atype.get('Name'): atype.get('Id') for atype in activity_types}
except Exception as e:
logger.error(f"Failed to fetch activity types: {e}")
return None
def main():
auth = AuthHandler()
client = SuperOfficeClient(auth)
get_activity_types(client)
if __name__ == "__main__":
main()