46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* Class WC_REST_Payments_Timeline_Controller
|
|
*
|
|
* @package WooCommerce\Payments\Admin
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
/**
|
|
* REST controller for the timeline, which includes all events related to an intention.
|
|
*/
|
|
class WC_REST_Payments_Timeline_Controller extends WC_Payments_REST_Controller {
|
|
/**
|
|
* Endpoint path.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $rest_base = 'payments/timeline';
|
|
|
|
/**
|
|
* Configure REST API routes.
|
|
*/
|
|
public function register_routes() {
|
|
register_rest_route(
|
|
$this->namespace,
|
|
'/' . $this->rest_base . '/(?P<intention_id>\w+)',
|
|
[
|
|
'methods' => WP_REST_Server::READABLE,
|
|
'callback' => [ $this, 'get_timeline' ],
|
|
'permission_callback' => [ $this, 'check_permission' ],
|
|
]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Retrieve timeline to respond with via API.
|
|
*
|
|
* @param WP_REST_Request $request Full data about the request.
|
|
*/
|
|
public function get_timeline( $request ) {
|
|
$intention_id = $request->get_param( 'intention_id' );
|
|
return $this->forward_request( 'get_timeline', [ $intention_id ] );
|
|
}
|
|
}
|