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
f0b42c10
Commit
f0b42c10
authored
Nov 09, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grapify subscription API
parent
c392b0cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
23 deletions
+14
-23
lib/api/subscriptions.rb
lib/api/subscriptions.rb
+14
-23
No files found.
lib/api/subscriptions.rb
View file @
f0b42c10
...
...
@@ -9,23 +9,20 @@ module API
'labels'
=>
proc
{
|
id
|
find_project_label
(
id
)
},
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
requires
:subscribable_id
,
type:
String
,
desc:
'The ID of a resource'
end
resource
:projects
do
subscribable_types
.
each
do
|
type
,
finder
|
type_singularized
=
type
.
singularize
type_id_str
=
:"
#{
type_singularized
}
_id"
entity_class
=
Entities
.
const_get
(
type_singularized
.
camelcase
)
# Subscribe to a resource
#
# Parameters:
# id (required) - The ID of a project
# subscribable_id (required) - The ID of a resource
# Example Request:
# POST /projects/:id/labels/:subscribable_id/subscription
# POST /projects/:id/issues/:subscribable_id/subscription
# POST /projects/:id/merge_requests/:subscribable_id/subscription
post
":id/
#{
type
}
/:
#{
type_id_str
}
/subscription"
do
resource
=
instance_exec
(
params
[
type_id_str
],
&
finder
)
desc
'Subscribe to a resource'
do
success
entity_class
end
post
":id/
#{
type
}
/:subscribable_id/subscription"
do
resource
=
instance_exec
(
params
[
:subscribable_id
],
&
finder
)
if
resource
.
subscribed?
(
current_user
)
not_modified!
...
...
@@ -35,17 +32,11 @@ module API
end
end
# Unsubscribe from a resource
#
# Parameters:
# id (required) - The ID of a project
# subscribable_id (required) - The ID of a resource
# Example Request:
# DELETE /projects/:id/labels/:subscribable_id/subscription
# DELETE /projects/:id/issues/:subscribable_id/subscription
# DELETE /projects/:id/merge_requests/:subscribable_id/subscription
delete
":id/
#{
type
}
/:
#{
type_id_str
}
/subscription"
do
resource
=
instance_exec
(
params
[
type_id_str
],
&
finder
)
desc
'Unsubscribe from a resource'
do
success
entity_class
end
delete
":id/
#{
type
}
/:subscribable_id/subscription"
do
resource
=
instance_exec
(
params
[
:subscribable_id
],
&
finder
)
if
!
resource
.
subscribed?
(
current_user
)
not_modified!
...
...
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