Commit 12f96cd593ce242bc787eadd60c9c35d66ffeb9e
1 parent
550076d8
Exists in
staging
and in
1 other branch
api: create boxes enpoint
Showing
3 changed files
with
29 additions
and
1 deletions
Show diff stats
lib/noosfero/api/api.rb
lib/noosfero/api/entities.rb
@@ -111,7 +111,6 @@ module Noosfero | @@ -111,7 +111,6 @@ module Noosfero | ||
111 | end | 111 | end |
112 | expose :image, :using => Image | 112 | expose :image, :using => Image |
113 | expose :region, :using => Region | 113 | expose :region, :using => Region |
114 | - expose :boxes, :using => Box | ||
115 | end | 114 | end |
116 | 115 | ||
117 | class UserBasic < Entity | 116 | class UserBasic < Entity |
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | +module Noosfero | ||
2 | + module API | ||
3 | + module V1 | ||
4 | + | ||
5 | + class Boxes < Grape::API | ||
6 | + | ||
7 | + kinds = %w[profile community person enterprise] | ||
8 | + kinds.each do |kind| | ||
9 | + | ||
10 | + resource kind.pluralize.to_sym do | ||
11 | + | ||
12 | + segment "/:#{kind}_id" do | ||
13 | + resource :boxes do | ||
14 | + get do | ||
15 | + profile = environment.send(kind.pluralize).find(params["#{kind}_id"]) | ||
16 | + present profile.boxes, :with => Entities::Box | ||
17 | + end | ||
18 | + end | ||
19 | + end | ||
20 | + | ||
21 | + end | ||
22 | + | ||
23 | + end | ||
24 | + end | ||
25 | + | ||
26 | + end | ||
27 | + end | ||
28 | +end |