mparticle 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +73 -0
  3. data/docs/ApiResponse.md +8 -0
  4. data/docs/ApiResponseErrors.md +9 -0
  5. data/docs/AppEvent.md +18 -0
  6. data/docs/ApplicationInformation.md +11 -0
  7. data/docs/ApplicationStateTransitionEvent.md +20 -0
  8. data/docs/AttributionInfo.md +10 -0
  9. data/docs/Batch.md +18 -0
  10. data/docs/BreadcrumbEvent.md +17 -0
  11. data/docs/CommerceEvent.md +22 -0
  12. data/docs/CrashReportEvent.md +26 -0
  13. data/docs/DeviceCurrentState.md +23 -0
  14. data/docs/DeviceInformation.md +41 -0
  15. data/docs/EventBase.md +9 -0
  16. data/docs/EventData.md +15 -0
  17. data/docs/EventsApi.md +124 -0
  18. data/docs/FirstRunEvent.md +15 -0
  19. data/docs/GeoLocation.md +10 -0
  20. data/docs/MediaInfo.md +15 -0
  21. data/docs/NetworkPerformanceEvent.md +22 -0
  22. data/docs/OptOutEvent.md +16 -0
  23. data/docs/Product.md +19 -0
  24. data/docs/ProductAction.md +19 -0
  25. data/docs/ProductImpression.md +9 -0
  26. data/docs/ProfileEvent.md +18 -0
  27. data/docs/Promotion.md +11 -0
  28. data/docs/PromotionAction.md +9 -0
  29. data/docs/PushMessageEvent.md +22 -0
  30. data/docs/PushRegistrationEvent.md +17 -0
  31. data/docs/ScreenViewEvent.md +17 -0
  32. data/docs/SessionEndEvent.md +16 -0
  33. data/docs/SessionStartEvent.md +15 -0
  34. data/docs/ShoppingCart.md +8 -0
  35. data/docs/SourceInformation.md +11 -0
  36. data/docs/UserIdentities.md +17 -0
  37. data/example/main.rb +32 -0
  38. data/lib/.DS_Store +0 -0
  39. data/lib/mparticle/.DS_Store +0 -0
  40. data/lib/mparticle/api/events_api.rb +129 -0
  41. data/lib/mparticle/api_client.rb +398 -0
  42. data/lib/mparticle/api_error.rb +26 -0
  43. data/lib/mparticle/configuration.rb +160 -0
  44. data/lib/mparticle/models/api_response.rb +178 -0
  45. data/lib/mparticle/models/api_response_errors.rb +185 -0
  46. data/lib/mparticle/models/app_event.rb +311 -0
  47. data/lib/mparticle/models/application_information.rb +203 -0
  48. data/lib/mparticle/models/application_state_transition_event.rb +352 -0
  49. data/lib/mparticle/models/attribution_info.rb +209 -0
  50. data/lib/mparticle/models/batch.rb +348 -0
  51. data/lib/mparticle/models/breadcrumb_event.rb +269 -0
  52. data/lib/mparticle/models/commerce_event.rb +306 -0
  53. data/lib/mparticle/models/crash_report_event.rb +362 -0
  54. data/lib/mparticle/models/device_current_state.rb +356 -0
  55. data/lib/mparticle/models/device_information.rb +506 -0
  56. data/lib/mparticle/models/event_base.rb +228 -0
  57. data/lib/mparticle/models/event_data.rb +241 -0
  58. data/lib/mparticle/models/first_run_event.rb +241 -0
  59. data/lib/mparticle/models/geo_location.rb +204 -0
  60. data/lib/mparticle/models/media_info.rb +296 -0
  61. data/lib/mparticle/models/network_performance_event.rb +334 -0
  62. data/lib/mparticle/models/opt_out_event.rb +255 -0
  63. data/lib/mparticle/models/product.rb +297 -0
  64. data/lib/mparticle/models/product_action.rb +330 -0
  65. data/lib/mparticle/models/product_impression.rb +197 -0
  66. data/lib/mparticle/models/profile_event.rb +316 -0
  67. data/lib/mparticle/models/promotion.rb +223 -0
  68. data/lib/mparticle/models/promotion_action.rb +230 -0
  69. data/lib/mparticle/models/push_message_event.rb +369 -0
  70. data/lib/mparticle/models/push_registration_event.rb +269 -0
  71. data/lib/mparticle/models/screen_view_event.rb +264 -0
  72. data/lib/mparticle/models/session_end_event.rb +255 -0
  73. data/lib/mparticle/models/session_start_event.rb +241 -0
  74. data/lib/mparticle/models/shopping_cart.rb +183 -0
  75. data/lib/mparticle/models/source_information.rb +246 -0
  76. data/lib/mparticle/models/user_identities.rb +257 -0
  77. data/lib/mparticle/version.rb +3 -0
  78. data/lib/mparticle.rb +61 -0
  79. data/mparticle.gemspec +19 -0
  80. metadata +163 -0
