REST API: Add Private REST API docblock and response headers.

This commit is contained in:
Timmy Crawford 2019-03-12 16:26:10 -07:00
parent 73fbed3411
commit 6c22bfb96a
4 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<?php
/**
* REST API Product Attribute Terms controller customized for Products Block.
*
* Private API: This endpoint is designed to only
* Handles requests to the /products/attributes/<attribute_id/terms endpoint.
*
* @package WooCommerce\Blocks\Products\Rest\Controller
@ -127,6 +127,7 @@ 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

@ -1,6 +1,7 @@
<?php
/**
* REST API Product Attributes controller customized for Products Block.
* Private API: This endpoint is designed to only be used `internally` by the block post editor.
*
* Handles requests to the /products/attributes endpoint.
*
@ -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

@ -1,6 +1,7 @@
<?php
/**
* REST API Product Categories controller customized for Products Block.
* Private API: This endpoint is designed to only be used `internally` by the block post editor.
*
* Handles requests to the /products/categories endpoint.
*
@ -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

@ -1,6 +1,7 @@
<?php
/**
* REST API Products controller customized for Products Block.
* Private API: This endpoint is designed to only be used `internally` by the block post editor.
*
* Handles requests to the /products endpoint.
*
@ -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;