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