ultracart_api 4.0.141 → 4.0.142

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -4
  3. data/docs/DatawarehouseApi.md +651 -0
  4. data/docs/Report.md +36 -0
  5. data/docs/ReportAuth.md +24 -0
  6. data/docs/ReportAuthResponse.md +26 -0
  7. data/docs/ReportDataSet.md +46 -0
  8. data/docs/ReportDataSetColumn.md +18 -0
  9. data/docs/ReportDataSetPage.md +36 -0
  10. data/docs/ReportDataSetPageResponse.md +26 -0
  11. data/docs/ReportDataSetQuery.md +40 -0
  12. data/docs/ReportDataSetResponse.md +26 -0
  13. data/docs/ReportDataSetRow.md +18 -0
  14. data/docs/ReportDataSetSchema.md +20 -0
  15. data/docs/ReportDataSource.md +28 -0
  16. data/docs/ReportDataSourceSchema.md +22 -0
  17. data/docs/ReportExecuteQueriesRequest.md +30 -0
  18. data/docs/ReportFilter.md +28 -0
  19. data/docs/ReportFilterConnection.md +20 -0
  20. data/docs/ReportPage.md +24 -0
  21. data/docs/ReportPageVisualization.md +34 -0
  22. data/docs/ReportPageVisualizationDimension.md +30 -0
  23. data/docs/ReportPageVisualizationMetric.md +24 -0
  24. data/docs/ReportResponse.md +26 -0
  25. data/docs/ReportsResponse.md +26 -0
  26. data/lib/ultracart_api/api/datawarehouse_api.rb +626 -0
  27. data/lib/ultracart_api/models/report.rb +342 -0
  28. data/lib/ultracart_api/models/report_auth.rb +247 -0
  29. data/lib/ultracart_api/models/report_auth_response.rb +256 -0
  30. data/lib/ultracart_api/models/report_data_set.rb +397 -0
  31. data/lib/ultracart_api/models/report_data_set_column.rb +219 -0
  32. data/lib/ultracart_api/models/report_data_set_page.rb +308 -0
  33. data/lib/ultracart_api/models/report_data_set_page_response.rb +256 -0
  34. data/lib/ultracart_api/models/report_data_set_query.rb +365 -0
  35. data/lib/ultracart_api/models/report_data_set_response.rb +256 -0
  36. data/lib/ultracart_api/models/report_data_set_row.rb +221 -0
  37. data/lib/ultracart_api/models/report_data_set_schema.rb +263 -0
  38. data/lib/ultracart_api/models/report_data_source.rb +267 -0
  39. data/lib/ultracart_api/models/report_data_source_schema.rb +273 -0
  40. data/lib/ultracart_api/models/report_execute_queries_request.rb +313 -0
  41. data/lib/ultracart_api/models/report_filter.rb +307 -0
  42. data/lib/ultracart_api/models/report_filter_connection.rb +228 -0
  43. data/lib/ultracart_api/models/report_page.rb +251 -0
  44. data/lib/ultracart_api/models/report_page_visualization.rb +334 -0
  45. data/lib/ultracart_api/models/report_page_visualization_dimension.rb +279 -0
  46. data/lib/ultracart_api/models/report_page_visualization_metric.rb +283 -0
  47. data/lib/ultracart_api/models/report_response.rb +256 -0
  48. data/lib/ultracart_api/models/reports_response.rb +258 -0
  49. data/lib/ultracart_api/version.rb +1 -1
  50. data/lib/ultracart_api.rb +23 -0
  51. metadata +47 -1
