-
Notifications
You must be signed in to change notification settings - Fork 0
API: Task
Route: GET /api/v1/task_lists/:task_list_id/tasks/:id
This will return informations about the task :id contained in the task_list :task_list_id.
Example:
curl -X GET \
-H "Accept: application/json" \
-d 'auth_token=sYpP3xEY6SvxxEeBZ8Ee' \
http://localhost:3000/api/v1/task_lists/3/tasks/1
Will have the following output:
{
"id": 1,
"task_list_id": 3,
"title": "Chercher du lait",
"finished": false,
"assigned_user": {
"id": 1,
"display_name": "dimitri.jorge"
}
}
Notes:
- The assigned user can contain an id null if there are not user assigned
- There can only be one uniq task with a given title in a task list
- The finished field can be either true or false
Route: GET /api/v1/task_lists/:task_list_id/tasks
This will return an array containing all the tasks contained in the task_list :task_list_id.
Example:
curl -X GET \
-H "Accept: application/json" \
-d 'auth_token=sYcyvuHUopjT46iMhkU5' \
http://localhost:3001/api/v1/task_lists/3/tasks
The output will be an array of tasks (see the show section).
Route: POST /api/v1/task_lists/:task_list_id/tasks
You MUST send a title param with your query (at least 4 characters). You can assign a user to the task directly at the creation.
Example:
curl -X POST \
-H "Accept: application/json" \
-d 'auth_token=sYcyvuHUopjT46iMhkU5' \
-d 'task[title]=Chercher du lait&task[user_id]=4' \
http://localhost:3001/api/v1/task_lists/3
See the show section for the output.
Route: PUT /api/v1/task_lists/:task_list_id/tasks/:id
You can update the title or the assigned user of the task identified by :id using this call.
Example:
curl -X PUT \
-H "Accept: application/json" \
-d 'auth_token=sYcyvuHUopjT46iMhkU5' \
-d 'task[title]=A title&task[user_id]=42' \
http://localhost:3001/api/v1/task_lists/3/tasks/1
See the show section for the output.
Route: GET /api/v1/task_lists/:task_list_id/tasks/:id
This call WILL set the finished boolean to true.
Example: http://localhost:3001/api/v1/task_lists/3/tasks/1/finish
.
You can cancel this by passing a parameter cancel equal to true.
Example: http://localhost:3001/api/v1/task_lists/3/tasks/1/finish?cancel=true
.
Route: DELETE /api/v1/task_lists/:task_list_id/tasks/:id
Note: Anyone in the family can delete a task.
This WILL delete the task identified by :id.
Example:
curl -X DELETE \
-H "Accept: application/json" \
-d 'auth_token=sYcyvuHUopjT46iMhkU5' \
http://localhost:3001/api/v1/task_lists/3/tasks/1
The response will be empty with a 204 status code in case of success.