Take in user_id as a required query param (This will be swapped out for API authentication later). Check if the visit_id to which this order is being posted to does infact belong to the given user_id. If it does not, return a 403 Unauthorized error. If it does, process the request normally. You may use user_id 1 for which a user already exists in the DB for testing the endpoint.
Please remember to create a unit test for the above endpoint in main_test.go update the openapi.yaml to document the above changes!
Create a POST /orders endpoint to create a new order. This is useful to add orders to a preexisting visit.
The request body will look as follows:
Take in
user_id
as a required query param (This will be swapped out for API authentication later). Check if thevisit_id
to which this order is being posted to does infact belong to the givenuser_id
. If it does not, return a403 Unauthorized
error. If it does, process the request normally. You may use user_id 1 for which a user already exists in the DB for testing the endpoint.Please remember to create a unit test for the above endpoint in
main_test.go
update theopenapi.yaml
to document the above changes!