Commit b728c983b45ccad4801b6a49662ac8aabd90cddd
1 parent
86746db6
Exists in
staging
and in
4 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 @@ |
| 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 | ... | ... |