import requests
import json
import logging

def send_interview_report(api_url, interview_id, recording_url, report_data):
    # Prepare the payload
    payload = {
        "interviewId": interview_id,
        "recordingUrl": recording_url,
        "reportData": report_data,
    }

    logging.info(f"Payload: {payload}")

    # Dump the payload to a JSON file for debugging
    with open("payload_dump.json", "w") as json_file:
        json.dump(payload, json_file, indent=4)
    
    try:
        # Send the POST request
        response = requests.put(api_url, json=payload)
        
        # Raise an exception if the request was not successful
        response.raise_for_status()
        
        # Return the JSON response
        return response.json()
    
    except requests.exceptions.RequestException as e:
        print(f"An error occurred: {e}")
        return None