authlete 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,174 +1,177 @@
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
- require 'set'
19
-
20
-
21
- module Authlete
22
- module Model
23
- class ServiceOwner
24
- # The API key of the service owner. (Long)
25
- attr_accessor :apiKey
26
- alias_method :api_key, :apiKey
27
- alias_method :api_key=, :apiKey=
28
-
29
- # The API secret of the service owner. (String)
30
- attr_accessor :apiSecret
31
- alias_method :api_secret, :apiSecret
32
- alias_method :api_secret=, :apiSecret=
33
-
34
- # The email address of the service owner. (String)
35
- attr_accessor :email
36
-
37
- # The login ID of the service owner. (String)
38
- attr_accessor :loginId
39
- alias_method :login_id, :loginId
40
- alias_method :login_id=, :loginId=
41
-
42
- # The service owner name. (String)
43
- attr_accessor :name
44
-
45
- # The service owner number. (Integer)
46
- attr_accessor :number
47
-
48
- private
49
-
50
- # Integer attributes.
51
- INTEGER_ATTRIBUTES = ::Set.new([
52
- :apiKey, :number
53
- ])
54
-
55
- # String attributes.
56
- STRING_ATTRIBUTES = ::Set.new([
57
- :apiSecret, :email, :loginId, :name
58
- ])
59
-
60
- # Mapping from snake cases to camel cases.
61
- SNAKE_TO_CAMEL = {
62
- :api_key => :apiKey,
63
- :api_secret => :apiSecret,
64
- :login_id => :loginId
65
- }
66
-
67
- # The constructor
68
- def initialize(hash = nil)
69
- # Set default values to integer attributes.
70
- INTEGER_ATTRIBUTES.each do |attr|
71
- send("#{attr}=", 0)
72
- end
73
-
74
- # Set default values to string attributes.
75
- STRING_ATTRIBUTES.each do |attr|
76
- send("#{attr}=", nil)
77
- end
78
-
79
- # Set attribute values using the given hash.
80
- authlete_model_service_update(hash)
81
- end
82
-
83
- def authlete_model_service_to_key(key)
84
- key = key.to_sym
85
-
86
- # Convert snakecase to camelcase, if necessary.
87
- if SNAKE_TO_CAMEL.has_key?(key)
88
- key = SNAKE_TO_CAMEL[key]
89
- end
90
-
91
- return key
92
- end
93
-
94
- def authlete_model_service_simple_attribute?(key)
95
- INTEGER_ATTRIBUTES.include?(key) or
96
- STRING_ATTRIBUTES.include?(key)
97
- end
98
-
99
- def authlete_model_service_update(hash)
100
- if hash.nil?
101
- return
102
- end
103
-
104
- hash.each do |key, value|
105
- key = authlete_model_service_to_key(key)
106
-
107
- # If the attribute is a simple one.
108
- if authlete_model_service_simple_attribute?(key)
109
- send("#{key}=", value)
110
- next
111
- end
112
- end
113
-
114
- return self
115
- end
116
-
117
- public
118
-
119
- # Construct an instance from the given hash.
120
- #
121
- # If the given argument is nil or is not a Hash, nil is returned.
122
- # Otherwise, Service.new(hash) is returned.
123
- def self.parse(hash)
124
- if hash.nil? or (hash.kind_of?(Hash) == false)
125
- return nil
126
- end
127
-
128
- return Service.new(hash)
129
- end
130
-
131
- # Set attribute values using the given hash.
132
- def update(hash)
133
- authlete_model_service_update(hash)
134
- end
135
-
136
- # Convert this object into a hash.
137
- def to_hash
138
- hash = {}
139
-
140
- instance_variables.each do |var|
141
- key = var.to_s.delete("@").to_sym
142
- val = instance_variable_get(var)
143
-
144
- if authlete_model_service_simple_attribute?(key) or val.nil?
145
- hash[key] = val
146
- end
147
- end
148
-
149
- return hash
150
- end
151
-
152
- def [](key)
153
- key = authlete_model_service_to_key(key)
154
-
155
- if respond_to?(key)
156
- return send(key)
157
- else
158
- return nil
159
- end
160
- end
161
-
162
- def []=(key, value)
163
- key = authlete_model_service_to_key(key)
164
- method = "#{key}="
165
-
166
- if respond_to?(method)
167
- return send(method, value)
168
- else
169
- return nil
170
- end
171
- end
172
- end
173
- end
174
- end
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
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ class ServiceOwner
24
+ # The API key of the service owner. (Long)
25
+ attr_accessor :apiKey
26
+ alias_method :api_key, :apiKey
27
+ alias_method :api_key=, :apiKey=
28
+
29
+ # The API secret of the service owner. (String)
30
+ attr_accessor :apiSecret
31
+ alias_method :api_secret, :apiSecret
32
+ alias_method :api_secret=, :apiSecret=
33
+
34
+ # The email address of the service owner. (String)
35
+ attr_accessor :email
36
+
37
+ # The login ID of the service owner. (String)
38
+ attr_accessor :loginId
39
+ alias_method :login_id, :loginId
40
+ alias_method :login_id=, :loginId=
41
+
42
+ # The service owner name. (String)
43
+ attr_accessor :name
44
+
45
+ # The service owner number. (Integer)
46
+ attr_accessor :number
47
+
48
+ # The plan. (String)
49
+ attr_accessor :plan
50
+
51
+ private
52
+
53
+ # Integer attributes.
54
+ INTEGER_ATTRIBUTES = ::Set.new([
55
+ :apiKey, :number
56
+ ])
57
+
58
+ # String attributes.
59
+ STRING_ATTRIBUTES = ::Set.new([
60
+ :apiSecret, :email, :loginId, :name, :plan
61
+ ])
62
+
63
+ # Mapping from snake cases to camel cases.
64
+ SNAKE_TO_CAMEL = {
65
+ :api_key => :apiKey,
66
+ :api_secret => :apiSecret,
67
+ :login_id => :loginId
68
+ }
69
+
70
+ # The constructor
71
+ def initialize(hash = nil)
72
+ # Set default values to integer attributes.
73
+ INTEGER_ATTRIBUTES.each do |attr|
74
+ send("#{attr}=", 0)
75
+ end
76
+
77
+ # Set default values to string attributes.
78
+ STRING_ATTRIBUTES.each do |attr|
79
+ send("#{attr}=", nil)
80
+ end
81
+
82
+ # Set attribute values using the given hash.
83
+ authlete_model_service_update(hash)
84
+ end
85
+
86
+ def authlete_model_service_to_key(key)
87
+ key = key.to_sym
88
+
89
+ # Convert snakecase to camelcase, if necessary.
90
+ if SNAKE_TO_CAMEL.has_key?(key)
91
+ key = SNAKE_TO_CAMEL[key]
92
+ end
93
+
94
+ return key
95
+ end
96
+
97
+ def authlete_model_service_simple_attribute?(key)
98
+ INTEGER_ATTRIBUTES.include?(key) or
99
+ STRING_ATTRIBUTES.include?(key)
100
+ end
101
+
102
+ def authlete_model_service_update(hash)
103
+ if hash.nil?
104
+ return
105
+ end
106
+
107
+ hash.each do |key, value|
108
+ key = authlete_model_service_to_key(key)
109
+
110
+ # If the attribute is a simple one.
111
+ if authlete_model_service_simple_attribute?(key)
112
+ send("#{key}=", value)
113
+ next
114
+ end
115
+ end
116
+
117
+ return self
118
+ end
119
+
120
+ public
121
+
122
+ # Construct an instance from the given hash.
123
+ #
124
+ # If the given argument is nil or is not a Hash, nil is returned.
125
+ # Otherwise, Service.new(hash) is returned.
126
+ def self.parse(hash)
127
+ if hash.nil? or (hash.kind_of?(Hash) == false)
128
+ return nil
129
+ end
130
+
131
+ return Service.new(hash)
132
+ end
133
+
134
+ # Set attribute values using the given hash.
135
+ def update(hash)
136
+ authlete_model_service_update(hash)
137
+ end
138
+
139
+ # Convert this object into a hash.
140
+ def to_hash
141
+ hash = {}
142
+
143
+ instance_variables.each do |var|
144
+ key = var.to_s.delete("@").to_sym
145
+ val = instance_variable_get(var)
146
+
147
+ if authlete_model_service_simple_attribute?(key) or val.nil?
148
+ hash[key] = val
149
+ end
150
+ end
151
+
152
+ return hash
153
+ end
154
+
155
+ def [](key)
156
+ key = authlete_model_service_to_key(key)
157
+
158
+ if respond_to?(key)
159
+ return send(key)
160
+ else
161
+ return nil
162
+ end
163
+ end
164
+
165
+ def []=(key, value)
166
+ key = authlete_model_service_to_key(key)
167
+ method = "#{key}="
168
+
169
+ if respond_to?(method)
170
+ return send(method, value)
171
+ else
172
+ return nil
173
+ end
174
+ end
175
+ end
176
+ end
177
+ end
@@ -1,135 +1,135 @@
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
- require 'set'
19
-
20
-
21
- module Authlete
22
- module Model
23
- class TaggedValue
24
- # The language tag part. (String)
25
- attr_accessor :tag
26
-
27
- # The value part. (String)
28
- attr_accessor :value
29
-
30
-
31
- private
32
-
33
- # String attributes.
34
- STRING_ATTRIBUTES = ::Set.new([:tag, :value])
35
-
36
- # The constructor
37
- def initialize(hash = new)
38
- # Set default values to string attributes.
39
- STRING_ATTRIBUTES.each do |attr|
40
- send("#{attr}=", nil)
41
- end
42
-
43
- # Set attribute values using the given hash.
44
- authlete_model_taggedValue_update(hash)
45
- end
46
-
47
- def authlete_model_taggedValue_to_key(key)
48
- key = key.to_sym
49
-
50
- # Convert snakecase to camelcase, if necessary.
51
- if SNAKE_TO_CAMEL.has_key?(key)
52
- key = SNAKE_TO_CAMEL[key]
53
- end
54
-
55
- return key
56
- end
57
-
58
- def authlete_model_taggedValue_simple_attribute?(key)
59
- STRING_ATTRIBUTES.include?(key)
60
- end
61
-
62
- def authlete_model_taggedValue_update(hash)
63
- if hash.nil?
64
- return
65
- end
66
-
67
- hash.each do |key, value|
68
- key = authlete_model_taggedValue_to_key(key)
69
-
70
- # If the attribute is a simple one.
71
- if authlete_model_taggedValue_simple_attribute?(key)
72
- send("#{key}=", value)
73
- next
74
- end
75
- end
76
-
77
- return self
78
- end
79
-
80
- public
81
-
82
- # Construct an instance from the given hash.
83
- #
84
- # If the given argument is nil or is not a Hash, nil is returned.
85
- # Otherwise, TaggedValue.new(hash) is returned.
86
- def self.parse(hash)
87
- if hash.nil? or (hash.kind_of?(Hash) == false)
88
- return nil
89
- end
90
-
91
- return Authlete::Model::TaggedValue.new(hash)
92
- end
93
-
94
- # Set attribute values using the given hash.
95
- def update(hash)
96
- authlete_model_taggedValue_update(hash)
97
- end
98
-
99
- # Convert this object into a hash.
100
- def to_hash
101
- hash = {}
102
-
103
- instance_variables.each do |var|
104
- key = var.to_s.delete("@").to_sym
105
- val = instance_variable_get(var)
106
-
107
- hash[key] = val
108
- end
109
-
110
- return hash
111
- end
112
-
113
- def [](key)
114
- key = authlete_model_taggedValue_to_key(key)
115
-
116
- if respond_to?(key)
117
- return send(key)
118
- else
119
- return nil
120
- end
121
- end
122
-
123
- def []=(key, value)
124
- key = authlete_model_taggedValue_to_key(key)
125
- method = "#{key}="
126
-
127
- if respond_to?(method)
128
- return send(method, value)
129
- else
130
- return nil
131
- end
132
- end
133
- end
134
- end
135
- end
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
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ class TaggedValue
24
+ # The language tag part. (String)
25
+ attr_accessor :tag
26
+
27
+ # The value part. (String)
28
+ attr_accessor :value
29
+
30
+
31
+ private
32
+
33
+ # String attributes.
34
+ STRING_ATTRIBUTES = ::Set.new([:tag, :value])
35
+
36
+ # The constructor
37
+ def initialize(hash = new)
38
+ # Set default values to string attributes.
39
+ STRING_ATTRIBUTES.each do |attr|
40
+ send("#{attr}=", nil)
41
+ end
42
+
43
+ # Set attribute values using the given hash.
44
+ authlete_model_taggedValue_update(hash)
45
+ end
46
+
47
+ def authlete_model_taggedValue_to_key(key)
48
+ key = key.to_sym
49
+
50
+ # Convert snakecase to camelcase, if necessary.
51
+ if SNAKE_TO_CAMEL.has_key?(key)
52
+ key = SNAKE_TO_CAMEL[key]
53
+ end
54
+
55
+ return key
56
+ end
57
+
58
+ def authlete_model_taggedValue_simple_attribute?(key)
59
+ STRING_ATTRIBUTES.include?(key)
60
+ end
61
+
62
+ def authlete_model_taggedValue_update(hash)
63
+ if hash.nil?
64
+ return
65
+ end
66
+
67
+ hash.each do |key, value|
68
+ key = authlete_model_taggedValue_to_key(key)
69
+
70
+ # If the attribute is a simple one.
71
+ if authlete_model_taggedValue_simple_attribute?(key)
72
+ send("#{key}=", value)
73
+ next
74
+ end
75
+ end
76
+
77
+ return self
78
+ end
79
+
80
+ public
81
+
82
+ # Construct an instance from the given hash.
83
+ #
84
+ # If the given argument is nil or is not a Hash, nil is returned.
85
+ # Otherwise, TaggedValue.new(hash) is returned.
86
+ def self.parse(hash)
87
+ if hash.nil? or (hash.kind_of?(Hash) == false)
88
+ return nil
89
+ end
90
+
91
+ return Authlete::Model::TaggedValue.new(hash)
92
+ end
93
+
94
+ # Set attribute values using the given hash.
95
+ def update(hash)
96
+ authlete_model_taggedValue_update(hash)
97
+ end
98
+
99
+ # Convert this object into a hash.
100
+ def to_hash
101
+ hash = {}
102
+
103
+ instance_variables.each do |var|
104
+ key = var.to_s.delete("@").to_sym
105
+ val = instance_variable_get(var)
106
+
107
+ hash[key] = val
108
+ end
109
+
110
+ return hash
111
+ end
112
+
113
+ def [](key)
114
+ key = authlete_model_taggedValue_to_key(key)
115
+
116
+ if respond_to?(key)
117
+ return send(key)
118
+ else
119
+ return nil
120
+ end
121
+ end
122
+
123
+ def []=(key, value)
124
+ key = authlete_model_taggedValue_to_key(key)
125
+ method = "#{key}="
126
+
127
+ if respond_to?(method)
128
+ return send(method, value)
129
+ else
130
+ return nil
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end