xbim_comms 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +210 -0
  4. data/Rakefile +10 -0
  5. data/lib/xbim_comms/api/contacts_api.rb +206 -0
  6. data/lib/xbim_comms/api/conversations_api.rb +2670 -0
  7. data/lib/xbim_comms/api/files_api.rb +107 -0
  8. data/lib/xbim_comms/api/snapshots_api.rb +100 -0
  9. data/lib/xbim_comms/api_client.rb +390 -0
  10. data/lib/xbim_comms/api_error.rb +57 -0
  11. data/lib/xbim_comms/configuration.rb +278 -0
  12. data/lib/xbim_comms/models/aggregate.rb +227 -0
  13. data/lib/xbim_comms/models/aggregate_list_value.rb +220 -0
  14. data/lib/xbim_comms/models/analytical_result.rb +270 -0
  15. data/lib/xbim_comms/models/analytical_result_all_of.rb +258 -0
  16. data/lib/xbim_comms/models/animation.rb +232 -0
  17. data/lib/xbim_comms/models/animation_all_of.rb +220 -0
  18. data/lib/xbim_comms/models/bitmap.rb +303 -0
  19. data/lib/xbim_comms/models/blob.rb +245 -0
  20. data/lib/xbim_comms/models/boolean_value.rb +218 -0
  21. data/lib/xbim_comms/models/clipping_plane.rb +231 -0
  22. data/lib/xbim_comms/models/coloring.rb +229 -0
  23. data/lib/xbim_comms/models/column_request.rb +279 -0
  24. data/lib/xbim_comms/models/component.rb +236 -0
  25. data/lib/xbim_comms/models/components.rb +240 -0
  26. data/lib/xbim_comms/models/contact.rb +227 -0
  27. data/lib/xbim_comms/models/contact_list.rb +238 -0
  28. data/lib/xbim_comms/models/conversation.rb +392 -0
  29. data/lib/xbim_comms/models/conversation_create.rb +273 -0
  30. data/lib/xbim_comms/models/conversation_list.rb +238 -0
  31. data/lib/xbim_comms/models/conversation_tenant.rb +254 -0
  32. data/lib/xbim_comms/models/conversation_update.rb +302 -0
  33. data/lib/xbim_comms/models/entity_key.rb +227 -0
  34. data/lib/xbim_comms/models/exception_message.rb +245 -0
  35. data/lib/xbim_comms/models/file.rb +266 -0
  36. data/lib/xbim_comms/models/file_all_of.rb +254 -0
  37. data/lib/xbim_comms/models/int32_value.rb +218 -0
  38. data/lib/xbim_comms/models/key_frame.rb +236 -0
  39. data/lib/xbim_comms/models/line.rb +231 -0
  40. data/lib/xbim_comms/models/message.rb +416 -0
  41. data/lib/xbim_comms/models/message_content.rb +220 -0
  42. data/lib/xbim_comms/models/message_create.rb +273 -0
  43. data/lib/xbim_comms/models/message_list.rb +238 -0
  44. data/lib/xbim_comms/models/message_part.rb +246 -0
  45. data/lib/xbim_comms/models/message_update.rb +297 -0
  46. data/lib/xbim_comms/models/orthogonal_camera.rb +269 -0
  47. data/lib/xbim_comms/models/participant.rb +232 -0
  48. data/lib/xbim_comms/models/participant_with_role.rb +293 -0
  49. data/lib/xbim_comms/models/participant_with_role_create.rb +266 -0
  50. data/lib/xbim_comms/models/participant_with_role_list.rb +238 -0
  51. data/lib/xbim_comms/models/participant_with_role_update.rb +261 -0
  52. data/lib/xbim_comms/models/perspective_camera.rb +269 -0
  53. data/lib/xbim_comms/models/pie_chart.rb +257 -0
  54. data/lib/xbim_comms/models/pie_chart_all_of.rb +245 -0
  55. data/lib/xbim_comms/models/point.rb +227 -0
  56. data/lib/xbim_comms/models/preview_row.rb +220 -0
  57. data/lib/xbim_comms/models/schedule.rb +270 -0
  58. data/lib/xbim_comms/models/schedule_all_of.rb +258 -0
  59. data/lib/xbim_comms/models/schedule_column.rb +384 -0
  60. data/lib/xbim_comms/models/schedule_request.rb +252 -0
  61. data/lib/xbim_comms/models/schedule_request_all_of.rb +240 -0
  62. data/lib/xbim_comms/models/section_box.rb +274 -0
  63. data/lib/xbim_comms/models/sheet.rb +268 -0
  64. data/lib/xbim_comms/models/sheet_all_of.rb +256 -0
  65. data/lib/xbim_comms/models/sheet_part.rb +254 -0
  66. data/lib/xbim_comms/models/snapshot.rb +270 -0
  67. data/lib/xbim_comms/models/text.rb +220 -0
  68. data/lib/xbim_comms/models/view.rb +239 -0
  69. data/lib/xbim_comms/models/view_all_of.rb +227 -0
  70. data/lib/xbim_comms/models/view_setup_hints.rb +236 -0
  71. data/lib/xbim_comms/models/viewpoint.rb +296 -0
  72. data/lib/xbim_comms/models/visibility.rb +238 -0
  73. data/lib/xbim_comms/version.rb +15 -0
  74. data/lib/xbim_comms.rb +104 -0
  75. data/spec/api/contacts_api_spec.rb +74 -0
  76. data/spec/api/conversations_api_spec.rb +521 -0
  77. data/spec/api/files_api_spec.rb +50 -0
  78. data/spec/api/snapshots_api_spec.rb +49 -0
  79. data/spec/api_client_spec.rb +226 -0
  80. data/spec/configuration_spec.rb +42 -0
  81. data/spec/models/aggregate_list_value_spec.rb +34 -0
  82. data/spec/models/aggregate_spec.rb +40 -0
  83. data/spec/models/analytical_result_all_of_spec.rb +58 -0
  84. data/spec/models/analytical_result_spec.rb +58 -0
  85. data/spec/models/animation_all_of_spec.rb +34 -0
  86. data/spec/models/animation_spec.rb +34 -0
  87. data/spec/models/bitmap_spec.rb +68 -0
  88. data/spec/models/blob_spec.rb +52 -0
  89. data/spec/models/boolean_value_spec.rb +34 -0
  90. data/spec/models/clipping_plane_spec.rb +40 -0
  91. data/spec/models/coloring_spec.rb +40 -0
  92. data/spec/models/column_request_spec.rb +56 -0
  93. data/spec/models/component_spec.rb +46 -0
  94. data/spec/models/components_spec.rb +46 -0
  95. data/spec/models/contact_list_spec.rb +46 -0
  96. data/spec/models/contact_spec.rb +40 -0
  97. data/spec/models/conversation_create_spec.rb +64 -0
  98. data/spec/models/conversation_list_spec.rb +46 -0
  99. data/spec/models/conversation_spec.rb +122 -0
  100. data/spec/models/conversation_tenant_spec.rb +58 -0
  101. data/spec/models/conversation_update_spec.rb +68 -0
  102. data/spec/models/entity_key_spec.rb +40 -0
  103. data/spec/models/exception_message_spec.rb +52 -0
  104. data/spec/models/file_all_of_spec.rb +58 -0
  105. data/spec/models/file_spec.rb +58 -0
  106. data/spec/models/int32_value_spec.rb +34 -0
  107. data/spec/models/key_frame_spec.rb +46 -0
  108. data/spec/models/line_spec.rb +40 -0
  109. data/spec/models/message_content_spec.rb +34 -0
  110. data/spec/models/message_create_spec.rb +64 -0
  111. data/spec/models/message_list_spec.rb +46 -0
  112. data/spec/models/message_part_spec.rb +46 -0
  113. data/spec/models/message_spec.rb +146 -0
  114. data/spec/models/message_update_spec.rb +68 -0
  115. data/spec/models/orthogonal_camera_spec.rb +64 -0
  116. data/spec/models/participant_spec.rb +40 -0
  117. data/spec/models/participant_with_role_create_spec.rb +44 -0
  118. data/spec/models/participant_with_role_list_spec.rb +46 -0
  119. data/spec/models/participant_with_role_spec.rb +62 -0
  120. data/spec/models/participant_with_role_update_spec.rb +44 -0
  121. data/spec/models/perspective_camera_spec.rb +64 -0
  122. data/spec/models/pie_chart_all_of_spec.rb +52 -0
  123. data/spec/models/pie_chart_spec.rb +52 -0
  124. data/spec/models/point_spec.rb +40 -0
  125. data/spec/models/preview_row_spec.rb +34 -0
  126. data/spec/models/schedule_all_of_spec.rb +58 -0
  127. data/spec/models/schedule_column_spec.rb +118 -0
  128. data/spec/models/schedule_request_all_of_spec.rb +46 -0
  129. data/spec/models/schedule_request_spec.rb +46 -0
  130. data/spec/models/schedule_spec.rb +58 -0
  131. data/spec/models/section_box_spec.rb +70 -0
  132. data/spec/models/sheet_all_of_spec.rb +58 -0
  133. data/spec/models/sheet_part_spec.rb +58 -0
  134. data/spec/models/sheet_spec.rb +58 -0
  135. data/spec/models/snapshot_spec.rb +50 -0
  136. data/spec/models/text_spec.rb +28 -0
  137. data/spec/models/view_all_of_spec.rb +40 -0
  138. data/spec/models/view_setup_hints_spec.rb +46 -0
  139. data/spec/models/view_spec.rb +40 -0
  140. data/spec/models/viewpoint_spec.rb +82 -0
  141. data/spec/models/visibility_spec.rb +46 -0
  142. data/spec/spec_helper.rb +111 -0
  143. data/xbim_comms-1.0.0.gem +0 -0
  144. data/xbim_comms.gemspec +38 -0
  145. metadata +226 -0
