Tags API
Tags
An API is available to manipulate farm labels created by the user. These labels have a text and a color, and can be assigned to a farm. They can be seen in the farm selector in the upper section of the platform.
POST
POST /api/tags_campos/tag
Receives the following parameters in the query string:
desc
:string
, (mandatory.) tag's description.color
:string
, (optional.) color in hexadecimal format without "#". Example: FD37E6. If the parameter is not sent, a random color is assigned.id_campo
:integer
, (optional.) If this parameter is sent, it is assigned to the corresponding farm.
Use example
fetch("https://api.auravant.com/api/tags_campos/tag?id_campo=11111&desc=tag1&color=C51965", {
method: "POST",
headers: {
Authorization: "Bearer "+token
}
}).then(resp => resp.json()).then(result => console.log(result))
Response example
{
"color": "C51965",
"res": "creado",
"tag": "tag1",
"id_tag": 123,
"id_campo": 11111
}
Posible errors
- Invalid color format
{
"info": "El color debe tener formato de 6 caracteres sin hash inicial ej FD37E6",
"res": "err",
"code": 2
}
- Tag's name already exists
{
"info": "El nombre de la llave ya existe para ese usaurio",
"res": "err",
"code": 3
}
PATCH
PATCH /api/tags_campos/tag
Receives the following parameters in the query string:
id_tag
:integer
, (mandatory.) ID of the tag to be modifieddesc
:string
, Tag's description.color
:string
, color in hexadecimal format without "#". Example: FD37E6. If the parameter is not sent, a random color is assigned.
⚠️ NOTE: It is mandatory to send at least one of the two parameters (desc or color)
Use example
fetch("https://api.auravant.com/api/tags_campos/tag?id_tag=1234&color=aa00aa&desc=modified", {
method: "PATCH",
headers: {
Authorization: "Bearer "+token
}
}).then(resp => resp.json()).then(result => console.log(result))
Response example
{
"color": "aa00aa",
"id_usuario": 000000,
"tag": "modified",
"id_tag": 1234,
"res": "modificado"
}
Posible errors
- Invalid format color
{
"info": "El color debe tener formato de 6 caracteres sin hash inicial ej FD37E6",
"res": "err",
"code": 2
}
- Inexistant label ID
{
"info": "Id de tag inexistente",
"res": "err",
"code": 3
}
- Label name already exists
{
"info": "El nombre de la llave ya existe para ese usaurio",
"res": "err",
"code": -6
}
GET
GET /api/tags_campos/tag
It has three forms of use:
tag
: fetches information from a single tag.farm
: fetches information from the tags associated with a farm.user
: fetches information from all user tags.
Depending on what is passed through the query string, the form of use varies.
What could be sent:
id_campo
:integer
, (ID of the farm from which it is sought to obtain the associated labels.) It fetches all the tags associated with a field.id_tag
:integer
, (ID of the tag whose information is sought to be obtained.) It fetches the information of the specified tag.- If no parameters are sent in the query string, the form of use corresponds to the user's tags. It will bring all the tags created by the logged in user.
Use example
fetch("https://api.auravant.com/api/tags_campos/tag?id_tag=1234", {
method: "GET",
headers: {
Authorization: "Bearer "+token
}
}).then(resp => resp.json()).then(result => console.log(result))
Response examples
tag:
{
"filter": "tag info",
"result": {
"934": {
"color": "aa00aa",
"tag": "modified"
}
}
}
farm:
{
"filter": "farm tags",
"result": {
"934": {
"color": "987A60",
"tag": "tag2"
},
"935": {
"color": "C51965",
"tag": "tags"
}
}
}
user:
{
"filter": "user tags",
"result": {
"934": {
"color": "987A60",
"tag": "tag 2"
},
"935": {
"color": "C51965",
"tag": "tags"
},
"936": {
"color": "50432B",
"tag": "tag4"
}
}
}
DELETE
DELETE /api/tags_campos/tag
Receives the following parameters in the query string:
id_tag
:integer
, (mandatory.) Label's ID.
Use example
fetch("https://api.auravant.com/api/tags_campos/tag?id_tag=1234", {
method: "DELETE",
headers: {
Authorization: "Bearer "+token
}
}).then(resp => resp.json()).then(result => console.log(result))
Response example
{
"res": "eliminado",
"id_tag": 1234
}
Posible error
{
"info": "Codigo de tag inexistente",
"res": "err",
"code": 3
}
Associate a label to a farm
POST
POST /api/tags_campos/asociar
Receives the following parameters in the query string:
id_tag
:integer
, (mandatory.) ID of the label to be associated.id_campo
:integer
, (mandatory.) ID of the farm to which the label is going to be associated with.
Returns the total labels associated with the farm to which the label is associated.
Ejemplo de uso
fetch("https://api.auravant.com/api/tags_campos/asociar?id_tag=1235&id_campo=111111", {
method: "POST",
headers: {
Authorization: "Bearer "+token
}
}).then(resp => resp.json()).then(result => console.log(result))
Response example
{
"1234": {
"tag": "modified",
"color": "aa00aa"
},
"1235": {
"tag": "nuevotag",
"color": "15ffcd"
}
}
Posible errors
{
"info": "Faltan Parametros",
"res": "err",
"code": 1
}
DELETE
DELETE /api/tags_campos/asociar
Receives the following parameters in the query string:
id_tag
:integer
, (mandatory.) ID of the label to be disassociated.id_campo
:integer
, (mandatory.) ID of the farm to which the label is going to be disassociated from.
Returns the total labels associated with the farm to which the label is disassociated.
Use example
fetch("https://api.auravant.com/api/tags_campos/asociar?id_tag=1234&id_campo=111111", {
method: "DELETE",
headers: {
Authorization: "Bearer "+token
}
}).then(resp => resp.json()).then(result => console.log(result))
Response example
{
"1235": {
"tag": "nuevotag",
"color": "15ffcd"
}
}
Posible errors
{
"info": "Faltan Parametros",
"res": "err",
"code": 1
}