api.rb
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 'points' do
{points: current_person.points}
end
end
resource :people do
get ':id/badges' do
person = environment.people.visible_for_person(current_person).find_by_id(params[:id])
return not_found! if person.blank?
present person.badges
end
get ':id/points' do
person = environment.people.visible_for_person(current_person).find_by_id(params[:id])
return not_found! if person.blank?
{:points => person.points}
end
get ':id/level' do
person = environment.people.visible_for_person(current_person).find_by_id(params[:id])
return not_found! if person.blank?
{:level => person.level, :percent => person.gamification_plugin_level_percent}
end
end
end
end