← All changes
|
src/ai/http-request/infrastructure/api-client-interface.php
+22
-6
28.0
→
28.5
View file →
| @@ -15,18 +15,18 @@ | ||
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Performs a request to the API. |
| 18 | 18 | * |
| 19 | - * @param string $action_path The action path for the request. | |
| 20 | - * @param array<string> $body The body of the request. | |
| 21 | - * @param array<string> $headers The headers for the request. | |
| 22 | - * @param bool $is_post Whether the request is a POST request. | |
| 19 | + * @param string $action_path The action path for the request. | |
| 20 | + * @param array<string>|null $body The body of the request, or null/empty to send no body. | |
| 21 | + * @param array<string> $headers The headers for the request. | |
| 22 | + * @param string $http_method The HTTP method for the request. One of `Request::METHOD_*`. | |
| 23 | 23 | * |
| 24 | 24 | * @return array<int|string|array<string>> The response from the API. |
| 25 | 25 | * |
| 26 | - * @throws WP_Request_Exception When the wp_remote_post() returns an error. | |
| 26 | + * @throws WP_Request_Exception When the underlying WordPress HTTP call returns an error. | |
| 27 | 27 | */ |
| 28 | - public function perform_request( string $action_path, $body, $headers, bool $is_post ): array; | |
| 28 | + public function perform_request( string $action_path, $body, $headers, string $http_method ): array; | |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Gets the timeout of the requests in seconds. |
| 32 | 32 | * |
| @@ -32,5 +32,21 @@ | ||
| 32 | 32 | * |
| 33 | 33 | * @return int The timeout of the suggestion requests in seconds. |
| 34 | 34 | */ |
| 35 | 35 | public function get_request_timeout(): int; |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Builds the full URL for a request to the AI API, applying the same filter perform_request() uses. | |
| 39 | + * | |
| 40 | + * @param string $action_path The action path for the request. | |
| 41 | + * | |
| 42 | + * @return string The full URL for the request. | |
| 43 | + */ | |
| 44 | + public function get_url( string $action_path ): string; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Returns the RFC 8707 resource indicator for the AI API: the origin of the configured base URL. | |
| 48 | + * | |
| 49 | + * @return string The AI resource server origin (e.g. https://ai.yoa.st). | |
| 50 | + */ | |
| 51 | + public function get_resource_url(): string; | |
| 36 | 52 | } |