wordpress-seo
/
src
/
dashboard
/
infrastructure
/
search-console
/
site-kit-search-console-api-call.php
site-kit-search-console-api-call.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/dashboard/infrastructure/search-console/site-kit-search-console-api-call.php
| 1 | <?php |
| 2 | |
| 3 | // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong |
| 4 | // phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded |
| 5 | namespace Yoast\WP\SEO\Dashboard\Infrastructure\Search_Console; |
| 6 | |
| 7 | use WP_REST_Request; |
| 8 | use WP_REST_Response; |
| 9 | |
| 10 | /** |
| 11 | * Class that hold the code to do the REST call to the Site Kit api. |
| 12 | * |
| 13 | * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded |
| 14 | */ |
| 15 | class Site_Kit_Search_Console_Api_Call { |
| 16 | |
| 17 | /** |
| 18 | * The search analytics API route path. |
| 19 | */ |
| 20 | private const SEARCH_CONSOLE_DATA_SEARCH_ANALYTICS_ROUTE = '/google-site-kit/v1/modules/search-console/data/searchanalytics'; |
| 21 | |
| 22 | /** |
| 23 | * Runs the internal REST api call. |
| 24 | * |
| 25 | * @param array<string, array<string, string>> $api_parameters The api parameters. |
| 26 | * |
| 27 | * @return WP_REST_Response |
| 28 | */ |
| 29 | public function do_request( array $api_parameters ): WP_REST_Response { |
| 30 | $request = new WP_REST_Request( 'GET', self::SEARCH_CONSOLE_DATA_SEARCH_ANALYTICS_ROUTE ); |
| 31 | $request->set_query_params( $api_parameters ); |
| 32 | return \rest_do_request( $request ); |
| 33 | } |
| 34 | } |
| 35 |