WordPress\AiClient\Providers\Http\DTO
Request::__construct
Constructor.
Method of the class: Request{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Request = new Request(); $Request->__construct( $method, $uri, $headers, $data, ?\WordPress\AiClient\Providers\Http\DTO\RequestOptions $options );
- $method(HttpMethodEnum) (required)
- The HTTP method.
- $uri(string) (required)
- The request URI.
- $headers(array)
- .
Default:[] - $data
- .
Default:null - ?\WordPress\AiClient\Providers\Http\DTO\RequestOptions $options
- .
Default:null
Changelog
| Since 0.1.0 | Introduced. |
Request::__construct() Request:: construct code WP 7.1.4
public function __construct(HttpMethodEnum $method, string $uri, array $headers = [], $data = null, ?\WordPress\AiClient\Providers\Http\DTO\RequestOptions $options = null)
{
if (empty($uri)) {
throw new InvalidArgumentException('URI cannot be empty.');
}
$this->method = $method;
$this->uri = $uri;
$this->headers = new HeadersCollection($headers);
// Separate data and body based on type
if (is_string($data)) {
$this->body = $data;
} elseif (is_array($data)) {
$this->data = $data;
}
$this->options = $options;
}