Commit 882029d9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Expose ProjectHook attributes via API

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent fff69bdb
...@@ -24,6 +24,10 @@ module API ...@@ -24,6 +24,10 @@ module API
expose :id, :url, :created_at expose :id, :url, :created_at
end end
class ProjectHook < Hook
expose :project_id, :push_events, :issues_events, :merge_requests_events
end
class ForkedFromProject < Grape::Entity class ForkedFromProject < Grape::Entity
expose :id expose :id
expose :name, :name_with_namespace expose :name, :name_with_namespace
......
...@@ -22,7 +22,7 @@ module API ...@@ -22,7 +22,7 @@ module API
# GET /projects/:id/hooks # GET /projects/:id/hooks
get ":id/hooks" do get ":id/hooks" do
@hooks = paginate user_project.hooks @hooks = paginate user_project.hooks
present @hooks, with: Entities::Hook present @hooks, with: Entities::ProjectHook
end end
# Get a project hook # Get a project hook
...@@ -34,7 +34,7 @@ module API ...@@ -34,7 +34,7 @@ module API
# GET /projects/:id/hooks/:hook_id # GET /projects/:id/hooks/:hook_id
get ":id/hooks/:hook_id" do get ":id/hooks/:hook_id" do
@hook = user_project.hooks.find(params[:hook_id]) @hook = user_project.hooks.find(params[:hook_id])
present @hook, with: Entities::Hook present @hook, with: Entities::ProjectHook
end end
...@@ -50,7 +50,7 @@ module API ...@@ -50,7 +50,7 @@ module API
@hook = user_project.hooks.new({"url" => params[:url]}) @hook = user_project.hooks.new({"url" => params[:url]})
if @hook.save if @hook.save
present @hook, with: Entities::Hook present @hook, with: Entities::ProjectHook
else else
if @hook.errors[:url].present? if @hook.errors[:url].present?
error!("Invalid url given", 422) error!("Invalid url given", 422)
...@@ -73,7 +73,7 @@ module API ...@@ -73,7 +73,7 @@ module API
attrs = attributes_for_keys [:url] attrs = attributes_for_keys [:url]
if @hook.update_attributes attrs if @hook.update_attributes attrs
present @hook, with: Entities::Hook present @hook, with: Entities::ProjectHook
else else
if @hook.errors[:url].present? if @hook.errors[:url].present?
error!("Invalid url given", 422) error!("Invalid url given", 422)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment