aggcat 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aggcat/base.rb +10 -8
- data/lib/aggcat/client.rb +1 -1
- data/lib/aggcat/version.rb +1 -1
- metadata +1 -1
data/lib/aggcat/base.rb
CHANGED
@@ -27,17 +27,19 @@ module Aggcat
|
|
27
27
|
|
28
28
|
protected
|
29
29
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def oauth_client
|
31
|
+
OAuth::AccessToken.new(oauth_consumer, *oauth_token)
|
32
|
+
end
|
33
|
+
|
34
|
+
def oauth_consumer
|
35
|
+
@oauth_consumer ||= OAuth::Consumer.new(@consumer_key, @consumer_secret, {:timeout => TIMEOUT})
|
34
36
|
end
|
35
37
|
|
36
38
|
def oauth_token
|
37
|
-
now = Time.now
|
38
|
-
if @oauth_token.nil? || @
|
39
|
+
now = Time.now
|
40
|
+
if @oauth_token.nil? || @oauth_token_expire_at <= now
|
39
41
|
@oauth_token = new_token(saml_message(@customer_id))
|
40
|
-
@
|
42
|
+
@oauth_token_expire_at = now + 9 * 60 # 9 minutes
|
41
43
|
end
|
42
44
|
@oauth_token
|
43
45
|
end
|
@@ -53,7 +55,7 @@ module Aggcat
|
|
53
55
|
#http.set_debug_output($stdout)
|
54
56
|
response = http.request(request)
|
55
57
|
params = CGI::parse(response.body)
|
56
|
-
|
58
|
+
[params['oauth_token'][0], params['oauth_token_secret'][0]]
|
57
59
|
end
|
58
60
|
|
59
61
|
def saml_message(user_id)
|
data/lib/aggcat/client.rb
CHANGED
@@ -91,7 +91,7 @@ module Aggcat
|
|
91
91
|
private
|
92
92
|
|
93
93
|
def request(method, uri, *options)
|
94
|
-
response =
|
94
|
+
response = oauth_client.send(method.to_sym, BASE_URL + uri, *options)
|
95
95
|
result = {:response_code => response.code, :response => parse_xml(response.body)}
|
96
96
|
if response['challengeSessionId']
|
97
97
|
result[:challenge_session_id] = response['challengeSessionId']
|
data/lib/aggcat/version.rb
CHANGED