| @@ 56-112 (lines=57) @@ | ||
| 53 | /** |
|
| 54 | * Register the routes for orders. |
|
| 55 | */ |
|
| 56 | public function register_routes() { |
|
| 57 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 58 | array( |
|
| 59 | 'methods' => WP_REST_Server::READABLE, |
|
| 60 | 'callback' => array( $this, 'get_items' ), |
|
| 61 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 62 | 'args' => $this->get_collection_params(), |
|
| 63 | ), |
|
| 64 | array( |
|
| 65 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 66 | 'callback' => array( $this, 'create_item' ), |
|
| 67 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 68 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 69 | ), |
|
| 70 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 71 | ) ); |
|
| 72 | ||
| 73 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 74 | array( |
|
| 75 | 'methods' => WP_REST_Server::READABLE, |
|
| 76 | 'callback' => array( $this, 'get_item' ), |
|
| 77 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 78 | 'args' => array( |
|
| 79 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 80 | ), |
|
| 81 | ), |
|
| 82 | array( |
|
| 83 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 84 | 'callback' => array( $this, 'update_item' ), |
|
| 85 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 86 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 87 | ), |
|
| 88 | array( |
|
| 89 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 90 | 'callback' => array( $this, 'delete_item' ), |
|
| 91 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 92 | 'args' => array( |
|
| 93 | 'force' => array( |
|
| 94 | 'default' => false, |
|
| 95 | 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), |
|
| 96 | ), |
|
| 97 | 'reassign' => array(), |
|
| 98 | ), |
|
| 99 | ), |
|
| 100 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 101 | ) ); |
|
| 102 | ||
| 103 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 104 | array( |
|
| 105 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 106 | 'callback' => array( $this, 'batch_items' ), |
|
| 107 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 108 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 109 | ), |
|
| 110 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 111 | ) ); |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Prepare a single order output for response. |
|
| @@ 57-113 (lines=57) @@ | ||
| 54 | /** |
|
| 55 | * Register the routes for products. |
|
| 56 | */ |
|
| 57 | public function register_routes() { |
|
| 58 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 59 | array( |
|
| 60 | 'methods' => WP_REST_Server::READABLE, |
|
| 61 | 'callback' => array( $this, 'get_items' ), |
|
| 62 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 63 | 'args' => $this->get_collection_params(), |
|
| 64 | ), |
|
| 65 | array( |
|
| 66 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 67 | 'callback' => array( $this, 'create_item' ), |
|
| 68 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 69 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 70 | ), |
|
| 71 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 72 | ) ); |
|
| 73 | ||
| 74 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 75 | array( |
|
| 76 | 'methods' => WP_REST_Server::READABLE, |
|
| 77 | 'callback' => array( $this, 'get_item' ), |
|
| 78 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 79 | 'args' => array( |
|
| 80 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 81 | ), |
|
| 82 | ), |
|
| 83 | array( |
|
| 84 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 85 | 'callback' => array( $this, 'update_item' ), |
|
| 86 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 87 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 88 | ), |
|
| 89 | array( |
|
| 90 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 91 | 'callback' => array( $this, 'delete_item' ), |
|
| 92 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 93 | 'args' => array( |
|
| 94 | 'force' => array( |
|
| 95 | 'default' => false, |
|
| 96 | 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), |
|
| 97 | ), |
|
| 98 | 'reassign' => array(), |
|
| 99 | ), |
|
| 100 | ), |
|
| 101 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 102 | ) ); |
|
| 103 | ||
| 104 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 105 | array( |
|
| 106 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 107 | 'callback' => array( $this, 'batch_items' ), |
|
| 108 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 109 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 110 | ), |
|
| 111 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 112 | ) ); |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Query args. |
|
| @@ 42-97 (lines=56) @@ | ||
| 39 | /** |
|
| 40 | * Register the routes for taxes. |
|
| 41 | */ |
|
| 42 | public function register_routes() { |
|
| 43 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 44 | array( |
|
| 45 | 'methods' => WP_REST_Server::READABLE, |
|
| 46 | 'callback' => array( $this, 'get_items' ), |
|
| 47 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 48 | 'args' => $this->get_collection_params(), |
|
| 49 | ), |
|
| 50 | array( |
|
| 51 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 52 | 'callback' => array( $this, 'create_item' ), |
|
| 53 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 54 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 55 | ), |
|
| 56 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 57 | ) ); |
|
| 58 | ||
| 59 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 60 | array( |
|
| 61 | 'methods' => WP_REST_Server::READABLE, |
|
| 62 | 'callback' => array( $this, 'get_item' ), |
|
| 63 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 64 | 'args' => array( |
|
| 65 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 66 | ), |
|
| 67 | ), |
|
| 68 | array( |
|
| 69 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 70 | 'callback' => array( $this, 'update_item' ), |
|
| 71 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 72 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 73 | ), |
|
| 74 | array( |
|
| 75 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 76 | 'callback' => array( $this, 'delete_item' ), |
|
| 77 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 78 | 'args' => array( |
|
| 79 | 'force' => array( |
|
| 80 | 'default' => false, |
|
| 81 | 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), |
|
| 82 | ), |
|
| 83 | ), |
|
| 84 | ), |
|
| 85 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 86 | ) ); |
|
| 87 | ||
| 88 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 89 | array( |
|
| 90 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 91 | 'callback' => array( $this, 'batch_items' ), |
|
| 92 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 93 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 94 | ), |
|
| 95 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 96 | ) ); |
|
| 97 | } |
|
| 98 | ||
| 99 | /** |
|
| 100 | * Check whether a given request has permission to read taxes. |
|