| 1 |
<?php |
| 2 |
/** |
| 3 |
* Parse.ly Content API Endpoint: Analytics Post Details |
| 4 |
* |
| 5 |
* @package Parsely |
| 6 |
* @since 3.17.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare(strict_types=1); |
| 10 |
|
| 11 |
namespace Parsely\Services\Content_API\Endpoints; |
| 12 |
|
| 13 |
use WP_Error; |
| 14 |
|
| 15 |
/** |
| 16 |
* The endpoint for the /analytics/post/detail API request. |
| 17 |
* |
| 18 |
* @since 3.17.0 |
| 19 |
* |
| 20 |
* @link https://docs.parse.ly/api-analytics-endpoint/#2-get-analytics-post-detail |
| 21 |
*/ |
| 22 |
class Endpoint_Analytics_Post_Details extends Content_API_Base_Endpoint { |
| 23 |
/** |
| 24 |
* Returns the endpoint for the API request. |
| 25 |
* |
| 26 |
* @since 3.17.0 |
| 27 |
* |
| 28 |
* @return string |
| 29 |
*/ |
| 30 |
public function get_endpoint(): string { |
| 31 |
return '/analytics/post/detail'; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Executes the API request. |
| 36 |
* |
| 37 |
* @since 3.17.0 |
| 38 |
* |
| 39 |
* @param array<mixed> $args The arguments to pass to the API request. |
| 40 |
* @return WP_Error|array<mixed> The response from the API request. |
| 41 |
*/ |
| 42 |
public function call( array $args = array() ) { |
| 43 |
$query_args = array( |
| 44 |
'url' => $args['url'], |
| 45 |
'period_start' => $args['period_start'], |
| 46 |
'period_end' => $args['period_end'], |
| 47 |
); |
| 48 |
|
| 49 |
// Filter out the empty values. |
| 50 |
$query_args = array_filter( $query_args ); |
| 51 |
|
| 52 |
return $this->request( 'GET', $query_args ); |
| 53 |
} |
| 54 |
} |
| 55 |
|