61 lines
1.8 KiB
Python
61 lines
1.8 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
|
|
from config import settings
|
|
|
|
def find_missing():
|
|
print("🔎 Scanning for Associate IDs not in Whitelist...")
|
|
client = SuperOfficeClient()
|
|
if not client.access_token:
|
|
print("❌ Auth failed.")
|
|
return
|
|
|
|
whitelist = settings.ROBOPLANET_WHITELIST
|
|
|
|
# Fetch 500 contacts
|
|
limit = 500
|
|
endpoint = f"Contact?$orderby=contactId desc&$top={limit}&$select=associateId"
|
|
|
|
print(f"📡 Scanning {limit} records...")
|
|
contacts = client.search(endpoint)
|
|
|
|
if contacts:
|
|
missing_ids = set()
|
|
match_count = 0
|
|
for c in contacts:
|
|
aid = c.get('associateId') or c.get('AssociateId')
|
|
if aid:
|
|
is_match = False
|
|
if str(aid).upper() in whitelist: is_match = True
|
|
try:
|
|
if int(aid) in whitelist: is_match = True
|
|
except: pass
|
|
|
|
if is_match:
|
|
match_count += 1
|
|
else:
|
|
missing_ids.add(aid)
|
|
|
|
print(f"\n📊 Scan Results ({limit} records):")
|
|
print(f" - Total Matches (Roboplanet): {match_count}")
|
|
print(f" - Missing/Other IDs: {len(missing_ids)}")
|
|
|
|
if missing_ids:
|
|
print("\n✅ Found IDs NOT in whitelist:")
|
|
for mid in sorted(list(missing_ids), key=lambda x: str(x)):
|
|
print(f" - {mid}")
|
|
|
|
print("\n👉 Bitte prüfe, ob eine dieser IDs ebenfalls zu Roboplanet gehört.")
|
|
else:
|
|
print("❌ No contacts found.")
|
|
|
|
if __name__ == "__main__":
|
|
find_missing()
|