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