google_plus 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/google_plus.rb +1 -1
- data/lib/google_plus/activity.rb +19 -0
- data/lib/google_plus/resource.rb +9 -2
- data/lib/google_plus/version.rb +1 -1
- metadata +6 -6
data/lib/google_plus.rb
CHANGED
data/lib/google_plus/activity.rb
CHANGED
@@ -26,14 +26,33 @@ module GooglePlus
|
|
26
26
|
GooglePlus::Cursor.new(self, :get, resource, params)
|
27
27
|
end
|
28
28
|
|
29
|
+
# get the comments for this activity
|
29
30
|
def list_comments
|
30
31
|
GooglePlus::Comment.for_activity(id)
|
31
32
|
end
|
32
33
|
|
34
|
+
# get the actor of this activity
|
33
35
|
def person
|
34
36
|
@person ||= GooglePlus::Person.get(actor.id)
|
35
37
|
end
|
36
38
|
|
39
|
+
# list the people of a certain action on this activity
|
40
|
+
# options available at https://developers.google.com/+/api/latest/people/listByActivity
|
41
|
+
def list_people(collection, params = {})
|
42
|
+
resource = "activities/#{id}/people/#{collection}"
|
43
|
+
GooglePlus::Cursor.new(GooglePlus::Person, :get, resource, params)
|
44
|
+
end
|
45
|
+
|
46
|
+
# get a cursor for the plusoners of this activity
|
47
|
+
def plusoners(params = {})
|
48
|
+
list_people(:plusoners)
|
49
|
+
end
|
50
|
+
|
51
|
+
# get a cursor for the resharers of this activity
|
52
|
+
def resharers(params = {})
|
53
|
+
list_people(:resharers)
|
54
|
+
end
|
55
|
+
|
37
56
|
def initialize(hash)
|
38
57
|
load_hash(hash)
|
39
58
|
end
|
data/lib/google_plus/resource.rb
CHANGED
@@ -11,12 +11,19 @@ module GooglePlus
|
|
11
11
|
|
12
12
|
# Make a request to an external resource
|
13
13
|
def make_request(method, resource, params = {})
|
14
|
+
# Put together the common params
|
14
15
|
params[:key] ||= GooglePlus.api_key unless GooglePlus.api_key.nil?
|
15
16
|
params[:userIp] = params.delete(:user_ip) if params.has_key?(:user_ip)
|
16
17
|
params[:pp] = '0' # google documentation is incorrect, it says 'prettyPrint'
|
18
|
+
# Add the access token if we have it
|
19
|
+
headers = {}
|
20
|
+
if token = params[:access_token] || GooglePlus.access_token
|
21
|
+
headers[:Authorization] = "OAuth #{token}"
|
22
|
+
end
|
23
|
+
# And make the request
|
17
24
|
begin
|
18
|
-
RestClient.get "#{BASE_URI}#{resource}", :params => params
|
19
|
-
rescue RestClient::Forbidden, RestClient::BadRequest => e
|
25
|
+
RestClient.get "#{BASE_URI}#{resource}", headers.merge(:params => params)
|
26
|
+
rescue RestClient::Unauthorized, RestClient::Forbidden, RestClient::BadRequest => e
|
20
27
|
raise GooglePlus::RequestError.new(e)
|
21
28
|
rescue SocketError => e
|
22
29
|
raise GooglePlus::ConnectionError.new(e)
|
data/lib/google_plus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-05 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &70129871014340 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 2.6.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70129871014340
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rest-client
|
28
|
-
requirement: &
|
28
|
+
requirement: &70129871013840 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 1.6.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70129871013840
|
37
37
|
description: Google+ Ruby Gem
|
38
38
|
email: john.crepezzi@gmail.com
|
39
39
|
executables: []
|