@@ -0,0 +1,279 @@
1
+ =begin
2
+ #Flex Comms API 2.0
3
+
4
+ #Communication centralised around construction data
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: info@xbim.net
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module XbimComms
17
+ class ColumnRequest
18
+ attr_accessor :name
19
+
20
+ attr_accessor :description
21
+
22
+ attr_accessor :units
23
+
24
+ attr_accessor :data_type
25
+
26
+ class EnumAttributeValidator
27
+ attr_reader :datatype
28
+ attr_reader :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'name' => :'name',
52
+ :'description' => :'description',
53
+ :'units' => :'units',
54
+ :'data_type' => :'dataType'
55
+ }
56
+ end
57
+
58
+ # Returns all the JSON keys this model knows about
59
+ def self.acceptable_attributes
60
+ attribute_map.values
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'name' => :'String',
67
+ :'description' => :'String',
68
+ :'units' => :'String',
69
+ :'data_type' => :'String'
70
+ }
71
+ end
72
+
73
+ # List of attributes with nullable: true
74
+ def self.openapi_nullable
75
+ Set.new([
76
+ ])
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ if (!attributes.is_a?(Hash))
83
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XbimComms::ColumnRequest` initialize method"
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ attributes = attributes.each_with_object({}) { |(k, v), h|
88
+ if (!self.class.attribute_map.key?(k.to_sym))
89
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XbimComms::ColumnRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
90
+ end
91
+ h[k.to_sym] = v
92
+ }
93
+
94
+ if attributes.key?(:'name')
95
+ self.name = attributes[:'name']
96
+ end
97
+
98
+ if attributes.key?(:'description')
99
+ self.description = attributes[:'description']
100
+ end
101
+
102
+ if attributes.key?(:'units')
103
+ self.units = attributes[:'units']
104
+ end
105
+
106
+ if attributes.key?(:'data_type')
107
+ self.data_type = attributes[:'data_type']
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ data_type_validator = EnumAttributeValidator.new('String', ["TEXT", "LOGICAL", "DATE", "INTEGER", "REAL"])
122
+ return false unless data_type_validator.valid?(@data_type)
123
+ true
124
+ end
125
+
126
+ # Custom attribute writer method checking allowed values (enum).
127
+ # @param [Object] data_type Object to be assigned
128
+ def data_type=(data_type)
129
+ validator = EnumAttributeValidator.new('String', ["TEXT", "LOGICAL", "DATE", "INTEGER", "REAL"])
130
+ unless validator.valid?(data_type)
131
+ fail ArgumentError, "invalid value for \"data_type\", must be one of #{validator.allowable_values}."
132
+ end
133
+ @data_type = data_type
134
+ end
135
+
136
+ # Checks equality by comparing each attribute.
137
+ # @param [Object] Object to be compared
138
+ def ==(o)
139
+ return true if self.equal?(o)
140
+ self.class == o.class &&
141
+ name == o.name &&
142
+ description == o.description &&
143
+ units == o.units &&
144
+ data_type == o.data_type
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [name, description, units, data_type].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ new.build_from_hash(attributes)
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def build_from_hash(attributes)
170
+ return nil unless attributes.is_a?(Hash)
171
+ self.class.openapi_types.each_pair do |key, type|
172
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
173
+ self.send("#{key}=", nil)
174
+ elsif type =~ /\AArray<(.*)>/i
175
+ # check to ensure the input is an array given that the attribute
176
+ # is documented as an array but the input is not
177
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
178
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
179
+ end
180
+ elsif !attributes[self.class.attribute_map[key]].nil?
181
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
182
+ end
183
+ end
184
+
185
+ self
186
+ end
187
+
188
+ # Deserializes the data based on type
189
+ # @param string type Data type
190
+ # @param string value Value to be deserialized
191
+ # @return [Object] Deserialized data
192
+ def _deserialize(type, value)
193
+ case type.to_sym
194
+ when :Time
195
+ Time.parse(value)
196
+ when :Date
197
+ Date.parse(value)
198
+ when :String
199
+ value.to_s
200
+ when :Integer
201
+ value.to_i
202
+ when :Float
203
+ value.to_f
204
+ when :Boolean
205
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
206
+ true
207
+ else
208
+ false
209
+ end
210
+ when :Object
211
+ # generic object (usually a Hash), return directly
212
+ value
213
+ when /\AArray<(?<inner_type>.+)>\z/
214
+ inner_type = Regexp.last_match[:inner_type]
215
+ value.map { |v| _deserialize(inner_type, v) }
216
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
217
+ k_type = Regexp.last_match[:k_type]
218
+ v_type = Regexp.last_match[:v_type]
219
+ {}.tap do |hash|
220
+ value.each do |k, v|
221
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
222
+ end
223
+ end
224
+ else # model
225
+ # models (e.g. Pet) or oneOf
226
+ klass = XbimComms.const_get(type)
227
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
228
+ end
229
+ end
230
+
231
+ # Returns the string representation of the object
232
+ # @return [String] String presentation of the object
233
+ def to_s
234
+ to_hash.to_s
235
+ end
236
+
237
+ # to_body is an alias to to_hash (backward compatibility)
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_body
240
+ to_hash
241
+ end
242
+
243
+ # Returns the object in the form of hash
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_hash
246
+ hash = {}
247
+ self.class.attribute_map.each_pair do |attr, param|
248
+ value = self.send(attr)
249
+ if value.nil?
250
+ is_nullable = self.class.openapi_nullable.include?(attr)
251
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
252
+ end
253
+
254
+ hash[param] = _to_hash(value)
255
+ end
256
+ hash
257
+ end
258
+
259
+ # Outputs non-array value in the form of hash
260
+ # For object, use to_hash. Otherwise, just return the value
261
+ # @param [Object] value Any valid value
262
+ # @return [Hash] Returns the value in the form of hash
263
+ def _to_hash(value)
264
+ if value.is_a?(Array)
265
+ value.compact.map { |v| _to_hash(v) }
266
+ elsif value.is_a?(Hash)
267
+ {}.tap do |hash|
268
+ value.each { |k, v| hash[k] = _to_hash(v) }
269
+ end
270
+ elsif value.respond_to? :to_hash
271
+ value.to_hash
272
+ else
273
+ value
274
+ end
275
+ end
276
+
277
+ end
278
+
279
+ end
@@ -0,0 +1,236 @@
1
+ =begin
2
+ #Flex Comms API 2.0
3
+
4
+ #Communication centralised around construction data
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: info@xbim.net
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module XbimComms
17
+ class Component
18
+ attr_accessor :ifc_guid
19
+
20
+ attr_accessor :originating_system
21
+
22
+ attr_accessor :authoring_tool_id
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'ifc_guid' => :'ifc_guid',
28
+ :'originating_system' => :'originating_system',
29
+ :'authoring_tool_id' => :'authoring_tool_id'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'ifc_guid' => :'String',
42
+ :'originating_system' => :'String',
43
+ :'authoring_tool_id' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XbimComms::Component` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XbimComms::Component`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'ifc_guid')
69
+ self.ifc_guid = attributes[:'ifc_guid']
70
+ end
71
+
72
+ if attributes.key?(:'originating_system')
73
+ self.originating_system = attributes[:'originating_system']
74
+ end
75
+
76
+ if attributes.key?(:'authoring_tool_id')
77
+ self.authoring_tool_id = attributes[:'authoring_tool_id']
78
+ end
79
+ end
80
+
81
+ # Show invalid properties with the reasons. Usually used together with valid?
82
+ # @return Array for valid properties with the reasons
83
+ def list_invalid_properties
84
+ invalid_properties = Array.new
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ ifc_guid == o.ifc_guid &&
100
+ originating_system == o.originating_system &&
101
+ authoring_tool_id == o.authoring_tool_id
102
+ end
103
+
104
+ # @see the `==` method
105
+ # @param [Object] Object to be compared
106
+ def eql?(o)
107
+ self == o
108
+ end
109
+
110
+ # Calculates hash code according to all attributes.
111
+ # @return [Integer] Hash code
112
+ def hash
113
+ [ifc_guid, originating_system, authoring_tool_id].hash
114
+ end
115
+
116
+ # Builds the object from hash
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ # @return [Object] Returns the model itself
119
+ def self.build_from_hash(attributes)
120
+ new.build_from_hash(attributes)
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ self.class.openapi_types.each_pair do |key, type|
129
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
130
+ self.send("#{key}=", nil)
131
+ elsif type =~ /\AArray<(.*)>/i
132
+ # check to ensure the input is an array given that the attribute
133
+ # is documented as an array but the input is not
134
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
135
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
136
+ end
137
+ elsif !attributes[self.class.attribute_map[key]].nil?
138
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
139
+ end
140
+ end
141
+
142
+ self
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def _deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ # models (e.g. Pet) or oneOf
183
+ klass = XbimComms.const_get(type)
184
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = self.send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ end