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,356 @@
1
+ require 'date'
2
+
3
+ module MParticle
4
+
5
+ class DeviceCurrentState
6
+ attr_accessor :time_since_start_ms
7
+
8
+ attr_accessor :battery_level
9
+
10
+ attr_accessor :data_connection_type
11
+
12
+ attr_accessor :data_connection_type_detail
13
+
14
+ attr_accessor :gps_state
15
+
16
+ attr_accessor :total_system_memory_usage_bytes
17
+
18
+ attr_accessor :disk_space_free_bytes
19
+
20
+ attr_accessor :cpu
21
+
22
+ attr_accessor :system_memory_available_bytes
23
+
24
+ attr_accessor :system_memory_low
25
+
26
+ attr_accessor :system_memory_threshold_bytes
27
+
28
+ attr_accessor :application_memory_available_bytes
29
+
30
+ attr_accessor :application_memory_max_bytes
31
+
32
+ attr_accessor :application_memory_total_bytes
33
+
34
+ attr_accessor :device_orientation
35
+
36
+ attr_accessor :status_bar_orientation
37
+
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'time_since_start_ms' => :'time_since_start_ms',
64
+ :'battery_level' => :'battery_level',
65
+ :'data_connection_type' => :'data_connection_type',
66
+ :'data_connection_type_detail' => :'data_connection_type_detail',
67
+ :'gps_state' => :'gps_state',
68
+ :'total_system_memory_usage_bytes' => :'total_system_memory_usage_bytes',
69
+ :'disk_space_free_bytes' => :'disk_space_free_bytes',
70
+ :'cpu' => :'cpu',
71
+ :'system_memory_available_bytes' => :'system_memory_available_bytes',
72
+ :'system_memory_low' => :'system_memory_low',
73
+ :'system_memory_threshold_bytes' => :'system_memory_threshold_bytes',
74
+ :'application_memory_available_bytes' => :'application_memory_available_bytes',
75
+ :'application_memory_max_bytes' => :'application_memory_max_bytes',
76
+ :'application_memory_total_bytes' => :'application_memory_total_bytes',
77
+ :'device_orientation' => :'device_orientation',
78
+ :'status_bar_orientation' => :'status_bar_orientation'
79
+ }
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.swagger_types
84
+ {
85
+ :'time_since_start_ms' => :'Integer',
86
+ :'battery_level' => :'Float',
87
+ :'data_connection_type' => :'String',
88
+ :'data_connection_type_detail' => :'String',
89
+ :'gps_state' => :'BOOLEAN',
90
+ :'total_system_memory_usage_bytes' => :'Integer',
91
+ :'disk_space_free_bytes' => :'Integer',
92
+ :'cpu' => :'String',
93
+ :'system_memory_available_bytes' => :'Float',
94
+ :'system_memory_low' => :'BOOLEAN',
95
+ :'system_memory_threshold_bytes' => :'Float',
96
+ :'application_memory_available_bytes' => :'Float',
97
+ :'application_memory_max_bytes' => :'Float',
98
+ :'application_memory_total_bytes' => :'Float',
99
+ :'device_orientation' => :'String',
100
+ :'status_bar_orientation' => :'String'
101
+ }
102
+ end
103
+
104
+ # Initializes the object
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ def initialize(attributes = {})
107
+ return unless attributes.is_a?(Hash)
108
+
109
+ # convert string to symbol for hash key
110
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
111
+
112
+ if attributes.has_key?(:'time_since_start_ms')
113
+ self.time_since_start_ms = attributes[:'time_since_start_ms']
114
+ end
115
+
116
+ if attributes.has_key?(:'battery_level')
117
+ self.battery_level = attributes[:'battery_level']
118
+ end
119
+
120
+ if attributes.has_key?(:'data_connection_type')
121
+ self.data_connection_type = attributes[:'data_connection_type']
122
+ end
123
+
124
+ if attributes.has_key?(:'data_connection_type_detail')
125
+ self.data_connection_type_detail = attributes[:'data_connection_type_detail']
126
+ end
127
+
128
+ if attributes.has_key?(:'gps_state')
129
+ self.gps_state = attributes[:'gps_state']
130
+ end
131
+
132
+ if attributes.has_key?(:'total_system_memory_usage_bytes')
133
+ self.total_system_memory_usage_bytes = attributes[:'total_system_memory_usage_bytes']
134
+ end
135
+
136
+ if attributes.has_key?(:'disk_space_free_bytes')
137
+ self.disk_space_free_bytes = attributes[:'disk_space_free_bytes']
138
+ end
139
+
140
+ if attributes.has_key?(:'cpu')
141
+ self.cpu = attributes[:'cpu']
142
+ end
143
+
144
+ if attributes.has_key?(:'system_memory_available_bytes')
145
+ self.system_memory_available_bytes = attributes[:'system_memory_available_bytes']
146
+ end
147
+
148
+ if attributes.has_key?(:'system_memory_low')
149
+ self.system_memory_low = attributes[:'system_memory_low']
150
+ end
151
+
152
+ if attributes.has_key?(:'system_memory_threshold_bytes')
153
+ self.system_memory_threshold_bytes = attributes[:'system_memory_threshold_bytes']
154
+ end
155
+
156
+ if attributes.has_key?(:'application_memory_available_bytes')
157
+ self.application_memory_available_bytes = attributes[:'application_memory_available_bytes']
158
+ end
159
+
160
+ if attributes.has_key?(:'application_memory_max_bytes')
161
+ self.application_memory_max_bytes = attributes[:'application_memory_max_bytes']
162
+ end
163
+
164
+ if attributes.has_key?(:'application_memory_total_bytes')
165
+ self.application_memory_total_bytes = attributes[:'application_memory_total_bytes']
166
+ end
167
+
168
+ if attributes.has_key?(:'device_orientation')
169
+ self.device_orientation = attributes[:'device_orientation']
170
+ end
171
+
172
+ if attributes.has_key?(:'status_bar_orientation')
173
+ self.status_bar_orientation = attributes[:'status_bar_orientation']
174
+ end
175
+
176
+ end
177
+
178
+ # Show invalid properties with the reasons. Usually used together with valid?
179
+ # @return Array for valid properies with the reasons
180
+ def list_invalid_properties
181
+ invalid_properties = Array.new
182
+ return invalid_properties
183
+ end
184
+
185
+ # Check to see if the all the properties in the model are valid
186
+ # @return true if the model is valid
187
+ def valid?
188
+ device_orientation_validator = EnumAttributeValidator.new('String', ["unknown", "portrait", "portrait_upside_down", "landscape", "LandscapeLeft", "LandscapeRight", "FaceUp", "FaceDown", "Square"])
189
+ return false unless device_orientation_validator.valid?(@device_orientation)
190
+ status_bar_orientation_validator = EnumAttributeValidator.new('String', ["unknown", "portrait", "portrait_upside_down", "landscape", "LandscapeLeft", "LandscapeRight", "FaceUp", "FaceDown", "Square"])
191
+ return false unless status_bar_orientation_validator.valid?(@status_bar_orientation)
192
+ return true
193
+ end
194
+
195
+ # Custom attribute writer method checking allowed values (enum).
196
+ # @param [Object] device_orientation Object to be assigned
197
+ def device_orientation=(device_orientation)
198
+ validator = EnumAttributeValidator.new('String', ["unknown", "portrait", "portrait_upside_down", "landscape", "LandscapeLeft", "LandscapeRight", "FaceUp", "FaceDown", "Square"])
199
+ unless validator.valid?(device_orientation)
200
+ fail ArgumentError, "invalid value for 'device_orientation', must be one of #{validator.allowable_values}."
201
+ end
202
+ @device_orientation = device_orientation
203
+ end
204
+
205
+ # Custom attribute writer method checking allowed values (enum).
206
+ # @param [Object] status_bar_orientation Object to be assigned
207
+ def status_bar_orientation=(status_bar_orientation)
208
+ validator = EnumAttributeValidator.new('String', ["unknown", "portrait", "portrait_upside_down", "landscape", "LandscapeLeft", "LandscapeRight", "FaceUp", "FaceDown", "Square"])
209
+ unless validator.valid?(status_bar_orientation)
210
+ fail ArgumentError, "invalid value for 'status_bar_orientation', must be one of #{validator.allowable_values}."
211
+ end
212
+ @status_bar_orientation = status_bar_orientation
213
+ end
214
+
215
+ # Checks equality by comparing each attribute.
216
+ # @param [Object] Object to be compared
217
+ def ==(o)
218
+ return true if self.equal?(o)
219
+ self.class == o.class &&
220
+ time_since_start_ms == o.time_since_start_ms &&
221
+ battery_level == o.battery_level &&
222
+ data_connection_type == o.data_connection_type &&
223
+ data_connection_type_detail == o.data_connection_type_detail &&
224
+ gps_state == o.gps_state &&
225
+ total_system_memory_usage_bytes == o.total_system_memory_usage_bytes &&
226
+ disk_space_free_bytes == o.disk_space_free_bytes &&
227
+ cpu == o.cpu &&
228
+ system_memory_available_bytes == o.system_memory_available_bytes &&
229
+ system_memory_low == o.system_memory_low &&
230
+ system_memory_threshold_bytes == o.system_memory_threshold_bytes &&
231
+ application_memory_available_bytes == o.application_memory_available_bytes &&
232
+ application_memory_max_bytes == o.application_memory_max_bytes &&
233
+ application_memory_total_bytes == o.application_memory_total_bytes &&
234
+ device_orientation == o.device_orientation &&
235
+ status_bar_orientation == o.status_bar_orientation
236
+ end
237
+
238
+ # @see the `==` method
239
+ # @param [Object] Object to be compared
240
+ def eql?(o)
241
+ self == o
242
+ end
243
+
244
+ # Calculates hash code according to all attributes.
245
+ # @return [Fixnum] Hash code
246
+ def hash
247
+ [time_since_start_ms, battery_level, data_connection_type, data_connection_type_detail, gps_state, total_system_memory_usage_bytes, disk_space_free_bytes, cpu, system_memory_available_bytes, system_memory_low, system_memory_threshold_bytes, application_memory_available_bytes, application_memory_max_bytes, application_memory_total_bytes, device_orientation, status_bar_orientation].hash
248
+ end
249
+
250
+ # Builds the object from hash
251
+ # @param [Hash] attributes Model attributes in the form of hash
252
+ # @return [Object] Returns the model itself
253
+ def build_from_hash(attributes)
254
+ return nil unless attributes.is_a?(Hash)
255
+ self.class.swagger_types.each_pair do |key, type|
256
+ if type =~ /\AArray<(.*)>/i
257
+ # check to ensure the input is an array given that the the attribute
258
+ # is documented as an array but the input is not
259
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
260
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
261
+ end
262
+ elsif !attributes[self.class.attribute_map[key]].nil?
263
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
264
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
265
+ end
266
+
267
+ self
268
+ end
269
+
270
+ # Deserializes the data based on type
271
+ # @param string type Data type
272
+ # @param string value Value to be deserialized
273
+ # @return [Object] Deserialized data
274
+ def _deserialize(type, value)
275
+ case type.to_sym
276
+ when :DateTime
277
+ DateTime.parse(value)
278
+ when :Date
279
+ Date.parse(value)
280
+ when :String
281
+ value.to_s
282
+ when :Integer
283
+ value.to_i
284
+ when :Float
285
+ value.to_f
286
+ when :BOOLEAN
287
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
288
+ true
289
+ else
290
+ false
291
+ end
292
+ when :Object
293
+ # generic object (usually a Hash), return directly
294
+ value
295
+ when /\AArray<(?<inner_type>.+)>\z/
296
+ inner_type = Regexp.last_match[:inner_type]
297
+ value.map { |v| _deserialize(inner_type, v) }
298
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
299
+ k_type = Regexp.last_match[:k_type]
300
+ v_type = Regexp.last_match[:v_type]
301
+ {}.tap do |hash|
302
+ value.each do |k, v|
303
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
304
+ end
305
+ end
306
+ else # model
307
+ temp_model = MParticle.const_get(type).new
308
+ temp_model.build_from_hash(value)
309
+ end
310
+ end
311
+
312
+ # Returns the string representation of the object
313
+ # @return [String] String presentation of the object
314
+ def to_s
315
+ to_hash.to_s
316
+ end
317
+
318
+ # to_body is an alias to to_hash (backward compatibility)
319
+ # @return [Hash] Returns the object in the form of hash
320
+ def to_body
321
+ to_hash
322
+ end
323
+
324
+ # Returns the object in the form of hash
325
+ # @return [Hash] Returns the object in the form of hash
326
+ def to_hash
327
+ hash = {}
328
+ self.class.attribute_map.each_pair do |attr, param|
329
+ value = self.send(attr)
330
+ next if value.nil?
331
+ hash[param] = _to_hash(value)
332
+ end
333
+ hash
334
+ end
335
+
336
+ # Outputs non-array value in the form of hash
337
+ # For object, use to_hash. Otherwise, just return the value
338
+ # @param [Object] value Any valid value
339
+ # @return [Hash] Returns the value in the form of hash
340
+ def _to_hash(value)
341
+ if value.is_a?(Array)
342
+ value.compact.map{ |v| _to_hash(v) }
343
+ elsif value.is_a?(Hash)
344
+ {}.tap do |hash|
345
+ value.each { |k, v| hash[k] = _to_hash(v) }
346
+ end
347
+ elsif value.respond_to? :to_hash
348
+ value.to_hash
349
+ else
350
+ value
351
+ end
352
+ end
353
+
354
+ end
355
+
356
+ end