apiToken; return $this->client()->get($this->url($endpoint), $params); } /** * Perform a POST request to the Technitium API. * The token is included in the form data. */ public function post(string $endpoint, array $data = []): Response { $data['token'] = $this->apiToken; return $this->client() ->asForm() ->post($this->url($endpoint), $data); } /** * Check if the API response indicates success. * Technitium uses {"status": "ok"} for successful responses. */ public function isSuccessful(Response $response): bool { return $response->successful() && $response->json('status') === 'ok'; } /** * Extract the response payload from a Technitium API response. * Data lives under the "response" key. */ public function responseData(Response $response, ?string $key = null): mixed { $data = $response->json('response'); if ($key !== null) { return $data[$key] ?? null; } return $data; } private function client(): PendingRequest { return Http::timeout(15)->connectTimeout(5); } private function url(string $endpoint): string { return $this->serverUrl.'/api/'.ltrim($endpoint, '/'); } }