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
Boxiang Sun
gitlab-ce
Commits
d291ea97
Commit
d291ea97
authored
Aug 12, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GrapeDSL for Award Emoji endpoints
parent
f2c0f823
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
33 deletions
+31
-33
lib/api/award_emoji.rb
lib/api/award_emoji.rb
+31
-33
No files found.
lib/api/award_emoji.rb
View file @
d291ea97
...
@@ -8,16 +8,19 @@ module API
...
@@ -8,16 +8,19 @@ module API
awardable_string
=
awardable_type
.
pluralize
awardable_string
=
awardable_type
.
pluralize
awardable_id_string
=
"
#{
awardable_type
}
_id"
awardable_id_string
=
"
#{
awardable_type
}
_id"
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
requires
:"
#{
awardable_id_string
}
"
,
type:
Integer
,
desc:
"The ID of an Issue, Merge Request or Snippet"
end
[
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/award_emoji"
,
[
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/award_emoji"
,
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/notes/:note_id/award_emoji"
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/notes/:note_id/award_emoji"
].
each
do
|
endpoint
|
].
each
do
|
endpoint
|
# Get a list of project +awardable+ award emoji
#
desc
'Get a list of project +awardable+ award emoji'
do
# Parameters:
detail
'This feature was introduced in 8.9'
# id (required) - The ID of a project
success
Entities
::
AwardEmoji
# awardable_id (required) - The ID of an issue or MR
end
# Example Request:
# GET /projects/:id/issues/:awardable_id/award_emoji
get
endpoint
do
get
endpoint
do
if
can_read_awardable?
if
can_read_awardable?
awards
=
paginate
(
awardable
.
award_emoji
)
awards
=
paginate
(
awardable
.
award_emoji
)
...
@@ -27,14 +30,13 @@ module API
...
@@ -27,14 +30,13 @@ module API
end
end
end
end
# Get a specific award emoji
desc
'Get a specific award emoji'
do
#
detail
'This feature was introduced in 8.9'
# Parameters:
success
Entities
::
AwardEmoji
# id (required) - The ID of a project
end
# awardable_id (required) - The ID of an issue or MR
params
do
# award_id (required) - The ID of the award
requires
:award_id
,
type:
Integer
,
desc:
'The ID of the award'
# Example Request:
end
# GET /projects/:id/issues/:awardable_id/award_emoji/:award_id
get
"
#{
endpoint
}
/:award_id"
do
get
"
#{
endpoint
}
/:award_id"
do
if
can_read_awardable?
if
can_read_awardable?
present
awardable
.
award_emoji
.
find
(
params
[
:award_id
]),
with:
Entities
::
AwardEmoji
present
awardable
.
award_emoji
.
find
(
params
[
:award_id
]),
with:
Entities
::
AwardEmoji
...
@@ -43,17 +45,14 @@ module API
...
@@ -43,17 +45,14 @@ module API
end
end
end
end
# Award a new Emoji
desc
'Award a new Emoji'
do
#
detail
'This feature was introduced in 8.9'
# Parameters:
success
Entities
::
AwardEmoji
# id (required) - The ID of a project
end
# awardable_id (required) - The ID of an issue or mr
params
do
# name (required) - The name of a award_emoji (without colons)
requires
:name
,
type:
String
,
desc:
'The name of a award_emoji (without colons)'
# Example Request:
end
# POST /projects/:id/issues/:awardable_id/award_emoji
post
endpoint
do
post
endpoint
do
required_attributes!
[
:name
]
not_found!
(
'Award Emoji'
)
unless
can_read_awardable?
&&
can_award_awardable?
not_found!
(
'Award Emoji'
)
unless
can_read_awardable?
&&
can_award_awardable?
award
=
awardable
.
create_award_emoji
(
params
[
:name
],
current_user
)
award
=
awardable
.
create_award_emoji
(
params
[
:name
],
current_user
)
...
@@ -65,14 +64,13 @@ module API
...
@@ -65,14 +64,13 @@ module API
end
end
end
end
# Delete a +awardables+ award emoji
desc
'Delete a +awardables+ award emoji'
do
#
detail
'This feature was introduced in 8.9'
# Parameters:
success
Entities
::
AwardEmoji
# id (required) - The ID of a project
end
# awardable_id (required) - The ID of an issue or MR
params
do
# award_emoji_id (required) - The ID of an award emoji
requires
:award_id
,
type:
Integer
,
desc:
'The ID of an award emoji'
# Example Request:
end
# DELETE /projects/:id/issues/:issue_id/notes/:note_id/award_emoji/:award_id
delete
"
#{
endpoint
}
/:award_id"
do
delete
"
#{
endpoint
}
/:award_id"
do
award
=
awardable
.
award_emoji
.
find
(
params
[
:award_id
])
award
=
awardable
.
award_emoji
.
find
(
params
[
:award_id
])
...
...
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