authlete 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/authlete/api.rb +8 -1
- data/lib/authlete/exception.rb +20 -7
- data/lib/authlete/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662907ba2a7276166936aa2ed397701824927bc8
|
4
|
+
data.tar.gz: 6062abfae7550fef0ea5f4f351c52635c88c2316
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d126adab10d831dfa28f09daf23e11b65d80b1d4f168a4930e4b9021f2caab81da72c2c607c6d0b36305cdf056621fe5231a2afbf08ca12a71a2462cf8a033
|
7
|
+
data.tar.gz: 3cd79914b05138d679df1ec92d75ecfb29998c4abb16bfbd037fb066a10695b52c6ed2b8ea1f0fa98638da05b43b7ab4be160bec0aae6002bdc9d6dc0214b96d
|
data/lib/authlete/api.rb
CHANGED
@@ -89,6 +89,7 @@ module Authlete
|
|
89
89
|
|
90
90
|
def execute(parameters)
|
91
91
|
begin
|
92
|
+
puts "calling....."
|
92
93
|
return RestClient::Request.new(parameters).execute
|
93
94
|
rescue => e
|
94
95
|
raise create_api_exception(e)
|
@@ -99,9 +100,13 @@ module Authlete
|
|
99
100
|
message = exception.message
|
100
101
|
response = exception.response
|
101
102
|
|
103
|
+
puts "HOGE!!!!"
|
104
|
+
|
102
105
|
# Create a base exception.
|
103
106
|
authlete_exception = Authlete::Exception.new(:message => message)
|
104
107
|
|
108
|
+
puts "After exception"
|
109
|
+
|
105
110
|
if response.nil?
|
106
111
|
# No response information. Then, return an exception without HTTP
|
107
112
|
# response information.
|
@@ -126,8 +131,10 @@ module Authlete
|
|
126
131
|
return authlete_exception
|
127
132
|
end
|
128
133
|
|
134
|
+
puts "after json parse"
|
135
|
+
|
129
136
|
# Set the Authlete API result info if it's available.
|
130
|
-
if has_authlete_api_result?(
|
137
|
+
if has_authlete_api_result?(response_body_json)
|
131
138
|
authlete_exception.result = Authlete::Model::Result.new(response_body_json)
|
132
139
|
end
|
133
140
|
|
data/lib/authlete/exception.rb
CHANGED
@@ -34,24 +34,37 @@ module Authlete
|
|
34
34
|
|
35
35
|
def initialize(hash = {})
|
36
36
|
# The error message from RestClient or the other general exceptions.
|
37
|
-
@message
|
37
|
+
@message = extract_value(hash, :message)
|
38
|
+
|
39
|
+
# HTTP status code.
|
38
40
|
@statusCode = extract_integer_value(hash, :statusCode)
|
39
|
-
|
41
|
+
|
42
|
+
# Set result.
|
43
|
+
result = extract_value(hash, :result)
|
44
|
+
@result = result.nil? ? nil : Authlete::Model::Result.new(result)
|
40
45
|
end
|
41
46
|
|
42
47
|
public
|
43
48
|
|
44
|
-
def
|
45
|
-
@result
|
49
|
+
def result_code
|
50
|
+
@result && @result.resultCode
|
46
51
|
end
|
47
52
|
|
48
|
-
def
|
49
|
-
|
53
|
+
def result_message
|
54
|
+
@result && @result.resultMessage
|
55
|
+
end
|
56
|
+
|
57
|
+
def available_message
|
58
|
+
result_message || @message || self.class.default_message
|
50
59
|
end
|
51
60
|
|
52
61
|
def to_s
|
53
62
|
"#{self.class.default_message} => { message:'#{@message}', status_code:'#{@statusCode}', " +
|
54
|
-
"result_code:'#{
|
63
|
+
"result_code:'#{result_code}', result_message:'#{result_message}' }"
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.default_message
|
67
|
+
self.name
|
55
68
|
end
|
56
69
|
end
|
57
70
|
end
|
data/lib/authlete/version.rb
CHANGED