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,307 @@
|
|
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 Report
|
17
|
+
attr_accessor :active
|
18
|
+
|
19
|
+
attr_accessor :data_sources
|
20
|
+
|
21
|
+
attr_accessor :default_dataset_id
|
22
|
+
|
23
|
+
attr_accessor :default_project_id
|
24
|
+
|
25
|
+
attr_accessor :filters
|
26
|
+
|
27
|
+
attr_accessor :merchant_id
|
28
|
+
|
29
|
+
attr_accessor :name
|
30
|
+
|
31
|
+
attr_accessor :pages
|
32
|
+
|
33
|
+
# Object identifier for this report.
|
34
|
+
attr_accessor :report_oid
|
35
|
+
|
36
|
+
# Security level to execute report under
|
37
|
+
attr_accessor :security_level
|
38
|
+
|
39
|
+
class EnumAttributeValidator
|
40
|
+
attr_reader :datatype
|
41
|
+
attr_reader :allowable_values
|
42
|
+
|
43
|
+
def initialize(datatype, allowable_values)
|
44
|
+
@allowable_values = allowable_values.map do |value|
|
45
|
+
case datatype.to_s
|
46
|
+
when /Integer/i
|
47
|
+
value.to_i
|
48
|
+
when /Float/i
|
49
|
+
value.to_f
|
50
|
+
else
|
51
|
+
value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def valid?(value)
|
57
|
+
!value || allowable_values.include?(value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
62
|
+
def self.attribute_map
|
63
|
+
{
|
64
|
+
:'active' => :'active',
|
65
|
+
:'data_sources' => :'data_sources',
|
66
|
+
:'default_dataset_id' => :'default_dataset_id',
|
67
|
+
:'default_project_id' => :'default_project_id',
|
68
|
+
:'filters' => :'filters',
|
69
|
+
:'merchant_id' => :'merchant_id',
|
70
|
+
:'name' => :'name',
|
71
|
+
:'pages' => :'pages',
|
72
|
+
:'report_oid' => :'report_oid',
|
73
|
+
:'security_level' => :'security_level'
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
# Attribute type mapping.
|
78
|
+
def self.swagger_types
|
79
|
+
{
|
80
|
+
:'active' => :'BOOLEAN',
|
81
|
+
:'data_sources' => :'Array<ReportDataSource>',
|
82
|
+
:'default_dataset_id' => :'String',
|
83
|
+
:'default_project_id' => :'String',
|
84
|
+
:'filters' => :'Array<ReportFilter>',
|
85
|
+
:'merchant_id' => :'String',
|
86
|
+
:'name' => :'String',
|
87
|
+
:'pages' => :'Array<ReportPage>',
|
88
|
+
:'report_oid' => :'Integer',
|
89
|
+
:'security_level' => :'String'
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
# Initializes the object
|
94
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
95
|
+
def initialize(attributes = {})
|
96
|
+
return unless attributes.is_a?(Hash)
|
97
|
+
|
98
|
+
# convert string to symbol for hash key
|
99
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
100
|
+
|
101
|
+
if attributes.has_key?(:'active')
|
102
|
+
self.active = attributes[:'active']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.has_key?(:'data_sources')
|
106
|
+
if (value = attributes[:'data_sources']).is_a?(Array)
|
107
|
+
self.data_sources = value
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.has_key?(:'default_dataset_id')
|
112
|
+
self.default_dataset_id = attributes[:'default_dataset_id']
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.has_key?(:'default_project_id')
|
116
|
+
self.default_project_id = attributes[:'default_project_id']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.has_key?(:'filters')
|
120
|
+
if (value = attributes[:'filters']).is_a?(Array)
|
121
|
+
self.filters = value
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'merchant_id')
|
126
|
+
self.merchant_id = attributes[:'merchant_id']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.has_key?(:'name')
|
130
|
+
self.name = attributes[:'name']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.has_key?(:'pages')
|
134
|
+
if (value = attributes[:'pages']).is_a?(Array)
|
135
|
+
self.pages = value
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.has_key?(:'report_oid')
|
140
|
+
self.report_oid = attributes[:'report_oid']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.has_key?(:'security_level')
|
144
|
+
self.security_level = attributes[:'security_level']
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
149
|
+
# @return Array for valid properties with the reasons
|
150
|
+
def list_invalid_properties
|
151
|
+
invalid_properties = Array.new
|
152
|
+
invalid_properties
|
153
|
+
end
|
154
|
+
|
155
|
+
# Check to see if the all the properties in the model are valid
|
156
|
+
# @return true if the model is valid
|
157
|
+
def valid?
|
158
|
+
security_level_validator = EnumAttributeValidator.new('String', ['standard', 'low', 'medium', 'high'])
|
159
|
+
return false unless security_level_validator.valid?(@security_level)
|
160
|
+
true
|
161
|
+
end
|
162
|
+
|
163
|
+
# Custom attribute writer method checking allowed values (enum).
|
164
|
+
# @param [Object] security_level Object to be assigned
|
165
|
+
def security_level=(security_level)
|
166
|
+
validator = EnumAttributeValidator.new('String', ['standard', 'low', 'medium', 'high'])
|
167
|
+
unless validator.valid?(security_level)
|
168
|
+
fail ArgumentError, 'invalid value for "security_level", must be one of #{validator.allowable_values}.'
|
169
|
+
end
|
170
|
+
@security_level = security_level
|
171
|
+
end
|
172
|
+
|
173
|
+
# Checks equality by comparing each attribute.
|
174
|
+
# @param [Object] Object to be compared
|
175
|
+
def ==(o)
|
176
|
+
return true if self.equal?(o)
|
177
|
+
self.class == o.class &&
|
178
|
+
active == o.active &&
|
179
|
+
data_sources == o.data_sources &&
|
180
|
+
default_dataset_id == o.default_dataset_id &&
|
181
|
+
default_project_id == o.default_project_id &&
|
182
|
+
filters == o.filters &&
|
183
|
+
merchant_id == o.merchant_id &&
|
184
|
+
name == o.name &&
|
185
|
+
pages == o.pages &&
|
186
|
+
report_oid == o.report_oid &&
|
187
|
+
security_level == o.security_level
|
188
|
+
end
|
189
|
+
|
190
|
+
# @see the `==` method
|
191
|
+
# @param [Object] Object to be compared
|
192
|
+
def eql?(o)
|
193
|
+
self == o
|
194
|
+
end
|
195
|
+
|
196
|
+
# Calculates hash code according to all attributes.
|
197
|
+
# @return [Fixnum] Hash code
|
198
|
+
def hash
|
199
|
+
[active, data_sources, default_dataset_id, default_project_id, filters, merchant_id, name, pages, report_oid, security_level].hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Builds the object from hash
|
203
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
204
|
+
# @return [Object] Returns the model itself
|
205
|
+
def build_from_hash(attributes)
|
206
|
+
return nil unless attributes.is_a?(Hash)
|
207
|
+
self.class.swagger_types.each_pair do |key, type|
|
208
|
+
if type =~ /\AArray<(.*)>/i
|
209
|
+
# check to ensure the input is an array given that the attribute
|
210
|
+
# is documented as an array but the input is not
|
211
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
212
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
213
|
+
end
|
214
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
215
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
216
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
217
|
+
end
|
218
|
+
|
219
|
+
self
|
220
|
+
end
|
221
|
+
|
222
|
+
# Deserializes the data based on type
|
223
|
+
# @param string type Data type
|
224
|
+
# @param string value Value to be deserialized
|
225
|
+
# @return [Object] Deserialized data
|
226
|
+
def _deserialize(type, value)
|
227
|
+
case type.to_sym
|
228
|
+
when :DateTime
|
229
|
+
DateTime.parse(value)
|
230
|
+
when :Date
|
231
|
+
Date.parse(value)
|
232
|
+
when :String
|
233
|
+
value.to_s
|
234
|
+
when :Integer
|
235
|
+
value.to_i
|
236
|
+
when :Float
|
237
|
+
value.to_f
|
238
|
+
when :BOOLEAN
|
239
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
240
|
+
true
|
241
|
+
else
|
242
|
+
false
|
243
|
+
end
|
244
|
+
when :Object
|
245
|
+
# generic object (usually a Hash), return directly
|
246
|
+
value
|
247
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
248
|
+
inner_type = Regexp.last_match[:inner_type]
|
249
|
+
value.map { |v| _deserialize(inner_type, v) }
|
250
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
251
|
+
k_type = Regexp.last_match[:k_type]
|
252
|
+
v_type = Regexp.last_match[:v_type]
|
253
|
+
{}.tap do |hash|
|
254
|
+
value.each do |k, v|
|
255
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
else # model
|
259
|
+
temp_model = UltracartClient.const_get(type).new
|
260
|
+
temp_model.build_from_hash(value)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Returns the string representation of the object
|
265
|
+
# @return [String] String presentation of the object
|
266
|
+
def to_s
|
267
|
+
to_hash.to_s
|
268
|
+
end
|
269
|
+
|
270
|
+
# to_body is an alias to to_hash (backward compatibility)
|
271
|
+
# @return [Hash] Returns the object in the form of hash
|
272
|
+
def to_body
|
273
|
+
to_hash
|
274
|
+
end
|
275
|
+
|
276
|
+
# Returns the object in the form of hash
|
277
|
+
# @return [Hash] Returns the object in the form of hash
|
278
|
+
def to_hash
|
279
|
+
hash = {}
|
280
|
+
self.class.attribute_map.each_pair do |attr, param|
|
281
|
+
value = self.send(attr)
|
282
|
+
next if value.nil?
|
283
|
+
hash[param] = _to_hash(value)
|
284
|
+
end
|
285
|
+
hash
|
286
|
+
end
|
287
|
+
|
288
|
+
# Outputs non-array value in the form of hash
|
289
|
+
# For object, use to_hash. Otherwise, just return the value
|
290
|
+
# @param [Object] value Any valid value
|
291
|
+
# @return [Hash] Returns the value in the form of hash
|
292
|
+
def _to_hash(value)
|
293
|
+
if value.is_a?(Array)
|
294
|
+
value.compact.map { |v| _to_hash(v) }
|
295
|
+
elsif value.is_a?(Hash)
|
296
|
+
{}.tap do |hash|
|
297
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
298
|
+
end
|
299
|
+
elsif value.respond_to? :to_hash
|
300
|
+
value.to_hash
|
301
|
+
else
|
302
|
+
value
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
end
|
@@ -0,0 +1,212 @@
|
|
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 ReportAuth
|
17
|
+
# Unique UUID assigned to this client
|
18
|
+
attr_accessor :client_uuid
|
19
|
+
|
20
|
+
attr_accessor :jwt
|
21
|
+
|
22
|
+
attr_accessor :merchant_id
|
23
|
+
|
24
|
+
attr_accessor :websocket_url
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:'client_uuid' => :'client_uuid',
|
30
|
+
:'jwt' => :'jwt',
|
31
|
+
:'merchant_id' => :'merchant_id',
|
32
|
+
:'websocket_url' => :'websocket_url'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute type mapping.
|
37
|
+
def self.swagger_types
|
38
|
+
{
|
39
|
+
:'client_uuid' => :'String',
|
40
|
+
:'jwt' => :'String',
|
41
|
+
:'merchant_id' => :'String',
|
42
|
+
:'websocket_url' => :'String'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Initializes the object
|
47
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
48
|
+
def initialize(attributes = {})
|
49
|
+
return unless attributes.is_a?(Hash)
|
50
|
+
|
51
|
+
# convert string to symbol for hash key
|
52
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
53
|
+
|
54
|
+
if attributes.has_key?(:'client_uuid')
|
55
|
+
self.client_uuid = attributes[:'client_uuid']
|
56
|
+
end
|
57
|
+
|
58
|
+
if attributes.has_key?(:'jwt')
|
59
|
+
self.jwt = attributes[:'jwt']
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:'merchant_id')
|
63
|
+
self.merchant_id = attributes[:'merchant_id']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:'websocket_url')
|
67
|
+
self.websocket_url = attributes[:'websocket_url']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
72
|
+
# @return Array for valid properties with the reasons
|
73
|
+
def list_invalid_properties
|
74
|
+
invalid_properties = Array.new
|
75
|
+
invalid_properties
|
76
|
+
end
|
77
|
+
|
78
|
+
# Check to see if the all the properties in the model are valid
|
79
|
+
# @return true if the model is valid
|
80
|
+
def valid?
|
81
|
+
true
|
82
|
+
end
|
83
|
+
|
84
|
+
# Checks equality by comparing each attribute.
|
85
|
+
# @param [Object] Object to be compared
|
86
|
+
def ==(o)
|
87
|
+
return true if self.equal?(o)
|
88
|
+
self.class == o.class &&
|
89
|
+
client_uuid == o.client_uuid &&
|
90
|
+
jwt == o.jwt &&
|
91
|
+
merchant_id == o.merchant_id &&
|
92
|
+
websocket_url == o.websocket_url
|
93
|
+
end
|
94
|
+
|
95
|
+
# @see the `==` method
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def eql?(o)
|
98
|
+
self == o
|
99
|
+
end
|
100
|
+
|
101
|
+
# Calculates hash code according to all attributes.
|
102
|
+
# @return [Fixnum] Hash code
|
103
|
+
def hash
|
104
|
+
[client_uuid, jwt, merchant_id, websocket_url].hash
|
105
|
+
end
|
106
|
+
|
107
|
+
# Builds the object from hash
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
+
# @return [Object] Returns the model itself
|
110
|
+
def build_from_hash(attributes)
|
111
|
+
return nil unless attributes.is_a?(Hash)
|
112
|
+
self.class.swagger_types.each_pair do |key, type|
|
113
|
+
if type =~ /\AArray<(.*)>/i
|
114
|
+
# check to ensure the input is an array given that the attribute
|
115
|
+
# is documented as an array but the input is not
|
116
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
117
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
118
|
+
end
|
119
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
120
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
121
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
122
|
+
end
|
123
|
+
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
# Deserializes the data based on type
|
128
|
+
# @param string type Data type
|
129
|
+
# @param string value Value to be deserialized
|
130
|
+
# @return [Object] Deserialized data
|
131
|
+
def _deserialize(type, value)
|
132
|
+
case type.to_sym
|
133
|
+
when :DateTime
|
134
|
+
DateTime.parse(value)
|
135
|
+
when :Date
|
136
|
+
Date.parse(value)
|
137
|
+
when :String
|
138
|
+
value.to_s
|
139
|
+
when :Integer
|
140
|
+
value.to_i
|
141
|
+
when :Float
|
142
|
+
value.to_f
|
143
|
+
when :BOOLEAN
|
144
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
145
|
+
true
|
146
|
+
else
|
147
|
+
false
|
148
|
+
end
|
149
|
+
when :Object
|
150
|
+
# generic object (usually a Hash), return directly
|
151
|
+
value
|
152
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
153
|
+
inner_type = Regexp.last_match[:inner_type]
|
154
|
+
value.map { |v| _deserialize(inner_type, v) }
|
155
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
156
|
+
k_type = Regexp.last_match[:k_type]
|
157
|
+
v_type = Regexp.last_match[:v_type]
|
158
|
+
{}.tap do |hash|
|
159
|
+
value.each do |k, v|
|
160
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
else # model
|
164
|
+
temp_model = UltracartClient.const_get(type).new
|
165
|
+
temp_model.build_from_hash(value)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the string representation of the object
|
170
|
+
# @return [String] String presentation of the object
|
171
|
+
def to_s
|
172
|
+
to_hash.to_s
|
173
|
+
end
|
174
|
+
|
175
|
+
# to_body is an alias to to_hash (backward compatibility)
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
177
|
+
def to_body
|
178
|
+
to_hash
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns the object in the form of hash
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_hash
|
184
|
+
hash = {}
|
185
|
+
self.class.attribute_map.each_pair do |attr, param|
|
186
|
+
value = self.send(attr)
|
187
|
+
next if value.nil?
|
188
|
+
hash[param] = _to_hash(value)
|
189
|
+
end
|
190
|
+
hash
|
191
|
+
end
|
192
|
+
|
193
|
+
# Outputs non-array value in the form of hash
|
194
|
+
# For object, use to_hash. Otherwise, just return the value
|
195
|
+
# @param [Object] value Any valid value
|
196
|
+
# @return [Hash] Returns the value in the form of hash
|
197
|
+
def _to_hash(value)
|
198
|
+
if value.is_a?(Array)
|
199
|
+
value.compact.map { |v| _to_hash(v) }
|
200
|
+
elsif value.is_a?(Hash)
|
201
|
+
{}.tap do |hash|
|
202
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
203
|
+
end
|
204
|
+
elsif value.respond_to? :to_hash
|
205
|
+
value.to_hash
|
206
|
+
else
|
207
|
+
value
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|