From 8df699a336af347628f83274b1eb11255f353e9e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 6 Jun 2013 19:19:17 +0300 Subject: API: project events --- lib/api/entities.rb | 6 ++++++ lib/api/projects.rb | 14 ++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8e815f2b25c..0d8cac5c8fd 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -120,5 +120,11 @@ module API expose :note expose :author, using: Entities::UserBasic end + + class Event < Grape::Entity + expose :title, :project_id, :action_name + expose :target_id, :target_type, :author_id + expose :data, :target_title + end end end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 7fcde3794f4..6dc051e4ba2 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -41,6 +41,20 @@ module API present user_project, with: Entities::Project end + # Get a single project events + # + # Parameters: + # id (required) - The ID of a project + # Example Request: + # GET /projects/:id + get ":id/events" do + limit = (params[:per_page] || 20).to_i + offset = (params[:page] || 0).to_i * limit + events = user_project.events.recent.limit(limit).offset(offset) + + present events, with: Entities::Event + end + # Create new project # # Parameters: -- cgit v1.2.1