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.
- checksums.yaml +4 -4
- data/README.md +36 -4
- data/docs/DatawarehouseApi.md +651 -0
- data/docs/Report.md +36 -0
- data/docs/ReportAuth.md +24 -0
- data/docs/ReportAuthResponse.md +26 -0
- data/docs/ReportDataSet.md +46 -0
- data/docs/ReportDataSetColumn.md +18 -0
- data/docs/ReportDataSetPage.md +36 -0
- data/docs/ReportDataSetPageResponse.md +26 -0
- data/docs/ReportDataSetQuery.md +40 -0
- data/docs/ReportDataSetResponse.md +26 -0
- data/docs/ReportDataSetRow.md +18 -0
- data/docs/ReportDataSetSchema.md +20 -0
- data/docs/ReportDataSource.md +28 -0
- data/docs/ReportDataSourceSchema.md +22 -0
- data/docs/ReportExecuteQueriesRequest.md +30 -0
- data/docs/ReportFilter.md +28 -0
- data/docs/ReportFilterConnection.md +20 -0
- data/docs/ReportPage.md +24 -0
- data/docs/ReportPageVisualization.md +34 -0
- data/docs/ReportPageVisualizationDimension.md +30 -0
- data/docs/ReportPageVisualizationMetric.md +24 -0
- data/docs/ReportResponse.md +26 -0
- data/docs/ReportsResponse.md +26 -0
- data/lib/ultracart_api/api/datawarehouse_api.rb +626 -0
- data/lib/ultracart_api/models/report.rb +342 -0
- data/lib/ultracart_api/models/report_auth.rb +247 -0
- data/lib/ultracart_api/models/report_auth_response.rb +256 -0
- data/lib/ultracart_api/models/report_data_set.rb +397 -0
- data/lib/ultracart_api/models/report_data_set_column.rb +219 -0
- data/lib/ultracart_api/models/report_data_set_page.rb +308 -0
- data/lib/ultracart_api/models/report_data_set_page_response.rb +256 -0
- data/lib/ultracart_api/models/report_data_set_query.rb +365 -0
- data/lib/ultracart_api/models/report_data_set_response.rb +256 -0
- data/lib/ultracart_api/models/report_data_set_row.rb +221 -0
- data/lib/ultracart_api/models/report_data_set_schema.rb +263 -0
- data/lib/ultracart_api/models/report_data_source.rb +267 -0
- data/lib/ultracart_api/models/report_data_source_schema.rb +273 -0
- data/lib/ultracart_api/models/report_execute_queries_request.rb +313 -0
- data/lib/ultracart_api/models/report_filter.rb +307 -0
- data/lib/ultracart_api/models/report_filter_connection.rb +228 -0
- data/lib/ultracart_api/models/report_page.rb +251 -0
- data/lib/ultracart_api/models/report_page_visualization.rb +334 -0
- data/lib/ultracart_api/models/report_page_visualization_dimension.rb +279 -0
- data/lib/ultracart_api/models/report_page_visualization_metric.rb +283 -0
- data/lib/ultracart_api/models/report_response.rb +256 -0
- data/lib/ultracart_api/models/reports_response.rb +258 -0
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +23 -0
- metadata +47 -1
@@ -0,0 +1,251 @@
|
|
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 ReportPage
|
18
|
+
# Height of the report page in inches
|
19
|
+
attr_accessor :height
|
20
|
+
|
21
|
+
attr_accessor :title
|
22
|
+
|
23
|
+
# Visualizations on the report page.
|
24
|
+
attr_accessor :visualizations
|
25
|
+
|
26
|
+
# Width of the report page in inches
|
27
|
+
attr_accessor :width
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'height' => :'height',
|
33
|
+
:'title' => :'title',
|
34
|
+
:'visualizations' => :'visualizations',
|
35
|
+
:'width' => :'width'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns all the JSON keys this model knows about
|
40
|
+
def self.acceptable_attributes
|
41
|
+
attribute_map.values
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute type mapping.
|
45
|
+
def self.openapi_types
|
46
|
+
{
|
47
|
+
:'height' => :'Float',
|
48
|
+
:'title' => :'String',
|
49
|
+
:'visualizations' => :'Array<ReportPageVisualization>',
|
50
|
+
:'width' => :'Float'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# List of attributes with nullable: true
|
55
|
+
def self.openapi_nullable
|
56
|
+
Set.new([
|
57
|
+
])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Initializes the object
|
61
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
62
|
+
def initialize(attributes = {})
|
63
|
+
if (!attributes.is_a?(Hash))
|
64
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ReportPage` initialize method"
|
65
|
+
end
|
66
|
+
|
67
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
68
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
69
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
70
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ReportPage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
71
|
+
end
|
72
|
+
h[k.to_sym] = v
|
73
|
+
}
|
74
|
+
|
75
|
+
if attributes.key?(:'height')
|
76
|
+
self.height = attributes[:'height']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.key?(:'title')
|
80
|
+
self.title = attributes[:'title']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.key?(:'visualizations')
|
84
|
+
if (value = attributes[:'visualizations']).is_a?(Array)
|
85
|
+
self.visualizations = value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'width')
|
90
|
+
self.width = attributes[:'width']
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
95
|
+
# @return Array for valid properties with the reasons
|
96
|
+
def list_invalid_properties
|
97
|
+
invalid_properties = Array.new
|
98
|
+
invalid_properties
|
99
|
+
end
|
100
|
+
|
101
|
+
# Check to see if the all the properties in the model are valid
|
102
|
+
# @return true if the model is valid
|
103
|
+
def valid?
|
104
|
+
true
|
105
|
+
end
|
106
|
+
|
107
|
+
# Checks equality by comparing each attribute.
|
108
|
+
# @param [Object] Object to be compared
|
109
|
+
def ==(o)
|
110
|
+
return true if self.equal?(o)
|
111
|
+
self.class == o.class &&
|
112
|
+
height == o.height &&
|
113
|
+
title == o.title &&
|
114
|
+
visualizations == o.visualizations &&
|
115
|
+
width == o.width
|
116
|
+
end
|
117
|
+
|
118
|
+
# @see the `==` method
|
119
|
+
# @param [Object] Object to be compared
|
120
|
+
def eql?(o)
|
121
|
+
self == o
|
122
|
+
end
|
123
|
+
|
124
|
+
# Calculates hash code according to all attributes.
|
125
|
+
# @return [Integer] Hash code
|
126
|
+
def hash
|
127
|
+
[height, title, visualizations, width].hash
|
128
|
+
end
|
129
|
+
|
130
|
+
# Builds the object from hash
|
131
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
132
|
+
# @return [Object] Returns the model itself
|
133
|
+
def self.build_from_hash(attributes)
|
134
|
+
new.build_from_hash(attributes)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Builds the object from hash
|
138
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
139
|
+
# @return [Object] Returns the model itself
|
140
|
+
def build_from_hash(attributes)
|
141
|
+
return nil unless attributes.is_a?(Hash)
|
142
|
+
attributes = attributes.transform_keys(&:to_sym)
|
143
|
+
self.class.openapi_types.each_pair do |key, type|
|
144
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
145
|
+
self.send("#{key}=", nil)
|
146
|
+
elsif type =~ /\AArray<(.*)>/i
|
147
|
+
# check to ensure the input is an array given that the attribute
|
148
|
+
# is documented as an array but the input is not
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
151
|
+
end
|
152
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
153
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
self
|
158
|
+
end
|
159
|
+
|
160
|
+
# Deserializes the data based on type
|
161
|
+
# @param string type Data type
|
162
|
+
# @param string value Value to be deserialized
|
163
|
+
# @return [Object] Deserialized data
|
164
|
+
def _deserialize(type, value)
|
165
|
+
case type.to_sym
|
166
|
+
when :Time
|
167
|
+
Time.parse(value)
|
168
|
+
when :Date
|
169
|
+
Date.parse(value)
|
170
|
+
when :String
|
171
|
+
value.to_s
|
172
|
+
when :Integer
|
173
|
+
value.to_i
|
174
|
+
when :Float
|
175
|
+
value.to_f
|
176
|
+
when :Boolean
|
177
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
178
|
+
true
|
179
|
+
else
|
180
|
+
false
|
181
|
+
end
|
182
|
+
when :Object
|
183
|
+
# generic object (usually a Hash), return directly
|
184
|
+
value
|
185
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
186
|
+
inner_type = Regexp.last_match[:inner_type]
|
187
|
+
value.map { |v| _deserialize(inner_type, v) }
|
188
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
189
|
+
k_type = Regexp.last_match[:k_type]
|
190
|
+
v_type = Regexp.last_match[:v_type]
|
191
|
+
{}.tap do |hash|
|
192
|
+
value.each do |k, v|
|
193
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
else # model
|
197
|
+
# models (e.g. Pet) or oneOf
|
198
|
+
klass = UltracartClient.const_get(type)
|
199
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the string representation of the object
|
204
|
+
# @return [String] String presentation of the object
|
205
|
+
def to_s
|
206
|
+
to_hash.to_s
|
207
|
+
end
|
208
|
+
|
209
|
+
# to_body is an alias to to_hash (backward compatibility)
|
210
|
+
# @return [Hash] Returns the object in the form of hash
|
211
|
+
def to_body
|
212
|
+
to_hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns the object in the form of hash
|
216
|
+
# @return [Hash] Returns the object in the form of hash
|
217
|
+
def to_hash
|
218
|
+
hash = {}
|
219
|
+
self.class.attribute_map.each_pair do |attr, param|
|
220
|
+
value = self.send(attr)
|
221
|
+
if value.nil?
|
222
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
223
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
224
|
+
end
|
225
|
+
|
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
|
+
|
251
|
+
end
|
@@ -0,0 +1,334 @@
|
|
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 ReportPageVisualization
|
18
|
+
# A JSON representation of the configuration for this visualization
|
19
|
+
attr_accessor :config
|
20
|
+
|
21
|
+
attr_accessor :data_source_name
|
22
|
+
|
23
|
+
attr_accessor :dimensions
|
24
|
+
|
25
|
+
attr_accessor :metrics
|
26
|
+
|
27
|
+
attr_accessor :name
|
28
|
+
|
29
|
+
# True if the visualization should show a comparison based upon the date range
|
30
|
+
attr_accessor :show_comparison
|
31
|
+
|
32
|
+
# A JSON representation of the style configuration for this visualization
|
33
|
+
attr_accessor :styles
|
34
|
+
|
35
|
+
# Type of visualization
|
36
|
+
attr_accessor :type
|
37
|
+
|
38
|
+
# A UUID for the visualization
|
39
|
+
attr_accessor :visualization_uuid
|
40
|
+
|
41
|
+
class EnumAttributeValidator
|
42
|
+
attr_reader :datatype
|
43
|
+
attr_reader :allowable_values
|
44
|
+
|
45
|
+
def initialize(datatype, allowable_values)
|
46
|
+
@allowable_values = allowable_values.map do |value|
|
47
|
+
case datatype.to_s
|
48
|
+
when /Integer/i
|
49
|
+
value.to_i
|
50
|
+
when /Float/i
|
51
|
+
value.to_f
|
52
|
+
else
|
53
|
+
value
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def valid?(value)
|
59
|
+
!value || allowable_values.include?(value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
64
|
+
def self.attribute_map
|
65
|
+
{
|
66
|
+
:'config' => :'config',
|
67
|
+
:'data_source_name' => :'data_source_name',
|
68
|
+
:'dimensions' => :'dimensions',
|
69
|
+
:'metrics' => :'metrics',
|
70
|
+
:'name' => :'name',
|
71
|
+
:'show_comparison' => :'show_comparison',
|
72
|
+
:'styles' => :'styles',
|
73
|
+
:'type' => :'type',
|
74
|
+
:'visualization_uuid' => :'visualization_uuid'
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns all the JSON keys this model knows about
|
79
|
+
def self.acceptable_attributes
|
80
|
+
attribute_map.values
|
81
|
+
end
|
82
|
+
|
83
|
+
# Attribute type mapping.
|
84
|
+
def self.openapi_types
|
85
|
+
{
|
86
|
+
:'config' => :'String',
|
87
|
+
:'data_source_name' => :'String',
|
88
|
+
:'dimensions' => :'Array<ReportPageVisualizationDimension>',
|
89
|
+
:'metrics' => :'Array<ReportPageVisualizationMetric>',
|
90
|
+
:'name' => :'String',
|
91
|
+
:'show_comparison' => :'Boolean',
|
92
|
+
:'styles' => :'String',
|
93
|
+
:'type' => :'String',
|
94
|
+
:'visualization_uuid' => :'String'
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
# List of attributes with nullable: true
|
99
|
+
def self.openapi_nullable
|
100
|
+
Set.new([
|
101
|
+
])
|
102
|
+
end
|
103
|
+
|
104
|
+
# Initializes the object
|
105
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
106
|
+
def initialize(attributes = {})
|
107
|
+
if (!attributes.is_a?(Hash))
|
108
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ReportPageVisualization` initialize method"
|
109
|
+
end
|
110
|
+
|
111
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
112
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
113
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
114
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ReportPageVisualization`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
115
|
+
end
|
116
|
+
h[k.to_sym] = v
|
117
|
+
}
|
118
|
+
|
119
|
+
if attributes.key?(:'config')
|
120
|
+
self.config = attributes[:'config']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'data_source_name')
|
124
|
+
self.data_source_name = attributes[:'data_source_name']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'dimensions')
|
128
|
+
if (value = attributes[:'dimensions']).is_a?(Array)
|
129
|
+
self.dimensions = value
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:'metrics')
|
134
|
+
if (value = attributes[:'metrics']).is_a?(Array)
|
135
|
+
self.metrics = value
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'name')
|
140
|
+
self.name = attributes[:'name']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:'show_comparison')
|
144
|
+
self.show_comparison = attributes[:'show_comparison']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.key?(:'styles')
|
148
|
+
self.styles = attributes[:'styles']
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.key?(:'type')
|
152
|
+
self.type = attributes[:'type']
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.key?(:'visualization_uuid')
|
156
|
+
self.visualization_uuid = attributes[:'visualization_uuid']
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
161
|
+
# @return Array for valid properties with the reasons
|
162
|
+
def list_invalid_properties
|
163
|
+
invalid_properties = Array.new
|
164
|
+
invalid_properties
|
165
|
+
end
|
166
|
+
|
167
|
+
# Check to see if the all the properties in the model are valid
|
168
|
+
# @return true if the model is valid
|
169
|
+
def valid?
|
170
|
+
type_validator = EnumAttributeValidator.new('String', ["score card", "line chart", "bar chart", "text", "table"])
|
171
|
+
return false unless type_validator.valid?(@type)
|
172
|
+
true
|
173
|
+
end
|
174
|
+
|
175
|
+
# Custom attribute writer method checking allowed values (enum).
|
176
|
+
# @param [Object] type Object to be assigned
|
177
|
+
def type=(type)
|
178
|
+
validator = EnumAttributeValidator.new('String', ["score card", "line chart", "bar chart", "text", "table"])
|
179
|
+
unless validator.valid?(type)
|
180
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
181
|
+
end
|
182
|
+
@type = type
|
183
|
+
end
|
184
|
+
|
185
|
+
# Checks equality by comparing each attribute.
|
186
|
+
# @param [Object] Object to be compared
|
187
|
+
def ==(o)
|
188
|
+
return true if self.equal?(o)
|
189
|
+
self.class == o.class &&
|
190
|
+
config == o.config &&
|
191
|
+
data_source_name == o.data_source_name &&
|
192
|
+
dimensions == o.dimensions &&
|
193
|
+
metrics == o.metrics &&
|
194
|
+
name == o.name &&
|
195
|
+
show_comparison == o.show_comparison &&
|
196
|
+
styles == o.styles &&
|
197
|
+
type == o.type &&
|
198
|
+
visualization_uuid == o.visualization_uuid
|
199
|
+
end
|
200
|
+
|
201
|
+
# @see the `==` method
|
202
|
+
# @param [Object] Object to be compared
|
203
|
+
def eql?(o)
|
204
|
+
self == o
|
205
|
+
end
|
206
|
+
|
207
|
+
# Calculates hash code according to all attributes.
|
208
|
+
# @return [Integer] Hash code
|
209
|
+
def hash
|
210
|
+
[config, data_source_name, dimensions, metrics, name, show_comparison, styles, type, visualization_uuid].hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Builds the object from hash
|
214
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
215
|
+
# @return [Object] Returns the model itself
|
216
|
+
def self.build_from_hash(attributes)
|
217
|
+
new.build_from_hash(attributes)
|
218
|
+
end
|
219
|
+
|
220
|
+
# Builds the object from hash
|
221
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
222
|
+
# @return [Object] Returns the model itself
|
223
|
+
def build_from_hash(attributes)
|
224
|
+
return nil unless attributes.is_a?(Hash)
|
225
|
+
attributes = attributes.transform_keys(&:to_sym)
|
226
|
+
self.class.openapi_types.each_pair do |key, type|
|
227
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
228
|
+
self.send("#{key}=", nil)
|
229
|
+
elsif type =~ /\AArray<(.*)>/i
|
230
|
+
# check to ensure the input is an array given that the attribute
|
231
|
+
# is documented as an array but the input is not
|
232
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
233
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
234
|
+
end
|
235
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
236
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
self
|
241
|
+
end
|
242
|
+
|
243
|
+
# Deserializes the data based on type
|
244
|
+
# @param string type Data type
|
245
|
+
# @param string value Value to be deserialized
|
246
|
+
# @return [Object] Deserialized data
|
247
|
+
def _deserialize(type, value)
|
248
|
+
case type.to_sym
|
249
|
+
when :Time
|
250
|
+
Time.parse(value)
|
251
|
+
when :Date
|
252
|
+
Date.parse(value)
|
253
|
+
when :String
|
254
|
+
value.to_s
|
255
|
+
when :Integer
|
256
|
+
value.to_i
|
257
|
+
when :Float
|
258
|
+
value.to_f
|
259
|
+
when :Boolean
|
260
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
261
|
+
true
|
262
|
+
else
|
263
|
+
false
|
264
|
+
end
|
265
|
+
when :Object
|
266
|
+
# generic object (usually a Hash), return directly
|
267
|
+
value
|
268
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
269
|
+
inner_type = Regexp.last_match[:inner_type]
|
270
|
+
value.map { |v| _deserialize(inner_type, v) }
|
271
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
272
|
+
k_type = Regexp.last_match[:k_type]
|
273
|
+
v_type = Regexp.last_match[:v_type]
|
274
|
+
{}.tap do |hash|
|
275
|
+
value.each do |k, v|
|
276
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
else # model
|
280
|
+
# models (e.g. Pet) or oneOf
|
281
|
+
klass = UltracartClient.const_get(type)
|
282
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
# Returns the string representation of the object
|
287
|
+
# @return [String] String presentation of the object
|
288
|
+
def to_s
|
289
|
+
to_hash.to_s
|
290
|
+
end
|
291
|
+
|
292
|
+
# to_body is an alias to to_hash (backward compatibility)
|
293
|
+
# @return [Hash] Returns the object in the form of hash
|
294
|
+
def to_body
|
295
|
+
to_hash
|
296
|
+
end
|
297
|
+
|
298
|
+
# Returns the object in the form of hash
|
299
|
+
# @return [Hash] Returns the object in the form of hash
|
300
|
+
def to_hash
|
301
|
+
hash = {}
|
302
|
+
self.class.attribute_map.each_pair do |attr, param|
|
303
|
+
value = self.send(attr)
|
304
|
+
if value.nil?
|
305
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
306
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
307
|
+
end
|
308
|
+
|
309
|
+
hash[param] = _to_hash(value)
|
310
|
+
end
|
311
|
+
hash
|
312
|
+
end
|
313
|
+
|
314
|
+
# Outputs non-array value in the form of hash
|
315
|
+
# For object, use to_hash. Otherwise, just return the value
|
316
|
+
# @param [Object] value Any valid value
|
317
|
+
# @return [Hash] Returns the value in the form of hash
|
318
|
+
def _to_hash(value)
|
319
|
+
if value.is_a?(Array)
|
320
|
+
value.compact.map { |v| _to_hash(v) }
|
321
|
+
elsif value.is_a?(Hash)
|
322
|
+
{}.tap do |hash|
|
323
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
324
|
+
end
|
325
|
+
elsif value.respond_to? :to_hash
|
326
|
+
value.to_hash
|
327
|
+
else
|
328
|
+
value
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
end
|
333
|
+
|
334
|
+
end
|