API de consultas.
$ python manage.py test -v 2
$ python manage.py runserver 0.0.0.0:8000
Para acessar a adminstração é necessário a criação de um usuário.
$ python manage.py createsuperuser
A api disponibiliza dois endpoints:
$ curl -X GET http://localhost:8000/api/v1/appointments/
$ curl -d '{"patient":"01fcc220-49ee-4b9c-8a9a-0d5ea9a4293f", "physician":"d4feda94-cf49-4580-abe9-21fb02a9d5db", "price": "200.00"}' -H "Content-Type: application/json" -X POST http://localhost:8000/api/v1/appointments/
Resultado
{
"id": "ab2ec149-ba5d-4ccd-9945-16d3255dd3ae",
"start_date": "2021-06-14T15:03:16.822947-03:00",
"end_date": null,
"price": "200.00",
"patient": "01fcc220-49ee-4b9c-8a9a-0d5ea9a4293f",
"physician": "d4feda94-cf49-4580-abe9-21fb02a9d5db"
}
$ curl -d '{"id":"ab2ec149-ba5d-4ccd-9945-16d3255dd3ae","start_date":"2021-06-14T15:03:16.822947-03:00","end_date":null,"price":"150.00","patient":"01fcc220-49ee-4b9c-8a9a-0d5ea9a4293f","physician":"d4feda94-cf49-4580-abe9-21fb02a9d5db"}' -H "Content-Type: application/json" -X PUT http://localhost:8000/api/v1/appointments/ab2ec149-ba5d-4ccd-9945-16d3255dd3ae/
Resultado
{
"id": "ab2ec149-ba5d-4ccd-9945-16d3255dd3ae",
"start_date": "2021-06-14T15:03:16.822947-03:00",
"end_date": null,
"price": "150.00",
"patient": "01fcc220-49ee-4b9c-8a9a-0d5ea9a4293f",
"physician": "d4feda94-cf49-4580-abe9-21fb02a9d5db"
}
$ curl -d '{"price":"300.00"}' -H "Content-Type: application/json" -X PATCH http://localhost:8000/api/v1/appointments/ab2ec149-ba5d-4ccd-9945-16d3255dd3ae/
Resultado
{
"id": "ab2ec149-ba5d-4ccd-9945-16d3255dd3ae",
"start_date": "2021-06-14T15:03:16.822947-03:00",
"end_date": null,
"price": "300.00",
"patient": "01fcc220-49ee-4b9c-8a9a-0d5ea9a4293f",
"physician": "d4feda94-cf49-4580-abe9-21fb02a9d5db"
}
$ curl -X DELETE http://localhost:8000/api/v1/appointments/ab2ec149-ba5d-4ccd-9945-16d3255dd3ae/
$ curl -X PUT http://localhost:8000/api/v1/appointments/ab2ec149-ba5d-4ccd-9945-16d3255dd3ae/finish/
{
"id": "ab2ec149-ba5d-4ccd-9945-16d3255dd3ae",
"start_date": "2021-06-14T15:03:16.822947-03:00",
"end_date": "2021-06-14T15:43:03.997454-03:00",
"price": "200.00",
"patient": "01fcc220-49ee-4b9c-8a9a-0d5ea9a4293f",
"physician": "d4feda94-cf49-4580-abe9-21fb02a9d5db"
}