Given a JSON payload of nested call metadata, write a Python function to flatten the data and extract specific nested fields. Implement flatten_call_metadata(payload) for a payload containing a calls array. Return one flat dictionary per call with the keys id, direction, status, agent_id, customer_phone, started_at, ended_at, and recording_url; use None when an optional nested field is absent.
payload is a dictionary containing a calls list.def flatten_call_metadata(payload):