@@ -0,0 +1,256 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class ReportAuthResponse
18
+ attr_accessor :error
19
+
20
+ attr_accessor :metadata
21
+
22
+ attr_accessor :report_auth
23
+
24
+ # Indicates if API call was successful
25
+ attr_accessor :success
26
+
27
+ attr_accessor :warning
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'error' => :'error',
33
+ :'metadata' => :'metadata',
34
+ :'report_auth' => :'report_auth',
35
+ :'success' => :'success',
36
+ :'warning' => :'warning'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'error' => :'Error',
49
+ :'metadata' => :'ResponseMetadata',
50
+ :'report_auth' => :'ReportAuth',
51
+ :'success' => :'Boolean',
52
+ :'warning' => :'Warning'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ReportAuthResponse` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ReportAuthResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'error')
78
+ self.error = attributes[:'error']
79
+ end
80
+
81
+ if attributes.key?(:'metadata')
82
+ self.metadata = attributes[:'metadata']
83
+ end
84
+
85
+ if attributes.key?(:'report_auth')
86
+ self.report_auth = attributes[:'report_auth']
87
+ end
88
+
89
+ if attributes.key?(:'success')
90
+ self.success = attributes[:'success']
91
+ end
92
+
93
+ if attributes.key?(:'warning')
94
+ self.warning = attributes[:'warning']
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ true
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ error == o.error &&
117
+ metadata == o.metadata &&
118
+ report_auth == o.report_auth &&
119
+ success == o.success &&
120
+ warning == o.warning
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(o)
126
+ self == o
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [error, metadata, report_auth, success, warning].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ new.build_from_hash(attributes)
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+ attributes = attributes.transform_keys(&:to_sym)
148
+ self.class.openapi_types.each_pair do |key, type|
149
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
150
+ self.send("#{key}=", nil)
151
+ elsif 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
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 :Time
172
+ Time.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
+ # models (e.g. Pet) or oneOf
203
+ klass = UltracartClient.const_get(type)
204
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ if value.nil?
227
+ is_nullable = self.class.openapi_nullable.include?(attr)
228
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
+ end
230
+
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ end
255
+
256
+ end
@@ -0,0 +1,397 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class ReportDataSet
18
+ # A unique identifier assigned to the data set query that is returned.
19
+ attr_accessor :data_set_query_uuid
20
+
21
+ # A unique identifier assigned to the data set that is returned.
22
+ attr_accessor :data_set_uuid
23
+
24
+ # The BigQuery destination table id that contains the result.
25
+ attr_accessor :destination_table_id
26
+
27
+ # Error message if the query failed.
28
+ attr_accessor :error_message
29
+
30
+ # An identifier that can be used to help match up the returned data set
31
+ attr_accessor :for_object_id
32
+
33
+ # The type of object this data set is for
34
+ attr_accessor :for_object_type
35
+
36
+ # Initial pages returned in the dataset
37
+ attr_accessor :initial_pages
38
+
39
+ # The total number of results
40
+ attr_accessor :max_results
41
+
42
+ # Merchant that owns this data set
43
+ attr_accessor :merchant_id
44
+
45
+ # The size of the pages
46
+ attr_accessor :page_count
47
+
48
+ # The size of the pages
49
+ attr_accessor :page_size
50
+
51
+ # The schema associated with the data set.
52
+ attr_accessor :schema
53
+
54
+ # Security level this dataset was read from.
55
+ attr_accessor :security_level
56
+
57
+ attr_accessor :timezone
58
+
59
+ # Any other data that needs to be returned with the response to help the UI
60
+ attr_accessor :user_data
61
+
62
+ class EnumAttributeValidator
63
+ attr_reader :datatype
64
+ attr_reader :allowable_values
65
+
66
+ def initialize(datatype, allowable_values)
67
+ @allowable_values = allowable_values.map do |value|
68
+ case datatype.to_s
69
+ when /Integer/i
70
+ value.to_i
71
+ when /Float/i
72
+ value.to_f
73
+ else
74
+ value
75
+ end
76
+ end
77
+ end
78
+
79
+ def valid?(value)
80
+ !value || allowable_values.include?(value)
81
+ end
82
+ end
83
+
84
+ # Attribute mapping from ruby-style variable name to JSON key.
85
+ def self.attribute_map
86
+ {
87
+ :'data_set_query_uuid' => :'data_set_query_uuid',
88
+ :'data_set_uuid' => :'data_set_uuid',
89
+ :'destination_table_id' => :'destination_table_id',
90
+ :'error_message' => :'error_message',
91
+ :'for_object_id' => :'for_object_id',
92
+ :'for_object_type' => :'for_object_type',
93
+ :'initial_pages' => :'initial_pages',
94
+ :'max_results' => :'max_results',
95
+ :'merchant_id' => :'merchant_id',
96
+ :'page_count' => :'page_count',
97
+ :'page_size' => :'page_size',
98
+ :'schema' => :'schema',
99
+ :'security_level' => :'security_level',
100
+ :'timezone' => :'timezone',
101
+ :'user_data' => :'user_data'
102
+ }
103
+ end
104
+
105
+ # Returns all the JSON keys this model knows about
106
+ def self.acceptable_attributes
107
+ attribute_map.values
108
+ end
109
+
110
+ # Attribute type mapping.
111
+ def self.openapi_types
112
+ {
113
+ :'data_set_query_uuid' => :'String',
114
+ :'data_set_uuid' => :'String',
115
+ :'destination_table_id' => :'String',
116
+ :'error_message' => :'String',
117
+ :'for_object_id' => :'String',
118
+ :'for_object_type' => :'String',
119
+ :'initial_pages' => :'Array<ReportDataSetPage>',
120
+ :'max_results' => :'Integer',
121
+ :'merchant_id' => :'String',
122
+ :'page_count' => :'Integer',
123
+ :'page_size' => :'Integer',
124
+ :'schema' => :'Array<ReportDataSetSchema>',
125
+ :'security_level' => :'String',
126
+ :'timezone' => :'String',
127
+ :'user_data' => :'String'
128
+ }
129
+ end
130
+
131
+ # List of attributes with nullable: true
132
+ def self.openapi_nullable
133
+ Set.new([
134
+ ])
135
+ end
136
+
137
+ # Initializes the object
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ def initialize(attributes = {})
140
+ if (!attributes.is_a?(Hash))
141
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ReportDataSet` initialize method"
142
+ end
143
+
144
+ # check to see if the attribute exists and convert string to symbol for hash key
145
+ attributes = attributes.each_with_object({}) { |(k, v), h|
146
+ if (!self.class.attribute_map.key?(k.to_sym))
147
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ReportDataSet`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
148
+ end
149
+ h[k.to_sym] = v
150
+ }
151
+
152
+ if attributes.key?(:'data_set_query_uuid')
153
+ self.data_set_query_uuid = attributes[:'data_set_query_uuid']
154
+ end
155
+
156
+ if attributes.key?(:'data_set_uuid')
157
+ self.data_set_uuid = attributes[:'data_set_uuid']
158
+ end
159
+
160
+ if attributes.key?(:'destination_table_id')
161
+ self.destination_table_id = attributes[:'destination_table_id']
162
+ end
163
+
164
+ if attributes.key?(:'error_message')
165
+ self.error_message = attributes[:'error_message']
166
+ end
167
+
168
+ if attributes.key?(:'for_object_id')
169
+ self.for_object_id = attributes[:'for_object_id']
170
+ end
171
+
172
+ if attributes.key?(:'for_object_type')
173
+ self.for_object_type = attributes[:'for_object_type']
174
+ end
175
+
176
+ if attributes.key?(:'initial_pages')
177
+ if (value = attributes[:'initial_pages']).is_a?(Array)
178
+ self.initial_pages = value
179
+ end
180
+ end
181
+
182
+ if attributes.key?(:'max_results')
183
+ self.max_results = attributes[:'max_results']
184
+ end
185
+
186
+ if attributes.key?(:'merchant_id')
187
+ self.merchant_id = attributes[:'merchant_id']
188
+ end
189
+
190
+ if attributes.key?(:'page_count')
191
+ self.page_count = attributes[:'page_count']
192
+ end
193
+
194
+ if attributes.key?(:'page_size')
195
+ self.page_size = attributes[:'page_size']
196
+ end
197
+
198
+ if attributes.key?(:'schema')
199
+ if (value = attributes[:'schema']).is_a?(Array)
200
+ self.schema = value
201
+ end
202
+ end
203
+
204
+ if attributes.key?(:'security_level')
205
+ self.security_level = attributes[:'security_level']
206
+ end
207
+
208
+ if attributes.key?(:'timezone')
209
+ self.timezone = attributes[:'timezone']
210
+ end
211
+
212
+ if attributes.key?(:'user_data')
213
+ self.user_data = attributes[:'user_data']
214
+ end
215
+ end
216
+
217
+ # Show invalid properties with the reasons. Usually used together with valid?
218
+ # @return Array for valid properties with the reasons
219
+ def list_invalid_properties
220
+ invalid_properties = Array.new
221
+ invalid_properties
222
+ end
223
+
224
+ # Check to see if the all the properties in the model are valid
225
+ # @return true if the model is valid
226
+ def valid?
227
+ for_object_type_validator = EnumAttributeValidator.new('String', ["schema", "filter", "visualization"])
228
+ return false unless for_object_type_validator.valid?(@for_object_type)
229
+ true
230
+ end
231
+
232
+ # Custom attribute writer method checking allowed values (enum).
233
+ # @param [Object] for_object_type Object to be assigned
234
+ def for_object_type=(for_object_type)
235
+ validator = EnumAttributeValidator.new('String', ["schema", "filter", "visualization"])
236
+ unless validator.valid?(for_object_type)
237
+ fail ArgumentError, "invalid value for \"for_object_type\", must be one of #{validator.allowable_values}."
238
+ end
239
+ @for_object_type = for_object_type
240
+ end
241
+
242
+ # Checks equality by comparing each attribute.
243
+ # @param [Object] Object to be compared
244
+ def ==(o)
245
+ return true if self.equal?(o)
246
+ self.class == o.class &&
247
+ data_set_query_uuid == o.data_set_query_uuid &&
248
+ data_set_uuid == o.data_set_uuid &&
249
+ destination_table_id == o.destination_table_id &&
250
+ error_message == o.error_message &&
251
+ for_object_id == o.for_object_id &&
252
+ for_object_type == o.for_object_type &&
253
+ initial_pages == o.initial_pages &&
254
+ max_results == o.max_results &&
255
+ merchant_id == o.merchant_id &&
256
+ page_count == o.page_count &&
257
+ page_size == o.page_size &&
258
+ schema == o.schema &&
259
+ security_level == o.security_level &&
260
+ timezone == o.timezone &&
261
+ user_data == o.user_data
262
+ end
263
+
264
+ # @see the `==` method
265
+ # @param [Object] Object to be compared
266
+ def eql?(o)
267
+ self == o
268
+ end
269
+
270
+ # Calculates hash code according to all attributes.
271
+ # @return [Integer] Hash code
272
+ def hash
273
+ [data_set_query_uuid, data_set_uuid, destination_table_id, error_message, for_object_id, for_object_type, initial_pages, max_results, merchant_id, page_count, page_size, schema, security_level, timezone, user_data].hash
274
+ end
275
+
276
+ # Builds the object from hash
277
+ # @param [Hash] attributes Model attributes in the form of hash
278
+ # @return [Object] Returns the model itself
279
+ def self.build_from_hash(attributes)
280
+ new.build_from_hash(attributes)
281
+ end
282
+
283
+ # Builds the object from hash
284
+ # @param [Hash] attributes Model attributes in the form of hash
285
+ # @return [Object] Returns the model itself
286
+ def build_from_hash(attributes)
287
+ return nil unless attributes.is_a?(Hash)
288
+ attributes = attributes.transform_keys(&:to_sym)
289
+ self.class.openapi_types.each_pair do |key, type|
290
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
291
+ self.send("#{key}=", nil)
292
+ elsif type =~ /\AArray<(.*)>/i
293
+ # check to ensure the input is an array given that the attribute
294
+ # is documented as an array but the input is not
295
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
296
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
297
+ end
298
+ elsif !attributes[self.class.attribute_map[key]].nil?
299
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
300
+ end
301
+ end
302
+
303
+ self
304
+ end
305
+
306
+ # Deserializes the data based on type
307
+ # @param string type Data type
308
+ # @param string value Value to be deserialized
309
+ # @return [Object] Deserialized data
310
+ def _deserialize(type, value)
311
+ case type.to_sym
312
+ when :Time
313
+ Time.parse(value)
314
+ when :Date
315
+ Date.parse(value)
316
+ when :String
317
+ value.to_s
318
+ when :Integer
319
+ value.to_i
320
+ when :Float
321
+ value.to_f
322
+ when :Boolean
323
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
324
+ true
325
+ else
326
+ false
327
+ end
328
+ when :Object
329
+ # generic object (usually a Hash), return directly
330
+ value
331
+ when /\AArray<(?<inner_type>.+)>\z/
332
+ inner_type = Regexp.last_match[:inner_type]
333
+ value.map { |v| _deserialize(inner_type, v) }
334
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
335
+ k_type = Regexp.last_match[:k_type]
336
+ v_type = Regexp.last_match[:v_type]
337
+ {}.tap do |hash|
338
+ value.each do |k, v|
339
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
340
+ end
341
+ end
342
+ else # model
343
+ # models (e.g. Pet) or oneOf
344
+ klass = UltracartClient.const_get(type)
345
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
346
+ end
347
+ end
348
+
349
+ # Returns the string representation of the object
350
+ # @return [String] String presentation of the object
351
+ def to_s
352
+ to_hash.to_s
353
+ end
354
+
355
+ # to_body is an alias to to_hash (backward compatibility)
356
+ # @return [Hash] Returns the object in the form of hash
357
+ def to_body
358
+ to_hash
359
+ end
360
+
361
+ # Returns the object in the form of hash
362
+ # @return [Hash] Returns the object in the form of hash
363
+ def to_hash
364
+ hash = {}
365
+ self.class.attribute_map.each_pair do |attr, param|
366
+ value = self.send(attr)
367
+ if value.nil?
368
+ is_nullable = self.class.openapi_nullable.include?(attr)
369
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
370
+ end
371
+
372
+ hash[param] = _to_hash(value)
373
+ end
374
+ hash
375
+ end
376
+
377
+ # Outputs non-array value in the form of hash
378
+ # For object, use to_hash. Otherwise, just return the value
379
+ # @param [Object] value Any valid value
380
+ # @return [Hash] Returns the value in the form of hash
381
+ def _to_hash(value)
382
+ if value.is_a?(Array)
383
+ value.compact.map { |v| _to_hash(v) }
384
+ elsif value.is_a?(Hash)
385
+ {}.tap do |hash|
386
+ value.each { |k, v| hash[k] = _to_hash(v) }
387
+ end
388
+ elsif value.respond_to? :to_hash
389
+ value.to_hash
390
+ else
391
+ value
392
+ end
393
+ end
394
+
395
+ end
396
+
397
+ end