url($endpoint, $service); return $this->client()->get($url, $params); } public function post(string $endpoint, array $data = [], string $service = 'api'): \Illuminate\Http\Client\Response { $url = $this->url($endpoint, $service); return $this->client()->post($url, $data); } public function getWithToken(string $endpoint, string $token, string $service = 'api'): \Illuminate\Http\Client\Response { $url = $this->url($endpoint, $service); return $this->client() ->withToken($token) ->get($url); } public function postWithToken(string $endpoint, string $token, array $data = [], string $service = 'api'): \Illuminate\Http\Client\Response { $url = $this->url($endpoint, $service); return $this->client() ->withToken($token) ->post($url, $data); } public function downloadWithToken(string $endpoint, string $token, string $service = 'api'): string { $url = $this->url($endpoint, $service); $response = $this->client() ->withToken($token) ->withHeaders(['Accept-Encoding' => 'zip, gzip']) ->get($url); if ($response->failed()) { throw new \RuntimeException('Download failed: HTTP ' . $response->status()); } return $response->body(); } private function client(): PendingRequest { return Http::timeout($this->timeout) ->retry($this->retries, 500) ->withHeaders(['Accept' => 'application/json']); } private function url(string $endpoint, string $service): string { $base = match ($service) { 'auth' => $this->authDomain, 'filemanager' => $this->filemanagerDomain, default => $this->apiDomain, }; return rtrim($base, '/') . '/' . ltrim($endpoint, '/'); } }