<?php
require_once __DIR__.'/../../_bootstrap.php';
$u=apiUsuario($pdo);$uid=(int)$u['id'];
if($_SERVER['REQUEST_METHOD']!=='POST')jsonResponse(['ok'=>false,'erro'=>'Método não permitido.'],405);
$d=requestJson();
try{
    afConsentRevoke($pdo,$uid,(int)($d['link_id']??0),(string)($d['reason']??'Revogado pelo responsável'));
    jsonResponse(['ok'=>true,'message'=>'Consentimentos revogados.']);
}catch(Throwable $e){jsonResponse(['ok'=>false,'erro'=>$e->getMessage()],422);}
