Merge pull request #23007 from woocommerce/add/wc-blocks-v1/docblock-updates
REST API: Add Private REST API docblock and response headers.
This commit is contained in:
commit
39e5de3324
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
* Handles requests to the /products/attributes/<attribute_id/terms endpoint.
|
||||
*
|
||||
* @internal This API is used internally by the block post editor--it is still in flux. It should not be used outside of wc-blocks.
|
||||
* @package WooCommerce\Blocks\Products\Rest\Controller
|
||||
*/
|
||||
|
||||
|
@ -127,6 +128,8 @@ class WC_REST_Blocks_Product_Attribute_Terms_Controller extends WC_REST_Product_
|
|||
|
||||
$response = rest_ensure_response( $data );
|
||||
|
||||
$response->header( 'X-Woo-Notice', __( 'Private REST API for use by block editor only.', 'woocommerce' ) );
|
||||
|
||||
$response->add_links( $this->prepare_links( $item, $request ) );
|
||||
|
||||
return $response;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
* Handles requests to the /products/attributes endpoint.
|
||||
*
|
||||
* @internal This API is used internally by the block post editor--it is still in flux. It should not be used outside of wc-blocks.
|
||||
* @package WooCommerce\Blocks\Products\Rest\Controller
|
||||
*/
|
||||
|
||||
|
@ -152,6 +153,7 @@ class WC_REST_Blocks_Product_Attributes_Controller extends WC_REST_Product_Attri
|
|||
|
||||
$response = rest_ensure_response( $data );
|
||||
|
||||
$response->header( 'X-Woo-Notice', __( 'Private REST API for use by block editor only.', 'woocommerce' ) );
|
||||
$response->add_links( $this->prepare_links( $item ) );
|
||||
|
||||
return $response;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
* Handles requests to the /products/categories endpoint.
|
||||
*
|
||||
* @internal This API is used internally by the block post editor--it is still in flux. It should not be used outside of wc-blocks.
|
||||
* @package WooCommerce\Blocks\Products\Rest\Controller
|
||||
*/
|
||||
|
||||
|
@ -119,6 +120,7 @@ class WC_REST_Blocks_Product_Categories_Controller extends WC_REST_Product_Categ
|
|||
|
||||
$response = rest_ensure_response( $data );
|
||||
|
||||
$response->header( 'X-Woo-Notice', __( 'Private REST API for use by block editor only.', 'woocommerce' ) );
|
||||
$response->add_links( $this->prepare_links( $item, $request ) );
|
||||
|
||||
return $response;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
* Handles requests to the /products endpoint.
|
||||
*
|
||||
* @internal This API is used internally by the block post editor--it is still in flux. It should not be used outside of wc-blocks.
|
||||
* @package WooCommerce\Blocks\Products\Rest\Controller
|
||||
*/
|
||||
|
||||
|
@ -120,6 +121,7 @@ class WC_REST_Blocks_Products_Controller extends WC_REST_Products_Controller {
|
|||
$response = rest_ensure_response( $objects );
|
||||
$response->header( 'X-WP-Total', $query_results['total'] );
|
||||
$response->header( 'X-WP-TotalPages', (int) $max_pages );
|
||||
$response->header( 'X-Woo-Notice', __( 'Private REST API for use by block editor only.', 'woocommerce' ) );
|
||||
|
||||
$base = $this->rest_base;
|
||||
$attrib_prefix = '(?P<';
|
||||
|
@ -214,7 +216,7 @@ class WC_REST_Blocks_Products_Controller extends WC_REST_Products_Controller {
|
|||
|
||||
// Wrap the data in a response object.
|
||||
$response = rest_ensure_response( $data );
|
||||
|
||||
$response->header( 'X-Woo-Notice', __( 'Private REST API for use by block editor only.', 'woocommerce' ) );
|
||||
$response->add_links( $this->prepare_links( $product, $request ) );
|
||||
|
||||
return $response;
|
||||
|
|
Loading…
Reference in New Issue