Commit 12f96cd593ce242bc787eadd60c9c35d66ffeb9e

Authored by Victor Costa
1 parent 550076d8

api: create boxes enpoint

lib/noosfero/api/api.rb
... ... @@ -54,6 +54,7 @@ module Noosfero
54 54 mount V1::Environments
55 55 mount V1::Search
56 56 mount V1::Contacts
  57 + mount V1::Boxes
57 58  
58 59 mount Session
59 60  
... ...
lib/noosfero/api/entities.rb
... ... @@ -111,7 +111,6 @@ module Noosfero
111 111 end
112 112 expose :image, :using => Image
113 113 expose :region, :using => Region
114   - expose :boxes, :using => Box
115 114 end
116 115  
117 116 class UserBasic < Entity
... ...
lib/noosfero/api/v1/boxes.rb 0 → 100644
... ... @@ -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
... ...