authlete 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/authlete.rb +24 -1
  3. data/lib/authlete/api.rb +298 -146
  4. data/lib/authlete/authentication-server.rb +1 -1
  5. data/lib/authlete/exception.rb +6 -3
  6. data/lib/authlete/model/client-extension.rb +135 -135
  7. data/lib/authlete/model/client-list.rb +128 -128
  8. data/lib/authlete/model/client.rb +468 -468
  9. data/lib/authlete/model/hashable.rb +1 -1
  10. data/lib/authlete/model/pair.rb +102 -102
  11. data/lib/authlete/model/property.rb +116 -0
  12. data/lib/authlete/model/request/authentication-callback-request.rb +90 -90
  13. data/lib/authlete/model/request/authorization-fail-request.rb +107 -104
  14. data/lib/authlete/model/request/authorization-issue-request.rb +167 -133
  15. data/lib/authlete/model/request/authorization-request.rb +101 -101
  16. data/lib/authlete/model/request/client-authorization-delete-request.rb +123 -0
  17. data/lib/authlete/model/request/client-authorization-get-list-request.rb +123 -0
  18. data/lib/authlete/model/request/client-authorization-update-request.rb +118 -0
  19. data/lib/authlete/model/request/client-secret-update-request.rb +121 -0
  20. data/lib/authlete/model/request/developer-authentication-callback-request.rb +84 -84
  21. data/lib/authlete/model/request/granted-scopes-request.rb +103 -0
  22. data/lib/authlete/model/request/introspection-request.rb +117 -39
  23. data/lib/authlete/model/request/revocation-request.rb +125 -0
  24. data/lib/authlete/model/request/standard-introspection-request.rb +102 -0
  25. data/lib/authlete/model/request/token-create-request.rb +250 -0
  26. data/lib/authlete/model/request/token-fail-request.rb +104 -101
  27. data/lib/authlete/model/request/token-issue-request.rb +116 -101
  28. data/lib/authlete/model/request/token-request.rb +127 -121
  29. data/lib/authlete/model/request/token-update-request.rb +165 -0
  30. data/lib/authlete/model/request/user-info-issue-request.rb +113 -0
  31. data/lib/authlete/model/request/user-info-request.rb +102 -0
  32. data/lib/authlete/model/response/authentication-callback-response.rb +53 -53
  33. data/lib/authlete/model/response/authorization-fail-response.rb +48 -48
  34. data/lib/authlete/model/response/authorization-issue-response.rb +85 -48
  35. data/lib/authlete/model/response/authorization-response.rb +177 -164
  36. data/lib/authlete/model/response/client-authorization-get-list-response.rb +60 -0
  37. data/lib/authlete/model/response/client-secret-refresh-response.rb +48 -0
  38. data/lib/authlete/model/response/client-secret-update-response.rb +48 -0
  39. data/lib/authlete/model/response/developer-authentication-callback-response.rb +55 -55
  40. data/lib/authlete/model/response/granted-scopes-get-response.rb +63 -0
  41. data/lib/authlete/model/response/introspection-response.rb +163 -132
  42. data/lib/authlete/model/response/revocation-response.rb +49 -0
  43. data/lib/authlete/model/response/service-creatable-response.rb +50 -50
  44. data/lib/authlete/model/response/standard-introspection-response.rb +49 -0
  45. data/lib/authlete/model/response/token-create-response.rb +100 -0
  46. data/lib/authlete/model/response/token-fail-response.rb +49 -49
  47. data/lib/authlete/model/response/token-issue-response.rb +138 -49
  48. data/lib/authlete/model/response/token-response.rb +168 -70
  49. data/lib/authlete/model/response/token-update-response.rb +62 -0
  50. data/lib/authlete/model/response/user-info-issue-response.rb +47 -0
  51. data/lib/authlete/model/response/user-info-response.rb +85 -0
  52. data/lib/authlete/model/result.rb +44 -44
  53. data/lib/authlete/model/scope.rb +1 -1
  54. data/lib/authlete/model/service-list.rb +1 -1
  55. data/lib/authlete/model/service-owner.rb +1 -1
  56. data/lib/authlete/model/service.rb +4 -2
  57. data/lib/authlete/model/sns-credentials.rb +1 -1
  58. data/lib/authlete/model/tagged-value.rb +97 -97
  59. data/lib/authlete/utility.rb +1 -1
  60. data/lib/authlete/version.rb +2 -2
  61. metadata +24 -2
@@ -1,102 +1,105 @@
1
- # :nodoc:
2
- #
3
- # Copyright (C) 2014-2015 Authlete, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
-
18
- module Authlete
19
- module Model
20
- module Request
21
- # == Authlete::Model::Request::TokenFailRequest class
22
- #
23
- # This class represents a request to Authlete's /api/auth/token/fail API.
24
- class TokenFailRequest < Authlete::Model::Hashable
25
- # The ticket issued by Authlete's /api/auth/token API. (String)
26
- attr_accessor :ticket
27
-
28
- # The reason of the failure. (String)
29
- attr_accessor :reason
30
-
31
- private
32
-
33
- # String attributes.
34
- STRING_ATTRIBUTES = ::Set.new([ :ticket, :reason ])
35
-
36
- # The constructor which takes a hash that represents a JSON request to
37
- # Authlete's /api/auth/token/fail API.
38
- def initialize(hash = nil)
39
- # Set default values to string attributes.
40
- STRING_ATTRIBUTES.each do |attr|
41
- send("#{attr}=", nil)
42
- end
43
-
44
- # Set attribute values using the given hash.
45
- authlete_model_update(hash)
46
- end
47
-
48
- def authlete_model_convert_key(key)
49
- key.to_sym
50
- end
51
-
52
- def authlete_model_simple_attribute?(key)
53
- STRING_ATTRIBUTES.include?(key)
54
- end
55
-
56
- def authlete_model_update(hash)
57
- return if hash.nil?
58
-
59
- hash.each do |key, value|
60
- key = authlete_model_convert_key(key)
61
-
62
- if authlete_model_simple_attribute?(key)
63
- send("#{key}=", value)
64
- end
65
- end
66
-
67
- self
68
- end
69
-
70
- public
71
-
72
- # Construct an instance from the given hash.
73
- #
74
- # If the given argument is nil or is not a Hash, nil is returned.
75
- # Otherwise, TokenFailRequest.new(hash) is returned.
76
- def self.parse(hash)
77
- if hash.nil? or (hash.kind_of?(Hash) == false)
78
- return nil
79
- end
80
-
81
- return TokenFailRequest.new(hash)
82
- end
83
-
84
- # Convert this object into a hash.
85
- def to_hash
86
- hash = {}
87
-
88
- instance_variables.each do |var|
89
- key = var.to_s.delete("@").to_sym
90
- val = instance_variable_get(var)
91
-
92
- if authlete_model_simple_attribute?(key) or val.nil?
93
- hash[key] = val
94
- end
95
- end
96
-
97
- hash
98
- end
99
- end
100
- end
101
- end
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2018 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ module Request
24
+ # == Authlete::Model::Request::TokenFailRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/auth/token/fail API.
27
+ class TokenFailRequest < Authlete::Model::Hashable
28
+ # The ticket issued by Authlete's /api/auth/token API. (String)
29
+ attr_accessor :ticket
30
+
31
+ # The reason of the failure. (String)
32
+ attr_accessor :reason
33
+
34
+ private
35
+
36
+ # String attributes.
37
+ STRING_ATTRIBUTES = ::Set.new([ :ticket, :reason ])
38
+
39
+ # The constructor which takes a hash that represents a JSON request to
40
+ # Authlete's /api/auth/token/fail API.
41
+ def initialize(hash = nil)
42
+ # Set default values to string attributes.
43
+ STRING_ATTRIBUTES.each do |attr|
44
+ send("#{attr}=", nil)
45
+ end
46
+
47
+ # Set attribute values using the given hash.
48
+ authlete_model_update(hash)
49
+ end
50
+
51
+ def authlete_model_convert_key(key)
52
+ key.to_sym
53
+ end
54
+
55
+ def authlete_model_simple_attribute?(key)
56
+ STRING_ATTRIBUTES.include?(key)
57
+ end
58
+
59
+ def authlete_model_update(hash)
60
+ return if hash.nil?
61
+
62
+ hash.each do |key, value|
63
+ key = authlete_model_convert_key(key)
64
+
65
+ if authlete_model_simple_attribute?(key)
66
+ send("#{key}=", value)
67
+ end
68
+ end
69
+
70
+ self
71
+ end
72
+
73
+ public
74
+
75
+ # Construct an instance from the given hash.
76
+ #
77
+ # If the given argument is nil or is not a Hash, nil is returned.
78
+ # Otherwise, TokenFailRequest.new(hash) is returned.
79
+ def self.parse(hash)
80
+ if hash.nil? or (hash.kind_of?(Hash) == false)
81
+ return nil
82
+ end
83
+
84
+ return TokenFailRequest.new(hash)
85
+ end
86
+
87
+ # Convert this object into a hash.
88
+ def to_hash
89
+ hash = {}
90
+
91
+ instance_variables.each do |var|
92
+ key = var.to_s.delete("@").to_sym
93
+ val = instance_variable_get(var)
94
+
95
+ if authlete_model_simple_attribute?(key) or val.nil?
96
+ hash[key] = val
97
+ end
98
+ end
99
+
100
+ hash
101
+ end
102
+ end
103
+ end
104
+ end
102
105
  end