@@ -0,0 +1,334 @@
1
+ require 'date'
2
+
3
+ module MParticle
4
+
5
+ class NetworkPerformanceEvent
6
+ attr_accessor :timestamp_unixtime_ms
7
+
8
+ attr_accessor :event_id
9
+
10
+ attr_accessor :source_message_id
11
+
12
+ attr_accessor :session_id
13
+
14
+ attr_accessor :session_uuid
15
+
16
+ attr_accessor :custom_attributes
17
+
18
+ attr_accessor :location
19
+
20
+ attr_accessor :device_current_state
21
+
22
+ attr_accessor :http_verb
23
+
24
+ attr_accessor :url
25
+
26
+ attr_accessor :time_elapsed
27
+
28
+ attr_accessor :bytes_in
29
+
30
+ attr_accessor :bytes_out
31
+
32
+ attr_accessor :response_code
33
+
34
+ attr_accessor :data
35
+
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'timestamp_unixtime_ms' => :'timestamp_unixtime_ms',
41
+ :'event_id' => :'event_id',
42
+ :'source_message_id' => :'source_message_id',
43
+ :'session_id' => :'session_id',
44
+ :'session_uuid' => :'session_uuid',
45
+ :'custom_attributes' => :'custom_attributes',
46
+ :'location' => :'location',
47
+ :'device_current_state' => :'device_current_state',
48
+ :'http_verb' => :'http_verb',
49
+ :'url' => :'url',
50
+ :'time_elapsed' => :'time_elapsed',
51
+ :'bytes_in' => :'bytes_in',
52
+ :'bytes_out' => :'bytes_out',
53
+ :'response_code' => :'response_code',
54
+ :'data' => :'data'
55
+ }
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.swagger_types
60
+ {
61
+ :'timestamp_unixtime_ms' => :'Integer',
62
+ :'event_id' => :'Integer',
63
+ :'source_message_id' => :'String',
64
+ :'session_id' => :'Integer',
65
+ :'session_uuid' => :'String',
66
+ :'custom_attributes' => :'Hash<String, String>',
67
+ :'location' => :'GeoLocation',
68
+ :'device_current_state' => :'DeviceCurrentState',
69
+ :'http_verb' => :'String',
70
+ :'url' => :'String',
71
+ :'time_elapsed' => :'Integer',
72
+ :'bytes_in' => :'Integer',
73
+ :'bytes_out' => :'Integer',
74
+ :'response_code' => :'Integer',
75
+ :'data' => :'String'
76
+ }
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ return unless attributes.is_a?(Hash)
83
+
84
+ # convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
86
+
87
+ if attributes.has_key?(:'timestamp_unixtime_ms')
88
+ self.timestamp_unixtime_ms = attributes[:'timestamp_unixtime_ms']
89
+ end
90
+
91
+ if attributes.has_key?(:'event_id')
92
+ self.event_id = attributes[:'event_id']
93
+ end
94
+
95
+ if attributes.has_key?(:'source_message_id')
96
+ self.source_message_id = attributes[:'source_message_id']
97
+ end
98
+
99
+ if attributes.has_key?(:'session_id')
100
+ self.session_id = attributes[:'session_id']
101
+ end
102
+
103
+ if attributes.has_key?(:'session_uuid')
104
+ self.session_uuid = attributes[:'session_uuid']
105
+ end
106
+
107
+ if attributes.has_key?(:'custom_attributes')
108
+ if (value = attributes[:'custom_attributes']).is_a?(Array)
109
+ self.custom_attributes = value
110
+ end
111
+ end
112
+
113
+ if attributes.has_key?(:'location')
114
+ self.location = attributes[:'location']
115
+ end
116
+
117
+ if attributes.has_key?(:'device_current_state')
118
+ self.device_current_state = attributes[:'device_current_state']
119
+ end
120
+
121
+ if attributes.has_key?(:'http_verb')
122
+ self.http_verb = attributes[:'http_verb']
123
+ end
124
+
125
+ if attributes.has_key?(:'url')
126
+ self.url = attributes[:'url']
127
+ end
128
+
129
+ if attributes.has_key?(:'time_elapsed')
130
+ self.time_elapsed = attributes[:'time_elapsed']
131
+ end
132
+
133
+ if attributes.has_key?(:'bytes_in')
134
+ self.bytes_in = attributes[:'bytes_in']
135
+ end
136
+
137
+ if attributes.has_key?(:'bytes_out')
138
+ self.bytes_out = attributes[:'bytes_out']
139
+ end
140
+
141
+ if attributes.has_key?(:'response_code')
142
+ self.response_code = attributes[:'response_code']
143
+ end
144
+
145
+ if attributes.has_key?(:'data')
146
+ self.data = attributes[:'data']
147
+ end
148
+
149
+ end
150
+
151
+ # Show invalid properties with the reasons. Usually used together with valid?
152
+ # @return Array for valid properies with the reasons
153
+ def list_invalid_properties
154
+ invalid_properties = Array.new
155
+ if @http_verb.nil?
156
+ invalid_properties.push("invalid value for 'http_verb', http_verb cannot be nil.")
157
+ end
158
+
159
+ if @url.nil?
160
+ invalid_properties.push("invalid value for 'url', url cannot be nil.")
161
+ end
162
+
163
+ if @time_elapsed.nil?
164
+ invalid_properties.push("invalid value for 'time_elapsed', time_elapsed cannot be nil.")
165
+ end
166
+
167
+ if @bytes_in.nil?
168
+ invalid_properties.push("invalid value for 'bytes_in', bytes_in cannot be nil.")
169
+ end
170
+
171
+ if @bytes_out.nil?
172
+ invalid_properties.push("invalid value for 'bytes_out', bytes_out cannot be nil.")
173
+ end
174
+
175
+ if @response_code.nil?
176
+ invalid_properties.push("invalid value for 'response_code', response_code cannot be nil.")
177
+ end
178
+
179
+ return invalid_properties
180
+ end
181
+
182
+ # Check to see if the all the properties in the model are valid
183
+ # @return true if the model is valid
184
+ def valid?
185
+ return false if @http_verb.nil?
186
+ return false if @url.nil?
187
+ return false if @time_elapsed.nil?
188
+ return false if @bytes_in.nil?
189
+ return false if @bytes_out.nil?
190
+ return false if @response_code.nil?
191
+ return true
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
+ timestamp_unixtime_ms == o.timestamp_unixtime_ms &&
200
+ event_id == o.event_id &&
201
+ source_message_id == o.source_message_id &&
202
+ session_id == o.session_id &&
203
+ session_uuid == o.session_uuid &&
204
+ custom_attributes == o.custom_attributes &&
205
+ location == o.location &&
206
+ device_current_state == o.device_current_state &&
207
+ http_verb == o.http_verb &&
208
+ url == o.url &&
209
+ time_elapsed == o.time_elapsed &&
210
+ bytes_in == o.bytes_in &&
211
+ bytes_out == o.bytes_out &&
212
+ response_code == o.response_code &&
213
+ data == o.data
214
+ end
215
+
216
+ # @see the `==` method
217
+ # @param [Object] Object to be compared
218
+ def eql?(o)
219
+ self == o
220
+ end
221
+
222
+ # Calculates hash code according to all attributes.
223
+ # @return [Fixnum] Hash code
224
+ def hash
225
+ [timestamp_unixtime_ms, event_id, source_message_id, session_id, session_uuid, custom_attributes, location, device_current_state, http_verb, url, time_elapsed, bytes_in, bytes_out, response_code, data].hash
226
+ end
227
+
228
+ # Builds the object from hash
229
+ # @param [Hash] attributes Model attributes in the form of hash
230
+ # @return [Object] Returns the model itself
231
+ def build_from_hash(attributes)
232
+ return nil unless attributes.is_a?(Hash)
233
+ self.class.swagger_types.each_pair do |key, type|
234
+ if type =~ /\AArray<(.*)>/i
235
+ # check to ensure the input is an array given that the the attribute
236
+ # is documented as an array but the input is not
237
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
238
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
239
+ end
240
+ elsif !attributes[self.class.attribute_map[key]].nil?
241
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
242
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
243
+ end
244
+
245
+ self
246
+ end
247
+
248
+ # Deserializes the data based on type
249
+ # @param string type Data type
250
+ # @param string value Value to be deserialized
251
+ # @return [Object] Deserialized data
252
+ def _deserialize(type, value)
253
+ case type.to_sym
254
+ when :DateTime
255
+ DateTime.parse(value)
256
+ when :Date
257
+ Date.parse(value)
258
+ when :String
259
+ value.to_s
260
+ when :Integer
261
+ value.to_i
262
+ when :Float
263
+ value.to_f
264
+ when :BOOLEAN
265
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
266
+ true
267
+ else
268
+ false
269
+ end
270
+ when :Object
271
+ # generic object (usually a Hash), return directly
272
+ value
273
+ when /\AArray<(?<inner_type>.+)>\z/
274
+ inner_type = Regexp.last_match[:inner_type]
275
+ value.map { |v| _deserialize(inner_type, v) }
276
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
277
+ k_type = Regexp.last_match[:k_type]
278
+ v_type = Regexp.last_match[:v_type]
279
+ {}.tap do |hash|
280
+ value.each do |k, v|
281
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
282
+ end
283
+ end
284
+ else # model
285
+ temp_model = MParticle.const_get(type).new
286
+ temp_model.build_from_hash(value)
287
+ end
288
+ end
289
+
290
+ # Returns the string representation of the object
291
+ # @return [String] String presentation of the object
292
+ def to_s
293
+ to_hash.to_s
294
+ end
295
+
296
+ # to_body is an alias to to_hash (backward compatibility)
297
+ # @return [Hash] Returns the object in the form of hash
298
+ def to_body
299
+ to_hash
300
+ end
301
+
302
+ # Returns the object in the form of hash
303
+ # @return [Hash] Returns the object in the form of hash
304
+ def to_hash
305
+ hash = {}
306
+ self.class.attribute_map.each_pair do |attr, param|
307
+ value = self.send(attr)
308
+ next if value.nil?
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
@@ -0,0 +1,255 @@
1
+ require 'date'
2
+
3
+ module MParticle
4
+
5
+ class OptOutEvent
6
+ attr_accessor :timestamp_unixtime_ms
7
+
8
+ attr_accessor :event_id
9
+
10
+ attr_accessor :source_message_id
11
+
12
+ attr_accessor :session_id
13
+
14
+ attr_accessor :session_uuid
15
+
16
+ attr_accessor :custom_attributes
17
+
18
+ attr_accessor :location
19
+
20
+ attr_accessor :device_current_state
21
+
22
+ attr_accessor :is_opted_out
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'timestamp_unixtime_ms' => :'timestamp_unixtime_ms',
29
+ :'event_id' => :'event_id',
30
+ :'source_message_id' => :'source_message_id',
31
+ :'session_id' => :'session_id',
32
+ :'session_uuid' => :'session_uuid',
33
+ :'custom_attributes' => :'custom_attributes',
34
+ :'location' => :'location',
35
+ :'device_current_state' => :'device_current_state',
36
+ :'is_opted_out' => :'is_opted_out'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'timestamp_unixtime_ms' => :'Integer',
44
+ :'event_id' => :'Integer',
45
+ :'source_message_id' => :'String',
46
+ :'session_id' => :'Integer',
47
+ :'session_uuid' => :'String',
48
+ :'custom_attributes' => :'Hash<String, String>',
49
+ :'location' => :'GeoLocation',
50
+ :'device_current_state' => :'DeviceCurrentState',
51
+ :'is_opted_out' => :'BOOLEAN'
52
+ }
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ return unless attributes.is_a?(Hash)
59
+
60
+ # convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
62
+
63
+ if attributes.has_key?(:'timestamp_unixtime_ms')
64
+ self.timestamp_unixtime_ms = attributes[:'timestamp_unixtime_ms']
65
+ end
66
+
67
+ if attributes.has_key?(:'event_id')
68
+ self.event_id = attributes[:'event_id']
69
+ end
70
+
71
+ if attributes.has_key?(:'source_message_id')
72
+ self.source_message_id = attributes[:'source_message_id']
73
+ end
74
+
75
+ if attributes.has_key?(:'session_id')
76
+ self.session_id = attributes[:'session_id']
77
+ end
78
+
79
+ if attributes.has_key?(:'session_uuid')
80
+ self.session_uuid = attributes[:'session_uuid']
81
+ end
82
+
83
+ if attributes.has_key?(:'custom_attributes')
84
+ if (value = attributes[:'custom_attributes']).is_a?(Array)
85
+ self.custom_attributes = value
86
+ end
87
+ end
88
+
89
+ if attributes.has_key?(:'location')
90
+ self.location = attributes[:'location']
91
+ end
92
+
93
+ if attributes.has_key?(:'device_current_state')
94
+ self.device_current_state = attributes[:'device_current_state']
95
+ end
96
+
97
+ if attributes.has_key?(:'is_opted_out')
98
+ self.is_opted_out = attributes[:'is_opted_out']
99
+ end
100
+
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properies with the reasons
105
+ def list_invalid_properties
106
+ invalid_properties = Array.new
107
+ if @is_opted_out.nil?
108
+ invalid_properties.push("invalid value for 'is_opted_out', is_opted_out cannot be nil.")
109
+ end
110
+
111
+ return invalid_properties
112
+ end
113
+
114
+ # Check to see if the all the properties in the model are valid
115
+ # @return true if the model is valid
116
+ def valid?
117
+ return false if @is_opted_out.nil?
118
+ return true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ timestamp_unixtime_ms == o.timestamp_unixtime_ms &&
127
+ event_id == o.event_id &&
128
+ source_message_id == o.source_message_id &&
129
+ session_id == o.session_id &&
130
+ session_uuid == o.session_uuid &&
131
+ custom_attributes == o.custom_attributes &&
132
+ location == o.location &&
133
+ device_current_state == o.device_current_state &&
134
+ is_opted_out == o.is_opted_out
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Fixnum] Hash code
145
+ def hash
146
+ [timestamp_unixtime_ms, event_id, source_message_id, session_id, session_uuid, custom_attributes, location, device_current_state, is_opted_out].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ self.class.swagger_types.each_pair do |key, type|
155
+ if type =~ /\AArray<(.*)>/i
156
+ # check to ensure the input is an array given that the the attribute
157
+ # is documented as an array but the input is not
158
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
159
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
160
+ end
161
+ elsif !attributes[self.class.attribute_map[key]].nil?
162
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
163
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def _deserialize(type, value)
174
+ case type.to_sym
175
+ when :DateTime
176
+ DateTime.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :BOOLEAN
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+ when :Object
192
+ # generic object (usually a Hash), return directly
193
+ value
194
+ when /\AArray<(?<inner_type>.+)>\z/
195
+ inner_type = Regexp.last_match[:inner_type]
196
+ value.map { |v| _deserialize(inner_type, v) }
197
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
198
+ k_type = Regexp.last_match[:k_type]
199
+ v_type = Regexp.last_match[:v_type]
200
+ {}.tap do |hash|
201
+ value.each do |k, v|
202
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
203
+ end
204
+ end
205
+ else # model
206
+ temp_model = MParticle.const_get(type).new
207
+ temp_model.build_from_hash(value)
208
+ end
209
+ end
210
+
211
+ # Returns the string representation of the object
212
+ # @return [String] String presentation of the object
213
+ def to_s
214
+ to_hash.to_s
215
+ end
216
+
217
+ # to_body is an alias to to_hash (backward compatibility)
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_body
220
+ to_hash
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = self.send(attr)
229
+ next if value.nil?
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map{ |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end