Commit 8898935c1b2438a939525942de0c31338f36a13e
1 parent
9cc1bb44
Exists in
staging
and in
29 other branches
Ticket #45: Adding APi endpoint to get environment tags
Showing
1 changed file
with
8 additions
and
4 deletions
Show diff stats
app/api/v1/tags.rb
| 1 | module Api | 1 | module Api |
| 2 | module V1 | 2 | module V1 |
| 3 | class Tags < Grape::API | 3 | class Tags < Grape::API |
| 4 | - before { authenticate! } | ||
| 5 | - | ||
| 6 | resource :articles do | 4 | resource :articles do |
| 7 | - | ||
| 8 | resource ':id/tags' do | 5 | resource ':id/tags' do |
| 9 | - | ||
| 10 | get do | 6 | get do |
| 11 | article = find_article(environment.articles, params[:id]) | 7 | article = find_article(environment.articles, params[:id]) |
| 12 | present article.tag_list | 8 | present article.tag_list |
| @@ -14,6 +10,7 @@ module Api | @@ -14,6 +10,7 @@ module Api | ||
| 14 | 10 | ||
| 15 | desc "Add a tag to an article" | 11 | desc "Add a tag to an article" |
| 16 | post do | 12 | post do |
| 13 | + authenticate! | ||
| 17 | article = find_article(environment.articles, params[:id]) | 14 | article = find_article(environment.articles, params[:id]) |
| 18 | article.tag_list=params[:tags] | 15 | article.tag_list=params[:tags] |
| 19 | article.save | 16 | article.save |
| @@ -21,6 +18,13 @@ module Api | @@ -21,6 +18,13 @@ module Api | ||
| 21 | end | 18 | end |
| 22 | end | 19 | end |
| 23 | end | 20 | end |
| 21 | + | ||
| 22 | + resource :environment do | ||
| 23 | + desc 'Return the tag counts for this environment' | ||
| 24 | + get '/tags' do | ||
| 25 | + present environment.tag_counts | ||
| 26 | + end | ||
| 27 | + end | ||
| 24 | end | 28 | end |
| 25 | end | 29 | end |
| 26 | end | 30 | end |