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,506 @@
1
+ require 'date'
2
+
3
+ module MParticle
4
+
5
+ class DeviceInformation
6
+ attr_accessor :brand
7
+
8
+ attr_accessor :product
9
+
10
+ attr_accessor :device
11
+
12
+ attr_accessor :android_uuid
13
+
14
+ attr_accessor :device_manufacturer
15
+
16
+ attr_accessor :platform
17
+
18
+ attr_accessor :os_version
19
+
20
+ attr_accessor :device_model
21
+
22
+ attr_accessor :screen_height
23
+
24
+ attr_accessor :screen_width
25
+
26
+ attr_accessor :screen_dpi
27
+
28
+ attr_accessor :device_country
29
+
30
+ attr_accessor :locale_language
31
+
32
+ attr_accessor :locale_country
33
+
34
+ attr_accessor :network_country
35
+
36
+ attr_accessor :network_carrier
37
+
38
+ attr_accessor :network_code
39
+
40
+ attr_accessor :network_mobile_country_code
41
+
42
+ attr_accessor :timezone_offset
43
+
44
+ attr_accessor :build_identifier
45
+
46
+ attr_accessor :http_header_user_agent
47
+
48
+ attr_accessor :ios_advertising_id
49
+
50
+ attr_accessor :push_token
51
+
52
+ attr_accessor :cpu_architecture
53
+
54
+ attr_accessor :is_tablet
55
+
56
+ attr_accessor :push_notification_sound_enabled
57
+
58
+ attr_accessor :push_notification_vibrate_enabled
59
+
60
+ attr_accessor :radio_access_technology
61
+
62
+ attr_accessor :supports_telephony
63
+
64
+ attr_accessor :has_nfc
65
+
66
+ attr_accessor :bluetooth_enabled
67
+
68
+ attr_accessor :bluetooth_version
69
+
70
+ attr_accessor :ios_idfv
71
+
72
+ attr_accessor :android_advertising_id
73
+
74
+ class EnumAttributeValidator
75
+ attr_reader :datatype
76
+ attr_reader :allowable_values
77
+
78
+ def initialize(datatype, allowable_values)
79
+ @allowable_values = allowable_values.map do |value|
80
+ case datatype.to_s
81
+ when /Integer/i
82
+ value.to_i
83
+ when /Float/i
84
+ value.to_f
85
+ else
86
+ value
87
+ end
88
+ end
89
+ end
90
+
91
+ def valid?(value)
92
+ !value || allowable_values.include?(value)
93
+ end
94
+ end
95
+
96
+ # Attribute mapping from ruby-style variable name to JSON key.
97
+ def self.attribute_map
98
+ {
99
+ :'brand' => :'brand',
100
+ :'product' => :'product',
101
+ :'device' => :'device',
102
+ :'android_uuid' => :'android_uuid',
103
+ :'device_manufacturer' => :'device_manufacturer',
104
+ :'platform' => :'platform',
105
+ :'os_version' => :'os_version',
106
+ :'device_model' => :'device_model',
107
+ :'screen_height' => :'screen_height',
108
+ :'screen_width' => :'screen_width',
109
+ :'screen_dpi' => :'screen_dpi',
110
+ :'device_country' => :'device_country',
111
+ :'locale_language' => :'locale_language',
112
+ :'locale_country' => :'locale_country',
113
+ :'network_country' => :'network_country',
114
+ :'network_carrier' => :'network_carrier',
115
+ :'network_code' => :'network_code',
116
+ :'network_mobile_country_code' => :'network_mobile_country_code',
117
+ :'timezone_offset' => :'timezone_offset',
118
+ :'build_identifier' => :'build_identifier',
119
+ :'http_header_user_agent' => :'http_header_user_agent',
120
+ :'ios_advertising_id' => :'ios_advertising_id',
121
+ :'push_token' => :'push_token',
122
+ :'cpu_architecture' => :'cpu_architecture',
123
+ :'is_tablet' => :'is_tablet',
124
+ :'push_notification_sound_enabled' => :'push_notification_sound_enabled',
125
+ :'push_notification_vibrate_enabled' => :'push_notification_vibrate_enabled',
126
+ :'radio_access_technology' => :'radio_access_technology',
127
+ :'supports_telephony' => :'supports_telephony',
128
+ :'has_nfc' => :'has_nfc',
129
+ :'bluetooth_enabled' => :'bluetooth_enabled',
130
+ :'bluetooth_version' => :'bluetooth_version',
131
+ :'ios_idfv' => :'ios_idfv',
132
+ :'android_advertising_id' => :'android_advertising_id'
133
+ }
134
+ end
135
+
136
+ # Attribute type mapping.
137
+ def self.swagger_types
138
+ {
139
+ :'brand' => :'String',
140
+ :'product' => :'String',
141
+ :'device' => :'String',
142
+ :'android_uuid' => :'String',
143
+ :'device_manufacturer' => :'String',
144
+ :'platform' => :'String',
145
+ :'os_version' => :'String',
146
+ :'device_model' => :'String',
147
+ :'screen_height' => :'Integer',
148
+ :'screen_width' => :'Integer',
149
+ :'screen_dpi' => :'Integer',
150
+ :'device_country' => :'String',
151
+ :'locale_language' => :'String',
152
+ :'locale_country' => :'String',
153
+ :'network_country' => :'String',
154
+ :'network_carrier' => :'String',
155
+ :'network_code' => :'String',
156
+ :'network_mobile_country_code' => :'String',
157
+ :'timezone_offset' => :'Integer',
158
+ :'build_identifier' => :'String',
159
+ :'http_header_user_agent' => :'String',
160
+ :'ios_advertising_id' => :'String',
161
+ :'push_token' => :'String',
162
+ :'cpu_architecture' => :'String',
163
+ :'is_tablet' => :'BOOLEAN',
164
+ :'push_notification_sound_enabled' => :'BOOLEAN',
165
+ :'push_notification_vibrate_enabled' => :'BOOLEAN',
166
+ :'radio_access_technology' => :'String',
167
+ :'supports_telephony' => :'BOOLEAN',
168
+ :'has_nfc' => :'BOOLEAN',
169
+ :'bluetooth_enabled' => :'BOOLEAN',
170
+ :'bluetooth_version' => :'String',
171
+ :'ios_idfv' => :'String',
172
+ :'android_advertising_id' => :'String'
173
+ }
174
+ end
175
+
176
+ # Initializes the object
177
+ # @param [Hash] attributes Model attributes in the form of hash
178
+ def initialize(attributes = {})
179
+ return unless attributes.is_a?(Hash)
180
+
181
+ # convert string to symbol for hash key
182
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
183
+
184
+ if attributes.has_key?(:'brand')
185
+ self.brand = attributes[:'brand']
186
+ end
187
+
188
+ if attributes.has_key?(:'product')
189
+ self.product = attributes[:'product']
190
+ end
191
+
192
+ if attributes.has_key?(:'device')
193
+ self.device = attributes[:'device']
194
+ end
195
+
196
+ if attributes.has_key?(:'android_uuid')
197
+ self.android_uuid = attributes[:'android_uuid']
198
+ end
199
+
200
+ if attributes.has_key?(:'device_manufacturer')
201
+ self.device_manufacturer = attributes[:'device_manufacturer']
202
+ end
203
+
204
+ if attributes.has_key?(:'platform')
205
+ self.platform = attributes[:'platform']
206
+ end
207
+
208
+ if attributes.has_key?(:'os_version')
209
+ self.os_version = attributes[:'os_version']
210
+ end
211
+
212
+ if attributes.has_key?(:'device_model')
213
+ self.device_model = attributes[:'device_model']
214
+ end
215
+
216
+ if attributes.has_key?(:'screen_height')
217
+ self.screen_height = attributes[:'screen_height']
218
+ end
219
+
220
+ if attributes.has_key?(:'screen_width')
221
+ self.screen_width = attributes[:'screen_width']
222
+ end
223
+
224
+ if attributes.has_key?(:'screen_dpi')
225
+ self.screen_dpi = attributes[:'screen_dpi']
226
+ end
227
+
228
+ if attributes.has_key?(:'device_country')
229
+ self.device_country = attributes[:'device_country']
230
+ end
231
+
232
+ if attributes.has_key?(:'locale_language')
233
+ self.locale_language = attributes[:'locale_language']
234
+ end
235
+
236
+ if attributes.has_key?(:'locale_country')
237
+ self.locale_country = attributes[:'locale_country']
238
+ end
239
+
240
+ if attributes.has_key?(:'network_country')
241
+ self.network_country = attributes[:'network_country']
242
+ end
243
+
244
+ if attributes.has_key?(:'network_carrier')
245
+ self.network_carrier = attributes[:'network_carrier']
246
+ end
247
+
248
+ if attributes.has_key?(:'network_code')
249
+ self.network_code = attributes[:'network_code']
250
+ end
251
+
252
+ if attributes.has_key?(:'network_mobile_country_code')
253
+ self.network_mobile_country_code = attributes[:'network_mobile_country_code']
254
+ end
255
+
256
+ if attributes.has_key?(:'timezone_offset')
257
+ self.timezone_offset = attributes[:'timezone_offset']
258
+ end
259
+
260
+ if attributes.has_key?(:'build_identifier')
261
+ self.build_identifier = attributes[:'build_identifier']
262
+ end
263
+
264
+ if attributes.has_key?(:'http_header_user_agent')
265
+ self.http_header_user_agent = attributes[:'http_header_user_agent']
266
+ end
267
+
268
+ if attributes.has_key?(:'ios_advertising_id')
269
+ self.ios_advertising_id = attributes[:'ios_advertising_id']
270
+ end
271
+
272
+ if attributes.has_key?(:'push_token')
273
+ self.push_token = attributes[:'push_token']
274
+ end
275
+
276
+ if attributes.has_key?(:'cpu_architecture')
277
+ self.cpu_architecture = attributes[:'cpu_architecture']
278
+ end
279
+
280
+ if attributes.has_key?(:'is_tablet')
281
+ self.is_tablet = attributes[:'is_tablet']
282
+ end
283
+
284
+ if attributes.has_key?(:'push_notification_sound_enabled')
285
+ self.push_notification_sound_enabled = attributes[:'push_notification_sound_enabled']
286
+ end
287
+
288
+ if attributes.has_key?(:'push_notification_vibrate_enabled')
289
+ self.push_notification_vibrate_enabled = attributes[:'push_notification_vibrate_enabled']
290
+ end
291
+
292
+ if attributes.has_key?(:'radio_access_technology')
293
+ self.radio_access_technology = attributes[:'radio_access_technology']
294
+ end
295
+
296
+ if attributes.has_key?(:'supports_telephony')
297
+ self.supports_telephony = attributes[:'supports_telephony']
298
+ end
299
+
300
+ if attributes.has_key?(:'has_nfc')
301
+ self.has_nfc = attributes[:'has_nfc']
302
+ end
303
+
304
+ if attributes.has_key?(:'bluetooth_enabled')
305
+ self.bluetooth_enabled = attributes[:'bluetooth_enabled']
306
+ end
307
+
308
+ if attributes.has_key?(:'bluetooth_version')
309
+ self.bluetooth_version = attributes[:'bluetooth_version']
310
+ end
311
+
312
+ if attributes.has_key?(:'ios_idfv')
313
+ self.ios_idfv = attributes[:'ios_idfv']
314
+ end
315
+
316
+ if attributes.has_key?(:'android_advertising_id')
317
+ self.android_advertising_id = attributes[:'android_advertising_id']
318
+ end
319
+
320
+ end
321
+
322
+ # Show invalid properties with the reasons. Usually used together with valid?
323
+ # @return Array for valid properies with the reasons
324
+ def list_invalid_properties
325
+ invalid_properties = Array.new
326
+ return invalid_properties
327
+ end
328
+
329
+ # Check to see if the all the properties in the model are valid
330
+ # @return true if the model is valid
331
+ def valid?
332
+ platform_validator = EnumAttributeValidator.new('String', ["Unknown", "iOS", "Android", "tvOS"])
333
+ return false unless platform_validator.valid?(@platform)
334
+ return true
335
+ end
336
+
337
+ # Custom attribute writer method checking allowed values (enum).
338
+ # @param [Object] platform Object to be assigned
339
+ def platform=(platform)
340
+ validator = EnumAttributeValidator.new('String', ["Unknown", "iOS", "Android", "tvOS"])
341
+ unless validator.valid?(platform)
342
+ fail ArgumentError, "invalid value for 'platform', must be one of #{validator.allowable_values}."
343
+ end
344
+ @platform = platform
345
+ end
346
+
347
+ # Checks equality by comparing each attribute.
348
+ # @param [Object] Object to be compared
349
+ def ==(o)
350
+ return true if self.equal?(o)
351
+ self.class == o.class &&
352
+ brand == o.brand &&
353
+ product == o.product &&
354
+ device == o.device &&
355
+ android_uuid == o.android_uuid &&
356
+ device_manufacturer == o.device_manufacturer &&
357
+ platform == o.platform &&
358
+ os_version == o.os_version &&
359
+ device_model == o.device_model &&
360
+ screen_height == o.screen_height &&
361
+ screen_width == o.screen_width &&
362
+ screen_dpi == o.screen_dpi &&
363
+ device_country == o.device_country &&
364
+ locale_language == o.locale_language &&
365
+ locale_country == o.locale_country &&
366
+ network_country == o.network_country &&
367
+ network_carrier == o.network_carrier &&
368
+ network_code == o.network_code &&
369
+ network_mobile_country_code == o.network_mobile_country_code &&
370
+ timezone_offset == o.timezone_offset &&
371
+ build_identifier == o.build_identifier &&
372
+ http_header_user_agent == o.http_header_user_agent &&
373
+ ios_advertising_id == o.ios_advertising_id &&
374
+ push_token == o.push_token &&
375
+ cpu_architecture == o.cpu_architecture &&
376
+ is_tablet == o.is_tablet &&
377
+ push_notification_sound_enabled == o.push_notification_sound_enabled &&
378
+ push_notification_vibrate_enabled == o.push_notification_vibrate_enabled &&
379
+ radio_access_technology == o.radio_access_technology &&
380
+ supports_telephony == o.supports_telephony &&
381
+ has_nfc == o.has_nfc &&
382
+ bluetooth_enabled == o.bluetooth_enabled &&
383
+ bluetooth_version == o.bluetooth_version &&
384
+ ios_idfv == o.ios_idfv &&
385
+ android_advertising_id == o.android_advertising_id
386
+ end
387
+
388
+ # @see the `==` method
389
+ # @param [Object] Object to be compared
390
+ def eql?(o)
391
+ self == o
392
+ end
393
+
394
+ # Calculates hash code according to all attributes.
395
+ # @return [Fixnum] Hash code
396
+ def hash
397
+ [brand, product, device, android_uuid, device_manufacturer, platform, os_version, device_model, screen_height, screen_width, screen_dpi, device_country, locale_language, locale_country, network_country, network_carrier, network_code, network_mobile_country_code, timezone_offset, build_identifier, http_header_user_agent, ios_advertising_id, push_token, cpu_architecture, is_tablet, push_notification_sound_enabled, push_notification_vibrate_enabled, radio_access_technology, supports_telephony, has_nfc, bluetooth_enabled, bluetooth_version, ios_idfv, android_advertising_id].hash
398
+ end
399
+
400
+ # Builds the object from hash
401
+ # @param [Hash] attributes Model attributes in the form of hash
402
+ # @return [Object] Returns the model itself
403
+ def build_from_hash(attributes)
404
+ return nil unless attributes.is_a?(Hash)
405
+ self.class.swagger_types.each_pair do |key, type|
406
+ if type =~ /\AArray<(.*)>/i
407
+ # check to ensure the input is an array given that the the attribute
408
+ # is documented as an array but the input is not
409
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
410
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
411
+ end
412
+ elsif !attributes[self.class.attribute_map[key]].nil?
413
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
414
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
415
+ end
416
+
417
+ self
418
+ end
419
+
420
+ # Deserializes the data based on type
421
+ # @param string type Data type
422
+ # @param string value Value to be deserialized
423
+ # @return [Object] Deserialized data
424
+ def _deserialize(type, value)
425
+ case type.to_sym
426
+ when :DateTime
427
+ DateTime.parse(value)
428
+ when :Date
429
+ Date.parse(value)
430
+ when :String
431
+ value.to_s
432
+ when :Integer
433
+ value.to_i
434
+ when :Float
435
+ value.to_f
436
+ when :BOOLEAN
437
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
438
+ true
439
+ else
440
+ false
441
+ end
442
+ when :Object
443
+ # generic object (usually a Hash), return directly
444
+ value
445
+ when /\AArray<(?<inner_type>.+)>\z/
446
+ inner_type = Regexp.last_match[:inner_type]
447
+ value.map { |v| _deserialize(inner_type, v) }
448
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
449
+ k_type = Regexp.last_match[:k_type]
450
+ v_type = Regexp.last_match[:v_type]
451
+ {}.tap do |hash|
452
+ value.each do |k, v|
453
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
454
+ end
455
+ end
456
+ else # model
457
+ temp_model = MParticle.const_get(type).new
458
+ temp_model.build_from_hash(value)
459
+ end
460
+ end
461
+
462
+ # Returns the string representation of the object
463
+ # @return [String] String presentation of the object
464
+ def to_s
465
+ to_hash.to_s
466
+ end
467
+
468
+ # to_body is an alias to to_hash (backward compatibility)
469
+ # @return [Hash] Returns the object in the form of hash
470
+ def to_body
471
+ to_hash
472
+ end
473
+
474
+ # Returns the object in the form of hash
475
+ # @return [Hash] Returns the object in the form of hash
476
+ def to_hash
477
+ hash = {}
478
+ self.class.attribute_map.each_pair do |attr, param|
479
+ value = self.send(attr)
480
+ next if value.nil?
481
+ hash[param] = _to_hash(value)
482
+ end
483
+ hash
484
+ end
485
+
486
+ # Outputs non-array value in the form of hash
487
+ # For object, use to_hash. Otherwise, just return the value
488
+ # @param [Object] value Any valid value
489
+ # @return [Hash] Returns the value in the form of hash
490
+ def _to_hash(value)
491
+ if value.is_a?(Array)
492
+ value.compact.map{ |v| _to_hash(v) }
493
+ elsif value.is_a?(Hash)
494
+ {}.tap do |hash|
495
+ value.each { |k, v| hash[k] = _to_hash(v) }
496
+ end
497
+ elsif value.respond_to? :to_hash
498
+ value.to_hash
499
+ else
500
+ value
501
+ end
502
+ end
503
+
504
+ end
505
+
506
+ end