Data.php
| 1 | <?php |
| 2 | /** |
| 3 | * REST API Data Controller |
| 4 | * |
| 5 | * Handles requests to /data |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Admin\API; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * Data controller. |
| 14 | * |
| 15 | * @internal |
| 16 | * @extends WC_REST_Data_Controller |
| 17 | */ |
| 18 | class Data extends \WC_REST_Data_Controller { |
| 19 | |
| 20 | /** |
| 21 | * Endpoint namespace. |
| 22 | * |
| 23 | * @var string |
| 24 | */ |
| 25 | protected $namespace = 'wc-analytics'; |
| 26 | |
| 27 | /** |
| 28 | * Return the list of data resources. |
| 29 | * |
| 30 | * @param WP_REST_Request $request Request data. |
| 31 | * @return WP_Error|WP_REST_Response |
| 32 | */ |
| 33 | public function get_items( $request ) { |
| 34 | $response = parent::get_items( $request ); |
| 35 | $response->data[] = $this->prepare_response_for_collection( |
| 36 | $this->prepare_item_for_response( |
| 37 | (object) array( |
| 38 | 'slug' => 'download-ips', |
| 39 | 'description' => __( 'An endpoint used for searching download logs for a specific IP address.', 'woocommerce' ), |
| 40 | ), |
| 41 | $request |
| 42 | ) |
| 43 | ); |
| 44 | return $response; |
| 45 | } |
| 46 | } |
| 47 |