avm_client 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.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +104 -0
  5. data/Rakefile +10 -0
  6. data/avm_client.gemspec +45 -0
  7. data/docs/AdditionalFeatures.md +53 -0
  8. data/docs/BuiltForm.md +16 -0
  9. data/docs/DefaultApi.md +67 -0
  10. data/docs/EnergyEfficiency.md +16 -0
  11. data/docs/EnergyRating.md +16 -0
  12. data/docs/FloorLevel.md +16 -0
  13. data/docs/LeaseholdOrFreehold.md +16 -0
  14. data/docs/NewOrResale.md +16 -0
  15. data/docs/Problem.md +25 -0
  16. data/docs/PropertyFeatures.md +19 -0
  17. data/docs/PropertyType.md +16 -0
  18. data/docs/RequiredFeatures.md +27 -0
  19. data/docs/RoofInsulation.md +16 -0
  20. data/docs/RoofType.md +16 -0
  21. data/docs/Valuation.md +25 -0
  22. data/docs/ValuationPriceDistribution.md +21 -0
  23. data/docs/WallInsulation.md +16 -0
  24. data/docs/WallType.md +16 -0
  25. data/docs/WindowGlazingType.md +16 -0
  26. data/lib/avm_client/api/default_api.rb +146 -0
  27. data/lib/avm_client/avm_client.rb +386 -0
  28. data/lib/avm_client/avm_error.rb +57 -0
  29. data/lib/avm_client/configuration.rb +248 -0
  30. data/lib/avm_client/models/additional_features.rb +373 -0
  31. data/lib/avm_client/models/built_form.rb +40 -0
  32. data/lib/avm_client/models/energy_efficiency.rb +39 -0
  33. data/lib/avm_client/models/energy_rating.rb +42 -0
  34. data/lib/avm_client/models/floor_level.rb +59 -0
  35. data/lib/avm_client/models/leasehold_or_freehold.rb +36 -0
  36. data/lib/avm_client/models/new_or_resale.rb +36 -0
  37. data/lib/avm_client/models/problem.rb +264 -0
  38. data/lib/avm_client/models/property_features.rb +210 -0
  39. data/lib/avm_client/models/property_type.rb +38 -0
  40. data/lib/avm_client/models/required_features.rb +329 -0
  41. data/lib/avm_client/models/roof_insulation.rb +39 -0
  42. data/lib/avm_client/models/roof_type.rb +38 -0
  43. data/lib/avm_client/models/valuation.rb +239 -0
  44. data/lib/avm_client/models/valuation_price_distribution.rb +217 -0
  45. data/lib/avm_client/models/wall_insulation.rb +38 -0
  46. data/lib/avm_client/models/wall_type.rb +42 -0
  47. data/lib/avm_client/models/window_glazing_type.rb +40 -0
  48. data/lib/avm_client/version.rb +15 -0
  49. data/lib/avm_client.rb +58 -0
  50. metadata +272 -0
