ultracart_api 3.10.124 → 3.10.126
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -4
- data/docs/DatawarehouseApi.md +461 -0
- data/docs/Report.md +17 -0
- data/docs/ReportAuth.md +11 -0
- data/docs/ReportAuthResponse.md +12 -0
- data/docs/ReportDataSet.md +22 -0
- data/docs/ReportDataSetColumn.md +8 -0
- data/docs/ReportDataSetPage.md +17 -0
- data/docs/ReportDataSetPageResponse.md +12 -0
- data/docs/ReportDataSetQuery.md +19 -0
- data/docs/ReportDataSetResponse.md +12 -0
- data/docs/ReportDataSetRow.md +8 -0
- data/docs/ReportDataSetSchema.md +9 -0
- data/docs/ReportDataSetSummary.md +14 -0
- data/docs/ReportDataSource.md +13 -0
- data/docs/ReportDataSourceSchema.md +10 -0
- data/docs/ReportExecuteQueriesRequest.md +14 -0
- data/docs/ReportFilter.md +13 -0
- data/docs/ReportFilterConnection.md +9 -0
- data/docs/ReportPage.md +11 -0
- data/docs/ReportPageVisualization.md +16 -0
- data/docs/ReportPageVisualizationDimension.md +14 -0
- data/docs/ReportPageVisualizationMetric.md +11 -0
- data/docs/ReportResponse.md +12 -0
- data/docs/ReportWebsocketEvent.md +9 -0
- data/docs/ReportsResponse.md +12 -0
- data/lib/ultracart_api/api/datawarehouse_api.rb +529 -0
- data/lib/ultracart_api/models/report.rb +307 -0
- data/lib/ultracart_api/models/report_auth.rb +212 -0
- data/lib/ultracart_api/models/report_auth_response.rb +221 -0
- data/lib/ultracart_api/models/report_data_set.rb +362 -0
- data/lib/ultracart_api/models/report_data_set_column.rb +184 -0
- data/lib/ultracart_api/models/report_data_set_page.rb +273 -0
- data/lib/ultracart_api/models/report_data_set_page_response.rb +221 -0
- data/lib/ultracart_api/models/report_data_set_query.rb +330 -0
- data/lib/ultracart_api/models/report_data_set_response.rb +221 -0
- data/lib/ultracart_api/models/report_data_set_row.rb +186 -0
- data/lib/ultracart_api/models/report_data_set_schema.rb +228 -0
- data/lib/ultracart_api/models/report_data_set_summary.rb +281 -0
- data/lib/ultracart_api/models/report_data_source.rb +232 -0
- data/lib/ultracart_api/models/report_data_source_schema.rb +238 -0
- data/lib/ultracart_api/models/report_execute_queries_request.rb +278 -0
- data/lib/ultracart_api/models/report_filter.rb +272 -0
- data/lib/ultracart_api/models/report_filter_connection.rb +193 -0
- data/lib/ultracart_api/models/report_page.rb +216 -0
- data/lib/ultracart_api/models/report_page_visualization.rb +299 -0
- data/lib/ultracart_api/models/report_page_visualization_dimension.rb +244 -0
- data/lib/ultracart_api/models/report_page_visualization_metric.rb +248 -0
- data/lib/ultracart_api/models/report_response.rb +221 -0
- data/lib/ultracart_api/models/report_websocket_event.rb +228 -0
- data/lib/ultracart_api/models/reports_response.rb +223 -0
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +25 -0
- metadata +51 -1
@@ -0,0 +1,330 @@
|
|
1
|
+
=begin
|
2
|
+
#UltraCart Rest API V2
|
3
|
+
|
4
|
+
#UltraCart REST API Version 2
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
Contact: support@ultracart.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.15-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module UltracartClient
|
16
|
+
class ReportDataSetQuery
|
17
|
+
# True if a date range filter is provided with comparison date ranges and two results should be returned for the query.
|
18
|
+
attr_accessor :comparison_results
|
19
|
+
|
20
|
+
# A unique identifier assigned to the data set query that is returned.
|
21
|
+
attr_accessor :data_set_query_uuid
|
22
|
+
|
23
|
+
attr_accessor :data_source
|
24
|
+
|
25
|
+
attr_accessor :dimensions
|
26
|
+
|
27
|
+
attr_accessor :filter
|
28
|
+
|
29
|
+
# An identifier that can be used to help match up the returned data set
|
30
|
+
attr_accessor :for_object_id
|
31
|
+
|
32
|
+
# The type of object this data set is for
|
33
|
+
attr_accessor :for_object_type
|
34
|
+
|
35
|
+
attr_accessor :metrics
|
36
|
+
|
37
|
+
# Result set page size. The default value is 200 records. Max is 10000.
|
38
|
+
attr_accessor :page_size
|
39
|
+
|
40
|
+
attr_accessor :selected_filters
|
41
|
+
|
42
|
+
# True if the 15 minute cache should be skipped.
|
43
|
+
attr_accessor :skip_cache
|
44
|
+
|
45
|
+
# Any other data that needs to be returned with the response to help the UI
|
46
|
+
attr_accessor :user_data
|
47
|
+
|
48
|
+
class EnumAttributeValidator
|
49
|
+
attr_reader :datatype
|
50
|
+
attr_reader :allowable_values
|
51
|
+
|
52
|
+
def initialize(datatype, allowable_values)
|
53
|
+
@allowable_values = allowable_values.map do |value|
|
54
|
+
case datatype.to_s
|
55
|
+
when /Integer/i
|
56
|
+
value.to_i
|
57
|
+
when /Float/i
|
58
|
+
value.to_f
|
59
|
+
else
|
60
|
+
value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def valid?(value)
|
66
|
+
!value || allowable_values.include?(value)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
71
|
+
def self.attribute_map
|
72
|
+
{
|
73
|
+
:'comparison_results' => :'comparison_results',
|
74
|
+
:'data_set_query_uuid' => :'data_set_query_uuid',
|
75
|
+
:'data_source' => :'data_source',
|
76
|
+
:'dimensions' => :'dimensions',
|
77
|
+
:'filter' => :'filter',
|
78
|
+
:'for_object_id' => :'for_object_id',
|
79
|
+
:'for_object_type' => :'for_object_type',
|
80
|
+
:'metrics' => :'metrics',
|
81
|
+
:'page_size' => :'page_size',
|
82
|
+
:'selected_filters' => :'selected_filters',
|
83
|
+
:'skip_cache' => :'skip_cache',
|
84
|
+
:'user_data' => :'user_data'
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
# Attribute type mapping.
|
89
|
+
def self.swagger_types
|
90
|
+
{
|
91
|
+
:'comparison_results' => :'BOOLEAN',
|
92
|
+
:'data_set_query_uuid' => :'String',
|
93
|
+
:'data_source' => :'ReportDataSource',
|
94
|
+
:'dimensions' => :'Array<ReportPageVisualizationDimension>',
|
95
|
+
:'filter' => :'ReportFilter',
|
96
|
+
:'for_object_id' => :'String',
|
97
|
+
:'for_object_type' => :'String',
|
98
|
+
:'metrics' => :'Array<ReportPageVisualizationMetric>',
|
99
|
+
:'page_size' => :'Integer',
|
100
|
+
:'selected_filters' => :'Array<ReportFilter>',
|
101
|
+
:'skip_cache' => :'BOOLEAN',
|
102
|
+
:'user_data' => :'String'
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
# Initializes the object
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
+
def initialize(attributes = {})
|
109
|
+
return unless attributes.is_a?(Hash)
|
110
|
+
|
111
|
+
# convert string to symbol for hash key
|
112
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
113
|
+
|
114
|
+
if attributes.has_key?(:'comparison_results')
|
115
|
+
self.comparison_results = attributes[:'comparison_results']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.has_key?(:'data_set_query_uuid')
|
119
|
+
self.data_set_query_uuid = attributes[:'data_set_query_uuid']
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.has_key?(:'data_source')
|
123
|
+
self.data_source = attributes[:'data_source']
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.has_key?(:'dimensions')
|
127
|
+
if (value = attributes[:'dimensions']).is_a?(Array)
|
128
|
+
self.dimensions = value
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.has_key?(:'filter')
|
133
|
+
self.filter = attributes[:'filter']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.has_key?(:'for_object_id')
|
137
|
+
self.for_object_id = attributes[:'for_object_id']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.has_key?(:'for_object_type')
|
141
|
+
self.for_object_type = attributes[:'for_object_type']
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.has_key?(:'metrics')
|
145
|
+
if (value = attributes[:'metrics']).is_a?(Array)
|
146
|
+
self.metrics = value
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
if attributes.has_key?(:'page_size')
|
151
|
+
self.page_size = attributes[:'page_size']
|
152
|
+
end
|
153
|
+
|
154
|
+
if attributes.has_key?(:'selected_filters')
|
155
|
+
if (value = attributes[:'selected_filters']).is_a?(Array)
|
156
|
+
self.selected_filters = value
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
if attributes.has_key?(:'skip_cache')
|
161
|
+
self.skip_cache = attributes[:'skip_cache']
|
162
|
+
end
|
163
|
+
|
164
|
+
if attributes.has_key?(:'user_data')
|
165
|
+
self.user_data = attributes[:'user_data']
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
170
|
+
# @return Array for valid properties with the reasons
|
171
|
+
def list_invalid_properties
|
172
|
+
invalid_properties = Array.new
|
173
|
+
invalid_properties
|
174
|
+
end
|
175
|
+
|
176
|
+
# Check to see if the all the properties in the model are valid
|
177
|
+
# @return true if the model is valid
|
178
|
+
def valid?
|
179
|
+
for_object_type_validator = EnumAttributeValidator.new('String', ['schema', 'filter', 'visualization'])
|
180
|
+
return false unless for_object_type_validator.valid?(@for_object_type)
|
181
|
+
true
|
182
|
+
end
|
183
|
+
|
184
|
+
# Custom attribute writer method checking allowed values (enum).
|
185
|
+
# @param [Object] for_object_type Object to be assigned
|
186
|
+
def for_object_type=(for_object_type)
|
187
|
+
validator = EnumAttributeValidator.new('String', ['schema', 'filter', 'visualization'])
|
188
|
+
unless validator.valid?(for_object_type)
|
189
|
+
fail ArgumentError, 'invalid value for "for_object_type", must be one of #{validator.allowable_values}.'
|
190
|
+
end
|
191
|
+
@for_object_type = for_object_type
|
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
|
+
comparison_results == o.comparison_results &&
|
200
|
+
data_set_query_uuid == o.data_set_query_uuid &&
|
201
|
+
data_source == o.data_source &&
|
202
|
+
dimensions == o.dimensions &&
|
203
|
+
filter == o.filter &&
|
204
|
+
for_object_id == o.for_object_id &&
|
205
|
+
for_object_type == o.for_object_type &&
|
206
|
+
metrics == o.metrics &&
|
207
|
+
page_size == o.page_size &&
|
208
|
+
selected_filters == o.selected_filters &&
|
209
|
+
skip_cache == o.skip_cache &&
|
210
|
+
user_data == o.user_data
|
211
|
+
end
|
212
|
+
|
213
|
+
# @see the `==` method
|
214
|
+
# @param [Object] Object to be compared
|
215
|
+
def eql?(o)
|
216
|
+
self == o
|
217
|
+
end
|
218
|
+
|
219
|
+
# Calculates hash code according to all attributes.
|
220
|
+
# @return [Fixnum] Hash code
|
221
|
+
def hash
|
222
|
+
[comparison_results, data_set_query_uuid, data_source, dimensions, filter, for_object_id, for_object_type, metrics, page_size, selected_filters, skip_cache, user_data].hash
|
223
|
+
end
|
224
|
+
|
225
|
+
# Builds the object from hash
|
226
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
227
|
+
# @return [Object] Returns the model itself
|
228
|
+
def build_from_hash(attributes)
|
229
|
+
return nil unless attributes.is_a?(Hash)
|
230
|
+
self.class.swagger_types.each_pair do |key, type|
|
231
|
+
if type =~ /\AArray<(.*)>/i
|
232
|
+
# check to ensure the input is an array given that the attribute
|
233
|
+
# is documented as an array but the input is not
|
234
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
235
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
236
|
+
end
|
237
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
238
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
239
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
240
|
+
end
|
241
|
+
|
242
|
+
self
|
243
|
+
end
|
244
|
+
|
245
|
+
# Deserializes the data based on type
|
246
|
+
# @param string type Data type
|
247
|
+
# @param string value Value to be deserialized
|
248
|
+
# @return [Object] Deserialized data
|
249
|
+
def _deserialize(type, value)
|
250
|
+
case type.to_sym
|
251
|
+
when :DateTime
|
252
|
+
DateTime.parse(value)
|
253
|
+
when :Date
|
254
|
+
Date.parse(value)
|
255
|
+
when :String
|
256
|
+
value.to_s
|
257
|
+
when :Integer
|
258
|
+
value.to_i
|
259
|
+
when :Float
|
260
|
+
value.to_f
|
261
|
+
when :BOOLEAN
|
262
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
263
|
+
true
|
264
|
+
else
|
265
|
+
false
|
266
|
+
end
|
267
|
+
when :Object
|
268
|
+
# generic object (usually a Hash), return directly
|
269
|
+
value
|
270
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
271
|
+
inner_type = Regexp.last_match[:inner_type]
|
272
|
+
value.map { |v| _deserialize(inner_type, v) }
|
273
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
274
|
+
k_type = Regexp.last_match[:k_type]
|
275
|
+
v_type = Regexp.last_match[:v_type]
|
276
|
+
{}.tap do |hash|
|
277
|
+
value.each do |k, v|
|
278
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
else # model
|
282
|
+
temp_model = UltracartClient.const_get(type).new
|
283
|
+
temp_model.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
|
+
|
329
|
+
end
|
330
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
=begin
|
2
|
+
#UltraCart Rest API V2
|
3
|
+
|
4
|
+
#UltraCart REST API Version 2
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
Contact: support@ultracart.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.15-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module UltracartClient
|
16
|
+
class ReportDataSetResponse
|
17
|
+
attr_accessor :data_set
|
18
|
+
|
19
|
+
attr_accessor :error
|
20
|
+
|
21
|
+
attr_accessor :metadata
|
22
|
+
|
23
|
+
# Indicates if API call was successful
|
24
|
+
attr_accessor :success
|
25
|
+
|
26
|
+
attr_accessor :warning
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'data_set' => :'data_set',
|
32
|
+
:'error' => :'error',
|
33
|
+
:'metadata' => :'metadata',
|
34
|
+
:'success' => :'success',
|
35
|
+
:'warning' => :'warning'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.swagger_types
|
41
|
+
{
|
42
|
+
:'data_set' => :'ReportDataSet',
|
43
|
+
:'error' => :'Error',
|
44
|
+
:'metadata' => :'ResponseMetadata',
|
45
|
+
:'success' => :'BOOLEAN',
|
46
|
+
:'warning' => :'Warning'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Initializes the object
|
51
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
52
|
+
def initialize(attributes = {})
|
53
|
+
return unless attributes.is_a?(Hash)
|
54
|
+
|
55
|
+
# convert string to symbol for hash key
|
56
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
57
|
+
|
58
|
+
if attributes.has_key?(:'data_set')
|
59
|
+
self.data_set = attributes[:'data_set']
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:'error')
|
63
|
+
self.error = attributes[:'error']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:'metadata')
|
67
|
+
self.metadata = attributes[:'metadata']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:'success')
|
71
|
+
self.success = attributes[:'success']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.has_key?(:'warning')
|
75
|
+
self.warning = attributes[:'warning']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
80
|
+
# @return Array for valid properties with the reasons
|
81
|
+
def list_invalid_properties
|
82
|
+
invalid_properties = Array.new
|
83
|
+
invalid_properties
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check to see if the all the properties in the model are valid
|
87
|
+
# @return true if the model is valid
|
88
|
+
def valid?
|
89
|
+
true
|
90
|
+
end
|
91
|
+
|
92
|
+
# Checks equality by comparing each attribute.
|
93
|
+
# @param [Object] Object to be compared
|
94
|
+
def ==(o)
|
95
|
+
return true if self.equal?(o)
|
96
|
+
self.class == o.class &&
|
97
|
+
data_set == o.data_set &&
|
98
|
+
error == o.error &&
|
99
|
+
metadata == o.metadata &&
|
100
|
+
success == o.success &&
|
101
|
+
warning == o.warning
|
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 [Fixnum] Hash code
|
112
|
+
def hash
|
113
|
+
[data_set, error, metadata, success, warning].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 build_from_hash(attributes)
|
120
|
+
return nil unless attributes.is_a?(Hash)
|
121
|
+
self.class.swagger_types.each_pair do |key, type|
|
122
|
+
if type =~ /\AArray<(.*)>/i
|
123
|
+
# check to ensure the input is an array given that the attribute
|
124
|
+
# is documented as an array but the input is not
|
125
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
126
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
127
|
+
end
|
128
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
129
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
130
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
131
|
+
end
|
132
|
+
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# Deserializes the data based on type
|
137
|
+
# @param string type Data type
|
138
|
+
# @param string value Value to be deserialized
|
139
|
+
# @return [Object] Deserialized data
|
140
|
+
def _deserialize(type, value)
|
141
|
+
case type.to_sym
|
142
|
+
when :DateTime
|
143
|
+
DateTime.parse(value)
|
144
|
+
when :Date
|
145
|
+
Date.parse(value)
|
146
|
+
when :String
|
147
|
+
value.to_s
|
148
|
+
when :Integer
|
149
|
+
value.to_i
|
150
|
+
when :Float
|
151
|
+
value.to_f
|
152
|
+
when :BOOLEAN
|
153
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
154
|
+
true
|
155
|
+
else
|
156
|
+
false
|
157
|
+
end
|
158
|
+
when :Object
|
159
|
+
# generic object (usually a Hash), return directly
|
160
|
+
value
|
161
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
162
|
+
inner_type = Regexp.last_match[:inner_type]
|
163
|
+
value.map { |v| _deserialize(inner_type, v) }
|
164
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
165
|
+
k_type = Regexp.last_match[:k_type]
|
166
|
+
v_type = Regexp.last_match[:v_type]
|
167
|
+
{}.tap do |hash|
|
168
|
+
value.each do |k, v|
|
169
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
else # model
|
173
|
+
temp_model = UltracartClient.const_get(type).new
|
174
|
+
temp_model.build_from_hash(value)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns the string representation of the object
|
179
|
+
# @return [String] String presentation of the object
|
180
|
+
def to_s
|
181
|
+
to_hash.to_s
|
182
|
+
end
|
183
|
+
|
184
|
+
# to_body is an alias to to_hash (backward compatibility)
|
185
|
+
# @return [Hash] Returns the object in the form of hash
|
186
|
+
def to_body
|
187
|
+
to_hash
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns the object in the form of hash
|
191
|
+
# @return [Hash] Returns the object in the form of hash
|
192
|
+
def to_hash
|
193
|
+
hash = {}
|
194
|
+
self.class.attribute_map.each_pair do |attr, param|
|
195
|
+
value = self.send(attr)
|
196
|
+
next if value.nil?
|
197
|
+
hash[param] = _to_hash(value)
|
198
|
+
end
|
199
|
+
hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Outputs non-array value in the form of hash
|
203
|
+
# For object, use to_hash. Otherwise, just return the value
|
204
|
+
# @param [Object] value Any valid value
|
205
|
+
# @return [Hash] Returns the value in the form of hash
|
206
|
+
def _to_hash(value)
|
207
|
+
if value.is_a?(Array)
|
208
|
+
value.compact.map { |v| _to_hash(v) }
|
209
|
+
elsif value.is_a?(Hash)
|
210
|
+
{}.tap do |hash|
|
211
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
212
|
+
end
|
213
|
+
elsif value.respond_to? :to_hash
|
214
|
+
value.to_hash
|
215
|
+
else
|
216
|
+
value
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|