summaryrefslogtreecommitdiff
path: root/lib/api/project_events.rb
blob: 726e693826e3c6f0e9810e25b7b26179d6a0084a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module API
  class ProjectEvents < Grape::API::Instance
    include PaginationParams
    include APIGuard
    helpers ::API::Helpers::EventsHelpers

    params do
      requires :id, type: String, desc: 'The ID of a project'
    end
    resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
      desc "List a Project's visible events" do
        success Entities::Event
      end
      params do
        use :pagination
        use :event_filter_params
        use :sort_params
      end

      get ":id/events" do
        events = find_events(user_project)

        present_events(events)
      end
    end
  end
end