Files
Brancheneinstufung2/connector-superoffice/simulate_sendout_via_appointment.py

44 lines
1.5 KiB
Python

import os
import requests
import json
import logging
from superoffice_client import SuperOfficeClient
from config import settings
# Setup Logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("simulation-e2e")
def simulate_sendout(contact_id: int):
print(f"🚀 Starting Appointment Creation Test for Contact {contact_id}...")
# 1. Initialize SuperOffice Client
so_client = SuperOfficeClient()
if not so_client.access_token:
print("❌ Auth failed. Check .env")
return
# 2. Create Appointment (The "Sendout Proof")
print("📅 Creating Appointment as sendout proof...")
app_subject = f"[DIAGNOSTIC TEST] Can we create an activity?"
app_desc = f"This is a test to see if the API user can create appointments."
appointment = so_client.create_appointment(
subject=app_subject,
description=app_desc,
contact_id=contact_id,
person_id=None # Explicitly test without a person
)
if appointment:
# The key might be 'appointmentId' (lowercase 'a')
appt_id = appointment.get('appointmentId') or appointment.get('AppointmentId')
print(f"✅ SUCCESS! Appointment Created with ID: {appt_id}")
print(f"🔗 Check SuperOffice for Contact {contact_id} and look at the activities.")
else:
print("❌ Failed to create appointment.")
if __name__ == "__main__":
# Using the IDs we know exist from previous tests/status
TEST_CONTACT_ID = 171185
simulate_sendout(TEST_CONTACT_ID)