orkut 0.0.0.8 → 0.0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/orkut/authenticatable.rb +12 -3
- data/lib/orkut/client/comments.rb +10 -0
- data/lib/orkut/client/messages.rb +2 -2
- data/lib/orkut/client/people.rb +24 -1
- data/lib/orkut/client/timelines.rb +13 -8
- data/lib/orkut/config.rb +37 -1
- data/lib/orkut/connection.rb +37 -1
- data/lib/orkut/constants/action.rb +7 -0
- data/lib/orkut/constants/collection.rb +9 -0
- data/lib/orkut/constants/fields.rb +5 -0
- data/lib/orkut/constants/group.rb +6 -0
- data/lib/orkut/constants/internal_constants.rb +1 -0
- data/lib/orkut/constants/params.rb +1 -1
- data/lib/orkut/request.rb +20 -10
- data/lib/orkut/version.rb +1 -1
- metadata +8 -6
@@ -4,12 +4,21 @@ module Orkut
|
|
4
4
|
# Credentials hash
|
5
5
|
#
|
6
6
|
# @return [Hash]
|
7
|
-
def
|
7
|
+
def credentials_v1
|
8
8
|
{
|
9
9
|
:consumer_key => consumer_key,
|
10
10
|
:consumer_secret => consumer_secret,
|
11
11
|
:token => oauth_token,
|
12
|
-
:token_secret => oauth_token_secret
|
12
|
+
:token_secret => oauth_token_secret
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def credentials
|
17
|
+
{
|
18
|
+
:refresh_token => refresh_token,
|
19
|
+
:access_token => access_token,
|
20
|
+
:expires_in => expires_in,
|
21
|
+
:issued_at => issued_at
|
13
22
|
}
|
14
23
|
end
|
15
24
|
|
@@ -17,7 +26,7 @@ module Orkut
|
|
17
26
|
#
|
18
27
|
# @return [Boolean]
|
19
28
|
def authenticated?
|
20
|
-
credentials.values.all?
|
29
|
+
credentials.values.all? and credentials_v1.values.all?
|
21
30
|
end
|
22
31
|
|
23
32
|
end
|
@@ -1,10 +1,20 @@
|
|
1
1
|
require 'orkut/client/base'
|
2
|
+
require 'orkut/constants/fields'
|
3
|
+
require 'orkut/constants/group'
|
4
|
+
require 'orkut/constants/internal_constants'
|
5
|
+
require 'orkut/constants/method_names'
|
6
|
+
require 'orkut/constants/params'
|
7
|
+
require 'multi_json'
|
2
8
|
|
3
9
|
module Orkut
|
4
10
|
class Client
|
5
11
|
module Comments
|
6
12
|
include Base
|
7
13
|
# TODO implements features
|
14
|
+
|
15
|
+
def get_comments(options={})
|
16
|
+
|
17
|
+
end
|
8
18
|
end
|
9
19
|
end
|
10
20
|
end
|
@@ -21,7 +21,7 @@ module Orkut
|
|
21
21
|
Orkut::Constants::Fields::ID => request_id.to_s+'-'+Orkut::Constants::MethodNames::CREATE_ACTIVITIES,
|
22
22
|
Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::CREATE_ACTIVITIES
|
23
23
|
}]
|
24
|
-
MultiJson.decode(
|
24
|
+
MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
|
25
25
|
end
|
26
26
|
|
27
27
|
def post_scrap(options={})
|
@@ -38,7 +38,7 @@ module Orkut
|
|
38
38
|
Orkut::Constants::Fields::ID => request_id.to_s+'-'+Orkut::Constants::MethodNames::MESSAGES_CREATE,
|
39
39
|
Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::MESSAGES_CREATE
|
40
40
|
}]
|
41
|
-
MultiJson.decode(
|
41
|
+
MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
data/lib/orkut/client/people.rb
CHANGED
@@ -23,7 +23,30 @@ module Orkut
|
|
23
23
|
Orkut::Constants::Fields::ID => request_id.to_s+'-'+Orkut::Constants::MethodNames::PEOPLE_GET,
|
24
24
|
Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::PEOPLE_GET
|
25
25
|
}]
|
26
|
-
MultiJson.decode(
|
26
|
+
MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_person_full_profile(options={})
|
30
|
+
params = [{
|
31
|
+
Orkut::Constants::Fields::PARAMS => {
|
32
|
+
Orkut::Constants::Fields::FIELDS => [
|
33
|
+
Orkut::Constants::Fields::NAME,
|
34
|
+
Orkut::Constants::Fields::THUMBNAIL_URL,
|
35
|
+
Orkut::Constants::Fields::PROFILE_URL,
|
36
|
+
Orkut::Constants::Fields::STATUS,
|
37
|
+
Orkut::Constants::Fields::EMAILS,
|
38
|
+
Orkut::Constants::Fields::GENDER,
|
39
|
+
Orkut::Constants::Fields::PHONE_NUMBERS,
|
40
|
+
Orkut::Constants::Fields::BIRTHDAY,
|
41
|
+
Orkut::Constants::Fields::CURRENT_LOCATION
|
42
|
+
],
|
43
|
+
Orkut::Constants::Fields::GROUP_ID => Orkut::Constants::Group::SELF,
|
44
|
+
Orkut::Constants::Fields::USER_ID => (options[:user_id] || Orkut::Constants::InternalConstants::USERID_ME)
|
45
|
+
},
|
46
|
+
Orkut::Constants::Fields::ID => request_id.to_s+'-'+Orkut::Constants::MethodNames::PEOPLE_GET,
|
47
|
+
Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::PEOPLE_GET
|
48
|
+
}]
|
49
|
+
MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
|
27
50
|
end
|
28
51
|
|
29
52
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'orkut/client/base'
|
2
|
+
require 'orkut/constants/action'
|
3
|
+
require 'orkut/constants/collection'
|
2
4
|
require 'orkut/constants/fields'
|
3
5
|
require 'orkut/constants/group'
|
4
6
|
require 'orkut/constants/internal_constants'
|
@@ -24,16 +26,10 @@ module Orkut
|
|
24
26
|
Orkut::Constants::Fields::ID => request_id.to_s+'-'+Orkut::Constants::MethodNames::ACTIVITIES_GET,
|
25
27
|
Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::ACTIVITIES_GET
|
26
28
|
}]
|
27
|
-
teste = "[{\"params\":{"
|
28
29
|
unless options[:updated_before].blank?
|
29
30
|
params.first[Orkut::Constants::Fields::PARAMS][Orkut::Constants::Fields::UPDATED_BEFORE] = format_datetime(options[:updated_before])
|
30
|
-
teste += "\"updatedBefore\":\""+format_datetime(options[:updated_before])+"\","
|
31
31
|
end
|
32
|
-
|
33
|
-
puts '*********************************************************************************************************'
|
34
|
-
puts teste
|
35
|
-
puts '*********************************************************************************************************'
|
36
|
-
MultiJson.decode(post(nil, params.to_s, default_headers).body)
|
32
|
+
MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
|
37
33
|
end
|
38
34
|
|
39
35
|
def scraps_timeline(options={})
|
@@ -49,7 +45,16 @@ module Orkut
|
|
49
45
|
Orkut::Constants::Fields::ID => request_id.to_s+'-'+Orkut::Constants::MethodNames::MESSAGES_GET,
|
50
46
|
Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::MESSAGES_GET
|
51
47
|
}]
|
52
|
-
MultiJson.decode(
|
48
|
+
MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
|
49
|
+
end
|
50
|
+
|
51
|
+
def home_timeline22(options={})
|
52
|
+
params = {
|
53
|
+
Orkut::Constants::Fields::USER_ID => Orkut::Constants::InternalConstants::USERID_ME_SIMPLE,
|
54
|
+
Orkut::Constants::Fields::COLLECTION => Orkut::Constants::Collection::STREAM,
|
55
|
+
Orkut::Constants::Fields::ALT => Orkut::Constants::Params::JSON
|
56
|
+
}
|
57
|
+
execute(Orkut::Constants::Fields::ACTIVITIES, Orkut::Constants::Action::LIST, params)
|
53
58
|
end
|
54
59
|
end
|
55
60
|
end
|
data/lib/orkut/config.rb
CHANGED
@@ -16,7 +16,16 @@ module Orkut
|
|
16
16
|
:consumer_key,
|
17
17
|
:consumer_secret,
|
18
18
|
:oauth_token,
|
19
|
-
:oauth_token_secret
|
19
|
+
:oauth_token_secret,
|
20
|
+
:client_id,
|
21
|
+
:client_secret,
|
22
|
+
:scope,
|
23
|
+
:redirect_uri,
|
24
|
+
:refresh_token,
|
25
|
+
:access_token,
|
26
|
+
:expires_in,
|
27
|
+
:issued_at,
|
28
|
+
:code].freeze
|
20
29
|
|
21
30
|
DEFAULT_SITE = 'https://www.google.com'.freeze
|
22
31
|
|
@@ -48,6 +57,24 @@ module Orkut
|
|
48
57
|
# The value sent in the 'User-Agent' header if none is set
|
49
58
|
DEFAULT_USER_AGENT = "Orkut Ruby Gem #{Orkut::Version}".freeze
|
50
59
|
|
60
|
+
DEFAULT_CLIENT_ID = nil
|
61
|
+
|
62
|
+
DEFAULT_CLIENT_SECRET = nil
|
63
|
+
|
64
|
+
DEFAULT_SCOPE = 'https://www.googleapis.com/auth/orkut'.freeze
|
65
|
+
|
66
|
+
DEFAULT_REDIRECT_URI = ''
|
67
|
+
|
68
|
+
DEFAULT_REFRESH_TOKEN = nil
|
69
|
+
|
70
|
+
DEFAULT_ACCESS_TOKEN = nil
|
71
|
+
|
72
|
+
DEFAULT_EXPIRES_IN = nil
|
73
|
+
|
74
|
+
DEFAULT_ISSUED_AT = nil
|
75
|
+
|
76
|
+
DEFAULT_CODE = nil
|
77
|
+
|
51
78
|
attr_accessor *VALID_OPTIONS_KEYS
|
52
79
|
|
53
80
|
# When this module is extended, set all configuration options to their default values
|
@@ -82,6 +109,15 @@ module Orkut
|
|
82
109
|
self.oauth_token = DEFAULT_OAUTH_TOKEN
|
83
110
|
self.oauth_token_secret = DEFAULT_OAUTH_TOKEN_SECRET
|
84
111
|
self.user_agent = DEFAULT_USER_AGENT
|
112
|
+
self.client_id = DEFAULT_CLIENT_ID
|
113
|
+
self.client_secret = DEFAULT_CLIENT_SECRET
|
114
|
+
self.scope = DEFAULT_SCOPE
|
115
|
+
self.redirect_uri = DEFAULT_REDIRECT_URI
|
116
|
+
self.refresh_token = DEFAULT_REFRESH_TOKEN
|
117
|
+
self.access_token = DEFAULT_ACCESS_TOKEN
|
118
|
+
self.expires_in = DEFAULT_EXPIRES_IN
|
119
|
+
self.issued_at = DEFAULT_ISSUED_AT
|
120
|
+
self.code = DEFAULT_CODE
|
85
121
|
self
|
86
122
|
end
|
87
123
|
|
data/lib/orkut/connection.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'omniauth/oauth'
|
2
|
+
require 'google/api_client'
|
2
3
|
|
3
4
|
module Orkut
|
4
5
|
module Connection
|
5
6
|
private
|
6
7
|
|
7
|
-
def
|
8
|
+
def connection_v1(options={})
|
8
9
|
access_token = nil
|
9
10
|
if authenticated?
|
10
11
|
client_options = {
|
@@ -22,6 +23,41 @@ module Orkut
|
|
22
23
|
end
|
23
24
|
access_token
|
24
25
|
end
|
26
|
+
|
27
|
+
def connection(options={})
|
28
|
+
access_token = nil
|
29
|
+
if authenticated?
|
30
|
+
client = Google::APIClient.new
|
31
|
+
|
32
|
+
client.authorization.client_id = client_id
|
33
|
+
client.authorization.client_secret = client_secret
|
34
|
+
client.authorization.scope = scope
|
35
|
+
client.authorization.redirect_uri = redirect_uri
|
36
|
+
|
37
|
+
client.authorization.code = code
|
38
|
+
|
39
|
+
orkut = client.discovered_api('orkut', 'v2')
|
40
|
+
unless client.authorization.access_token
|
41
|
+
r = Rack::Response.new
|
42
|
+
r.redirect(client.authorization.authorization_uri.to_s)
|
43
|
+
r.finish
|
44
|
+
end
|
45
|
+
end
|
46
|
+
access_token
|
47
|
+
end
|
48
|
+
|
49
|
+
def authorization_uri(options={})
|
50
|
+
client = Google::APIClient.new
|
51
|
+
|
52
|
+
client.authorization.client_id = client_id
|
53
|
+
client.authorization.client_secret = client_secret
|
54
|
+
client.authorization.scope = scope
|
55
|
+
client.authorization.redirect_uri = redirect_uri
|
56
|
+
|
57
|
+
orkut = client.discovered_api('orkut', 'v2')
|
58
|
+
|
59
|
+
client.authorization.authorization_uri.to_s
|
60
|
+
end
|
25
61
|
|
26
62
|
end
|
27
63
|
end
|
@@ -13,7 +13,10 @@ module Orkut
|
|
13
13
|
ACCESSOR_TYPE = 'accessorType'
|
14
14
|
end
|
15
15
|
|
16
|
+
ACTIVITIES = 'activities'
|
16
17
|
ACTIVITY = 'activity'
|
18
|
+
ACTIVITY_ID = 'activityId'
|
19
|
+
ALT = 'alt'
|
17
20
|
BIRTHDAY = 'birthday'
|
18
21
|
COUNTRY = 'country'
|
19
22
|
CURRENT_LOCATION = 'currentLocation'
|
@@ -32,6 +35,7 @@ module Orkut
|
|
32
35
|
|
33
36
|
BODY = 'body'
|
34
37
|
COALESCE = 'coalesce'
|
38
|
+
COLLECTION = 'collection'
|
35
39
|
COMMENTS = 'comments'
|
36
40
|
COUNT = 'count'
|
37
41
|
CREATED = 'created'
|
@@ -41,6 +45,7 @@ module Orkut
|
|
41
45
|
# The list of entries in an ACL
|
42
46
|
ENTRIES = 'entries'
|
43
47
|
ERROR_TYPE = 'errorType'
|
48
|
+
FIELDS = 'fields'
|
44
49
|
FROM_USER_ID = 'fromUserId'
|
45
50
|
FROM_USER_PROFILE = 'fromUserProfile'
|
46
51
|
GENDER = 'gender'
|
data/lib/orkut/request.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'orkut/error'
|
1
2
|
module Orkut
|
2
3
|
# Defines HTTP request methods
|
3
4
|
module Request
|
@@ -7,16 +8,16 @@ module Orkut
|
|
7
8
|
# @response = @token.get('/people')
|
8
9
|
# @response = @token.get('/people', { 'Accept'=>'application/xml' })
|
9
10
|
#
|
10
|
-
def
|
11
|
-
|
11
|
+
def get_v1(path = nil, headers = {})
|
12
|
+
connection_v1.get(verify_path(path), headers)
|
12
13
|
end
|
13
14
|
|
14
15
|
# Make a regular HEAD request using AccessToken
|
15
16
|
#
|
16
17
|
# @response = @token.head('/people')
|
17
18
|
#
|
18
|
-
def
|
19
|
-
|
19
|
+
def head_v1(path = nil, headers = {})
|
20
|
+
connection_v1.head(verify_path(path), headers)
|
20
21
|
end
|
21
22
|
|
22
23
|
# Make a regular POST request using AccessToken
|
@@ -27,8 +28,8 @@ module Orkut
|
|
27
28
|
# @response = @token.post('/people', nil, {'Accept' => 'application/xml' })
|
28
29
|
# @response = @token.post('/people', @person.to_xml, { 'Accept'=>'application/xml', 'Content-Type' => 'application/xml' })
|
29
30
|
#
|
30
|
-
def
|
31
|
-
|
31
|
+
def post_v1(path = nil, body = '', headers = {})
|
32
|
+
connection_v1.post(verify_path(path), body, headers)
|
32
33
|
end
|
33
34
|
|
34
35
|
# Make a regular PUT request using AccessToken
|
@@ -39,8 +40,8 @@ module Orkut
|
|
39
40
|
# @response = @token.put('/people/123', nil, { 'Accept' => 'application/xml' })
|
40
41
|
# @response = @token.put('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
|
41
42
|
#
|
42
|
-
def
|
43
|
-
|
43
|
+
def put_v1(path = nil, body = '', headers = {})
|
44
|
+
connection_v1.put(verify_path(path), body, headers)
|
44
45
|
end
|
45
46
|
|
46
47
|
# Make a regular DELETE request using AccessToken
|
@@ -48,8 +49,17 @@ module Orkut
|
|
48
49
|
# @response = @token.delete('/people/123')
|
49
50
|
# @response = @token.delete('/people/123', { 'Accept' => 'application/xml' })
|
50
51
|
#
|
51
|
-
def
|
52
|
-
|
52
|
+
def delete_v1(path = nil, headers = {})
|
53
|
+
connection_v1.delete(verify_path(path), headers)
|
54
|
+
end
|
55
|
+
|
56
|
+
def execute(entity, action, body = {})
|
57
|
+
raise(Orkut::Error, 'Parameters entity and action cannot be nil') if entity.blank? or action.blank?
|
58
|
+
raise(Orkut::Error, 'Parameter body cannot be nil or empty') if body.blank? or body.empty?
|
59
|
+
orkut = connection.discovered_api('orkut', 'v2')
|
60
|
+
response = connection.execute(orkut.try(entity.to_sym).try(action.to_sym), body)
|
61
|
+
#status, headers, body = response
|
62
|
+
response
|
53
63
|
end
|
54
64
|
|
55
65
|
def verify_path(path)
|
data/lib/orkut/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orkut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
16
|
-
requirement: &
|
16
|
+
requirement: &15983140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15983140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: multi_json
|
27
|
-
requirement: &
|
27
|
+
requirement: &15982540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15982540
|
36
36
|
description: A Ruby wrapper for the Orkut REST/RPC API.
|
37
37
|
email:
|
38
38
|
- contato@umanni.com
|
@@ -62,7 +62,9 @@ files:
|
|
62
62
|
- lib/orkut/client/videos.rb
|
63
63
|
- lib/orkut/config.rb
|
64
64
|
- lib/orkut/connection.rb
|
65
|
+
- lib/orkut/constants/action.rb
|
65
66
|
- lib/orkut/constants/activity_type.rb
|
67
|
+
- lib/orkut/constants/collection.rb
|
66
68
|
- lib/orkut/constants/fields.rb
|
67
69
|
- lib/orkut/constants/group.rb
|
68
70
|
- lib/orkut/constants/internal_constants.rb
|