Commit d782d26ba04a20fac32968cce9472e906dfedfdd
1 parent
c279721d
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
API: adding tags endpoint
Showing
3 changed files
with
36 additions
and
0 deletions
Show diff stats
lib/noosfero/api/api.rb
lib/noosfero/api/entities.rb
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | +module Noosfero | |
| 2 | + module API | |
| 3 | + module V1 | |
| 4 | + class Tags < Grape::API | |
| 5 | + before { authenticate! } | |
| 6 | + | |
| 7 | + resource :articles do | |
| 8 | + | |
| 9 | + resource ':id/tags' do | |
| 10 | + | |
| 11 | + get do | |
| 12 | + article = find_article(environment.articles, params[:id]) | |
| 13 | + present article.tag_list, :with => Entities::Tag | |
| 14 | + end | |
| 15 | + | |
| 16 | + desc "Add a tag to an article" | |
| 17 | + post do | |
| 18 | + article = find_article(environment.articles, params[:id]) | |
| 19 | + article.tag_list=params[:tags] | |
| 20 | + article.save | |
| 21 | + present article.tag_list, :with => Entities::Tag | |
| 22 | + end | |
| 23 | + | |
| 24 | + end | |
| 25 | + end | |
| 26 | + | |
| 27 | + end | |
| 28 | + end | |
| 29 | + end | |
| 30 | +end | ... | ... |