From 189246a317b32df162261d93b5109e98c44aa6fe Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Thu, 24 Sep 2015 21:31:53 -0300 Subject: [PATCH] Adding badges endpoint and autentication for my bedges and levels --- lib/gamification_plugin/api.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/gamification_plugin/api.rb b/lib/gamification_plugin/api.rb index 1a36c62..7e33b87 100644 --- a/lib/gamification_plugin/api.rb +++ b/lib/gamification_plugin/api.rb @@ -2,15 +2,21 @@ class GamificationPlugin::API < Grape::API resource :gamification_plugin do - resource :my do - get 'badges' do - present current_person.badges - end - get 'level' do - {:level => current_person.level, :percent => current_person.gamification_plugin_level_percent} - end + get 'badges' do + environment.gamification_plugin_badges.group(:name).count + end + + resource :my do + get 'badges' do + authenticate! + present current_person.badges + end + get 'level' do + authenticate! + {:level => current_person.level, :percent => current_person.gamification_plugin_level_percent} end + end resource :people do get ':id/badges' do -- libgit2 0.21.2