unienv_api 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 +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/LICENSE +18 -0
- data/README.md +41 -0
- data/lib/api_gen/README.md +103 -0
- data/lib/api_gen/docs/Group.md +12 -0
- data/lib/api_gen/docs/Institute.md +10 -0
- data/lib/api_gen/docs/Profile.md +17 -0
- data/lib/api_gen/docs/ProfileApi.md +65 -0
- data/lib/api_gen/lib/swagger_client/api/profile_api.rb +77 -0
- data/lib/api_gen/lib/swagger_client/api_client.rb +391 -0
- data/lib/api_gen/lib/swagger_client/api_error.rb +38 -0
- data/lib/api_gen/lib/swagger_client/configuration.rb +209 -0
- data/lib/api_gen/lib/swagger_client/models/group.rb +303 -0
- data/lib/api_gen/lib/swagger_client/models/institute.rb +250 -0
- data/lib/api_gen/lib/swagger_client/models/profile.rb +425 -0
- data/lib/api_gen/lib/swagger_client/version.rb +15 -0
- data/lib/api_gen/lib/swagger_client.rb +43 -0
- data/lib/api_gen/spec/api/profile_api_spec.rb +48 -0
- data/lib/api_gen/spec/api_client_spec.rb +243 -0
- data/lib/api_gen/spec/configuration_spec.rb +42 -0
- data/lib/api_gen/spec/models/group_spec.rb +65 -0
- data/lib/api_gen/spec/models/institute_spec.rb +53 -0
- data/lib/api_gen/spec/models/profile_spec.rb +99 -0
- data/lib/api_gen/spec/spec_helper.rb +111 -0
- data/lib/unienv_api/version.rb +3 -0
- data/lib/unienv_api.rb +44 -0
- metadata +285 -0
@@ -0,0 +1,303 @@
|
|
1
|
+
=begin
|
2
|
+
#UniEnv Core API
|
3
|
+
|
4
|
+
#Документация по API UniEnv
|
5
|
+
|
6
|
+
OpenAPI spec version: v1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.24-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SwaggerClient
|
16
|
+
# Группа студента
|
17
|
+
class Group
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :title
|
21
|
+
|
22
|
+
attr_accessor :start_year
|
23
|
+
|
24
|
+
attr_accessor :end_year
|
25
|
+
|
26
|
+
# Номер курса
|
27
|
+
attr_accessor :current_course
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'id' => :'id',
|
33
|
+
:'title' => :'title',
|
34
|
+
:'start_year' => :'start_year',
|
35
|
+
:'end_year' => :'end_year',
|
36
|
+
:'current_course' => :'current_course'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Attribute type mapping.
|
41
|
+
def self.swagger_types
|
42
|
+
{
|
43
|
+
:'id' => :'Integer',
|
44
|
+
:'title' => :'String',
|
45
|
+
:'start_year' => :'Integer',
|
46
|
+
:'end_year' => :'Integer',
|
47
|
+
:'current_course' => :'String'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Initializes the object
|
52
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
53
|
+
def initialize(attributes = {})
|
54
|
+
return unless attributes.is_a?(Hash)
|
55
|
+
|
56
|
+
# convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
58
|
+
|
59
|
+
if attributes.has_key?(:'id')
|
60
|
+
self.id = attributes[:'id']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'title')
|
64
|
+
self.title = attributes[:'title']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.has_key?(:'start_year')
|
68
|
+
self.start_year = attributes[:'start_year']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.has_key?(:'end_year')
|
72
|
+
self.end_year = attributes[:'end_year']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes.has_key?(:'current_course')
|
76
|
+
self.current_course = attributes[:'current_course']
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
81
|
+
# @return Array for valid properties with the reasons
|
82
|
+
def list_invalid_properties
|
83
|
+
invalid_properties = Array.new
|
84
|
+
if @title.nil?
|
85
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
86
|
+
end
|
87
|
+
|
88
|
+
if @title.to_s.length > 50
|
89
|
+
invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 50.')
|
90
|
+
end
|
91
|
+
|
92
|
+
if @title.to_s.length < 1
|
93
|
+
invalid_properties.push('invalid value for "title", the character length must be great than or equal to 1.')
|
94
|
+
end
|
95
|
+
|
96
|
+
if !@start_year.nil? && @start_year > 2147483647
|
97
|
+
invalid_properties.push('invalid value for "start_year", must be smaller than or equal to 2147483647.')
|
98
|
+
end
|
99
|
+
|
100
|
+
if !@start_year.nil? && @start_year < -2147483648
|
101
|
+
invalid_properties.push('invalid value for "start_year", must be greater than or equal to -2147483648.')
|
102
|
+
end
|
103
|
+
|
104
|
+
if !@end_year.nil? && @end_year > 2147483647
|
105
|
+
invalid_properties.push('invalid value for "end_year", must be smaller than or equal to 2147483647.')
|
106
|
+
end
|
107
|
+
|
108
|
+
if !@end_year.nil? && @end_year < -2147483648
|
109
|
+
invalid_properties.push('invalid value for "end_year", must be greater than or equal to -2147483648.')
|
110
|
+
end
|
111
|
+
|
112
|
+
invalid_properties
|
113
|
+
end
|
114
|
+
|
115
|
+
# Check to see if the all the properties in the model are valid
|
116
|
+
# @return true if the model is valid
|
117
|
+
def valid?
|
118
|
+
return false if @title.nil?
|
119
|
+
return false if @title.to_s.length > 50
|
120
|
+
return false if @title.to_s.length < 1
|
121
|
+
return false if !@start_year.nil? && @start_year > 2147483647
|
122
|
+
return false if !@start_year.nil? && @start_year < -2147483648
|
123
|
+
return false if !@end_year.nil? && @end_year > 2147483647
|
124
|
+
return false if !@end_year.nil? && @end_year < -2147483648
|
125
|
+
true
|
126
|
+
end
|
127
|
+
|
128
|
+
# Custom attribute writer method with validation
|
129
|
+
# @param [Object] title Value to be assigned
|
130
|
+
def title=(title)
|
131
|
+
if title.nil?
|
132
|
+
fail ArgumentError, 'title cannot be nil'
|
133
|
+
end
|
134
|
+
|
135
|
+
if title.to_s.length > 50
|
136
|
+
fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 50.'
|
137
|
+
end
|
138
|
+
|
139
|
+
if title.to_s.length < 1
|
140
|
+
fail ArgumentError, 'invalid value for "title", the character length must be great than or equal to 1.'
|
141
|
+
end
|
142
|
+
|
143
|
+
@title = title
|
144
|
+
end
|
145
|
+
|
146
|
+
# Custom attribute writer method with validation
|
147
|
+
# @param [Object] start_year Value to be assigned
|
148
|
+
def start_year=(start_year)
|
149
|
+
if !start_year.nil? && start_year > 2147483647
|
150
|
+
fail ArgumentError, 'invalid value for "start_year", must be smaller than or equal to 2147483647.'
|
151
|
+
end
|
152
|
+
|
153
|
+
if !start_year.nil? && start_year < -2147483648
|
154
|
+
fail ArgumentError, 'invalid value for "start_year", must be greater than or equal to -2147483648.'
|
155
|
+
end
|
156
|
+
|
157
|
+
@start_year = start_year
|
158
|
+
end
|
159
|
+
|
160
|
+
# Custom attribute writer method with validation
|
161
|
+
# @param [Object] end_year Value to be assigned
|
162
|
+
def end_year=(end_year)
|
163
|
+
if !end_year.nil? && end_year > 2147483647
|
164
|
+
fail ArgumentError, 'invalid value for "end_year", must be smaller than or equal to 2147483647.'
|
165
|
+
end
|
166
|
+
|
167
|
+
if !end_year.nil? && end_year < -2147483648
|
168
|
+
fail ArgumentError, 'invalid value for "end_year", must be greater than or equal to -2147483648.'
|
169
|
+
end
|
170
|
+
|
171
|
+
@end_year = end_year
|
172
|
+
end
|
173
|
+
|
174
|
+
# Checks equality by comparing each attribute.
|
175
|
+
# @param [Object] Object to be compared
|
176
|
+
def ==(o)
|
177
|
+
return true if self.equal?(o)
|
178
|
+
self.class == o.class &&
|
179
|
+
id == o.id &&
|
180
|
+
title == o.title &&
|
181
|
+
start_year == o.start_year &&
|
182
|
+
end_year == o.end_year &&
|
183
|
+
current_course == o.current_course
|
184
|
+
end
|
185
|
+
|
186
|
+
# @see the `==` method
|
187
|
+
# @param [Object] Object to be compared
|
188
|
+
def eql?(o)
|
189
|
+
self == o
|
190
|
+
end
|
191
|
+
|
192
|
+
# Calculates hash code according to all attributes.
|
193
|
+
# @return [Fixnum] Hash code
|
194
|
+
def hash
|
195
|
+
[id, title, start_year, end_year, current_course].hash
|
196
|
+
end
|
197
|
+
|
198
|
+
# Builds the object from hash
|
199
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
200
|
+
# @return [Object] Returns the model itself
|
201
|
+
def build_from_hash(attributes)
|
202
|
+
return nil unless attributes.is_a?(Hash)
|
203
|
+
self.class.swagger_types.each_pair do |key, type|
|
204
|
+
if type =~ /\AArray<(.*)>/i
|
205
|
+
# check to ensure the input is an array given that the attribute
|
206
|
+
# is documented as an array but the input is not
|
207
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
208
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
209
|
+
end
|
210
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
211
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
212
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
213
|
+
end
|
214
|
+
|
215
|
+
self
|
216
|
+
end
|
217
|
+
|
218
|
+
# Deserializes the data based on type
|
219
|
+
# @param string type Data type
|
220
|
+
# @param string value Value to be deserialized
|
221
|
+
# @return [Object] Deserialized data
|
222
|
+
def _deserialize(type, value)
|
223
|
+
case type.to_sym
|
224
|
+
when :DateTime
|
225
|
+
DateTime.parse(value)
|
226
|
+
when :Date
|
227
|
+
Date.parse(value)
|
228
|
+
when :String
|
229
|
+
value.to_s
|
230
|
+
when :Integer
|
231
|
+
value.to_i
|
232
|
+
when :Float
|
233
|
+
value.to_f
|
234
|
+
when :BOOLEAN
|
235
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
236
|
+
true
|
237
|
+
else
|
238
|
+
false
|
239
|
+
end
|
240
|
+
when :Object
|
241
|
+
# generic object (usually a Hash), return directly
|
242
|
+
value
|
243
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
244
|
+
inner_type = Regexp.last_match[:inner_type]
|
245
|
+
value.map { |v| _deserialize(inner_type, v) }
|
246
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
247
|
+
k_type = Regexp.last_match[:k_type]
|
248
|
+
v_type = Regexp.last_match[:v_type]
|
249
|
+
{}.tap do |hash|
|
250
|
+
value.each do |k, v|
|
251
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
else # model
|
255
|
+
temp_model = SwaggerClient.const_get(type).new
|
256
|
+
temp_model.build_from_hash(value)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
# Returns the string representation of the object
|
261
|
+
# @return [String] String presentation of the object
|
262
|
+
def to_s
|
263
|
+
to_hash.to_s
|
264
|
+
end
|
265
|
+
|
266
|
+
# to_body is an alias to to_hash (backward compatibility)
|
267
|
+
# @return [Hash] Returns the object in the form of hash
|
268
|
+
def to_body
|
269
|
+
to_hash
|
270
|
+
end
|
271
|
+
|
272
|
+
# Returns the object in the form of hash
|
273
|
+
# @return [Hash] Returns the object in the form of hash
|
274
|
+
def to_hash
|
275
|
+
hash = {}
|
276
|
+
self.class.attribute_map.each_pair do |attr, param|
|
277
|
+
value = self.send(attr)
|
278
|
+
next if value.nil?
|
279
|
+
hash[param] = _to_hash(value)
|
280
|
+
end
|
281
|
+
hash
|
282
|
+
end
|
283
|
+
|
284
|
+
# Outputs non-array value in the form of hash
|
285
|
+
# For object, use to_hash. Otherwise, just return the value
|
286
|
+
# @param [Object] value Any valid value
|
287
|
+
# @return [Hash] Returns the value in the form of hash
|
288
|
+
def _to_hash(value)
|
289
|
+
if value.is_a?(Array)
|
290
|
+
value.compact.map { |v| _to_hash(v) }
|
291
|
+
elsif value.is_a?(Hash)
|
292
|
+
{}.tap do |hash|
|
293
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
294
|
+
end
|
295
|
+
elsif value.respond_to? :to_hash
|
296
|
+
value.to_hash
|
297
|
+
else
|
298
|
+
value
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
=begin
|
2
|
+
#UniEnv Core API
|
3
|
+
|
4
|
+
#Документация по API UniEnv
|
5
|
+
|
6
|
+
OpenAPI spec version: v1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.24-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SwaggerClient
|
16
|
+
class Institute
|
17
|
+
attr_accessor :id
|
18
|
+
|
19
|
+
attr_accessor :title
|
20
|
+
|
21
|
+
attr_accessor :short_title
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:'id' => :'id',
|
27
|
+
:'title' => :'title',
|
28
|
+
:'short_title' => :'short_title'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.swagger_types
|
34
|
+
{
|
35
|
+
:'id' => :'Integer',
|
36
|
+
:'title' => :'String',
|
37
|
+
:'short_title' => :'String'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Initializes the object
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
43
|
+
def initialize(attributes = {})
|
44
|
+
return unless attributes.is_a?(Hash)
|
45
|
+
|
46
|
+
# convert string to symbol for hash key
|
47
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
48
|
+
|
49
|
+
if attributes.has_key?(:'id')
|
50
|
+
self.id = attributes[:'id']
|
51
|
+
end
|
52
|
+
|
53
|
+
if attributes.has_key?(:'title')
|
54
|
+
self.title = attributes[:'title']
|
55
|
+
end
|
56
|
+
|
57
|
+
if attributes.has_key?(:'short_title')
|
58
|
+
self.short_title = attributes[:'short_title']
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
63
|
+
# @return Array for valid properties with the reasons
|
64
|
+
def list_invalid_properties
|
65
|
+
invalid_properties = Array.new
|
66
|
+
if @title.nil?
|
67
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
68
|
+
end
|
69
|
+
|
70
|
+
if @title.to_s.length > 255
|
71
|
+
invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 255.')
|
72
|
+
end
|
73
|
+
|
74
|
+
if @title.to_s.length < 1
|
75
|
+
invalid_properties.push('invalid value for "title", the character length must be great than or equal to 1.')
|
76
|
+
end
|
77
|
+
|
78
|
+
if !@short_title.nil? && @short_title.to_s.length > 255
|
79
|
+
invalid_properties.push('invalid value for "short_title", the character length must be smaller than or equal to 255.')
|
80
|
+
end
|
81
|
+
|
82
|
+
invalid_properties
|
83
|
+
end
|
84
|
+
|
85
|
+
# Check to see if the all the properties in the model are valid
|
86
|
+
# @return true if the model is valid
|
87
|
+
def valid?
|
88
|
+
return false if @title.nil?
|
89
|
+
return false if @title.to_s.length > 255
|
90
|
+
return false if @title.to_s.length < 1
|
91
|
+
return false if !@short_title.nil? && @short_title.to_s.length > 255
|
92
|
+
true
|
93
|
+
end
|
94
|
+
|
95
|
+
# Custom attribute writer method with validation
|
96
|
+
# @param [Object] title Value to be assigned
|
97
|
+
def title=(title)
|
98
|
+
if title.nil?
|
99
|
+
fail ArgumentError, 'title cannot be nil'
|
100
|
+
end
|
101
|
+
|
102
|
+
if title.to_s.length > 255
|
103
|
+
fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 255.'
|
104
|
+
end
|
105
|
+
|
106
|
+
if title.to_s.length < 1
|
107
|
+
fail ArgumentError, 'invalid value for "title", the character length must be great than or equal to 1.'
|
108
|
+
end
|
109
|
+
|
110
|
+
@title = title
|
111
|
+
end
|
112
|
+
|
113
|
+
# Custom attribute writer method with validation
|
114
|
+
# @param [Object] short_title Value to be assigned
|
115
|
+
def short_title=(short_title)
|
116
|
+
if !short_title.nil? && short_title.to_s.length > 255
|
117
|
+
fail ArgumentError, 'invalid value for "short_title", the character length must be smaller than or equal to 255.'
|
118
|
+
end
|
119
|
+
|
120
|
+
@short_title = short_title
|
121
|
+
end
|
122
|
+
|
123
|
+
# Checks equality by comparing each attribute.
|
124
|
+
# @param [Object] Object to be compared
|
125
|
+
def ==(o)
|
126
|
+
return true if self.equal?(o)
|
127
|
+
self.class == o.class &&
|
128
|
+
id == o.id &&
|
129
|
+
title == o.title &&
|
130
|
+
short_title == o.short_title
|
131
|
+
end
|
132
|
+
|
133
|
+
# @see the `==` method
|
134
|
+
# @param [Object] Object to be compared
|
135
|
+
def eql?(o)
|
136
|
+
self == o
|
137
|
+
end
|
138
|
+
|
139
|
+
# Calculates hash code according to all attributes.
|
140
|
+
# @return [Fixnum] Hash code
|
141
|
+
def hash
|
142
|
+
[id, title, short_title].hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Builds the object from hash
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
147
|
+
# @return [Object] Returns the model itself
|
148
|
+
def build_from_hash(attributes)
|
149
|
+
return nil unless attributes.is_a?(Hash)
|
150
|
+
self.class.swagger_types.each_pair do |key, type|
|
151
|
+
if type =~ /\AArray<(.*)>/i
|
152
|
+
# check to ensure the input is an array given that the attribute
|
153
|
+
# is documented as an array but the input is not
|
154
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
155
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
156
|
+
end
|
157
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
158
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
159
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
160
|
+
end
|
161
|
+
|
162
|
+
self
|
163
|
+
end
|
164
|
+
|
165
|
+
# Deserializes the data based on type
|
166
|
+
# @param string type Data type
|
167
|
+
# @param string value Value to be deserialized
|
168
|
+
# @return [Object] Deserialized data
|
169
|
+
def _deserialize(type, value)
|
170
|
+
case type.to_sym
|
171
|
+
when :DateTime
|
172
|
+
DateTime.parse(value)
|
173
|
+
when :Date
|
174
|
+
Date.parse(value)
|
175
|
+
when :String
|
176
|
+
value.to_s
|
177
|
+
when :Integer
|
178
|
+
value.to_i
|
179
|
+
when :Float
|
180
|
+
value.to_f
|
181
|
+
when :BOOLEAN
|
182
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
183
|
+
true
|
184
|
+
else
|
185
|
+
false
|
186
|
+
end
|
187
|
+
when :Object
|
188
|
+
# generic object (usually a Hash), return directly
|
189
|
+
value
|
190
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
191
|
+
inner_type = Regexp.last_match[:inner_type]
|
192
|
+
value.map { |v| _deserialize(inner_type, v) }
|
193
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
194
|
+
k_type = Regexp.last_match[:k_type]
|
195
|
+
v_type = Regexp.last_match[:v_type]
|
196
|
+
{}.tap do |hash|
|
197
|
+
value.each do |k, v|
|
198
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
else # model
|
202
|
+
temp_model = SwaggerClient.const_get(type).new
|
203
|
+
temp_model.build_from_hash(value)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns the string representation of the object
|
208
|
+
# @return [String] String presentation of the object
|
209
|
+
def to_s
|
210
|
+
to_hash.to_s
|
211
|
+
end
|
212
|
+
|
213
|
+
# to_body is an alias to to_hash (backward compatibility)
|
214
|
+
# @return [Hash] Returns the object in the form of hash
|
215
|
+
def to_body
|
216
|
+
to_hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Returns the object in the form of hash
|
220
|
+
# @return [Hash] Returns the object in the form of hash
|
221
|
+
def to_hash
|
222
|
+
hash = {}
|
223
|
+
self.class.attribute_map.each_pair do |attr, param|
|
224
|
+
value = self.send(attr)
|
225
|
+
next if value.nil?
|
226
|
+
hash[param] = _to_hash(value)
|
227
|
+
end
|
228
|
+
hash
|
229
|
+
end
|
230
|
+
|
231
|
+
# Outputs non-array value in the form of hash
|
232
|
+
# For object, use to_hash. Otherwise, just return the value
|
233
|
+
# @param [Object] value Any valid value
|
234
|
+
# @return [Hash] Returns the value in the form of hash
|
235
|
+
def _to_hash(value)
|
236
|
+
if value.is_a?(Array)
|
237
|
+
value.compact.map { |v| _to_hash(v) }
|
238
|
+
elsif value.is_a?(Hash)
|
239
|
+
{}.tap do |hash|
|
240
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
241
|
+
end
|
242
|
+
elsif value.respond_to? :to_hash
|
243
|
+
value.to_hash
|
244
|
+
else
|
245
|
+
value
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
end
|