@@ -1,102 +1,117 @@
1
- # :nodoc:
2
- #
3
- # Copyright (C) 2014-2015 Authlete, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
-
18
- module Authlete
19
- module Model
20
- module Request
21
- # == Authlete::Model::Request::TokenIssueRequest class
22
- #
23
- # This class represents a request to Authlete's /api/auth/token/issue API.
24
- class TokenIssueRequest < Authlete::Model::Hashable
25
- # The ticket issued by Authlete's /api/auth/authorization API. (String)
26
- attr_accessor :ticket
27
-
28
- # The subject (end-user) managed by the service. (String)
29
- attr_accessor :subject
30
-
31
- private
32
-
33
- # String attributes.
34
- STRING_ATTRIBUTES = ::Set.new([ :ticket, :subject ])
35
-
36
- # The constructor which takes a hash that represents a JSON request to
37
- # Authlete's /api/auth/token/issue API.
38
- def initialize(hash = nil)
39
- # Set default values to string attributes.
40
- STRING_ATTRIBUTES.each do |attr|
41
- send("#{attr}=", nil)
42
- end
43
-
44
- # Set attribute values using the given hash.
45
- authlete_model_update(hash)
46
- end
47
-
48
- def authlete_model_convert_key(key)
49
- key.to_sym
50
- end
51
-
52
- def authlete_model_simple_attribute?(key)
53
- STRING_ATTRIBUTES.include?(key)
54
- end
55
-
56
- def authlete_model_update(hash)
57
- return if hash.nil?
58
-
59
- hash.each do |key, value|
60
- key = authlete_model_convert_key(key)
61
-
62
- if authlete_model_simple_attribute?(key)
63
- send("#{key}=", value)
64
- end
65
- end
66
-
67
- self
68
- end
69
-
70
- public
71
-
72
- # Construct an instance from the given hash.
73
- #
74
- # If the given argument is nil or is not a Hash, nil is returned.
75
- # Otherwise, TokenIssueRequest.new(hash) is returned.
76
- def self.parse(hash)
77
- if hash.nil? or (hash.kind_of?(Hash) == false)
78
- return nil
79
- end
80
-
81
- return TokenIssueRequest.new(hash)
82
- end
83
-
84
- # Convert this object into a hash.
85
- def to_hash
86
- hash = {}
87
-
88
- instance_variables.each do |var|
89
- key = var.to_s.delete("@").to_sym
90
- val = instance_variable_get(var)
91
-
92
- if authlete_model_simple_attribute?(key) or val.nil?
93
- hash[key] = val
94
- end
95
- end
96
-
97
- hash
98
- end
99
- end
100
- end
101
- end
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2018 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ module Request
24
+ # == Authlete::Model::Request::TokenIssueRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/auth/token/issue API.
27
+ class TokenIssueRequest < Authlete::Model::Hashable
28
+ # The ticket issued by Authlete's /api/auth/authorization API. (String)
29
+ attr_accessor :ticket
30
+
31
+ # The subject (end-user) managed by the service. (String)
32
+ attr_accessor :subject
33
+
34
+ # Extra properties to associate with a newly created access token.
35
+ # (String)
36
+ attr_accessor :properties
37
+
38
+ private
39
+
40
+ # String attributes.
41
+ STRING_ATTRIBUTES = ::Set.new([ :ticket, :subject ])
42
+
43
+ # The constructor which takes a hash that represents a JSON request to
44
+ # Authlete's /api/auth/token/issue API.
45
+ def initialize(hash = nil)
46
+ # Set default values to string attributes.
47
+ STRING_ATTRIBUTES.each do |attr|
48
+ send("#{attr}=", nil)
49
+ end
50
+
51
+ @properties = nil
52
+
53
+ # Set attribute values using the given hash.
54
+ authlete_model_update(hash)
55
+ end
56
+
57
+ def authlete_model_convert_key(key)
58
+ key.to_sym
59
+ end
60
+
61
+ def authlete_model_simple_attribute?(key)
62
+ STRING_ATTRIBUTES.include?(key)
63
+ end
64
+
65
+ def authlete_model_update(hash)
66
+ return if hash.nil?
67
+
68
+ hash.each do |key, value|
69
+ key = authlete_model_convert_key(key)
70
+
71
+ if authlete_model_simple_attribute?(key)
72
+ send("#{key}=", value)
73
+ elsif key == :properties
74
+ @properties = get_parsed_array(value) do |element|
75
+ Authlete::Model::Property.parse(element)
76
+ end
77
+ end
78
+ end
79
+
80
+ self
81
+ end
82
+
83
+ public
84
+
85
+ # Construct an instance from the given hash.
86
+ #
87
+ # If the given argument is nil or is not a Hash, nil is returned.
88
+ # Otherwise, TokenIssueRequest.new(hash) is returned.
89
+ def self.parse(hash)
90
+ if hash.nil? or (hash.kind_of?(Hash) == false)
91
+ return nil
92
+ end
93
+
94
+ return TokenIssueRequest.new(hash)
95
+ end
96
+
97
+ # Convert this object into a hash.
98
+ def to_hash
99
+ hash = {}
100
+
101
+ instance_variables.each do |var|
102
+ key = var.to_s.delete("@").to_sym
103
+ val = instance_variable_get(var)
104
+
105
+ if authlete_model_simple_attribute?(key) or val.nil?
106
+ hash[key] = val
107
+ elsif key == :properties
108
+ hash[key] = val.map { |element| element.to_hash }
109
+ end
110
+ end
111
+
112
+ hash
113
+ end
114
+ end
115
+ end
116
+ end
102
117
  end
