import sys import os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from superoffice_client import SuperOfficeClient def create_test_person(contact_id: int): """ Creates a new person for a given contact ID. """ print(f"🚀 Attempting to create a person for Contact ID: {contact_id}") try: client = SuperOfficeClient() if not client.access_token: print("❌ Authentication failed.") return payload = { "Contact": {"ContactId": contact_id}, "Firstname": "Test", "Lastname": "Person", "Emails": [ { "Value": "floke.com@gmail.com", "Description": "Work Email" } ] } new_person = client._post("Person", payload) if new_person and "PersonId" in new_person: person_id = new_person["PersonId"] print(f"✅ SUCCESS! Created person with PersonId: {person_id}") return person_id else: print(f"❌ Failed to create person. Response: {new_person}") return None except Exception as e: print(f"An error occurred: {e}") return None if __name__ == "__main__": TEST_CONTACT_ID = 171185 if len(sys.argv) > 1: TEST_CONTACT_ID = int(sys.argv[1]) create_test_person(TEST_CONTACT_ID)