Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Commit

Permalink
Added support for plusoners and resharers
Browse files Browse the repository at this point in the history
  • Loading branch information
seejohnrun committed Oct 5, 2011
1 parent 9b68a22 commit 9082c45
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -84,6 +84,10 @@ cursor = person.activities_list(:max_results => 10)
cursor.next_page(:max_results => 5)
```

## Plusoners and Resharers

You can call `plusoners` and `resharers` on a `GooglePlus::Activity` to get a cursor or people that plus one'd or reshared an activity.

## Comments

You can get comments for an acitivty, using its ID:
Expand Down
19 changes: 19 additions & 0 deletions lib/google_plus/activity.rb
Expand Up @@ -26,14 +26,33 @@ def self.for_person(user_id, params = {})
GooglePlus::Cursor.new(self, :get, resource, params)
end

# get the comments for this activity
def list_comments
GooglePlus::Comment.for_activity(id)
end

# get the actor of this activity
def person
@person ||= GooglePlus::Person.get(actor.id)
end

# list the people of a certain action on this activity
# options available at https://developers.google.com/+/api/latest/people/listByActivity
def list_people(collection, params = {})
resource = "activities/#{id}/people/#{collection}"
GooglePlus::Cursor.new(GooglePlus::Person, :get, resource, params)
end

# get a cursor for the plusoners of this activity
def plusoners(params = {})
list_people(:plusoners)
end

# get a cursor for the resharers of this activity
def resharers(params = {})
list_people(:resharers)
end

def initialize(hash)
load_hash(hash)
end
Expand Down
44 changes: 44 additions & 0 deletions spec/examples/activity_spec.rb
Expand Up @@ -16,6 +16,50 @@

end

describe :plusoners do

before :each do
GooglePlus.api_key = TEST_API_KEY
end

it 'should be able to get a list of plusoners' do
activity = GooglePlus::Activity.get('z12bwfehenrus14jq04cfvgowmqhvfzrlfo')
plusoners = activity.plusoners
plusoners.items.should_not be_empty
plusoners.items.each { |r| r.should be_a(GooglePlus::Person) }
end

end

describe :resharers do

before :each do
GooglePlus.api_key = TEST_API_KEY
end

it 'should be able to get a list of resharers' do
activity = GooglePlus::Activity.get('z12bwfehenrus14jq04cfvgowmqhvfzrlfo')
resharers = activity.resharers
resharers.items.should_not be_empty
resharers.items.each { |r| r.should be_a(GooglePlus::Person) }
end

end

describe :list_people do

before :each do
GooglePlus.api_key = TEST_API_KEY
end

it 'should get nil for an invalid collection' do
activity = GooglePlus::Activity.get('z12bwfehenrus14jq04cfvgowmqhvfzrlfo')
hellos = activity.list_people 'hello'
hellos.items.should be_nil
end

end

describe :list_comments do

before :each do
Expand Down

0 comments on commit 9082c45

Please sign in to comment.