Commit 882029d9c62c54293147da0d5e2d3b6eaaa89535

Authored by Dmitriy Zaporozhets
1 parent fff69bdb

Expose ProjectHook attributes via API

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing 2 changed files with 8 additions and 4 deletions   Show diff stats
lib/api/entities.rb
... ... @@ -24,6 +24,10 @@ module API
24 24 expose :id, :url, :created_at
25 25 end
26 26  
  27 + class ProjectHook < Hook
  28 + expose :project_id, :push_events, :issues_events, :merge_requests_events
  29 + end
  30 +
27 31 class ForkedFromProject < Grape::Entity
28 32 expose :id
29 33 expose :name, :name_with_namespace
... ...
lib/api/project_hooks.rb
... ... @@ -22,7 +22,7 @@ module API
22 22 # GET /projects/:id/hooks
23 23 get ":id/hooks" do
24 24 @hooks = paginate user_project.hooks
25   - present @hooks, with: Entities::Hook
  25 + present @hooks, with: Entities::ProjectHook
26 26 end
27 27  
28 28 # Get a project hook
... ... @@ -34,7 +34,7 @@ module API
34 34 # GET /projects/:id/hooks/:hook_id
35 35 get ":id/hooks/:hook_id" do
36 36 @hook = user_project.hooks.find(params[:hook_id])
37   - present @hook, with: Entities::Hook
  37 + present @hook, with: Entities::ProjectHook
38 38 end
39 39  
40 40  
... ... @@ -50,7 +50,7 @@ module API
50 50  
51 51 @hook = user_project.hooks.new({"url" => params[:url]})
52 52 if @hook.save
53   - present @hook, with: Entities::Hook
  53 + present @hook, with: Entities::ProjectHook
54 54 else
55 55 if @hook.errors[:url].present?
56 56 error!("Invalid url given", 422)
... ... @@ -73,7 +73,7 @@ module API
73 73  
74 74 attrs = attributes_for_keys [:url]
75 75 if @hook.update_attributes attrs
76   - present @hook, with: Entities::Hook
  76 + present @hook, with: Entities::ProjectHook
77 77 else
78 78 if @hook.errors[:url].present?
79 79 error!("Invalid url given", 422)
... ...