Deploy: 2026-06-18 16:46:51

This commit is contained in:
Hamza-Ayed
2026-06-18 16:46:51 +03:00
parent 9a4d610bdd
commit e0c7f39ff6
4 changed files with 464 additions and 61 deletions

View File

@@ -517,4 +517,78 @@ EOT,
default => $syriaPrompts,
};
}
/**
* Fetch recent rides for a user from Siro
*/
public static function getUserRides(string $country, string $phone, int $limit = 5): ?array
{
$apiUrl = self::getApiUrl($country);
$apiKey = getenv('NABEH_API_KEY') ?: '';
$ridesUrl = $apiUrl . '/nabeh/get_user_rides.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ridesUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone' => $phone,
'limit' => $limit,
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
error_log("[SiroService] getUserRides failed: HTTP {$httpCode} - {$res}");
return null;
}
$data = json_decode($res, true);
return $data['rides'] ?? $data['data'] ?? null;
}
/**
* Submit a complaint with AI analysis via Siro
*/
public static function submitComplaint(string $country, string $phone, string $rideId, string $complaintText): ?array
{
$apiUrl = self::getApiUrl($country);
$apiKey = getenv('NABEH_API_KEY') ?: '';
$complaintUrl = $apiUrl . '/nabeh/submit_complaint.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $complaintUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone' => $phone,
'ride_id' => $rideId,
'complaint_text' => $complaintText,
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
error_log("[SiroService] submitComplaint failed: HTTP {$httpCode} - {$res}");
return null;
}
return json_decode($res, true);
}
}