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