Commit 8898935c1b2438a939525942de0c31338f36a13e

Authored by Caio Almeida
1 parent 9cc1bb44

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 1 module Api
2 2 module V1
3 3 class Tags < Grape::API
4   - before { authenticate! }
5   -
6 4 resource :articles do
7   -
8 5 resource ':id/tags' do
9   -
10 6 get do
11 7 article = find_article(environment.articles, params[:id])
12 8 present article.tag_list
... ... @@ -14,6 +10,7 @@ module Api
14 10  
15 11 desc "Add a tag to an article"
16 12 post do
  13 + authenticate!
17 14 article = find_article(environment.articles, params[:id])
18 15 article.tag_list=params[:tags]
19 16 article.save
... ... @@ -21,6 +18,13 @@ module Api
21 18 end
22 19 end
23 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 28 end
25 29 end
26 30 end
... ...