@@ -0,0 +1,329 @@
1
+ =begin
2
+ #AVM
3
+
4
+ #This is api for AVM (automated valuation machine)
5
+
6
+ The version of the AvmClient document: 1.0.0
7
+ Contact: info@enbisys.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AvmClient
16
+ class RequiredFeatures
17
+ # Postcode
18
+ attr_accessor :postcode
19
+
20
+ attr_accessor :new_or_resale
21
+
22
+ attr_accessor :floor_level
23
+
24
+ # Floor area (sqf)
25
+ attr_accessor :total_floor_area_in_sqf
26
+
27
+ attr_accessor :property_type
28
+
29
+ attr_accessor :number_of_rooms
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'postcode' => :'postcode',
35
+ :'new_or_resale' => :'newOrResale',
36
+ :'floor_level' => :'floorLevel',
37
+ :'total_floor_area_in_sqf' => :'totalFloorAreaInSqf',
38
+ :'property_type' => :'propertyType',
39
+ :'number_of_rooms' => :'numberOfRooms'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.avm_types
45
+ {
46
+ :'postcode' => :'String',
47
+ :'new_or_resale' => :'NewOrResale',
48
+ :'floor_level' => :'FloorLevel',
49
+ :'total_floor_area_in_sqf' => :'Integer',
50
+ :'property_type' => :'PropertyType',
51
+ :'number_of_rooms' => :'Integer'
52
+ }
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AvmClient::RequiredFeatures` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AvmClient::RequiredFeatures`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'postcode')
71
+ self.postcode = attributes[:'postcode']
72
+ end
73
+
74
+ if attributes.key?(:'new_or_resale')
75
+ self.new_or_resale = attributes[:'new_or_resale']
76
+ end
77
+
78
+ if attributes.key?(:'floor_level')
79
+ self.floor_level = attributes[:'floor_level']
80
+ end
81
+
82
+ if attributes.key?(:'total_floor_area_in_sqf')
83
+ self.total_floor_area_in_sqf = attributes[:'total_floor_area_in_sqf']
84
+ end
85
+
86
+ if attributes.key?(:'property_type')
87
+ self.property_type = attributes[:'property_type']
88
+ end
89
+
90
+ if attributes.key?(:'number_of_rooms')
91
+ self.number_of_rooms = attributes[:'number_of_rooms']
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ invalid_properties = Array.new
99
+ if @postcode.nil?
100
+ invalid_properties.push('invalid value for "postcode", postcode cannot be nil.')
101
+ end
102
+
103
+ if @new_or_resale.nil?
104
+ invalid_properties.push('invalid value for "new_or_resale", new_or_resale cannot be nil.')
105
+ end
106
+
107
+ if @floor_level.nil?
108
+ invalid_properties.push('invalid value for "floor_level", floor_level cannot be nil.')
109
+ end
110
+
111
+ if @total_floor_area_in_sqf.nil?
112
+ invalid_properties.push('invalid value for "total_floor_area_in_sqf", total_floor_area_in_sqf cannot be nil.')
113
+ end
114
+
115
+ if @total_floor_area_in_sqf > 10000
116
+ invalid_properties.push('invalid value for "total_floor_area_in_sqf", must be smaller than or equal to 10000.')
117
+ end
118
+
119
+ if @total_floor_area_in_sqf < 50
120
+ invalid_properties.push('invalid value for "total_floor_area_in_sqf", must be greater than or equal to 50.')
121
+ end
122
+
123
+ if @property_type.nil?
124
+ invalid_properties.push('invalid value for "property_type", property_type cannot be nil.')
125
+ end
126
+
127
+ if @number_of_rooms.nil?
128
+ invalid_properties.push('invalid value for "number_of_rooms", number_of_rooms cannot be nil.')
129
+ end
130
+
131
+ if @number_of_rooms > 9
132
+ invalid_properties.push('invalid value for "number_of_rooms", must be smaller than or equal to 9.')
133
+ end
134
+
135
+ if @number_of_rooms < 1
136
+ invalid_properties.push('invalid value for "number_of_rooms", must be greater than or equal to 1.')
137
+ end
138
+
139
+ invalid_properties
140
+ end
141
+
142
+ # Check to see if the all the properties in the model are valid
143
+ # @return true if the model is valid
144
+ def valid?
145
+ return false if @postcode.nil?
146
+ return false if @new_or_resale.nil?
147
+ return false if @floor_level.nil?
148
+ return false if @total_floor_area_in_sqf.nil?
149
+ return false if @total_floor_area_in_sqf > 10000
150
+ return false if @total_floor_area_in_sqf < 50
151
+ return false if @property_type.nil?
152
+ return false if @number_of_rooms.nil?
153
+ return false if @number_of_rooms > 9
154
+ return false if @number_of_rooms < 1
155
+ true
156
+ end
157
+
158
+ # Custom attribute writer method with validation
159
+ # @param [Object] total_floor_area_in_sqf Value to be assigned
160
+ def total_floor_area_in_sqf=(total_floor_area_in_sqf)
161
+ if total_floor_area_in_sqf.nil?
162
+ fail ArgumentError, 'total_floor_area_in_sqf cannot be nil'
163
+ end
164
+
165
+ if total_floor_area_in_sqf > 10000
166
+ fail ArgumentError, 'invalid value for "total_floor_area_in_sqf", must be smaller than or equal to 10000.'
167
+ end
168
+
169
+ if total_floor_area_in_sqf < 50
170
+ fail ArgumentError, 'invalid value for "total_floor_area_in_sqf", must be greater than or equal to 50.'
171
+ end
172
+
173
+ @total_floor_area_in_sqf = total_floor_area_in_sqf
174
+ end
175
+
176
+ # Custom attribute writer method with validation
177
+ # @param [Object] number_of_rooms Value to be assigned
178
+ def number_of_rooms=(number_of_rooms)
179
+ if number_of_rooms.nil?
180
+ fail ArgumentError, 'number_of_rooms cannot be nil'
181
+ end
182
+
183
+ if number_of_rooms > 9
184
+ fail ArgumentError, 'invalid value for "number_of_rooms", must be smaller than or equal to 9.'
185
+ end
186
+
187
+ if number_of_rooms < 1
188
+ fail ArgumentError, 'invalid value for "number_of_rooms", must be greater than or equal to 1.'
189
+ end
190
+
191
+ @number_of_rooms = number_of_rooms
192
+ end
193
+
194
+ # Checks equality by comparing each attribute.
195
+ # @param [Object] Object to be compared
196
+ def ==(o)
197
+ return true if self.equal?(o)
198
+ self.class == o.class &&
199
+ postcode == o.postcode &&
200
+ new_or_resale == o.new_or_resale &&
201
+ floor_level == o.floor_level &&
202
+ total_floor_area_in_sqf == o.total_floor_area_in_sqf &&
203
+ property_type == o.property_type &&
204
+ number_of_rooms == o.number_of_rooms
205
+ end
206
+
207
+ # @see the `==` method
208
+ # @param [Object] Object to be compared
209
+ def eql?(o)
210
+ self == o
211
+ end
212
+
213
+ # Calculates hash code according to all attributes.
214
+ # @return [Integer] Hash code
215
+ def hash
216
+ [postcode, new_or_resale, floor_level, total_floor_area_in_sqf, property_type, number_of_rooms].hash
217
+ end
218
+
219
+ # Builds the object from hash
220
+ # @param [Hash] attributes Model attributes in the form of hash
221
+ # @return [Object] Returns the model itself
222
+ def self.build_from_hash(attributes)
223
+ new.build_from_hash(attributes)
224
+ end
225
+
226
+ # Builds the object from hash
227
+ # @param [Hash] attributes Model attributes in the form of hash
228
+ # @return [Object] Returns the model itself
229
+ def build_from_hash(attributes)
230
+ return nil unless attributes.is_a?(Hash)
231
+ self.class.avm_types.each_pair do |key, type|
232
+ if type =~ /\AArray<(.*)>/i
233
+ # check to ensure the input is an array given that the attribute
234
+ # is documented as an array but the input is not
235
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
236
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
237
+ end
238
+ elsif !attributes[self.class.attribute_map[key]].nil?
239
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
240
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
241
+ end
242
+
243
+ self
244
+ end
245
+
246
+ # Deserializes the data based on type
247
+ # @param string type Data type
248
+ # @param string value Value to be deserialized
249
+ # @return [Object] Deserialized data
250
+ def _deserialize(type, value)
251
+ case type.to_sym
252
+ when :DateTime
253
+ DateTime.parse(value)
254
+ when :Date
255
+ Date.parse(value)
256
+ when :String
257
+ value.to_s
258
+ when :Integer
259
+ value.to_i
260
+ when :Float
261
+ value.to_f
262
+ when :Boolean
263
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
264
+ true
265
+ else
266
+ false
267
+ end
268
+ when :Object
269
+ # generic object (usually a Hash), return directly
270
+ value
271
+ when /\AArray<(?<inner_type>.+)>\z/
272
+ inner_type = Regexp.last_match[:inner_type]
273
+ value.map { |v| _deserialize(inner_type, v) }
274
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
275
+ k_type = Regexp.last_match[:k_type]
276
+ v_type = Regexp.last_match[:v_type]
277
+ {}.tap do |hash|
278
+ value.each do |k, v|
279
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
280
+ end
281
+ end
282
+ else # model
283
+ AvmClient.const_get(type).build_from_hash(value)
284
+ end
285
+ end
286
+
287
+ # Returns the string representation of the object
288
+ # @return [String] String presentation of the object
289
+ def to_s
290
+ to_hash.to_s
291
+ end
292
+
293
+ # to_body is an alias to to_hash (backward compatibility)
294
+ # @return [Hash] Returns the object in the form of hash
295
+ def to_body
296
+ to_hash
297
+ end
298
+
299
+ # Returns the object in the form of hash
300
+ # @return [Hash] Returns the object in the form of hash
301
+ def to_hash
302
+ hash = {}
303
+ self.class.attribute_map.each_pair do |attr, param|
304
+ value = self.send(attr)
305
+ next if value.nil?
306
+ hash[param] = _to_hash(value)
307
+ end
308
+ hash
309
+ end
310
+
311
+ # Outputs non-array value in the form of hash
312
+ # For object, use to_hash. Otherwise, just return the value
313
+ # @param [Object] value Any valid value
314
+ # @return [Hash] Returns the value in the form of hash
315
+ def _to_hash(value)
316
+ if value.is_a?(Array)
317
+ value.compact.map { |v| _to_hash(v) }
318
+ elsif value.is_a?(Hash)
319
+ {}.tap do |hash|
320
+ value.each { |k, v| hash[k] = _to_hash(v) }
321
+ end
322
+ elsif value.respond_to? :to_hash
323
+ value.to_hash
324
+ else
325
+ value
326
+ end
327
+ end
328
+ end
329
+ end
@@ -0,0 +1,39 @@
1
+ =begin
2
+ #AVM
3
+
4
+ #This is api for AVM (automated valuation machine)
5
+
6
+ The version of the AvmClient document: 1.0.0
7
+ Contact: info@enbisys.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AvmClient
16
+ class RoofInsulation
17
+ NO = "no".freeze
18
+ PARTIAL = "partial".freeze
19
+ INSULATED = "insulated".freeze
20
+ ADDITIONAL = "additional".freeze
21
+ DWELLING = "dwelling".freeze
22
+
23
+ # Builds the enum from string
24
+ # @param [String] The enum value in the form of the string
25
+ # @return [String] The enum value
26
+ def self.build_from_hash(value)
27
+ new.build_from_hash(value)
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def build_from_hash(value)
34
+ constantValues = RoofInsulation.constants.select { |c| RoofInsulation::const_get(c) == value }
35
+ raise "Invalid ENUM value #{value} for class #RoofInsulation" if constantValues.empty?
36
+ value
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,38 @@
1
+ =begin
2
+ #AVM
3
+
4
+ #This is api for AVM (automated valuation machine)
5
+
6
+ The version of the AvmClient document: 1.0.0
7
+ Contact: info@enbisys.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AvmClient
16
+ class RoofType
17
+ PITCHED = "pitched".freeze
18
+ FLAT = "flat".freeze
19
+ THATCHED = "thatched".freeze
20
+ DWELLING = "dwelling".freeze
21
+
22
+ # Builds the enum from string
23
+ # @param [String] The enum value in the form of the string
24
+ # @return [String] The enum value
25
+ def self.build_from_hash(value)
26
+ new.build_from_hash(value)
27
+ end
28
+
29
+ # Builds the enum from string
30
+ # @param [String] The enum value in the form of the string
31
+ # @return [String] The enum value
32
+ def build_from_hash(value)
33
+ constantValues = RoofType.constants.select { |c| RoofType::const_get(c) == value }
34
+ raise "Invalid ENUM value #{value} for class #RoofType" if constantValues.empty?
35
+ value
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,239 @@
1
+ =begin
2
+ #AVM
3
+
4
+ #This is api for AVM (automated valuation machine)
5
+
6
+ The version of the AvmClient document: 1.0.0
7
+ Contact: info@enbisys.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AvmClient
16
+ class Valuation
17
+ # Predicted price, pound
18
+ attr_accessor :most_probable_price
19
+
20
+ # Lower price boundary, pound
21
+ attr_accessor :price_range_from
22
+
23
+ # Higher price boundary, pound
24
+ attr_accessor :price_range_to
25
+
26
+ # Probability (in percents) that actual price is within the specified boundaries
27
+ attr_accessor :confidence
28
+
29
+ # Describes the probabilities (in percents) that actual price is within particular subranges
30
+ attr_accessor :price_distribution
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'most_probable_price' => :'mostProbablePrice',
36
+ :'price_range_from' => :'priceRangeFrom',
37
+ :'price_range_to' => :'priceRangeTo',
38
+ :'confidence' => :'confidence',
39
+ :'price_distribution' => :'priceDistribution'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.avm_types
45
+ {
46
+ :'most_probable_price' => :'Integer',
47
+ :'price_range_from' => :'Integer',
48
+ :'price_range_to' => :'Integer',
49
+ :'confidence' => :'Integer',
50
+ :'price_distribution' => :'Array<ValuationPriceDistribution>'
51
+ }
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AvmClient::Valuation` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AvmClient::Valuation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'most_probable_price')
70
+ self.most_probable_price = attributes[:'most_probable_price']
71
+ end
72
+
73
+ if attributes.key?(:'price_range_from')
74
+ self.price_range_from = attributes[:'price_range_from']
75
+ end
76
+
77
+ if attributes.key?(:'price_range_to')
78
+ self.price_range_to = attributes[:'price_range_to']
79
+ end
80
+
81
+ if attributes.key?(:'confidence')
82
+ self.confidence = attributes[:'confidence']
83
+ end
84
+
85
+ if attributes.key?(:'price_distribution')
86
+ if (value = attributes[:'price_distribution']).is_a?(Array)
87
+ self.price_distribution = value
88
+ end
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ invalid_properties = Array.new
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ true
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ most_probable_price == o.most_probable_price &&
111
+ price_range_from == o.price_range_from &&
112
+ price_range_to == o.price_range_to &&
113
+ confidence == o.confidence &&
114
+ price_distribution == o.price_distribution
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(o)
120
+ self == o
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [most_probable_price, price_range_from, price_range_to, confidence, price_distribution].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ new.build_from_hash(attributes)
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ self.class.avm_types.each_pair do |key, type|
142
+ if type =~ /\AArray<(.*)>/i
143
+ # check to ensure the input is an array given that the attribute
144
+ # is documented as an array but the input is not
145
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
146
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
147
+ end
148
+ elsif !attributes[self.class.attribute_map[key]].nil?
149
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
150
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
151
+ end
152
+
153
+ self
154
+ end
155
+
156
+ # Deserializes the data based on type
157
+ # @param string type Data type
158
+ # @param string value Value to be deserialized
159
+ # @return [Object] Deserialized data
160
+ def _deserialize(type, value)
161
+ case type.to_sym
162
+ when :DateTime
163
+ DateTime.parse(value)
164
+ when :Date
165
+ Date.parse(value)
166
+ when :String
167
+ value.to_s
168
+ when :Integer
169
+ value.to_i
170
+ when :Float
171
+ value.to_f
172
+ when :Boolean
173
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
174
+ true
175
+ else
176
+ false
177
+ end
178
+ when :Object
179
+ # generic object (usually a Hash), return directly
180
+ value
181
+ when /\AArray<(?<inner_type>.+)>\z/
182
+ inner_type = Regexp.last_match[:inner_type]
183
+ value.map { |v| _deserialize(inner_type, v) }
184
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
185
+ k_type = Regexp.last_match[:k_type]
186
+ v_type = Regexp.last_match[:v_type]
187
+ {}.tap do |hash|
188
+ value.each do |k, v|
189
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
190
+ end
191
+ end
192
+ else # model
193
+ AvmClient.const_get(type).build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ next if value.nil?
216
+ hash[param] = _to_hash(value)
217
+ end
218
+ hash
219
+ end
220
+
221
+ # Outputs non-array value in the form of hash
222
+ # For object, use to_hash. Otherwise, just return the value
223
+ # @param [Object] value Any valid value
224
+ # @return [Hash] Returns the value in the form of hash
225
+ def _to_hash(value)
226
+ if value.is_a?(Array)
227
+ value.compact.map { |v| _to_hash(v) }
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.each { |k, v| hash[k] = _to_hash(v) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash
234
+ else
235
+ value
236
+ end
237
+ end
238
+ end
239
+ end