Automattic\WooCommerce\Internal\RestApi\Routes\V4\Refunds
Controller::prepare_links
Prepare links for the request.
Method of the class: Controller{}
No Hooks.
Returns
Array.
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_links( $item, $request, $response ): array;
- $item(mixed) (required)
- WordPress representation of the item.
- $request(WP_REST_Request) (required)
- Request object.
- $response(WP_REST_Response) (required)
- Response object.
Controller::prepare_links() Controller::prepare links code WC 10.6.2
protected function prepare_links( $item, WP_REST_Request $request, WP_REST_Response $response ): array {
$links = array(
'self' => array(
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $item->get_id() ) ),
),
'collection' => array(
'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
),
'up' => array(
'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $item->get_parent_id() ) ),
),
);
if ( $item->get_refunded_by() ) {
$links['refunded_by'] = array(
'href' => rest_url( sprintf( '/wp/v2/users/%d', $item->get_refunded_by() ) ),
'embeddable' => true,
);
}
return $links;
}