API routes changed

This commit is contained in:
weryques 2018-01-25 11:47:09 -02:00
parent 115d84e63f
commit 01f42d5c0c
6 changed files with 17 additions and 17 deletions

View File

@ -41,7 +41,7 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller {
*/
public function register_routes() {
register_rest_route(
$this->namespace, '/' . $this->rest_base . '/collection/(?P<collection_id>[\d]+)',
$this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base,
array(
array(
'methods' => WP_REST_Server::READABLE,

View File

@ -39,7 +39,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_REST_Controller {
* Both of GETs return the metadata of matched objects
*/
public function register_routes() {
register_rest_route($this->namespace, '/' . $this->rest_base . '/collection/(?P<collection_id>[\d]+)',
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base ,
array(
array(
'methods' => WP_REST_Server::READABLE,
@ -64,7 +64,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_REST_Controller {
)
)
);
register_rest_route($this->namespace, '/' . $this->rest_base . '/item/(?P<item_id>[\d]+)',
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/'. $this->rest_base,
array(
array(
'methods' => WP_REST_Server::READABLE,

View File

@ -31,7 +31,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_REST_Controller {
}
public function register_routes() {
register_rest_route($this->namespace, '/' . $this->rest_base . '/taxonomy/(?P<taxonomy_id>[\d]+)',
register_rest_route($this->namespace, '/taxonomy/(?P<taxonomy_id>[\d]+)/' . $this->rest_base,
array(
array(
'methods' => WP_REST_Server::CREATABLE,
@ -45,7 +45,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_REST_Controller {
)
)
);
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<term_id>[\d]+)/taxonomy/(?P<taxonomy_id>[\d]+)',
register_rest_route($this->namespace,'/taxonomy/(?P<taxonomy_id>[\d]+)/'. $this->rest_base . '/(?P<term_id>[\d]+)' ,
array(
array(
'methods' => WP_REST_Server::DELETABLE,

View File

@ -22,7 +22,7 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'The Progressive JavasScript Framework'
]);
$request = new \WP_REST_Request('POST', $this->namespace . '/items/collection/' . $collection->get_id());
$request = new \WP_REST_Request('POST', $this->namespace . '/collection/' . $collection->get_id() . '/items');
$request->set_body($item_json);
$response = $this->server->dispatch($request);
@ -64,7 +64,7 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
true
);
$request = new \WP_REST_Request('GET', $this->namespace . '/items/collection/' . $collection->get_id());
$request = new \WP_REST_Request('GET', $this->namespace . '/collection/' . $collection->get_id() . '/items');
$response = $this->server->dispatch($request);
$this->assertEquals(200, $response->get_status());

View File

@ -34,7 +34,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$request = new \WP_REST_Request(
'POST',
$this->namespace . '/metadata/collection/' . $collection->get_id()
$this->namespace . '/collection/' . $collection->get_id() . '/metadata'
);
$request->set_body($metadata);
@ -92,7 +92,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$request = new \WP_REST_Request(
'GET',
$this->namespace . '/metadata/collection/' . $collection->get_id()
$this->namespace . '/collection/' . $collection->get_id() . '/metadata'
);
$response = $this->server->dispatch($request);
@ -107,7 +107,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$request = new \WP_REST_Request(
'GET',
$this->namespace . '/metadata/item/' . $item->get_id()
$this->namespace . '/item/' . $item->get_id() . '/metadata'
);
$response = $this->server->dispatch($request);
@ -164,7 +164,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$request = new \WP_REST_Request(
'PATCH',
$this->namespace . '/metadata/item/' . $item->get_id()
$this->namespace . '/item/' . $item->get_id() . '/metadata'
);
$request->set_body($meta_values);
@ -193,7 +193,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$request = new \WP_REST_Request(
'PATCH',
$this->namespace . '/metadata/collection/' . $collection->get_id()
$this->namespace . '/collection/' . $collection->get_id() . '/metadata'
);
$request->set_body($values);

View File

@ -20,7 +20,7 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
);
$request = new \WP_REST_Request(
'POST', $this->namespace . '/terms/taxonomy/' . $taxonomy->get_id()
'POST', $this->namespace . '/taxonomy/' . $taxonomy->get_id() . '/terms'
);
$term = json_encode([
@ -61,7 +61,7 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
true
);
$request = new \WP_REST_Request('DELETE', $this->namespace . '/terms/' . $term . '/taxonomy/' . $taxonomy->get_id());
$request = new \WP_REST_Request('DELETE', $this->namespace . '/taxonomy/' . $taxonomy->get_id() . '/terms/' . $term);
$response = $this->server->dispatch($request);
@ -101,7 +101,7 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
]);
$request = new \WP_REST_Request(
'PATCH', $this->namespace . '/terms/' . $term . '/taxonomy/' . $taxonomy->get_id()
'PATCH', $this->namespace . '/taxonomy/' . $taxonomy->get_id() . '/terms/' . $term
);
$request->set_body($new_attributes);
@ -153,7 +153,7 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
]);
$request = new \WP_REST_Request(
'GET', $this->namespace . '/terms/taxonomy/' . $taxonomy->get_id()
'GET', $this->namespace . '/taxonomy/' . $taxonomy->get_id() . '/terms'
);
$request->set_body($show_empty);
@ -171,7 +171,7 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
#### FETCH A TERM ####
$request = new \WP_REST_Request(
'GET', $this->namespace . '/terms/' . $term2 . '/taxonomy/' . $taxonomy->get_id()
'GET', $this->namespace . '/taxonomy/' . $taxonomy->get_id() . '/terms/' . $term2
);
$response = $this->server->dispatch($request);