Commit 5c39797bf9a5dd3ebd324126e6ee06d990266e9e
1 parent
fc162af5
Exists in
staging
and in
4 other branches
api: add activities endpoint
Showing
3 changed files
with
30 additions
and
0 deletions
Show diff stats
lib/noosfero/api/api.rb
lib/noosfero/api/entities.rb
@@ -236,6 +236,10 @@ module Noosfero | @@ -236,6 +236,10 @@ module Noosfero | ||
236 | expose :name | 236 | expose :name |
237 | end | 237 | end |
238 | 238 | ||
239 | + class Activity < Entity | ||
240 | + root 'activities', 'activity' | ||
241 | + expose :id, :params, :verb, :created_at, :updated_at, :comments_count, :visible | ||
242 | + end | ||
239 | 243 | ||
240 | end | 244 | end |
241 | end | 245 | end |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +module Noosfero | ||
2 | + module API | ||
3 | + module V1 | ||
4 | + class Activities < Grape::API | ||
5 | + before { authenticate! } | ||
6 | + | ||
7 | + resource :profiles do | ||
8 | + | ||
9 | + get ':id/activities' do | ||
10 | + profile = environment.profiles | ||
11 | + profile = profile.visible_for_person(current_person) if profile.respond_to?(:visible_for_person) | ||
12 | + profile = profile.find_by_id(params[:id]) | ||
13 | + activities = profile.activities.map(&:activity) | ||
14 | + present activities, :with => Entities::Activity, :current_person => current_person | ||
15 | + end | ||
16 | + | ||
17 | + get ':id/network_activities' do | ||
18 | + #TODO | ||
19 | + end | ||
20 | + | ||
21 | + end | ||
22 | + end | ||
23 | + end | ||
24 | + end | ||
25 | +end |