Commit 65b06407f3f0f85f9f60aa1f45c7e53f79a74b84
Committed by
Rodrigo Souto
1 parent
300e6a3b
Exists in
master
and in
29 other branches
adding category endpoint
Showing
2 changed files
with
25 additions
and
0 deletions
Show diff stats
lib/api/api.rb
@@ -0,0 +1,24 @@ | @@ -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 |