debian-mirror-gitlab/lib/api/v3/todos.rb

31 lines
821 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
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-09-10 17:25:29 +05:30
TodoService.new.mark_todos_as_done_by_ids(params[:id], current_user)
2018-03-17 18:26:18 +05:30
todo = current_user.todos.find(params[:id])
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
present todo, with: ::API::Entities::Todo, current_user: current_user
2017-08-17 22:00:37 +05:30
end
desc 'Mark all todos as done'
delete do
status(200)
todos = TodosFinder.new(current_user, params).execute
TodoService.new.mark_todos_as_done(todos, current_user).size
end
end
end
end
end