2017-02-21 04:23:15 -05:00
|
|
|
module API
|
|
|
|
module V3
|
|
|
|
class Todos < Grape::API
|
|
|
|
before { authenticate! }
|
|
|
|
|
|
|
|
resource :todos do
|
|
|
|
desc 'Mark a todo as done' do
|
|
|
|
success ::API::Entities::Todo
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :id, type: Integer, desc: 'The ID of the todo being marked as done'
|
|
|
|
end
|
|
|
|
delete ':id' do
|
2017-04-21 05:36:34 -04:00
|
|
|
TodoService.new.mark_todos_as_done_by_ids(params[:id], current_user)
|
|
|
|
todo = Todo.find(params[:id])
|
2017-02-21 04:23:15 -05:00
|
|
|
|
2017-04-21 05:36:34 -04:00
|
|
|
present todo, with: ::API::Entities::Todo, current_user: current_user
|
2017-02-21 04:23:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Mark all todos as done'
|
|
|
|
delete do
|
2017-02-20 14:32:44 -05:00
|
|
|
status(200)
|
2017-01-29 04:44:30 -05:00
|
|
|
|
2017-02-21 04:23:15 -05:00
|
|
|
todos = TodosFinder.new(current_user, params).execute
|
2017-01-29 04:44:30 -05:00
|
|
|
TodoService.new.mark_todos_as_done(todos, current_user).size
|
2017-02-21 04:23:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|