Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
b927473c
Commit
b927473c
authored
Oct 14, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grapify todos API
parent
4b889dbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
26 deletions
+19
-26
lib/api/todos.rb
lib/api/todos.rb
+19
-26
No files found.
lib/api/todos.rb
View file @
b927473c
...
@@ -8,18 +8,19 @@ module API
...
@@ -8,18 +8,19 @@ module API
'issues'
=>
->
(
id
)
{
find_project_issue
(
id
)
}
'issues'
=>
->
(
id
)
{
find_project_issue
(
id
)
}
}
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
do
resource
:projects
do
ISSUABLE_TYPES
.
each
do
|
type
,
finder
|
ISSUABLE_TYPES
.
each
do
|
type
,
finder
|
type_id_str
=
"
#{
type
.
singularize
}
_id"
.
to_sym
type_id_str
=
"
#{
type
.
singularize
}
_id"
.
to_sym
# Create a todo on an issuable
desc
'Create a todo on an issuable'
do
#
success
Entities
::
Todo
# Parameters:
end
# id (required) - The ID of a project
params
do
# issuable_id (required) - The ID of an issuable
requires
type_id_str
,
type:
Integer
,
desc:
'The ID of an issuable'
# Example Request:
end
# POST /projects/:id/issues/:issuable_id/todo
# POST /projects/:id/merge_requests/:issuable_id/todo
post
":id/
#{
type
}
/:
#{
type_id_str
}
/todo"
do
post
":id/
#{
type
}
/:
#{
type_id_str
}
/todo"
do
issuable
=
instance_exec
(
params
[
type_id_str
],
&
finder
)
issuable
=
instance_exec
(
params
[
type_id_str
],
&
finder
)
todo
=
TodoService
.
new
.
mark_todo
(
issuable
,
current_user
).
first
todo
=
TodoService
.
new
.
mark_todo
(
issuable
,
current_user
).
first
...
@@ -40,25 +41,21 @@ module API
...
@@ -40,25 +41,21 @@ module API
end
end
end
end
# Get a todo list
desc
'Get a todo list'
do
#
success
Entities
::
Todo
# Example Request:
end
# GET /todos
#
get
do
get
do
todos
=
find_todos
todos
=
find_todos
present
paginate
(
todos
),
with:
Entities
::
Todo
,
current_user:
current_user
present
paginate
(
todos
),
with:
Entities
::
Todo
,
current_user:
current_user
end
end
# Mark a todo as done
desc
'Mark a todo as done'
do
#
success
Entities
::
Todo
# Parameters:
end
# id: (required) - The ID of the todo being marked as done
params
do
#
requires
:id
,
type:
Integer
,
desc:
'The ID of the todo being marked as done'
# Example Request:
end
# DELETE /todos/:id
#
delete
':id'
do
delete
':id'
do
todo
=
current_user
.
todos
.
find
(
params
[
:id
])
todo
=
current_user
.
todos
.
find
(
params
[
:id
])
TodoService
.
new
.
mark_todos_as_done
([
todo
],
current_user
)
TodoService
.
new
.
mark_todos_as_done
([
todo
],
current_user
)
...
@@ -66,11 +63,7 @@ module API
...
@@ -66,11 +63,7 @@ module API
present
todo
.
reload
,
with:
Entities
::
Todo
,
current_user:
current_user
present
todo
.
reload
,
with:
Entities
::
Todo
,
current_user:
current_user
end
end
# Mark all todos as done
desc
'Mark all todos as done'
#
# Example Request:
# DELETE /todos
#
delete
do
delete
do
todos
=
find_todos
todos
=
find_todos
TodoService
.
new
.
mark_todos_as_done
(
todos
,
current_user
)
TodoService
.
new
.
mark_todos_as_done
(
todos
,
current_user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment