authlete 0.5.1 → 1.0.0
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.
- checksums.yaml +4 -4
- data/lib/authlete.rb +24 -1
- data/lib/authlete/api.rb +298 -146
- data/lib/authlete/authentication-server.rb +1 -1
- data/lib/authlete/exception.rb +6 -3
- data/lib/authlete/model/client-extension.rb +135 -135
- data/lib/authlete/model/client-list.rb +128 -128
- data/lib/authlete/model/client.rb +468 -468
- data/lib/authlete/model/hashable.rb +1 -1
- data/lib/authlete/model/pair.rb +102 -102
- data/lib/authlete/model/property.rb +116 -0
- data/lib/authlete/model/request/authentication-callback-request.rb +90 -90
- data/lib/authlete/model/request/authorization-fail-request.rb +107 -104
- data/lib/authlete/model/request/authorization-issue-request.rb +167 -133
- data/lib/authlete/model/request/authorization-request.rb +101 -101
- data/lib/authlete/model/request/client-authorization-delete-request.rb +123 -0
- data/lib/authlete/model/request/client-authorization-get-list-request.rb +123 -0
- data/lib/authlete/model/request/client-authorization-update-request.rb +118 -0
- data/lib/authlete/model/request/client-secret-update-request.rb +121 -0
- data/lib/authlete/model/request/developer-authentication-callback-request.rb +84 -84
- data/lib/authlete/model/request/granted-scopes-request.rb +103 -0
- data/lib/authlete/model/request/introspection-request.rb +117 -39
- data/lib/authlete/model/request/revocation-request.rb +125 -0
- data/lib/authlete/model/request/standard-introspection-request.rb +102 -0
- data/lib/authlete/model/request/token-create-request.rb +250 -0
- data/lib/authlete/model/request/token-fail-request.rb +104 -101
- data/lib/authlete/model/request/token-issue-request.rb +116 -101
- data/lib/authlete/model/request/token-request.rb +127 -121
- data/lib/authlete/model/request/token-update-request.rb +165 -0
- data/lib/authlete/model/request/user-info-issue-request.rb +113 -0
- data/lib/authlete/model/request/user-info-request.rb +102 -0
- data/lib/authlete/model/response/authentication-callback-response.rb +53 -53
- data/lib/authlete/model/response/authorization-fail-response.rb +48 -48
- data/lib/authlete/model/response/authorization-issue-response.rb +85 -48
- data/lib/authlete/model/response/authorization-response.rb +177 -164
- data/lib/authlete/model/response/client-authorization-get-list-response.rb +60 -0
- data/lib/authlete/model/response/client-secret-refresh-response.rb +48 -0
- data/lib/authlete/model/response/client-secret-update-response.rb +48 -0
- data/lib/authlete/model/response/developer-authentication-callback-response.rb +55 -55
- data/lib/authlete/model/response/granted-scopes-get-response.rb +63 -0
- data/lib/authlete/model/response/introspection-response.rb +163 -132
- data/lib/authlete/model/response/revocation-response.rb +49 -0
- data/lib/authlete/model/response/service-creatable-response.rb +50 -50
- data/lib/authlete/model/response/standard-introspection-response.rb +49 -0
- data/lib/authlete/model/response/token-create-response.rb +100 -0
- data/lib/authlete/model/response/token-fail-response.rb +49 -49
- data/lib/authlete/model/response/token-issue-response.rb +138 -49
- data/lib/authlete/model/response/token-response.rb +168 -70
- data/lib/authlete/model/response/token-update-response.rb +62 -0
- data/lib/authlete/model/response/user-info-issue-response.rb +47 -0
- data/lib/authlete/model/response/user-info-response.rb +85 -0
- data/lib/authlete/model/result.rb +44 -44
- data/lib/authlete/model/scope.rb +1 -1
- data/lib/authlete/model/service-list.rb +1 -1
- data/lib/authlete/model/service-owner.rb +1 -1
- data/lib/authlete/model/service.rb +4 -2
- data/lib/authlete/model/sns-credentials.rb +1 -1
- data/lib/authlete/model/tagged-value.rb +97 -97
- data/lib/authlete/utility.rb +1 -1
- data/lib/authlete/version.rb +2 -2
- metadata +24 -2
@@ -1,102 +1,105 @@
|
|
1
|
-
# :nodoc:
|
2
|
-
#
|
3
|
-
# Copyright (C) 2014-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# The
|
29
|
-
attr_accessor :
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
#
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# The
|
29
|
-
attr_accessor :
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
attr_accessor :
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|