Rotas
Documentação da api de rotas do julinho.
Autenticação ¶
Recurso de autenticação. Use esse endpoint para receber que token jwt válido, necessário para consumir os outros recursos da api. Cada token tem um tempo de expiração de 2 horas. Após esse tempo é necessário repetir o processo de autenticação.
Autenticação ¶
Obtém o tokenPOST/auth
Example URI
Headers
Content-Type: application/json
Body
{
"email": "admin@example.com",
"password": "adminpassword123"
}
200
Headers
Content-Type: application/json
Body
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoyMSwibmFtZSI6IkFkbWluIiwiZW1haWwiOiJhZG1pbkBleGFtcGxlLmNvbSIsImlhdCI6MTUwNjE4MTk1NSwiZXhwIjoxNTA2MTg5MTU1fQ.kGS_fafRIY3LX0Oe4dIuLikfVqYgN1TILZd9F-QKlcUk6PgstGTxEq97LdLOQy1PdSfYZwrNF5eFvl_7ru96_IYdx9c3ig3uep_Th9F17OJ4cjHnrZ-q4L44yct97N3PEC_ybswMtS0stvAwEnKIOzNzE4yUoW-sY1tYphB4Wb78SigSK0-0E-ydsBCazMlRPEG4UFoOuvtmND4kzoFTPmURqKYxxmEe99qNDeVu_tWkf8-0LjdKfHUDCA1wO1wNlMG65yjHrpCP5qLmr269iTBabDRotlo6ZB4mNw1IK3A50eh70wk18e7bq8vXZMFTrM3mcbjWUryKmOLkwfsW55-J37meoyL9tkjXa8O4HLMbR0pon9QvdLhbxYEJCB7fFGNklp-yQmn_hYaPj0fc-K4LZuQ1I0wU_HG2DRNQlKKoGlo8sg-CSWsEOe_6pVuiUqFukPc1hvDP2txSpvILD1gP87HGQ5lEu4CCPZB9tIwYlQ_ljI6reC-EqGz5XHfBP135XvFLehRn-j0HKr7d7U4RpO8S0fmnNHBdpLixUXxXUzRqszoXf0A7rC3IiwYtr8Ew-WKlEjtxiRJP_zRp1UMRYiOxDHSYN3d6a48RGX7yid5JaPhzjnZdtrPMo3XyOD-bNHCA_R1UnWv_nxLBmxDbpBepWWsTy8_ueaHzc7Q"
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid schema"
}
Andar ¶
Faz o julinho andar.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Rotas ¶
Recursos relacionados às rotas na API.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Coleção de Rotas ¶
Lista todas as rotasGET/routes
Example URI
200
Headers
Content-Type: application/json
Body
[
{
"id": 12,
"name": "firstRoute",
"points": [
{
"id": 22,
"name": "classroom",
"rfid": "123456789",
"action": "d"
},
{
"id": 21,
"name": "library",
"rfid": "123456",
"action": "e"
}
]
},
{
"id": 13,
"name": "secondRoute",
"points": [
{
"id": 21,
"name": "library",
"rfid": "123456",
"action": "f"
},
{
"id": 22,
"name": "classroom",
"rfid": "123456789",
"action": "p"
}
]
}
]
401
Headers
Content-Type: application/json
Body
{
"message": "Wrong authorization type"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Expired token"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized user"
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid schema"
}
404
Headers
Content-Type: application/json
Body
{
"message": "Not found"
}
500
Headers
Content-Type: application/json
Body
{
"message": "Internal Server Error"
}
Cria uma rotaPOST/routes
Example URI
Headers
Content-Type: application/json
Body
{
"name": "rota massa",
"points": [
{
"point": 22,
"action": "d"
},
{
"point": 21,
"action": "e"
}
]
}
201
Headers
Content-Type: application/json
Body
{
"id": 2,
"name": "rota massa",
"points": [
{
"id": 22,
"name": "classroom",
"rfid": "123456789",
"action": "d"
},
{
"id": 21,
"name": "library",
"rfid": "123456",
"action": "e"
}
]
}
401
Headers
Content-Type: application/json
Body
{
"message": "Wrong authorization type"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Expired token"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized user"
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid schema"
}
404
Headers
Content-Type: application/json
Body
{
"message": "Not found"
}
500
Headers
Content-Type: application/json
Body
{
"message": "Internal Server Error"
}
Rotas ¶
Consulta as informações de uma rotaGET/routes/{rota_id}
Example URI
- rota_id
string
(required) Example: 1A id de uma rota.
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"name": "firstRoute",
"points": [
{
"id": 22,
"name": "classroom",
"rfid": "123456789",
"action": "d"
},
{
"id": 21,
"name": "library",
"rfid": "123456",
"action": "e"
}
]
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid route id"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Wrong authorization type"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Expired token"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized user"
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid schema"
}
404
Headers
Content-Type: application/json
Body
{
"message": "Not found"
}
500
Headers
Content-Type: application/json
Body
{
"message": "Internal Server Error"
}
Altera as informações de uma rotaPUT/routes/{rota_id}
Example URI
- rota_id
string
(required) Example: 1A id de uma rota.
Headers
Content-Type: application/json
Body
{
"id": 1,
"name": "pow",
"points": [
{
"point": 22,
"action": "d"
},
{
"point": 21,
"action": "f"
}
]
}
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"name": "pow",
"points": [
{
"id": 22,
"name": "classroom",
"rfid": "123456789",
"action": "d"
},
{
"id": 21,
"name": "library",
"rfid": "123456",
"action": "f"
}
]
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid route id"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Wrong authorization type"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Expired token"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized user"
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid schema"
}
404
Headers
Content-Type: application/json
Body
{
"message": "Not found"
}
500
Headers
Content-Type: application/json
Body
{
"message": "Internal Server Error"
}
Deleta uma rotaDELETE/routes/{rota_id}
Example URI
- rota_id
string
(required) Example: 1A id de uma rota.
200
Headers
Content-Type: application/json
Body
{
"message": "Route 1 deleted with success"
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid route id"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Wrong authorization type"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Expired token"
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized user"
}
400
Headers
Content-Type: application/json
Body
{
"message": "Invalid schema"
}
404
Headers
Content-Type: application/json
Body
{
"message": "Not found"
}
500
Headers
Content-Type: application/json
Body
{
"message": "Internal Server Error"
}
Permissões ¶
Recurso de permissões
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Coleção de permissões ¶
Lista todas as permissões do usuário ou clientGET/permissions
Example URI
200
Headers
Content-Type: application/json
Body
[
{
"create": 1,
"read": 1,
"update": 1,
"delete": 1,
"name": "users"
},
{
"create": 1,
"read": 1,
"update": 1,
"delete": 1,
"name": "permissions"
},
{
"create": 1,
"read": 1,
"update": 1,
"delete": 1,
"name": "clients"
},
{
"create": 1,
"read": 1,
"update": 1,
"delete": 1,
"name": "points"
},
{
"create": 1,
"read": 1,
"update": 1,
"delete": 1,
"name": "routes"
}
]
Usuários ¶
Recursos relacionados aos usuários na API.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Coleção de usuários ¶
Lista todas os usuáriosGET/users
Example URI
200
Headers
Content-Type: application/json
Body
[
{
"id": 27,
"name": "Admin",
"role_id": 29,
"email": "admin@example.com"
},
{
"id": 28,
"name": "User",
"role_id": 30,
"email": "user@example.com"
}
]
Cria um usuárioPOST/users
Example URI
Headers
Content-Type: application/json
Body
{
"role_id": 1,
"password": "algumasenhadificil,
"email": "usuario@gmail.com",
"name" : "nome do usuário"
}
201
Headers
Content-Type: application/json
Body
{
"id": 1,
"name": "nome do usuário",
"role_id": 31,
"email": "usuario@gmail.com"
}
Usuários ¶
Busca as informações de um usuárioGET/users/{user_id}
Example URI
- user_id
string
(required) Example: 1A id de um usuário.
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"name": "Admin",
"role_id": 29,
"email": "admin@example.com"
}
Remove um usuárioDELETE/users/{user_id}
Example URI
- user_id
string
(required) Example: 1A id de um usuário.
204
Altera um usuárioPUT/users/{user_id}
Example URI
- user_id
string
(required) Example: 1A id de um usuário.
Headers
Content-Type: application/json
Body
{
"role_id": 1,
"password": "algumasenhadificil,
"email": "usuario@gmail.com",
"name" : "novo nome legal"
}
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"name": "novo nome legal",
"role_id": 29,
"email": "admin@example.com"
}
Pontos ¶
Recursos relacionados aos pontos rfid na API.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Coleção de pontos ¶
Lista todas os pontosGET/points
Example URI
200
Headers
Content-Type: application/json
Body
[
{
"id": 31,
"rfid": "123456",
"name": "library"
},
{
"id": 32,
"rfid": "123456789",
"name": "classroom"
}
]
Criar um pontoPOST/points
Example URI
Headers
Content-Type: application/json
Body
{
"rfid": "123456",
"name": "library"
}
201
Headers
Content-Type: application/json
Body
{
"id": 31,
"rfid": "123456",
"name": "library"
}
Pontos ¶
Busca as informações de um pontoGET/points/{point_id}
Example URI
- point_id
string
(required) Example: 1A id de um ponto.
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"rfid": "123456",
"name": "library"
}
Remove um pontoDELETE/points/{point_id}
Example URI
- point_id
string
(required) Example: 1A id de um ponto.
204
Altera um pontoPUT/points/{point_id}
Example URI
- point_id
string
(required) Example: 1A id de um ponto.
Headers
Content-Type: application/json
Body
{
"role_id": 1,
"rfid": "123456",
"name": "library 2"
}
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"rfid": "123456",
"name": "library 2"
}
Clientes ¶
Recursos relacionados aos clientes da API. Ex: Chatbot, Serviço de MQTT.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Coleção de clientes ¶
Criar um clientePOST/clients
Example URI
Headers
Content-Type: application/json
Body
{
"name": "julinho chat bot",
"permissions": [
{
"resource_id": 44,
"create": true,
"read": true,
"update": true,
"delete": true
}
],
"key": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqWhh8bCdBmYha6vVMaNa\niVHsjoCo8JvNl/FCQ8ElB8BEPisWSj9pLuqtn3/Ky1/QE+dLkpN1MWu/WwBR+67L\ntoj3ao8LxpKday25sdC7j1h5phgym4AQfirBjuGXhhVVUoNy2vRXDyJK/uVvVcmm\n3cu2UYjaFe2DnXUb2zOkvezwpcYNVTlsplDAbPR7OL+d2hqKeWdCUupu5nytsYi9\nxKlVoWHlLSDDC264/6FtKi2NULSdU+g0cAfNSjsFmBPFMQ5E4jCbGic/KKHvzLcI\n9Z0jhu0YvKQ5kMgR+cj3dGXoyUaVNXbENYyit8NMQTUkgnBrUxIAKRAJuODbk9l2\ngrasJ6oOrv5eo5OJvsVKVfd3EnBlZv/ZcVYIQq80u2loOoIqNg4B6ZsA2ooFvj8X\nZgyJN//Qpm9fehOlBqLYjpaDCVnFX+zzOCnCuBEOIq539aJrFkXWrFUSZX3r8CZO\norBqpceF9rpjJcayDua/oHPpDFVLSHSMJ0006c54zc5aN5frPQymPLaj45YqJXIS\n0U5K857WVAs49nlBnt+jZgorQ/hXqZlPFCAF/Ym7l6bi5hEtnMHnL5yDi9diL5nu\nZ0qCjllNfJiZVS3m+5UQZ2ghSd45x/GVPiqfhh8LtQMU5gvvhfV/wuiOXj4Xahrf\n6lrl637UM1pIjQuv6zJP6msCAwEAAQ==\n-----END PUBLIC KEY-----\n"
}
201
Headers
Content-Type: application/json
Body
{
"id": 1,
"name": "julinho chat bot",
"key": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqWhh8bCdBmYha6vVMaNa\niVHsjoCo8JvNl/FCQ8ElB8BEPisWSj9pLuqtn3/Ky1/QE+dLkpN1MWu/WwBR+67L\ntoj3ao8LxpKday25sdC7j1h5phgym4AQfirBjuGXhhVVUoNy2vRXDyJK/uVvVcmm\n3cu2UYjaFe2DnXUb2zOkvezwpcYNVTlsplDAbPR7OL+d2hqKeWdCUupu5nytsYi9\nxKlVoWHlLSDDC264/6FtKi2NULSdU+g0cAfNSjsFmBPFMQ5E4jCbGic/KKHvzLcI\n9Z0jhu0YvKQ5kMgR+cj3dGXoyUaVNXbENYyit8NMQTUkgnBrUxIAKRAJuODbk9l2\ngrasJ6oOrv5eo5OJvsVKVfd3EnBlZv/ZcVYIQq80u2loOoIqNg4B6ZsA2ooFvj8X\nZgyJN//Qpm9fehOlBqLYjpaDCVnFX+zzOCnCuBEOIq539aJrFkXWrFUSZX3r8CZO\norBqpceF9rpjJcayDua/oHPpDFVLSHSMJ0006c54zc5aN5frPQymPLaj45YqJXIS\n0U5K857WVAs49nlBnt+jZgorQ/hXqZlPFCAF/Ym7l6bi5hEtnMHnL5yDi9diL5nu\nZ0qCjllNfJiZVS3m+5UQZ2ghSd45x/GVPiqfhh8LtQMU5gvvhfV/wuiOXj4Xahrf\n6lrl637UM1pIjQuv6zJP6msCAwEAAQ==\n-----END PUBLIC KEY-----\n",
"permissions": [
{
"resource_id": 80,
"create": true,
"read": true,
"update": true,
"delete": true
}
]
}
Recursos ¶
Recursos relacionados aos recursos na API.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Coleção de recursos ¶
Lista todas os recursosGET/resource
Example URI
200
Headers
Content-Type: application/json
Body
[
{
"id": 80,
"name": "users"
},
{
"id": 81,
"name": "clients"
},
{
"id": 82,
"name": "points"
},
{
"id": 83,
"name": "routes"
},
{
"id": 84,
"name": "permissions"
},
{
"id": 85,
"name": "roles"
},
{
"id": 86,
"name": "resources"
}
]
Grupos ¶
Recursos relacionados aos grupos na API.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Status ¶
Recursos relacionados ao status do julinho.
-
Headers
Authorization: Bearer YOUR_JWT_TOKEN_HERE
Coleção de Status ¶
Obtém as ultimas 100 atualizações de status do julinhoGET/status
Example URI
200
Headers
Content-Type: application/json
Body
[
{
"time": "2017-10-19T18:03:39.000Z",
"topic": "help",
"status": false
},
{
"time": "2017-10-19T18:03:43.000Z",
"topic": "help",
"status": true
},
{
"time": "2017-10-19T18:03:44.000Z",
"topic": "help",
"status": false
}
]
Atualiza o statusPOST/status
Example URI
Headers
Content-Type: application/json
Body
{
"topic": "help",
"status": false
}
200
Headers
Content-Type: application/json
Body
{
"message": "Status updated with success"
}