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