authlete 1.0.24 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Makefile +40 -0
- data/Rakefile +5 -0
- data/authlete.gemspec +2 -2
- data/lib/authlete.rb +28 -9
- data/lib/authlete/api.rb +146 -321
- data/lib/authlete/authentication-server.rb +2 -2
- data/lib/authlete/exception.rb +14 -15
- data/lib/authlete/model/base.rb +30 -0
- data/lib/authlete/model/client-extension.rb +17 -119
- data/lib/authlete/model/client.rb +196 -345
- data/lib/authlete/model/hashable.rb +13 -33
- data/lib/authlete/model/named-uri.rb +13 -74
- data/lib/authlete/model/pair.rb +13 -74
- data/lib/authlete/model/param-initializer.rb +45 -0
- data/lib/authlete/model/property.rb +15 -85
- data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
- data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
- data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
- data/lib/authlete/model/request/authorization-request.rb +8 -73
- data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
- data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
- data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
- data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
- data/lib/authlete/model/request/base.rb +26 -0
- data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
- data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
- data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
- data/lib/authlete/model/request/client-registration-request.rb +49 -0
- data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
- data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
- data/lib/authlete/model/request/device-authorization-request.rb +63 -0
- data/lib/authlete/model/request/device-complete-request.rb +99 -0
- data/lib/authlete/model/request/device-verification-request.rb +40 -0
- data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
- data/lib/authlete/model/request/introspection-request.rb +24 -83
- data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
- data/lib/authlete/model/request/revocation-request.rb +14 -88
- data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
- data/lib/authlete/model/request/token-create-request.rb +52 -183
- data/lib/authlete/model/request/token-fail-request.rb +12 -74
- data/lib/authlete/model/request/token-issue-request.rb +22 -80
- data/lib/authlete/model/request/token-request.rb +44 -81
- data/lib/authlete/model/request/token-update-request.rb +35 -121
- data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
- data/lib/authlete/model/request/user-info-request.rb +25 -70
- data/lib/authlete/model/response/access-token.rb +96 -0
- data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
- data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
- data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
- data/lib/authlete/model/response/authorization-response.rb +97 -123
- data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
- data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
- data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
- data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
- data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
- data/lib/authlete/model/response/client-list-response.rb +58 -0
- data/lib/authlete/model/response/client-registration-response.rb +50 -0
- data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
- data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
- data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
- data/lib/authlete/model/response/device-authorization-response.rb +134 -0
- data/lib/authlete/model/response/device-complete-response.rb +39 -0
- data/lib/authlete/model/response/device-verification-response.rb +96 -0
- data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
- data/lib/authlete/model/response/introspection-response.rb +64 -58
- data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
- data/lib/authlete/model/response/revocation-response.rb +12 -15
- data/lib/authlete/model/response/service-list-response.rb +54 -0
- data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
- data/lib/authlete/model/response/token-create-response.rb +50 -55
- data/lib/authlete/model/response/token-fail-response.rb +14 -17
- data/lib/authlete/model/response/token-issue-response.rb +49 -62
- data/lib/authlete/model/response/token-list-response.rb +64 -0
- data/lib/authlete/model/response/token-response.rb +59 -79
- data/lib/authlete/model/response/token-update-response.rb +28 -23
- data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
- data/lib/authlete/model/response/user-info-response.rb +48 -42
- data/lib/authlete/model/result.rb +14 -13
- data/lib/authlete/model/scope.rb +29 -119
- data/lib/authlete/model/service-owner.rb +32 -116
- data/lib/authlete/model/service.rb +464 -685
- data/lib/authlete/model/sns-credentials.rb +18 -91
- data/lib/authlete/model/tagged-value.rb +14 -69
- data/lib/authlete/utility.rb +3 -32
- data/lib/authlete/version.rb +3 -3
- data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
- data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
- data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
- data/test/authlete/model/request/test_authorization-request.rb +57 -0
- data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
- data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
- data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
- data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
- data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
- data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
- data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
- data/test/authlete/model/request/test_client-registration-request.rb +68 -0
- data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
- data/test/authlete/model/request/test_device-complete-request.rb +102 -0
- data/test/authlete/model/request/test_device-verification-request.rb +57 -0
- data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
- data/test/authlete/model/request/test_introspection-request.rb +79 -0
- data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
- data/test/authlete/model/request/test_revocation-request.rb +67 -0
- data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
- data/test/authlete/model/request/test_token-create-request.rb +110 -0
- data/test/authlete/model/request/test_token-fail-request.rb +63 -0
- data/test/authlete/model/request/test_token-issue-request.rb +70 -0
- data/test/authlete/model/request/test_token-request.rb +94 -0
- data/test/authlete/model/request/test_token-update-request.rb +82 -0
- data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
- data/test/authlete/model/request/test_user-info-request.rb +75 -0
- data/test/authlete/model/response/test_access-token.rb +101 -0
- data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
- data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
- data/test/authlete/model/response/test_authorization-response.rb +145 -0
- data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
- data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
- data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
- data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
- data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
- data/test/authlete/model/response/test_client-list-response.rb +79 -0
- data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
- data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
- data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
- data/test/authlete/model/response/test_device-complete-response.rb +64 -0
- data/test/authlete/model/response/test_device-verification-response.rb +112 -0
- data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
- data/test/authlete/model/response/test_introspection-response.rb +127 -0
- data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
- data/test/authlete/model/response/test_revocation-response.rb +68 -0
- data/test/authlete/model/response/test_service-list-response.rb +72 -0
- data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
- data/test/authlete/model/response/test_token-create-response.rb +107 -0
- data/test/authlete/model/response/test_token-fail-response.rb +68 -0
- data/test/authlete/model/response/test_token-issue-response.rb +127 -0
- data/test/authlete/model/response/test_token-list-response.rb +84 -0
- data/test/authlete/model/response/test_token-response.rb +147 -0
- data/test/authlete/model/response/test_token-update-response.rb +87 -0
- data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
- data/test/authlete/model/response/test_user-info-response.rb +107 -0
- data/test/authlete/model/test_client-extension.rb +95 -0
- data/test/authlete/model/test_client.rb +461 -0
- data/test/authlete/model/test_named-uri.rb +85 -0
- data/test/authlete/model/test_pair.rb +85 -0
- data/test/authlete/model/test_property.rb +90 -0
- data/test/authlete/model/test_result.rb +68 -0
- data/test/authlete/model/test_scope.rb +106 -0
- data/test/authlete/model/test_service-owner.rb +80 -0
- data/test/authlete/model/test_service.rb +614 -0
- data/test/authlete/model/test_sns-credentials.rb +88 -0
- data/test/authlete/model/test_tagged-value.rb +83 -0
- data/test/authlete/test_exception.rb +70 -0
- metadata +169 -9
- data/lib/authlete/model/client-list.rb +0 -129
- data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
- data/lib/authlete/model/response/service-creatable-response.rb +0 -51
- data/lib/authlete/model/service-list.rb +0 -128
@@ -1,129 +0,0 @@
|
|
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
|
-
class ClientList < Authlete::Model::Hashable
|
24
|
-
include Authlete::Utility
|
25
|
-
# The start index (inclusive) of the clients in this list.
|
26
|
-
# (Integer)
|
27
|
-
attr_accessor :start
|
28
|
-
|
29
|
-
# The end index (exclusive) of the clients in this list.
|
30
|
-
# (Integer)
|
31
|
-
attr_accessor :end
|
32
|
-
|
33
|
-
# The total count of clients. (Integer)
|
34
|
-
attr_accessor :totalCount
|
35
|
-
alias_method :total_count, :totalCount
|
36
|
-
alias_method :total_count=, :totalCount=
|
37
|
-
|
38
|
-
# The list of clients. (Client array)
|
39
|
-
attr_accessor :clients
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
# Integer attributes.
|
44
|
-
INTEGER_ATTRIBUTES = ::Set.new([ :start, :end, :totalCount ])
|
45
|
-
|
46
|
-
# Mapping from snake cases to camel cases.
|
47
|
-
SNAKE_TO_CAMEL = { :total_count => :totalCount }
|
48
|
-
|
49
|
-
# The constructor
|
50
|
-
def initialize(hash = nil)
|
51
|
-
# Set default values to integer attributes.
|
52
|
-
INTEGER_ATTRIBUTES.each do |attr|
|
53
|
-
send("#{attr}=", 0)
|
54
|
-
end
|
55
|
-
|
56
|
-
@clients = nil
|
57
|
-
|
58
|
-
# Set attribute values using the given hash.
|
59
|
-
authlete_model_update(hash)
|
60
|
-
end
|
61
|
-
|
62
|
-
def authlete_model_convert_key(key)
|
63
|
-
key = key.to_sym
|
64
|
-
|
65
|
-
# Convert snakecase to camelcase, if necessary.
|
66
|
-
if SNAKE_TO_CAMEL.has_key?(key)
|
67
|
-
key = SNAKE_TO_CAMEL[key]
|
68
|
-
end
|
69
|
-
|
70
|
-
key
|
71
|
-
end
|
72
|
-
|
73
|
-
def authlete_model_simple_attribute?(key)
|
74
|
-
INTEGER_ATTRIBUTES.include?(key)
|
75
|
-
end
|
76
|
-
|
77
|
-
def authlete_model_update(hash)
|
78
|
-
return if hash.nil?
|
79
|
-
|
80
|
-
hash.each do |key, value|
|
81
|
-
key = authlete_model_convert_key(key)
|
82
|
-
|
83
|
-
if authlete_model_simple_attribute?(key)
|
84
|
-
send("#{key}=", value)
|
85
|
-
elsif key == :clients
|
86
|
-
# Get an array consisting of "Client" objects.
|
87
|
-
@clients = get_parsed_array(value) do |element|
|
88
|
-
Authlete::Model::Client.parse(element)
|
89
|
-
end
|
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, ClientList.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 ClientList.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
|
-
elsif val.kind_of?(Array)
|
121
|
-
hash[key] = val.map { |element| element.to_hash }
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
hash
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,60 +0,0 @@
|
|
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
|
-
module Authlete
|
19
|
-
module Model
|
20
|
-
module Response
|
21
|
-
# == Authlete::Model::Response::ClientAuthorizationGetListResponse class
|
22
|
-
#
|
23
|
-
# This class represents a response from Authlete's /api/client/authorization/get/list API.
|
24
|
-
class ClientAuthorizationGetListResponse
|
25
|
-
# Start index of search results (inclusive).
|
26
|
-
# (Integer)
|
27
|
-
attr_accessor :start
|
28
|
-
|
29
|
-
# End index of search results (exclusive).
|
30
|
-
# (Integer)
|
31
|
-
attr_accessor :end
|
32
|
-
|
33
|
-
# Unique Developer ID. (String)
|
34
|
-
attr_accessor :developer
|
35
|
-
|
36
|
-
# The total number of clients that meet the conditions. (Integer)
|
37
|
-
attr_accessor :totalCount
|
38
|
-
alias_method :total_count, :totalCount
|
39
|
-
alias_method :total_count=, :totalCount=
|
40
|
-
|
41
|
-
# The list of clients. (Client array)
|
42
|
-
attr_accessor :clients
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
# The constructor which takes a hash that represents a JSON response
|
47
|
-
# from Authlete's /api/client/authorization/get/list API.
|
48
|
-
def initialize(hash = {})
|
49
|
-
@start = extract_integer_value(hash, :start)
|
50
|
-
@end = extract_integer_value(hash, :end)
|
51
|
-
@developer = extract_value(hash, :developer)
|
52
|
-
@totalCount = extract_integer_value(hash, :totalCount)
|
53
|
-
@clients = extract_array_value(hash, :clients) do |element|
|
54
|
-
Authlete::Model::Client.parse(element)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,51 +0,0 @@
|
|
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
|
-
module Authlete
|
19
|
-
module Model
|
20
|
-
module Response
|
21
|
-
# == Authlete::Model::Response::ServiceCreatableResponse class
|
22
|
-
class ServiceCreatableResponse
|
23
|
-
include Authlete::Utility
|
24
|
-
# A boolean flag to indicate whether the service owner can
|
25
|
-
# create a new service or not.
|
26
|
-
attr_accessor :creatable
|
27
|
-
|
28
|
-
# The number of services that the service owner currently has.
|
29
|
-
attr_accessor :count
|
30
|
-
|
31
|
-
# The maximum number of services allowed in the plan of the
|
32
|
-
# service owner.
|
33
|
-
attr_accessor :limit
|
34
|
-
|
35
|
-
# The plan of the service owner.
|
36
|
-
attr_accessor :plan
|
37
|
-
|
38
|
-
# The constructor which takes a hash that represents a JSON
|
39
|
-
# response from /api/service/creatable API.
|
40
|
-
def initialize(hash = {})
|
41
|
-
@creatable = extract_boolean_value(hash, :creatable)
|
42
|
-
@count = extract_integer_value(hash, :count)
|
43
|
-
@limit = extract_integer_value(hash, :limit)
|
44
|
-
@plan = extract_value(hash, :plan)
|
45
|
-
end
|
46
|
-
|
47
|
-
alias_method :creatable?, :creatable
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,128 +0,0 @@
|
|
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
|
-
class ServiceList < Authlete::Model::Hashable
|
24
|
-
include Authlete::Utility
|
25
|
-
# The start index (inclusive) of the services in this list.
|
26
|
-
# (Integer)
|
27
|
-
attr_accessor :start
|
28
|
-
|
29
|
-
# The end index (exclusive) of the services in this list.
|
30
|
-
# (Integer)
|
31
|
-
attr_accessor :end
|
32
|
-
|
33
|
-
# The total count of services. (Integer)
|
34
|
-
attr_accessor :totalCount
|
35
|
-
alias_method :total_count, :totalCount
|
36
|
-
alias_method :total_count=, :totalCount=
|
37
|
-
|
38
|
-
# The list of services. (Service array)
|
39
|
-
attr_accessor :services
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
# Integer attributes.
|
44
|
-
INTEGER_ATTRIBUTES = ::Set.new([ :start, :end, :totalCount ])
|
45
|
-
|
46
|
-
# Mapping from snake cases to camel cases.
|
47
|
-
SNAKE_TO_CAMEL = { :total_count => :totalCount }
|
48
|
-
|
49
|
-
# The constructor
|
50
|
-
def initialize(hash = nil)
|
51
|
-
# Set default values to integer attributes.
|
52
|
-
INTEGER_ATTRIBUTES.each do |attr|
|
53
|
-
send("#{attr}=", 0)
|
54
|
-
end
|
55
|
-
|
56
|
-
@services = nil
|
57
|
-
|
58
|
-
# Set attribute values using the given hash.
|
59
|
-
authlete_model_update(hash)
|
60
|
-
end
|
61
|
-
|
62
|
-
def authlete_model_convert_key(key)
|
63
|
-
key = key.to_sym
|
64
|
-
|
65
|
-
# Convert snakecase to camelcase, if necessary.
|
66
|
-
if SNAKE_TO_CAMEL.has_key?(key)
|
67
|
-
key = SNAKE_TO_CAMEL[key]
|
68
|
-
end
|
69
|
-
|
70
|
-
key
|
71
|
-
end
|
72
|
-
|
73
|
-
def authlete_model_simple_attribute?(key)
|
74
|
-
INTEGER_ATTRIBUTES.include?(key)
|
75
|
-
end
|
76
|
-
|
77
|
-
def authlete_model_update(hash)
|
78
|
-
return if hash.nil?
|
79
|
-
|
80
|
-
hash.each do |key, value|
|
81
|
-
key = authlete_model_convert_key(key)
|
82
|
-
|
83
|
-
if authlete_model_simple_attribute?(key)
|
84
|
-
send("#{key}=", value)
|
85
|
-
elsif key == :services
|
86
|
-
@services = get_parsed_array(value) do |element|
|
87
|
-
Authlete::Model::Service.parse(element)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
self
|
93
|
-
end
|
94
|
-
|
95
|
-
public
|
96
|
-
|
97
|
-
# Construct an instance from the given hash.
|
98
|
-
#
|
99
|
-
# If the given argument is nil or is not a Hash, nil is returned.
|
100
|
-
# Otherwise, ServiceList.new(hash) is returned.
|
101
|
-
def self.parse(hash)
|
102
|
-
if hash.nil? or (hash.kind_of?(Hash) == false)
|
103
|
-
return nil
|
104
|
-
end
|
105
|
-
|
106
|
-
ServiceList.new(hash)
|
107
|
-
end
|
108
|
-
|
109
|
-
# Convert this object into a hash.
|
110
|
-
def to_hash
|
111
|
-
hash = {}
|
112
|
-
|
113
|
-
instance_variables.each do |var|
|
114
|
-
key = var.to_s.delete("@").to_sym
|
115
|
-
val = instance_variable_get(var)
|
116
|
-
|
117
|
-
if authlete_model_simple_attribute?(key) or val.nil?
|
118
|
-
hash[key] = val
|
119
|
-
elsif val.kind_of?(Array)
|
120
|
-
hash[key] = val.map { |element| element.to_hash }
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
hash
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|