| 1 |
<?php |
| 2 |
/** |
| 3 |
* Endpoints: Parse.ly `/analytics/post/detail` API proxy endpoint class |
| 4 |
* |
| 5 |
* @package Parsely |
| 6 |
* @since 3.6.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare(strict_types=1); |
| 10 |
|
| 11 |
namespace Parsely\Endpoints; |
| 12 |
|
| 13 |
use stdClass; |
| 14 |
use WP_REST_Request; |
| 15 |
use WP_Error; |
| 16 |
|
| 17 |
/** |
| 18 |
* Configures the `/stats/post/detail` REST API endpoint. |
| 19 |
*/ |
| 20 |
final class Analytics_Post_Detail_API_Proxy extends Base_API_Proxy { |
| 21 |
|
| 22 |
/** |
| 23 |
* Registers the endpoint's WP REST route. |
| 24 |
*/ |
| 25 |
public function run(): void { |
| 26 |
$this->register_endpoint( '/stats/post/detail' ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Cached "proxy" to the Parse.ly `/analytics/post/detail` API endpoint. |
| 31 |
* |
| 32 |
* @param WP_REST_Request $request The request object. |
| 33 |
* @return stdClass|WP_Error stdClass containing the data or a WP_Error object on failure. |
| 34 |
*/ |
| 35 |
public function get_items( WP_REST_Request $request ) { |
| 36 |
return $this->get_data( $request ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Generates the final data from the passed response. |
| 41 |
* |
| 42 |
* @param array<stdClass> $response The response received by the proxy. |
| 43 |
* @return array<stdClass> The generated data. |
| 44 |
*/ |
| 45 |
protected function generate_data( $response ): array { |
| 46 |
return $this->generate_post_data( $response ); |
| 47 |
} |
| 48 |
} |
| 49 |
|