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
| ... | ... | @@ -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 | ... | ... |