← All changes
|
src/services/suggestions-api/endpoints/class-endpoint-check-auth.php
+9
-16
3.23.3
→
3.24.3
View file →
| @@ -17,8 +17,9 @@ | ||
| 17 | 17 | * The endpoint for the /check-auth API request. |
| 18 | 18 | * |
| 19 | 19 | * @since 3.19.0 |
| 20 | 20 | * |
| 21 | + * @phpstan-import-type WP_HTTP_Request_Args from Base_Service_Endpoint | |
| 21 | 22 | * @phpstan-import-type WP_HTTP_Response from Base_Service_Endpoint |
| 22 | 23 | */ |
| 23 | 24 | class Endpoint_Check_Auth extends Suggestions_API_Base_Endpoint { |
| 24 | 25 | /** |
| @@ -49,30 +50,22 @@ | ||
| 49 | 50 | return $response; |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | /** |
| 53 | - * Sends a request to the remote API. | |
| 54 | + * Returns the request options for the remote API request. | |
| 54 | 55 | * |
| 55 | - * @since 3.19.0 | |
| 56 | + * @since 3.24.3 | |
| 56 | 57 | * |
| 57 | - * @param string $method The HTTP method to use for the request. | |
| 58 | - * @param array<mixed> $query_args The query arguments to send to the remote API. | |
| 59 | - * @param array<mixed> $data The data to send in the request body. | |
| 60 | - * @return WP_Error|array<mixed> The response from the remote API. | |
| 58 | + * @param string $method The HTTP method to use for the request. | |
| 59 | + * @return WP_HTTP_Request_Args The request options for the remote API request. | |
| 61 | 60 | */ |
| 62 | - protected function request( string $method, array $query_args = array(), array $data = array() ) { | |
| 63 | - // Get the URL to send the request to. | |
| 64 | - $request_url = $this->get_endpoint_url( $query_args ); | |
| 61 | + protected function get_request_options( string $method ): array { | |
| 62 | + $options = parent::get_request_options( $method ); | |
| 65 | 63 | |
| 66 | - // Build the request options. | |
| 67 | - $request_options = $this->get_request_options( $method ); | |
| 68 | 64 | // Set the body to an empty array, as leaving it to '{}' causes errors. |
| 69 | - $request_options['body'] = array(); | |
| 65 | + $options['body'] = array(); | |
| 70 | 66 | |
| 71 | - /** @var WP_HTTP_Response|WP_Error $response */ | |
| 72 | - $response = wp_safe_remote_request( $request_url, $request_options ); | |
| 73 | - | |
| 74 | - return $this->process_response( $response ); | |
| 67 | + return $options; | |
| 75 | 68 | } |
| 76 | 69 | |
| 77 | 70 | /** |
| 78 | 71 | * Processes the response from the remote API. |