From 3bc8fae6314696448677300f620e765c40a87f22 Mon Sep 17 00:00:00 2001 From: Max Rice Date: Sat, 23 Nov 2013 15:01:53 -0500 Subject: [PATCH] Remove PUT/DELETE endpoints Will be implemented in 2.2 Part of #4055 --- includes/api/class-wc-api-coupons.php | 23 +++++++---------------- includes/api/class-wc-api-customers.php | 21 +++++++-------------- includes/api/class-wc-api-orders.php | 8 +++----- includes/api/class-wc-api-products.php | 12 ++++-------- 4 files changed, 21 insertions(+), 43 deletions(-) diff --git a/includes/api/class-wc-api-coupons.php b/includes/api/class-wc-api-coupons.php index fd98a1f6f84..b91733f727e 100644 --- a/includes/api/class-wc-api-coupons.php +++ b/includes/api/class-wc-api-coupons.php @@ -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/ + * GET /coupons/ * * @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/ + # GET /coupons/ $routes[ $this->base . '/(?P\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/, 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 diff --git a/includes/api/class-wc-api-customers.php b/includes/api/class-wc-api-customers.php index 7a821718c64..53349ad5bb1 100644 --- a/includes/api/class-wc-api-customers.php +++ b/includes/api/class-wc-api-customers.php @@ -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/ + * GET /customers/ * GET /customers//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/ + # GET /customers/ $routes[ $this->base . '/(?P\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//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 */ diff --git a/includes/api/class-wc-api-orders.php b/includes/api/class-wc-api-orders.php index f3817b92d6e..f38b3bc4411 100644 --- a/includes/api/class-wc-api-orders.php +++ b/includes/api/class-wc-api-orders.php @@ -22,7 +22,7 @@ class WC_API_Orders extends WC_API_Resource { * * GET /orders * GET /orders/count - * GET|PUT|DELETE /orders/ + * GET|PUT /orders/ * GET /orders//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/ + # GET|PUT /orders/ $routes[ $this->base . '/(?P\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//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 diff --git a/includes/api/class-wc-api-products.php b/includes/api/class-wc-api-products.php index f70f2f9f394..f2345bc2f40 100644 --- a/includes/api/class-wc-api-products.php +++ b/includes/api/class-wc-api-products.php @@ -22,7 +22,7 @@ class WC_API_Products extends WC_API_Resource { * * GET /products * GET /products/count - * GET|PUT|DELETE /products/ + * GET /products/ * GET /products//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/ + # GET /products/ $routes[ $this->base . '/(?P\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//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