parent
a0cb0cbb4e
commit
3bc8fae631
|
@ -21,9 +21,9 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
/**
|
||||
* Register the routes for this class
|
||||
*
|
||||
* GET|POST /coupons
|
||||
* GET /coupons
|
||||
* GET /coupons/count
|
||||
* GET|PUT|DELETE /coupons/<id>
|
||||
* GET /coupons/<id>
|
||||
*
|
||||
* @since 2.1
|
||||
* @param array $routes
|
||||
|
@ -31,10 +31,9 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
*/
|
||||
public function register_routes( $routes ) {
|
||||
|
||||
# GET|POST /coupons
|
||||
# GET /coupons
|
||||
$routes[ $this->base ] = array(
|
||||
array( array( $this, 'get_coupons' ), WC_API_Server::READABLE ),
|
||||
array( array( $this, 'create_coupon' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ),
|
||||
);
|
||||
|
||||
# GET /coupons/count
|
||||
|
@ -42,11 +41,9 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
array( array( $this, 'get_coupons_count' ), WC_API_Server::READABLE ),
|
||||
);
|
||||
|
||||
# GET|PUT|DELETE /coupons/<id>
|
||||
# GET /coupons/<id>
|
||||
$routes[ $this->base . '/(?P<id>\d+)' ] = array(
|
||||
array( array( $this, 'get_coupon' ), WC_API_Server::READABLE ),
|
||||
array( array( $this, 'edit_coupon' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ),
|
||||
array( array( $this, 'delete_coupon' ), WC_API_Server::DELETABLE ),
|
||||
);
|
||||
|
||||
# GET /coupons/code/<code>, note that coupon codes can contain spaces, dashes and underscores
|
||||
|
@ -178,23 +175,19 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
/**
|
||||
* Create a coupon
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO implement in 2.2
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function create_coupon( $data ) {
|
||||
|
||||
// TODO: permissions check
|
||||
|
||||
// TODO: implement - what's the minimum set of data required?
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a coupon
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO implement in 2.2
|
||||
* @param int $id the coupon ID
|
||||
* @param array $data
|
||||
* @return array
|
||||
|
@ -206,15 +199,13 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
if ( is_wp_error( $id ) )
|
||||
return $id;
|
||||
|
||||
// TODO: implement
|
||||
|
||||
return $this->get_coupon( $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a coupon
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO enable along with PUT/POST in 2.2
|
||||
* @param int $id the coupon ID
|
||||
* @param bool $force true to permanently delete coupon, false to move to trash
|
||||
* @return array
|
||||
|
|
|
@ -44,9 +44,9 @@ class WC_API_Customers extends WC_API_Resource {
|
|||
/**
|
||||
* Register the routes for this class
|
||||
*
|
||||
* GET|POST /customers
|
||||
* GET /customers
|
||||
* GET /customers/count
|
||||
* GET|PUT|DELETE /customers/<id>
|
||||
* GET /customers/<id>
|
||||
* GET /customers/<id>/orders
|
||||
*
|
||||
* @since 2.1
|
||||
|
@ -55,10 +55,9 @@ class WC_API_Customers extends WC_API_Resource {
|
|||
*/
|
||||
public function register_routes( $routes ) {
|
||||
|
||||
# GET|POST /customers
|
||||
# GET /customers
|
||||
$routes[ $this->base ] = array(
|
||||
array( array( $this, 'get_customers' ), WC_API_SERVER::READABLE ),
|
||||
array( array( $this, 'create_customer' ), WC_API_SERVER::CREATABLE | WC_API_SERVER::ACCEPT_DATA ),
|
||||
);
|
||||
|
||||
# GET /customers/count
|
||||
|
@ -66,11 +65,9 @@ class WC_API_Customers extends WC_API_Resource {
|
|||
array( array( $this, 'get_customers_count' ), WC_API_SERVER::READABLE ),
|
||||
);
|
||||
|
||||
# GET|PUT|DELETE /customers/<id>
|
||||
# GET /customers/<id>
|
||||
$routes[ $this->base . '/(?P<id>\d+)' ] = array(
|
||||
array( array( $this, 'get_customer' ), WC_API_SERVER::READABLE ),
|
||||
array( array( $this, 'edit_customer' ), WC_API_SERVER::EDITABLE | WC_API_SERVER::ACCEPT_DATA ),
|
||||
array( array( $this, 'delete_customer' ), WC_API_SERVER::DELETABLE ),
|
||||
);
|
||||
|
||||
# GET /customers/<id>/orders
|
||||
|
@ -201,7 +198,7 @@ class WC_API_Customers extends WC_API_Resource {
|
|||
/**
|
||||
* Create a customer
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO implement in 2.2 with woocommerce_create_new_customer()
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
|
@ -210,15 +207,13 @@ class WC_API_Customers extends WC_API_Resource {
|
|||
if ( ! current_user_can( 'create_users' ) )
|
||||
return new WP_Error( 'woocommerce_api_user_cannot_create_customer', __( 'You do not have permission to create this customer', 'woocommerce' ), array( 'status' => 401 ) );
|
||||
|
||||
// TODO: implement - woocommerce_create_new_customer()
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a customer
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO implement in 2.2
|
||||
* @param int $id the customer ID
|
||||
* @param array $data
|
||||
* @return array
|
||||
|
@ -230,15 +225,13 @@ class WC_API_Customers extends WC_API_Resource {
|
|||
if ( ! is_wp_error( $id ) )
|
||||
return $id;
|
||||
|
||||
// TODO: implement
|
||||
|
||||
return $this->get_customer( $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a customer
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO enable along with PUT/POST in 2.2
|
||||
* @param int $id the customer ID
|
||||
* @return array
|
||||
*/
|
||||
|
|
|
@ -22,7 +22,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
*
|
||||
* GET /orders
|
||||
* GET /orders/count
|
||||
* GET|PUT|DELETE /orders/<id>
|
||||
* GET|PUT /orders/<id>
|
||||
* GET /orders/<id>/notes
|
||||
*
|
||||
* @since 2.1
|
||||
|
@ -41,11 +41,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
array( array( $this, 'get_orders_count' ), WC_API_Server::READABLE ),
|
||||
);
|
||||
|
||||
# GET|PUT|DELETE /orders/<id>
|
||||
# GET|PUT /orders/<id>
|
||||
$routes[ $this->base . '/(?P<id>\d+)' ] = array(
|
||||
array( array( $this, 'get_order' ), WC_API_Server::READABLE ),
|
||||
array( array( $this, 'edit_order' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ),
|
||||
array( array( $this, 'delete_order' ), WC_API_Server::DELETABLE ),
|
||||
);
|
||||
|
||||
# GET /orders/<id>/notes
|
||||
|
@ -255,7 +254,6 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
return array( 'count' => $query->found_posts );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Edit an order
|
||||
*
|
||||
|
@ -279,7 +277,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
/**
|
||||
* Delete an order
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO enable along with POST in 2.2
|
||||
* @param int $id the order ID
|
||||
* @param bool $force true to permanently delete order, false to move to trash
|
||||
* @return array
|
||||
|
|
|
@ -22,7 +22,7 @@ class WC_API_Products extends WC_API_Resource {
|
|||
*
|
||||
* GET /products
|
||||
* GET /products/count
|
||||
* GET|PUT|DELETE /products/<id>
|
||||
* GET /products/<id>
|
||||
* GET /products/<id>/reviews
|
||||
*
|
||||
* @since 2.1
|
||||
|
@ -41,11 +41,9 @@ class WC_API_Products extends WC_API_Resource {
|
|||
array( array( $this, 'get_products_count' ), WC_API_Server::READABLE ),
|
||||
);
|
||||
|
||||
# GET|PUT|DELETE /products/<id>
|
||||
# GET /products/<id>
|
||||
$routes[ $this->base . '/(?P<id>\d+)' ] = array(
|
||||
array( array( $this, 'get_product' ), WC_API_Server::READABLE ),
|
||||
array( array( $this, 'edit_product' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ),
|
||||
array( array( $this, 'delete_product' ), WC_API_Server::DELETABLE ),
|
||||
);
|
||||
|
||||
# GET /products/<id>/reviews
|
||||
|
@ -148,7 +146,7 @@ class WC_API_Products extends WC_API_Resource {
|
|||
/**
|
||||
* Edit a product
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO implement in 2.2
|
||||
* @param int $id the product ID
|
||||
* @param array $data
|
||||
* @return array
|
||||
|
@ -160,15 +158,13 @@ class WC_API_Products extends WC_API_Resource {
|
|||
if ( is_wp_error( $id ) )
|
||||
return $id;
|
||||
|
||||
// TODO: implement
|
||||
|
||||
return $this->get_product( $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product
|
||||
*
|
||||
* @since 2.1
|
||||
* @TODO enable along with PUT/POST in 2.2
|
||||
* @param int $id the product ID
|
||||
* @param bool $force true to permanently delete order, false to move to trash
|
||||
* @return array
|
||||
|
|
Loading…
Reference in New Issue