url = $url; } public static function factory(string $url): static { return new static($url); } public function method(string $method): static { $this->method = strtoupper($method); return $this; } public function header(string $name, string $value): static { $this->headers[$name] = $value; return $this; } public function body(string $body): static { $this->body = $body; return $this; } public function json(array $data): static { $this->header('Content-Type', 'application/json'); $this->header('Accept', 'application/json'); $this->body = json_encode($data, JSON_UNESCAPED_UNICODE); return $this; } public function timeout(int $seconds): static { $this->timeout = $seconds; return $this; } public function getMethod(): string { return $this->method; } public function getUrl(): string { return $this->url; } public function getHeaders(): array { return $this->headers; } public function getBody(): ?string { return $this->body; } public function getTimeout(): int { return $this->timeout; } }