Update tainacan-api.md

This commit is contained in:
Weryques 2018-02-22 13:07:39 -03:00 committed by GitHub
parent 4c63362d84
commit 0918656a8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 178 additions and 185 deletions

View File

@ -24,329 +24,322 @@ A REST API for Tainacan Plugin. This API uses the Wordpress REST API.
1. Route `wp-json/tainacan/v2/collections/(?P<collection_id>[\d]+)`
1.1. Endpoints supported:
1. Endpoints supported:
1.1.1. GET (Fetch a collection)
1.1.2. DELETE (Delete or Trash a collection and all your dependencies)
```
To delete pass in body of a requisition the parameter is_permanently as true.
To only trash pass false.
```
1.1.3 PATCH or PUT (Update a collection)
1. GET (Fetch a collection)
     
1. DELETE (Delete or Trash a collection and all your dependencies)
*To delete pass in body of a requisition the parameter `is_permanently` as true. To only trash pass false.*
1. PATCH or PUT (Update a collection)
Example of JSON passed in body for updating a collection:
Example of JSON passed in body for updating a collection:
   
```javascript
{
"name": "string",
"description": "string",
...
}
{
"name": "string",
"description": "string",
...
}
```
2. Route `wp-json/tainacan/v2/collections`
2.1. Endpoints supported:
1. Endpoints supported:
2.1.1. GET (Fetch all collections)
1. GET (Fetch all collections)
2.1.2. POST (Create a collection).
1. POST (Create a collection).
Example of JSON passed in body for creating a collection:
Example of JSON passed in body for creating a collection:
```javascript
{
"name": "string",
"description": "string",
"status": "string",
"order": "string",
"parent": "integer",
"slug": "string",
"default_orderby": "string",
"default_order": "string",
"columns": "string",
"default_view_mode": "string"
}
{
"name": "string",
"description": "string",
"status": "string",
"order": "string",
"parent": "integer",
"slug": "string",
"default_orderby": "string",
"default_order": "string",
"columns": "string",
"default_view_mode": "string"
}
```
------
#### Items
1. Route `wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/items`
1.1. Endpoints supported:
1. Endpoints supported:
1.1.1. GET (Fetch all items from a collection)
1. GET (Fetch all items from a collection)
1.1.2. POST (Create a item in a collection)
Example of JSON passed in body for creating a item:
1. POST (Create a item in a collection)
Example of JSON passed in body for creating a item:
```javascript
{
"title": "string",
"description": "string",
"status": "string",
}
{
"title": "string",
"description": "string",
"status": "string",
}
```
2. Route `wp-json/tainacan/v2/items/(?P<item_id>[\d]+)`
2.1. Endpoints supported:
1. Endpoints supported:
2.1.1. GET (Fetch a item)
1. GET (Fetch a item)
2.1.2. DELETE (Delete or Trash a item and all your dependencies)
1. DELETE (Delete or Trash a item and all your dependencies)
```
To delete pass in body of a requisition the parameter is_permanently as true.
To only trash pass false.
*To delete pass in body of a requisition the parameter is_permanently as true. To only trash pass false.*
1. PATCH or PUT (Update a item)
Example of JSON passed in body for updating a item:
   
```javascript
{
"title": "string",
"description": "string",
...
}
```
2.1.3. PATCH or PUT (Update a item)
Example of JSON passed in body for updating a item:
   
```
{
"title": "string",
"description": "string",
...
}
```
------
#### Fields
1. Route `wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/fields`
1.1. Endpoints supported:
1. Endpoints supported:
1. GET (Fetch all collection field)
1. POST (Create a field in collection and all it items)
1.1.1. POST (Create a field in collection and all it items)
In body of requisition pass a JSON with the attributes of field like:
In body of requisition pass a JSON with the attributes of field like:
```javascript
{
"name": "string",
"description": "string",
"field_type": "string",
"order": "string",
"parent": "integer",
"required": "string",
"collection_key": "string",
"multiple": "string",
"cardinality": "string",
"privacy": "string",
"mask": "string",
"default_value": "string",
"field_type_options": "string",
}
{
"name": "string",
"description": "string",
"field_type": "string",
"order": "string",
"parent": "integer",
"required": "string",
"collection_key": "string",
"multiple": "string",
"cardinality": "string",
"privacy": "string",
"mask": "string",
"default_value": "string",
"field_type_options": "string",
}
```
1.1.2 GET (Fetch all collection field)
2. Route `wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/fields/(?P<field_id>[\d]+)`
2.1. Endpoints supported:
1. Endpoints supported:
2.1.1. PATCH or PUT (Update a field in a collection and all it items)
1. PATCH or PUT (Update a field in a collection and all it items)
In body of requisition pass a JSON with the attributes you need to update, like:
In body of requisition pass a JSON with the attributes you need to update, like:
```javascript
{
"name": "string",
"description": "string",
}
{
"name": "string",
"description": "string",
}
```
------
#### Item Metadata
1. Route `wp-json/tainacan/v2/item/(?P<item_id>[\d]+)/metadata/(?P<metadata_id>[\d]+)`
1.1. Endpoints supported:
1. Endpoints supported:
1.1.1. PATCH or PUT (Set value of a metadata)
1. PATCH or PUT (Set value of a metadata)
In body of requisition pass a JSON with values of metadata, like:
In body of requisition pass a JSON with values of metadata, like:
```javascript
{
"values": [
{ "new": "any_type", "prev": "any_type"},
{ "new": "any_type", "prev": ""}
]
}
{
"values": [
{ "new": "any_type", "prev": "any_type"},
{ "new": "any_type", "prev": ""}
]
}
```
2. Route `wp-json/tainacan/v2/item/(?P<item_id>[\d]+)/metadata`
2.1. Enpoints supported:
1. Enpoints supported:
2.1.1. GET (Fetch all item metadata, with it values)
1. GET (Fetch all item metadata, with it values)
------
#### Taxonomies
1. Route `wp-json/tainacan/v2/taxonomies`
1.1. Endpoints supported:
1. Endpoints supported:
1.1.1. GET (Fetch all taxonomies)
1. GET (Fetch all taxonomies)
1.1.2. POST (Create a taxonomy)
1. POST (Create a taxonomy)
Example of JSON passed in body for creating a taxonomy:
Example of JSON passed in body for creating a taxonomy:
```javascript
{
"name": "string",
"description": "string",
"status": "string",
"parent": "string",
"slug": "string",
"allow_insert": "string",
"collections_ids": "array"
}
{
"name": "string",
"description": "string",
"status": "string",
"parent": "string",
"slug": "string",
"allow_insert": "string",
"collections_ids": "array"
}
```
2. Route `wp-json/tainacan/v2/taxonomies/(?P<taxonomy_id>[\d]+)`
2.1. Endpoints supported:
1. Endpoints supported:
2.1.1. GET (Fetch a taxonomy)
1. GET (Fetch a taxonomy)
2.1.2. DELETE (Delete or trash a taxonomy)
```
To delete pass in body of requisition the parameter is_permanently as true.
To only trash pass false.
```
1. DELETE (Delete or trash a taxonomy)
2.1.3. PATCH or PUT (Update a taxonomy)
*To delete pass in body of requisition the parameter is_permanently as true. To only trash pass false.*
1. PATCH or PUT (Update a taxonomy)
Example of JSON passed in body for updating a taxonomy:
Example of JSON passed in body for updating a taxonomy:
   
```javascript
{
"name": "string",
"description": "string",
...
}
{
"name": "string",
"description": "string",
...
}
```
3. Route `wp-json/tainacan/v2/taxonomies/(?P<taxonomy_id>[\d]+)/collection/(?P<collection_id>[\d]+)`
3.1. Routes supported:
1. Routes supported:
3.1.1. PATCH or PUT (Add a Collection in a Taxonomy)
1. PATCH or PUT (Add a Collection in a Taxonomy)
------
#### Filters
1. Route `wp-json/tainacan/v2/filters`
1. Route `wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/field/(?P<field_id>[\d]+)/filters`
1.1. Endpoints supported:
1. Endpoints supported:
1.1.1. POST (Create a filter)
1. POST (Create a filter)
Example of JSON passed in body for creating a filter:
Example of JSON passed in body for creating a filter:
```javascript
{
"collection_id": "int",
"metadata_id": "int",
"filter_type": "string",
"filter": {
"name": "string",
"description": "string",
...
}
}
{
"filter_type": "string",
"filter": {
"name": "string",
"description": "string",
...
}
}
```
1.1.2. GET (Fetch all filters)
2. Route `wp-json/tainacan/v2/filters/(?P<filter_id>[\d]+)`
2.1. Endpoints supported:
1. Endpoints supported:
2.1.1. DELETE (Delete or trash a filter)
1. GET (Fetch a filter)
1. DELETE (Delete or trash a filter)
```
To delete pass in body of requisition the parameter is_permanently as true.
To only trash pass false.
```
*To delete pass in body of requisition the parameter is_permanently as true. To only trash pass false.*
2.1.2. PATCH or PUT (Update a filter)
1. PATCH or PUT (Update a filter)
Example of JSON passed in body for updating a filter:
Example of JSON passed in body for updating a filter:
```javascript
{
"name": "string",
...
}
{
"name": "string",
...
}
```
2.1.3. GET (Fetch a filter)
3. Route `wp-json/tainacan/v2/filters`
1. Endpoints supported:
1. GET (Fetch all filters)
------
#### Terms
1. Route `wp-json/tainacan/v2/taxonomy/(?P<taxonomy_id>[\d]+)/terms`
1.1. Endpoints supported:
1. Endpoints supported:
1. GET (Fetch all tems of a taxonomy)
1.1.1. POST (Create a term in a taxonomy)
Example of JSON passed in body for creating a term:
1. POST (Create a term in a taxonomy)
Example of JSON passed in body for creating a term:
```javascript
{
"name": "string",
"user": "int",
...
}
{
"name": "string",
"user": "int",
...
}
```
1.1.2 GET (Fetch all tems of a taxonomy)
2. Route `wp-json/tainacan/v2/taxonomy/(?P<taxonomy_id>[\d]+)/terms/(?P<term_id>[\d]+)`
2.1. Endpoints supported:
1. Endpoints supported:
2.1.1. GET (Fecth a term of a taxonomy)
1. GET (Fecth a term of a taxonomy)
1. DELETE (Delete a term of a taxonoy)
2.1.2. PATCH or PUT (Update a term in a taxonomy)
1. PATCH or PUT (Update a term in a taxonomy)
Example of JSON passed in body for updating a term:
Example of JSON passed in body for updating a term:
```javascript
{
"name": "string",
...
}
{
"name": "string",
...
}
```
2.1.3. DELETE (Delete a term of a taxonoy)
------
#### Logs
1. Route `wp-json/tainacan/v2/logs`
1.1. Endpoints supported:
1. Endpoints supported:
1.1.1. GET (Get all logs)
1. GET (Get all logs)
2. Route `wp-json/tainacan/v2/logs/(?P<log_id>[\d]+)`
2.1. Enpoints supported:
1. Enpoints supported:
2.1.1. GET (Get a log)
1. GET (Get a log)
------
#### Others