PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / dashboard / infrastructure / analytics-4 / site-kit-analytics-4-api-call.php

site-kit-analytics-4-api-call.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.5, at src/dashboard/infrastructure/analytics-4/site-kit-analytics-4-api-call.php

36 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 // phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
5 namespace Yoast\WP\SEO\Dashboard\Infrastructure\Analytics_4;
6
7 use Google\Site_Kit\Core\REST_API\REST_Routes;
8 use WP_REST_Request;
9 use WP_REST_Response;
10
11 /**
12 * Class that hold the code to do the REST call to the Site Kit api.
13 *
14 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
15 */
16 class Site_Kit_Analytics_4_Api_Call {
17
18 /**
19 * The Analytics 4 API route path.
20 */
21 private const ANALYTICS_DATA_REPORT_ROUTE = '/modules/analytics-4/data/report';
22
23 /**
24 * Runs the internal REST api call.
25 *
26 * @param array<string, array<string, string>> $api_parameters The api parameters.
27 *
28 * @return WP_REST_Response
29 */
30 public function do_request( array $api_parameters ): WP_REST_Response {
31 $request = new WP_REST_Request( 'GET', '/' . REST_Routes::REST_ROOT . self::ANALYTICS_DATA_REPORT_ROUTE );
32 $request->set_query_params( $api_parameters );
33 return \rest_do_request( $request );
34 }
35 }
36