Request::__construct( WordPressAiClientProvidersHttpEnumsHttpMethodEnum $method, string $uri,  $headers = [],  $data = null, WordPressAiClientProvidersHttpDTORequestOptions|null $options = null )

In this article

Constructor.

Parameters

$methodWordPressAiClientProvidersHttpEnumsHttpMethodEnumrequired
The HTTP method.
$uristringrequired
The request URI.
mixed>|null $data The request data.
$optionsWordPressAiClientProvidersHttpDTORequestOptions|nulloptional
The request transport options.

Default:null

Source

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;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.