Data
This commit is contained in:
parent
28b0d9c331
commit
b44f6eb0d5
|
@ -5,25 +5,25 @@
|
|||
* Handles requests to the /data endpoint.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
* @since 3.5.0
|
||||
*/
|
||||
|
||||
namespace WooCommerce\RestApi\Version4\Controllers;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \WC_REST_Controller;
|
||||
|
||||
/**
|
||||
* REST API Data controller class.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
* @extends WC_REST_Controller
|
||||
* REST API Coupons controller class.
|
||||
*/
|
||||
class WC_REST_Data_Controller extends WC_REST_Controller {
|
||||
class Data extends WC_REST_Controller {
|
||||
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'wc/v3';
|
||||
protected $namespace = 'wc/v4';
|
||||
|
||||
/**
|
||||
* Route base.
|
||||
|
@ -39,7 +39,9 @@ class WC_REST_Data_Controller extends WC_REST_Controller {
|
|||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
|
@ -100,6 +102,10 @@ class WC_REST_Data_Controller extends WC_REST_Controller {
|
|||
'slug' => 'currencies',
|
||||
'description' => __( 'List of supported currencies.', 'woocommerce' ),
|
||||
),
|
||||
array(
|
||||
'slug' => 'download-ips',
|
||||
'description' => __( 'An endpoint used for searching download logs for a specific IP address.', 'woocommerce' ),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( $resources as $resource ) {
|
|
@ -5,25 +5,25 @@
|
|||
* Handles requests to the /data/continents endpoint.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
* @since 3.5.0
|
||||
*/
|
||||
|
||||
namespace WooCommerce\RestApi\Version4\Controllers\Data;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
|
||||
|
||||
/**
|
||||
* REST API Data continents controller class.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
* @extends WC_REST_Controller
|
||||
* REST API Data Continents controller class.
|
||||
*/
|
||||
class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
||||
class Continents extends DataController {
|
||||
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'wc/v3';
|
||||
protected $namespace = 'wc/v4';
|
||||
|
||||
/**
|
||||
* Route base.
|
||||
|
@ -39,7 +39,9 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
|
@ -49,7 +51,9 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
)
|
||||
);
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<location>[\w-]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<location>[\w-]+)',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
||||
|
@ -104,7 +108,8 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
if ( array_key_exists( $country_code, $locale_info ) ) {
|
||||
// Defensive programming against unexpected changes in locale-info.php.
|
||||
$country_data = wp_parse_args(
|
||||
$locale_info[ $country_code ], array(
|
||||
$locale_info[ $country_code ],
|
||||
array(
|
||||
'currency_code' => 'USD',
|
||||
'currency_pos' => 'left',
|
||||
'decimal_sep' => '.',
|
|
@ -5,25 +5,25 @@
|
|||
* Handles requests to the /data/countries endpoint.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
* @since 3.5.0
|
||||
*/
|
||||
|
||||
namespace WooCommerce\RestApi\Version4\Controllers\Data;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
|
||||
|
||||
/**
|
||||
* REST API Data countries controller class.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
* @extends WC_REST_Controller
|
||||
* REST API Data Countries controller class.
|
||||
*/
|
||||
class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
||||
class Countries extends DataController {
|
||||
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'wc/v3';
|
||||
protected $namespace = 'wc/v4';
|
||||
|
||||
/**
|
||||
* Route base.
|
||||
|
@ -39,7 +39,9 @@ class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
|||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
|
@ -49,7 +51,9 @@ class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
|||
)
|
||||
);
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<location>[\w-]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<location>[\w-]+)',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
|
@ -5,24 +5,25 @@
|
|||
* Handles requests to the /data/currencies endpoint.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
* @since 3.5.0
|
||||
*/
|
||||
|
||||
namespace WooCommerce\RestApi\Version4\Controllers\Data;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
|
||||
|
||||
/**
|
||||
* REST API Data Currencies controller class.
|
||||
*
|
||||
* @package WooCommerce/RestApi
|
||||
*/
|
||||
class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
||||
class Currencies extends DataController {
|
||||
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'wc/v3';
|
||||
protected $namespace = 'wc/v4';
|
||||
|
||||
/**
|
||||
* Route base.
|
||||
|
@ -36,7 +37,9 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
|||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
|
@ -46,7 +49,9 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
|||
)
|
||||
);
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/current', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/current',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_current_item' ),
|
||||
|
@ -56,7 +61,9 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
|||
)
|
||||
);
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<currency>[\w-]{3})', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<currency>[\w-]{3})',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
|
@ -4,18 +4,19 @@
|
|||
*
|
||||
* Handles requests to /data/download-ips
|
||||
*
|
||||
* @package WooCommerce Admin/API
|
||||
* @package WooCommerce/RestApi
|
||||
*/
|
||||
|
||||
namespace WooCommerce\RestApi\Version4\Controllers\Data;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
|
||||
|
||||
/**
|
||||
* Data Download IP controller.
|
||||
*
|
||||
* @package WooCommerce Admin/API
|
||||
* @extends WC_REST_Data_Controller
|
||||
*/
|
||||
class WC_Admin_REST_Data_Download_Ips_Controller extends WC_REST_Data_Controller {
|
||||
class DownloadIPs extends DataController {
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
|
@ -12,25 +12,25 @@
|
|||
|
||||
## New endpoints
|
||||
|
||||
- Added `reports/products` endpoint.
|
||||
- Added `reports/products/stats` endpoint.
|
||||
- Added `reports/categories` endpoint.
|
||||
- Added `reports/orders` endpoint.
|
||||
- Added `reports/orders/stats` endpoint.
|
||||
- Added `reports/performance-indicators` endpoint.
|
||||
- Added `reports/revenue/stats` endpoint.
|
||||
- Added `reports/stock` endpoint.
|
||||
- Added `reports/stock/stats` endpoint.
|
||||
- Added `reports/taxes` endpoint.
|
||||
- Added `reports/taxes/stats` endpoint.
|
||||
- Added `reports/variations` endpoint.
|
||||
- Added `reports/coupons` endpoint.
|
||||
- Added `reports/coupons/stats` endpoint.
|
||||
- Added `reports/customer` endpoint.
|
||||
- Added `reports/customers/stats` endpoint.
|
||||
- Added `reports/downloads` endpoint.
|
||||
- Added `reports/downloads/stats` endpoint.
|
||||
- Added `reports/import` endpoint.
|
||||
- `reports/products`
|
||||
- `reports/products/stats`
|
||||
- `reports/categories`
|
||||
- `reports/orders`
|
||||
- `reports/orders/stats`
|
||||
- `reports/performance-indicators`
|
||||
- `reports/revenue/stats`
|
||||
- `reports/stock`
|
||||
- `reports/stock/stats`
|
||||
- `reports/taxes`
|
||||
- `reports/taxes/stats`
|
||||
- `reports/variations`
|
||||
- `reports/coupons`
|
||||
- `reports/coupons/stats`
|
||||
- `reports/customer`
|
||||
- `reports/customers/stats`
|
||||
- `reports/downloads`
|
||||
- `reports/downloads/stats`
|
||||
- `reports/import`
|
||||
|
||||
## Removed endpoints
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* REST API Data Controller
|
||||
*
|
||||
* Handles requests to /data
|
||||
*
|
||||
* @package WooCommerce Admin/API
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Data controller.
|
||||
*
|
||||
* @package WooCommerce Admin/API
|
||||
* @extends WC_REST_Data_Controller
|
||||
*/
|
||||
class WC_Admin_REST_Data_Controller extends WC_REST_Data_Controller {
|
||||
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'wc/v4';
|
||||
|
||||
/**
|
||||
* Return the list of data resources.
|
||||
*
|
||||
* @param WP_REST_Request $request Request data.
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public function get_items( $request ) {
|
||||
$response = parent::get_items( $request );
|
||||
$response->data[] = $this->prepare_response_for_collection(
|
||||
$this->prepare_item_for_response(
|
||||
(object) array(
|
||||
'slug' => 'download-ips',
|
||||
'description' => __( 'An endpoint used for searching download logs for a specific IP address.', 'woocommerce' ),
|
||||
),
|
||||
$request
|
||||
)
|
||||
);
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* REST API Data countries controller.
|
||||
*
|
||||
* Handles requests to the /data/countries endpoint.
|
||||
*
|
||||
* @package WooCommerce Admin/API
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* REST API Data countries controller class.
|
||||
*
|
||||
* @package WooCommerce Admin/API
|
||||
* @extends WC_REST_Data_Countries_Controller
|
||||
*/
|
||||
class WC_Admin_REST_Data_Countries_Controller extends WC_REST_Data_Countries_Controller {
|
||||
|
||||
/**
|
||||
* Endpoint namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'wc/v4';
|
||||
|
||||
}
|
Loading…
Reference in New Issue