Back to top

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 token
POST/auth

Example URI

POST /auth
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "email": "admin@example.com",
  "password": "adminpassword123"
}
Response  200
HideShow
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"
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid schema"
}

Andar

Faz o julinho andar.

  • Headers

    Authorization: Bearer YOUR_JWT_TOKEN_HERE

Andar

Manda o julinho andar
POST/walk

Example URI

POST /walk
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "route": "NOME_DA_ROTA",
  "robot": "NOME_DO_ROBO"
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Route sent with success!"
}

Rotas

Recursos relacionados às rotas na API.

  • Headers

    Authorization: Bearer YOUR_JWT_TOKEN_HERE

Coleção de Rotas

Lista todas as rotas
GET/routes

Example URI

GET /routes
Response  200
HideShow
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"
      }
    ]
  }
]
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Wrong authorization type"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Expired token"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Unauthorized user"
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid schema"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Not found"
}
Response  500
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Internal Server Error"
}

Cria uma rota
POST/routes

Example URI

POST /routes
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "name": "rota massa",
  "points": [
    {
      "point": 22,
      "action": "d"
    },
    {
      "point": 21,
      "action": "e"
    }
  ]
}
Response  201
HideShow
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"
    }
  ]
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Wrong authorization type"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Expired token"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Unauthorized user"
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid schema"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Not found"
}
Response  500
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Internal Server Error"
}

Rotas

Consulta as informações de uma rota
GET/routes/{rota_id}

Example URI

GET /routes/1
URI Parameters
HideShow
rota_id
string (required) Example: 1

A id de uma rota.

Response  200
HideShow
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"
    }
  ]
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid route id"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Wrong authorization type"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Expired token"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Unauthorized user"
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid schema"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Not found"
}
Response  500
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Internal Server Error"
}

Altera as informações de uma rota
PUT/routes/{rota_id}

Example URI

PUT /routes/1
URI Parameters
HideShow
rota_id
string (required) Example: 1

A id de uma rota.

Request
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 1,
  "name": "pow",
  "points": [
    {
      "point": 22,
      "action": "d"
    },
    {
      "point": 21,
      "action": "f"
    }
  ]
}
Response  200
HideShow
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"
    }
  ]
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid route id"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Wrong authorization type"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Expired token"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Unauthorized user"
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid schema"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Not found"
}
Response  500
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Internal Server Error"
}

Deleta uma rota
DELETE/routes/{rota_id}

Example URI

DELETE /routes/1
URI Parameters
HideShow
rota_id
string (required) Example: 1

A id de uma rota.

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Route 1 deleted with success"
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid route id"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Wrong authorization type"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Expired token"
}
Response  401
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Unauthorized user"
}
Response  400
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Invalid schema"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Not found"
}
Response  500
HideShow
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 client
GET/permissions

Example URI

GET /permissions
Response  200
HideShow
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ários
GET/users

Example URI

GET /users
Response  200
HideShow
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ário
POST/users

Example URI

POST /users
Request
HideShow
Headers
Content-Type: application/json
Body
{
    "role_id": 1,
    "password": "algumasenhadificil,
    "email": "usuario@gmail.com",
    "name" : "nome do usuário"
}
Response  201
HideShow
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ário
GET/users/{user_id}

Example URI

GET /users/1
URI Parameters
HideShow
user_id
string (required) Example: 1

A id de um usuário.

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 1,
  "name": "Admin",
  "role_id": 29,
  "email": "admin@example.com"
}

Remove um usuário
DELETE/users/{user_id}

Example URI

DELETE /users/1
URI Parameters
HideShow
user_id
string (required) Example: 1

A id de um usuário.

Response  204

Altera um usuário
PUT/users/{user_id}

Example URI

PUT /users/1
URI Parameters
HideShow
user_id
string (required) Example: 1

A id de um usuário.

Request
HideShow
Headers
Content-Type: application/json
Body
{
    "role_id": 1,
    "password": "algumasenhadificil,
    "email": "usuario@gmail.com",
    "name" : "novo nome legal"
}
Response  200
HideShow
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 pontos
GET/points

Example URI

GET /points
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "id": 31,
    "rfid": "123456",
    "name": "library"
  },
  {
    "id": 32,
    "rfid": "123456789",
    "name": "classroom"
  }
]

Criar um ponto
POST/points

Example URI

POST /points
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "rfid": "123456",
  "name": "library"
}
Response  201
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 31,
  "rfid": "123456",
  "name": "library"
}

Pontos

Busca as informações de um ponto
GET/points/{point_id}

Example URI

GET /points/1
URI Parameters
HideShow
point_id
string (required) Example: 1

A id de um ponto.

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 1,
  "rfid": "123456",
  "name": "library"
}

Remove um ponto
DELETE/points/{point_id}

Example URI

DELETE /points/1
URI Parameters
HideShow
point_id
string (required) Example: 1

A id de um ponto.

Response  204

Altera um ponto
PUT/points/{point_id}

Example URI

PUT /points/1
URI Parameters
HideShow
point_id
string (required) Example: 1

A id de um ponto.

Request
HideShow
Headers
Content-Type: application/json
Body
{
  "role_id": 1,
  "rfid": "123456",
  "name": "library 2"
}
Response  200
HideShow
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 cliente
POST/clients

Example URI

POST /clients
Request
HideShow
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"
}
Response  201
HideShow
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 recursos
GET/resource

Example URI

GET /resource
Response  200
HideShow
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

Coleção de grupos

Lista todas os grupos
GET/roles

Example URI

GET /roles
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "id": 35,
    "name": "admin"
  },
  {
    "id": 36,
    "name": "user"
  }
]

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 julinho
GET/status

Example URI

GET /status
Response  200
HideShow
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 status
POST/status

Example URI

POST /status
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "topic": "help",
  "status": false
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Status updated with success"
}

Generated by aglio on 12 Dec 2017