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:
Mike Jolley 2019-03-13 14:26:13 +00:00 committed by GitHub
commit 39e5de3324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;