Commit 65b06407f3f0f85f9f60aa1f45c7e53f79a74b84

Authored by Leandro Santos
Committed by Rodrigo Souto
1 parent 300e6a3b

adding category endpoint

Showing 2 changed files with 25 additions and 0 deletions   Show diff stats
lib/api/api.rb
... ... @@ -16,6 +16,7 @@ module API
16 16 mount V1::Communities
17 17 mount V1::People
18 18 mount V1::Enterprises
  19 + mount V1::Categories
19 20 mount Session
20 21  
21 22 end
... ...
lib/api/v1/categories.rb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +module API
  2 + module V1
  3 + class Categories < Grape::API
  4 + before { detect_stuff_by_domain }
  5 + before { authenticate! }
  6 +
  7 + resource :categories do
  8 +
  9 + get do
  10 + type = params[:category_type]
  11 + categories = type.nil? ? environment.categories : environment.categories.find(:all, :conditions => {:type => type})
  12 + present categories, :with => Entities::Category
  13 + end
  14 +
  15 + desc "Return the category by id"
  16 + get ':id' do
  17 + present environment.categories.find(params[:id]), :with => Entities::Category
  18 + end
  19 +
  20 + end
  21 +
  22 + end
  23 + end
  24 +end
... ...