feat(so-sync): bidirectional round-trip for company data established [lessons-learned]
This commit is contained in:
@@ -9,37 +9,17 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def discover_contact_structure():
|
||||
load_dotenv(dotenv_path="../.env")
|
||||
auth = AuthHandler()
|
||||
client = SuperOfficeClient(auth)
|
||||
load_dotenv(dotenv_path="/home/node/clawd/.env", override=True)
|
||||
client = SuperOfficeClient()
|
||||
|
||||
logger.info("Fetching a single contact to inspect structure...")
|
||||
logger.info("Fetching contact ID 2 to inspect structure...")
|
||||
|
||||
# Try to get the first contact (usually ID 1 exists or can be found)
|
||||
# If not, we try to create a dummy and then inspect it.
|
||||
url = client._get_url("v1/Contact/1")
|
||||
try:
|
||||
resp = client.session.get(url, headers=client._get_headers())
|
||||
if resp.status_code == 200:
|
||||
contact = resp.json()
|
||||
print("\n--- CONTACT STRUCTURE ---")
|
||||
print(json.dumps(contact, indent=2))
|
||||
else:
|
||||
logger.warning(f"Contact 1 not found (Status {resp.status_code}). Trying to list contacts...")
|
||||
url = client._get_url("v1/Contact?$top=1")
|
||||
resp = client.session.get(url, headers=client._get_headers())
|
||||
resp.raise_for_status()
|
||||
contacts = resp.json().get("value", [])
|
||||
if contacts:
|
||||
print("\n--- CONTACT STRUCTURE (from list) ---")
|
||||
print(json.dumps(contacts[0], indent=2))
|
||||
else:
|
||||
print("\nNo contacts found in tenant. Please create one manually in the UI or stay tuned.")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to fetch contact: {e}")
|
||||
if hasattr(e, 'response') and e.response is not None:
|
||||
print(f"Details: {e.response.text}")
|
||||
contact = client._get("Contact/2")
|
||||
if contact:
|
||||
print("\n--- CONTACT STRUCTURE ---")
|
||||
print(json.dumps(contact, indent=2))
|
||||
else:
|
||||
logger.error("Failed to fetch contact.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
discover_contact_structure()
|
||||
|
||||
Reference in New Issue
Block a user