53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
import sys
|
|
import os
|
|
import json
|
|
|
|
# Absolute path setup
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
connector_dir = os.path.abspath(os.path.join(current_dir, '..'))
|
|
sys.path.insert(0, connector_dir)
|
|
|
|
from superoffice_client import SuperOfficeClient
|
|
|
|
def check_selection():
|
|
selection_id = 10960
|
|
print(f"🔎 Inspecting Selection {selection_id} (Alle_Contacts_Roboplanet)...")
|
|
client = SuperOfficeClient()
|
|
if not client.access_token:
|
|
print("❌ Auth failed.")
|
|
return
|
|
|
|
# 1. Get Selection Metadata
|
|
print("\n📋 Fetching Selection Details...")
|
|
details = client._get(f"Selection/{selection_id}")
|
|
if details:
|
|
print(f" Name: {details.get('Name')}")
|
|
print(f" Description: {details.get('Description')}")
|
|
print(f" Type: {details.get('SelectionType')}") # e.g. Dynamic, Static
|
|
|
|
# 2. Fetch Members via direct Selection endpoint
|
|
print("\n👥 Fetching first 10 Members via direct Selection endpoint...")
|
|
# Direct endpoint for Contact members of a selection
|
|
endpoint = f"Selection/{selection_id}/ContactMembers?$top=10"
|
|
|
|
try:
|
|
members_resp = client._get(endpoint)
|
|
# OData usually returns a 'value' list
|
|
members = members_resp.get('value', []) if isinstance(members_resp, dict) else members_resp
|
|
|
|
if members and isinstance(members, list):
|
|
print(f"✅ Found {len(members)} members in first page:")
|
|
for m in members:
|
|
# Structure might be flat or nested
|
|
name = m.get('Name') or m.get('name')
|
|
cid = m.get('ContactId') or m.get('contactId')
|
|
print(f" - {name} (ContactID: {cid})")
|
|
else:
|
|
print("⚠️ No members found or response format unexpected.")
|
|
print(f"DEBUG: {json.dumps(members_resp, indent=2)}")
|
|
except Exception as e:
|
|
print(f"❌ Direct Selection members query failed: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
check_selection()
|