namespace App\Core\Services; use App\Core\Interfaces\ApiInterface; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; class FreeFireService implements ApiInterface { public function getPlayerInfo(string $uid, string $region): array { $apiUrl = config('app.env') === 'production' ? env('FF_API_URL') : 'https://devsketvia.xyz/player-info'; $timeout = (int) env('FF_API_TIMEOUT', 10); try { $response = Http::timeout($timeout)->get($apiUrl, [ 'uid' => $uid, 'region' => $region ]); if ($response->successful()) { $data = $response->json(); // Assuming API returns specific error flags or empty data if (empty($data) || isset($data['error'])) { return ['error' => 'Player not found.']; } return $data; } return ['error' => 'API Error: Invalid UID or Region.']; } catch (\Exception $e) { Log::error('FF API Error: ' . $e->getMessage()); return ['error' => 'Service temporarily unavailable.']; } } }