| @@ 42-85 (lines=44) @@ | ||
| 39 | /** |
|
| 40 | * Register the routes for order notes. |
|
| 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' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( |
|
| 55 | 'note' => array( |
|
| 56 | 'required' => true, |
|
| 57 | ), |
|
| 58 | ) ), |
|
| 59 | ), |
|
| 60 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 61 | ) ); |
|
| 62 | ||
| 63 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 64 | array( |
|
| 65 | 'methods' => WP_REST_Server::READABLE, |
|
| 66 | 'callback' => array( $this, 'get_item' ), |
|
| 67 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 68 | 'args' => array( |
|
| 69 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 70 | ), |
|
| 71 | ), |
|
| 72 | array( |
|
| 73 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 74 | 'callback' => array( $this, 'delete_item' ), |
|
| 75 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 76 | 'args' => array( |
|
| 77 | 'force' => array( |
|
| 78 | 'default' => false, |
|
| 79 | 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), |
|
| 80 | ), |
|
| 81 | ), |
|
| 82 | ), |
|
| 83 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 84 | ) ); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Check whether a given request has permission to read order notes. |
|
| @@ 57-101 (lines=45) @@ | ||
| 54 | /** |
|
| 55 | * Register the routes for order refunds. |
|
| 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' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( |
|
| 70 | 'email' => array( |
|
| 71 | 'required' => true, |
|
| 72 | ), |
|
| 73 | ) ), |
|
| 74 | ), |
|
| 75 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 76 | ) ); |
|
| 77 | ||
| 78 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 79 | array( |
|
| 80 | 'methods' => WP_REST_Server::READABLE, |
|
| 81 | 'callback' => array( $this, 'get_item' ), |
|
| 82 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 83 | 'args' => array( |
|
| 84 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 85 | ), |
|
| 86 | ), |
|
| 87 | array( |
|
| 88 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 89 | 'callback' => array( $this, 'delete_item' ), |
|
| 90 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 91 | 'args' => array( |
|
| 92 | 'force' => array( |
|
| 93 | 'default' => false, |
|
| 94 | 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), |
|
| 95 | ), |
|
| 96 | 'reassign' => array(), |
|
| 97 | ), |
|
| 98 | ), |
|
| 99 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 100 | ) ); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Prepare a single order refund output for response. |
|