$file = 'deal_updates.txt';
$input = file_get_contents('php://input');
$data = json_decode($input, true);
if (isset($data['event']) && $data['event'] === 'ONCRMDEALUPDATE') {
$dealId = $data['data']['FIELDS']['ID'];
$newStatus = $data['data']['FIELDS']['STATUS_ID'];
$updateDate = date('Y-m-d H:i:s');
$log = "Deal ID: $dealId | New Status: $newStatus | Updated at: $updateDate\n";
file_put_contents($file, $log, FILE_APPEND);
}
http_response_code(200);
echo 'OK';