@@ -1,122 +1,128 @@
1
- # :nodoc:
2
- #
3
- # Copyright (C) 2014-2015 Authlete, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
-
18
- module Authlete
19
- module Model
20
- module Request
21
- # == Authlete::Model::Request::TokenRequest class
22
- #
23
- # This class represents a request to Authlete's /api/auth/token API.
24
- class TokenRequest < Authlete::Model::Hashable
25
- # OAuth 2.0 token request parameters. (String)
26
- attr_accessor :parameters
27
-
28
- # Client ID. (String)
29
- attr_accessor :clientId
30
- alias_method :client_id, :clientId
31
- alias_method :client_id=, :clientId=
32
-
33
- # Client Secret. (String)
34
- attr_accessor :clientSecret
35
- alias_method :client_secret, :clientSecret
36
- alias_method :client_secret=, :clientSecret=
37
-
38
- private
39
-
40
- # String attributes.
41
- STRING_ATTRIBUTES = ::Set.new([ :parameters, :clientId, :clientSecret ])
42
-
43
- # Mapping from snake cases to camel cases.
44
- SNAKE_TO_CAMEL = {
45
- :client_id => :clientId,
46
- :client_secret => :clientSecret
47
- }
48
-
49
- # The constructor which takes a hash that represents a JSON request
50
- # to Authlete's /api/auth/token API.
51
- def initialize(hash = nil)
52
- # Set default values to string attributes.
53
- STRING_ATTRIBUTES.each do |attr|
54
- send("#{attr}=", nil)
55
- end
56
-
57
- # Set attribute values using the given hash.
58
- authlete_model_update(hash)
59
- end
60
-
61
- def authlete_model_convert_key(key)
62
- key = key.to_sym
63
-
64
- # Convert snakecase to camelcase, if necessary.
65
- if SNAKE_TO_CAMEL.has_key?(key)
66
- key = SNAKE_TO_CAMEL[key]
67
- end
68
-
69
- key
70
- end
71
-
72
- def authlete_model_simple_attribute?(key)
73
- STRING_ATTRIBUTES.include?(key)
74
- end
75
-
76
- def authlete_model_update(hash)
77
- return if hash.nil?
78
-
79
- hash.each do |key, value|
80
- key = authlete_model_convert_key(key)
81
-
82
- if authlete_model_simple_attribute?(key)
83
- send("#{key}=", value)
84
- end
85
- end
86
-
87
- self
88
- end
89
-
90
- public
91
-
92
- # Construct an instance from the given hash.
93
- #
94
- # If the given argument is nil or is not a Hash, nil is returned.
95
- # Otherwise, TokenRequest.new(hash) is returned.
96
- def self.parse(hash)
97
- if hash.nil? or (hash.kind_of?(Hash) == false)
98
- return nil
99
- end
100
-
101
- return TokenRequest.new(hash)
102
- end
103
-
104
- # Convert this object into a hash.
105
- def to_hash
106
- hash = {}
107
-
108
- instance_variables.each do |var|
109
- key = var.to_s.delete("@").to_sym
110
- val = instance_variable_get(var)
111
-
112
- if authlete_model_simple_attribute?(key) or val.nil?
113
- hash[key] = val
114
- end
115
- end
116
-
117
- hash
118
- end
119
- end
120
- end
121
- end
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2018 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ module Request
24
+ # == Authlete::Model::Request::TokenRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/auth/token API.
27
+ class TokenRequest < Authlete::Model::Hashable
28
+ # OAuth 2.0 token request parameters. (String)
29
+ attr_accessor :parameters
30
+
31
+ # Client ID. (String)
32
+ attr_accessor :clientId
33
+ alias_method :client_id, :clientId
34
+ alias_method :client_id=, :clientId=
35
+
36
+ # Client Secret. (String)
37
+ attr_accessor :clientSecret
38
+ alias_method :client_secret, :clientSecret
39
+ alias_method :client_secret=, :clientSecret=
40
+
41
+ # Extra properties to associate with an access token. (String)
42
+ attr_accessor :properties
43
+
44
+ private
45
+
46
+ # String attributes.
47
+ STRING_ATTRIBUTES = ::Set.new([ :parameters, :clientId, :clientSecret, :properties ])
48
+
49
+ # Mapping from snake cases to camel cases.
50
+ SNAKE_TO_CAMEL = {
51
+ :client_id => :clientId,
52
+ :client_secret => :clientSecret
53
+ }
54
+
55
+ # The constructor which takes a hash that represents a JSON request
56
+ # to Authlete's /api/auth/token API.
57
+ def initialize(hash = nil)
58
+ # Set default values to string attributes.
59
+ STRING_ATTRIBUTES.each do |attr|
60
+ send("#{attr}=", nil)
61
+ end
62
+
63
+ # Set attribute values using the given hash.
64
+ authlete_model_update(hash)
65
+ end
66
+
67
+ def authlete_model_convert_key(key)
68
+ key = key.to_sym
69
+
70
+ # Convert snakecase to camelcase, if necessary.
71
+ if SNAKE_TO_CAMEL.has_key?(key)
72
+ key = SNAKE_TO_CAMEL[key]
73
+ end
74
+
75
+ key
76
+ end
77
+
78
+ def authlete_model_simple_attribute?(key)
79
+ STRING_ATTRIBUTES.include?(key)
80
+ end
81
+
82
+ def authlete_model_update(hash)
83
+ return if hash.nil?
84
+
85
+ hash.each do |key, value|
86
+ key = authlete_model_convert_key(key)
87
+
88
+ if authlete_model_simple_attribute?(key)
89
+ send("#{key}=", value)
90
+ end
91
+ end
92
+
93
+ self
94
+ end
95
+
96
+ public
97
+
98
+ # Construct an instance from the given hash.
99
+ #
100
+ # If the given argument is nil or is not a Hash, nil is returned.
101
+ # Otherwise, TokenRequest.new(hash) is returned.
102
+ def self.parse(hash)
103
+ if hash.nil? or (hash.kind_of?(Hash) == false)
104
+ return nil
105
+ end
106
+
107
+ return TokenRequest.new(hash)
108
+ end
109
+
110
+ # Convert this object into a hash.
111
+ def to_hash
112
+ hash = {}
113
+
114
+ instance_variables.each do |var|
115
+ key = var.to_s.delete("@").to_sym
116
+ val = instance_variable_get(var)
117
+
118
+ if authlete_model_simple_attribute?(key) or val.nil?
119
+ hash[key] = val
120
+ end
121
+ end
122
+
123
+ hash
124
+ end
125
+ end
126
+ end
127
+ end
122
128
  end