2018-09-29 22:34:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-29 05:49:17 +00:00
|
|
|
module API
|
2020-04-28 03:09:53 +00:00
|
|
|
class Events < Grape::API
|
2017-05-29 05:49:17 +00:00
|
|
|
include PaginationParams
|
2018-07-15 13:00:48 +00:00
|
|
|
include APIGuard
|
2019-04-17 11:13:48 +00:00
|
|
|
helpers ::API::Helpers::EventsHelpers
|
2017-05-29 05:49:17 +00:00
|
|
|
|
2019-04-17 11:13:48 +00:00
|
|
|
allow_access_with_scope :read_user, if: -> (request) { request.get? }
|
2017-05-29 05:49:17 +00:00
|
|
|
|
|
|
|
resource :events do
|
|
|
|
desc "List currently authenticated user's events" do
|
|
|
|
detail 'This feature was introduced in GitLab 9.3.'
|
|
|
|
success Entities::Event
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
use :event_filter_params
|
|
|
|
use :sort_params
|
|
|
|
end
|
2018-12-07 17:09:00 +00:00
|
|
|
|
2017-05-29 05:49:17 +00:00
|
|
|
get do
|
|
|
|
authenticate!
|
|
|
|
|
2018-12-07 17:09:00 +00:00
|
|
|
events = find_events(current_user)
|
2017-05-29 05:49:17 +00:00
|
|
|
|
2018-12-07 17:09:00 +00:00
|
|
|
present_events(events)
|
2017-05-29 05:49:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
2017-06-02 03:41:47 +00:00
|
|
|
requires :id, type: String, desc: 'The ID or Username of the user'
|
2017-05-29 05:49:17 +00:00
|
|
|
end
|
|
|
|
resource :users do
|
|
|
|
desc 'Get the contribution events of a specified user' do
|
|
|
|
detail 'This feature was introduced in GitLab 8.13.'
|
|
|
|
success Entities::Event
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
use :event_filter_params
|
|
|
|
use :sort_params
|
|
|
|
end
|
2018-12-07 17:09:00 +00:00
|
|
|
|
2017-05-29 05:49:17 +00:00
|
|
|
get ':id/events' do
|
2017-06-02 03:41:47 +00:00
|
|
|
user = find_user(params[:id])
|
2017-05-29 05:49:17 +00:00
|
|
|
not_found!('User') unless user
|
|
|
|
|
2018-12-07 17:09:00 +00:00
|
|
|
events = find_events(user)
|
2017-05-29 05:49:17 +00:00
|
|
|
|
|
|
|
present_events(events)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|