38 lines
1.2 KiB
Ruby
38 lines
1.2 KiB
Ruby
module Gitlab
|
|
# Notes API
|
|
class Notes < Grape::API
|
|
before { authenticate! }
|
|
|
|
NOTEABLE_TYPES = [Issue, Snippet]
|
|
|
|
resource :projects do
|
|
# Get a list of project wall notes
|
|
#
|
|
# Parameters:
|
|
# id (required) - The ID or code name of a project
|
|
# Example Request:
|
|
# GET /projects/:id/notes
|
|
get ":id/notes" do
|
|
@notes = user_project.common_notes
|
|
present paginate(@notes), with: Entities::Note
|
|
end
|
|
|
|
NOTEABLE_TYPES.each do |noteable_type|
|
|
noteables_str = noteable_type.to_s.underscore.pluralize
|
|
noteable_id_str = "#{noteable_type.to_s.underscore}_id"
|
|
|
|
# Get a list of project +noteable+ notes
|
|
#
|
|
# Parameters:
|
|
# id (required) - The ID or code name of a project
|
|
# noteable_id (required) - The ID of an issue or snippet
|
|
# Example Request:
|
|
# GET /projects/:id/noteable/:noteable_id/notes
|
|
get ":id/#{noteables_str}/:#{noteable_id_str}/notes" do
|
|
@noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"])
|
|
present paginate(@noteable.notes), with: Entities::Note
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|