mparticle 1.0.5 → 1.0.10
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.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/docs/Batch.md +3 -0
- data/docs/CCPAConsentState.md +10 -0
- data/docs/ConsentState.md +4 -3
- data/docs/UserIdentities.md +12 -0
- data/example/main.rb +13 -3
- data/lib/mparticle.rb +3 -0
- data/lib/mparticle/api_client.rb +1 -1
- data/lib/mparticle/models/batch.rb +35 -4
- data/lib/mparticle/models/batch_context.rb +177 -0
- data/lib/mparticle/models/ccpa_consent_state.rb +233 -0
- data/lib/mparticle/models/consent_state.rb +9 -0
- data/lib/mparticle/models/data_plan_context.rb +186 -0
- data/lib/mparticle/models/user_identities.rb +112 -4
- data/lib/mparticle/version.rb +1 -1
- data/mparticle.gemspec +2 -2
- data/spec/models/batch_spec.rb +20 -0
- data/spec/models/ccpa_consent_state_spec.rb +34 -0
- data/spec/models/consent_state_spec.rb +5 -0
- data/spec/models/data_plan_context_spec.rb +19 -0
- data/spec/models/user_identities_spec.rb +59 -0
- metadata +14 -9
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -34
- data/mparticle-1.0.4.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b4b30c931a78c920091ae233dda6a478d5f2fbf9b57ca4470a8ee4d1fd866d1
|
4
|
+
data.tar.gz: 4a8f7748c45ab84b9a180c84001379b0d102b9b973c2b302ed1de367afcc3ccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54b7b4841fec9dbac24534a31fcc003b360e3d49a165d9d330116b291005f9be7b85f6161387c7fc8f4351c0a2d0c867c1a36c2c14d3d8b5ff590e1b480a8403
|
7
|
+
data.tar.gz: 6aa790099163be36dfc190374048755bd905ae8d9b3476ffc1ca0687423a0e15f8f7b5926fbe766dba59ea8c620ce090dcc1fe9122c1e44bea843ade1d16743c
|
data/README.md
CHANGED
@@ -41,6 +41,11 @@ api_instance = MParticle::EventsApi.new(config)
|
|
41
41
|
|
42
42
|
batch = MParticle::Batch.new
|
43
43
|
batch.environment = 'development'
|
44
|
+
batch.context = MParticle::BatchContext.new
|
45
|
+
|
46
|
+
batch.context.data_plan = MParticle::DataPlanContext.new
|
47
|
+
batch.context.data_plan.plan_id = 'my_plan_id'
|
48
|
+
batch.context.data_plan.plan_version = 1
|
44
49
|
|
45
50
|
user_identities = MParticle::UserIdentities.new
|
46
51
|
user_identities.customerid = '12345'
|
data/docs/Batch.md
CHANGED
@@ -18,3 +18,6 @@
|
|
18
18
|
| **api_key** | **String** | | [optional] |
|
19
19
|
| **mpid** | **Integer** | | [optional] |
|
20
20
|
| **mp_deviceid** | **String** | | [optional] |
|
21
|
+
| **timestamp_unixtime_ms** | **Integer** | | [optional] |
|
22
|
+
| **context** | [**BatchContext**](BatchContext.md) | | [optional] |
|
23
|
+
| **integration_attributes** | **Hash<Integer,Hash<String,String>>** | | [optional] |
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# mParticle.CCPAConsentState
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
| Name | Type | Description | Notes |
|
6
|
+
| ------------------------- | ----------- | ----------- | ----- |
|
7
|
+
| **consented** | **Boolean** | | |
|
8
|
+
| **timestamp_unixtime_ms** | **Number** | | |
|
9
|
+
| **location** | **String** | | |
|
10
|
+
| **hardware_id** | **String** | | |
|
data/docs/ConsentState.md
CHANGED
data/docs/UserIdentities.md
CHANGED
@@ -13,5 +13,17 @@ Name | Type | Description | Notes
|
|
13
13
|
**email** | **String** | | [optional]
|
14
14
|
**_alias** | **String** | | [optional]
|
15
15
|
**facebook_custom_audience_id** | **String** | | [optional]
|
16
|
+
**other_id_2** | **String** | | [optional]
|
17
|
+
**other_id_3** | **String** | | [optional]
|
18
|
+
**other_id_4** | **String** | | [optional]
|
19
|
+
**other_id_5** | **String** | | [optional]
|
20
|
+
**other_id_6** | **String** | | [optional]
|
21
|
+
**other_id_7** | **String** | | [optional]
|
22
|
+
**other_id_8** | **String** | | [optional]
|
23
|
+
**other_id_9** | **String** | | [optional]
|
24
|
+
**other_id_10** | **String** | | [optional]
|
25
|
+
**mobile_number** | **String** | | [optional]
|
26
|
+
**phone_number_2** | **String** | | [optional]
|
27
|
+
**phone_number_3** | **String** | | [optional]
|
16
28
|
|
17
29
|
|
data/example/main.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# load the gem
|
4
4
|
require 'mparticle'
|
5
|
+
require 'date'
|
5
6
|
config = MParticle::Configuration.new
|
6
7
|
config.api_key = 'REPLACE WITH API KEY'
|
7
8
|
config.api_secret = 'REPLACE WITH API SECRET'
|
@@ -10,6 +11,7 @@ config.api_secret = 'REPLACE WITH API SECRET'
|
|
10
11
|
api_instance = MParticle::EventsApi.new(config)
|
11
12
|
|
12
13
|
batch = MParticle::Batch.new
|
14
|
+
batch.timestamp_unixtime_ms = DateTime.now.strftime('%Q').to_i
|
13
15
|
batch.environment = 'development'
|
14
16
|
|
15
17
|
user_identities = MParticle::UserIdentities.new
|
@@ -51,6 +53,13 @@ commerce_event = {
|
|
51
53
|
batch.events = [MParticle::SessionStartEvent.new, app_event, MParticle::SessionEndEvent.new]
|
52
54
|
batch.user_identities = user_identities
|
53
55
|
|
56
|
+
ccpa_consent_state = MParticle::CCPAConsentState.new
|
57
|
+
ccpa_consent_state.document = 'document.agreement.v3'
|
58
|
+
ccpa_consent_state.consented = true
|
59
|
+
ccpa_consent_state.timestamp_unixtime_ms = Time.now.to_i
|
60
|
+
ccpa_consent_state.location = 'mparticle.test/signup'
|
61
|
+
ccpa_consent_state.hardware_id = 'IDFA:a5d96n32-224a-3b11-1088-a202695bc710'
|
62
|
+
|
54
63
|
gdpr_consent_state = MParticle::GDPRConsentState.new
|
55
64
|
gdpr_consent_state.document = 'document_agreement.v2'
|
56
65
|
gdpr_consent_state.consented = true
|
@@ -60,8 +69,9 @@ gdpr_consent_state.hardware_id = 'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'
|
|
60
69
|
|
61
70
|
consent_state = MParticle::ConsentState.new
|
62
71
|
# Make sure this purpose matches your consent purpose in
|
63
|
-
#
|
64
|
-
# https://docs.mparticle.com/guides/consent-management
|
72
|
+
# Workspace Settings > Workspace > Regulations
|
73
|
+
# https://docs.mparticle.com/guides/consent-management/
|
74
|
+
consent_state.ccpa = { 'data_sale_opt_out' => ccpa_consent_state }
|
65
75
|
consent_state.gdpr = { 'document_agreement' => gdpr_consent_state }
|
66
76
|
batch.consent_state = consent_state
|
67
77
|
|
@@ -78,5 +88,5 @@ begin
|
|
78
88
|
# wait for the thread, otherwise process may exit too early
|
79
89
|
thread.join
|
80
90
|
rescue MParticle::ApiError => e
|
81
|
-
puts "Exception when calling mParticle: #{e}"
|
91
|
+
puts "Exception when calling mParticle: #{e.response_body}"
|
82
92
|
end
|
data/lib/mparticle.rb
CHANGED
@@ -13,6 +13,7 @@ require 'mparticle/models/application_state_transition_event'
|
|
13
13
|
require 'mparticle/models/attribution_info'
|
14
14
|
require 'mparticle/models/batch'
|
15
15
|
require 'mparticle/models/breadcrumb_event'
|
16
|
+
require 'mparticle/models/ccpa_consent_state'
|
16
17
|
require 'mparticle/models/commerce_event'
|
17
18
|
require 'mparticle/models/consent_state'
|
18
19
|
require 'mparticle/models/crash_report_event'
|
@@ -40,6 +41,8 @@ require 'mparticle/models/session_start_event'
|
|
40
41
|
require 'mparticle/models/shopping_cart'
|
41
42
|
require 'mparticle/models/source_information'
|
42
43
|
require 'mparticle/models/user_identities'
|
44
|
+
require 'mparticle/models/batch_context'
|
45
|
+
require 'mparticle/models/data_plan_context'
|
43
46
|
|
44
47
|
# APIs
|
45
48
|
require 'mparticle/api/events_api'
|
data/lib/mparticle/api_client.rb
CHANGED
@@ -19,7 +19,7 @@ module MParticle
|
|
19
19
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
20
20
|
def initialize(config)
|
21
21
|
@config = config
|
22
|
-
@user_agent = "mParticle Ruby client/1.0.
|
22
|
+
@user_agent = "mParticle Ruby client/1.0.10"
|
23
23
|
@default_headers = {
|
24
24
|
'Content-Type' => "application/json",
|
25
25
|
'User-Agent' => @user_agent
|
@@ -31,6 +31,12 @@ module MParticle
|
|
31
31
|
|
32
32
|
attr_accessor :mp_deviceid
|
33
33
|
|
34
|
+
attr_accessor :timestamp_unixtime_ms
|
35
|
+
|
36
|
+
attr_accessor :context
|
37
|
+
|
38
|
+
attr_accessor :integration_attributes
|
39
|
+
|
34
40
|
class EnumAttributeValidator
|
35
41
|
attr_reader :datatype
|
36
42
|
attr_reader :allowable_values
|
@@ -109,7 +115,10 @@ module MParticle
|
|
109
115
|
:'user_identities' => :'user_identities',
|
110
116
|
:'api_key' => :'api_key',
|
111
117
|
:'mpid' => :'mpid',
|
112
|
-
:'mp_deviceid' => :'mp_deviceid'
|
118
|
+
:'mp_deviceid' => :'mp_deviceid',
|
119
|
+
:'timestamp_unixtime_ms' => :'timestamp_unixtime_ms',
|
120
|
+
:'context' => :'context',
|
121
|
+
:'integration_attributes' => :'integration_attributes'
|
113
122
|
}
|
114
123
|
end
|
115
124
|
|
@@ -128,7 +137,11 @@ module MParticle
|
|
128
137
|
:'user_identities' => :'UserIdentities',
|
129
138
|
:'api_key' => :'String',
|
130
139
|
:'mpid' => :'Integer',
|
131
|
-
:'mp_deviceid' => :'String'
|
140
|
+
:'mp_deviceid' => :'String',
|
141
|
+
:'timestamp_unixtime_ms' => :'Integer',
|
142
|
+
:'consent_state' => :'ConsentState',
|
143
|
+
:'context' => :'BatchContext',
|
144
|
+
:'integration_attributes' => :'Hash<Integer,Hash<String,String>>'
|
132
145
|
}
|
133
146
|
end
|
134
147
|
|
@@ -196,6 +209,22 @@ module MParticle
|
|
196
209
|
self.mp_deviceid = attributes[:'mp_deviceid']
|
197
210
|
end
|
198
211
|
|
212
|
+
if attributes.has_key?(:'timestamp_unixtime_ms')
|
213
|
+
self.timestamp_unixtime_ms = attributes[:'timestamp_unixtime_ms']
|
214
|
+
end
|
215
|
+
|
216
|
+
if attributes.has_key?(:'consent_state')
|
217
|
+
self.consent_state = attributes[:'consent_state']
|
218
|
+
end
|
219
|
+
|
220
|
+
if attributes.has_key?(:'context')
|
221
|
+
self.context = attributes[:'context']
|
222
|
+
end
|
223
|
+
|
224
|
+
if attributes.has_key?(:'integration_attributes')
|
225
|
+
self.integration_attributes = attributes[:'integration_attributes']
|
226
|
+
end
|
227
|
+
|
199
228
|
end
|
200
229
|
|
201
230
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -245,7 +274,9 @@ module MParticle
|
|
245
274
|
user_identities == o.user_identities &&
|
246
275
|
api_key == o.api_key &&
|
247
276
|
mpid == o.mpid &&
|
248
|
-
mp_deviceid == o.mp_deviceid
|
277
|
+
mp_deviceid == o.mp_deviceid &&
|
278
|
+
timestamp_unixtime_ms == o.timestamp_unixtime_ms &&
|
279
|
+
integration_attributes == o.integration_attributes
|
249
280
|
end
|
250
281
|
|
251
282
|
# @see the `==` method
|
@@ -257,7 +288,7 @@ module MParticle
|
|
257
288
|
# Calculates hash code according to all attributes.
|
258
289
|
# @return [Fixnum] Hash code
|
259
290
|
def hash
|
260
|
-
[events, source_request_id, environment, ip, schema_version, device_info, application_info, user_attributes, deleted_user_attributes, user_identities, api_key, mpid, mp_deviceid].hash
|
291
|
+
[events, source_request_id, environment, ip, schema_version, device_info, application_info, user_attributes, deleted_user_attributes, user_identities, api_key, mpid, mp_deviceid, timestamp_unixtime_ms, integration_attributes].hash
|
261
292
|
end
|
262
293
|
|
263
294
|
# Builds the object from hash
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module MParticle
|
4
|
+
|
5
|
+
class BatchContext
|
6
|
+
attr_accessor :data_plan
|
7
|
+
|
8
|
+
|
9
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
10
|
+
def self.attribute_map
|
11
|
+
{
|
12
|
+
:'data_plan' => :'data_plan'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
# Attribute type mapping.
|
17
|
+
def self.swagger_types
|
18
|
+
{
|
19
|
+
:'data_plan' => :'DataPlanContext'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Initializes the object
|
24
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
25
|
+
def initialize(attributes = {})
|
26
|
+
return unless attributes.is_a?(Hash)
|
27
|
+
|
28
|
+
# convert string to symbol for hash key
|
29
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
30
|
+
|
31
|
+
if attributes.has_key?(:'data_plan')
|
32
|
+
self.data_plan = attributes[:'data_plan']
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
38
|
+
# @return Array for valid properies with the reasons
|
39
|
+
def list_invalid_properties
|
40
|
+
invalid_properties = Array.new
|
41
|
+
return invalid_properties
|
42
|
+
end
|
43
|
+
|
44
|
+
# Check to see if the all the properties in the model are valid
|
45
|
+
# @return true if the model is valid
|
46
|
+
def valid?
|
47
|
+
return true
|
48
|
+
end
|
49
|
+
|
50
|
+
# Checks equality by comparing each attribute.
|
51
|
+
# @param [Object] Object to be compared
|
52
|
+
def ==(o)
|
53
|
+
return true if self.equal?(o)
|
54
|
+
self.class == o.class &&
|
55
|
+
data_plan == o.data_plan
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# @see the `==` method
|
60
|
+
# @param [Object] Object to be compared
|
61
|
+
def eql?(o)
|
62
|
+
self == o
|
63
|
+
end
|
64
|
+
|
65
|
+
# Calculates hash code according to all attributes.
|
66
|
+
# @return [Fixnum] Hash code
|
67
|
+
def hash
|
68
|
+
[data_plan].hash
|
69
|
+
end
|
70
|
+
|
71
|
+
# Builds the object from hash
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
# @return [Object] Returns the model itself
|
74
|
+
def build_from_hash(attributes)
|
75
|
+
return nil unless attributes.is_a?(Hash)
|
76
|
+
self.class.swagger_types.each_pair do |key, type|
|
77
|
+
if type =~ /\AArray<(.*)>/i
|
78
|
+
# check to ensure the input is an array given that the the attribute
|
79
|
+
# is documented as an array but the input is not
|
80
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
81
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
82
|
+
end
|
83
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
84
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
85
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
86
|
+
end
|
87
|
+
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
# Deserializes the data based on type
|
92
|
+
# @param string type Data type
|
93
|
+
# @param string value Value to be deserialized
|
94
|
+
# @return [Object] Deserialized data
|
95
|
+
def _deserialize(type, value)
|
96
|
+
case type.to_sym
|
97
|
+
when :DateTime
|
98
|
+
DateTime.parse(value)
|
99
|
+
when :Date
|
100
|
+
Date.parse(value)
|
101
|
+
when :String
|
102
|
+
value.to_s
|
103
|
+
when :Integer
|
104
|
+
value.to_i
|
105
|
+
when :Float
|
106
|
+
value.to_f
|
107
|
+
when :BOOLEAN
|
108
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
109
|
+
true
|
110
|
+
else
|
111
|
+
false
|
112
|
+
end
|
113
|
+
when :Object
|
114
|
+
# generic object (usually a Hash), return directly
|
115
|
+
value
|
116
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
117
|
+
inner_type = Regexp.last_match[:inner_type]
|
118
|
+
value.map { |v| _deserialize(inner_type, v) }
|
119
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
120
|
+
k_type = Regexp.last_match[:k_type]
|
121
|
+
v_type = Regexp.last_match[:v_type]
|
122
|
+
{}.tap do |hash|
|
123
|
+
value.each do |k, v|
|
124
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
else # model
|
128
|
+
temp_model = MParticle.const_get(type).new
|
129
|
+
temp_model.build_from_hash(value)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Returns the string representation of the object
|
134
|
+
# @return [String] String presentation of the object
|
135
|
+
def to_s
|
136
|
+
to_hash.to_s
|
137
|
+
end
|
138
|
+
|
139
|
+
# to_body is an alias to to_hash (backward compatibility)
|
140
|
+
# @return [Hash] Returns the object in the form of hash
|
141
|
+
def to_body
|
142
|
+
to_hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the object in the form of hash
|
146
|
+
# @return [Hash] Returns the object in the form of hash
|
147
|
+
def to_hash
|
148
|
+
hash = {}
|
149
|
+
self.class.attribute_map.each_pair do |attr, param|
|
150
|
+
value = self.send(attr)
|
151
|
+
next if value.nil?
|
152
|
+
hash[param] = _to_hash(value)
|
153
|
+
end
|
154
|
+
hash
|
155
|
+
end
|
156
|
+
|
157
|
+
# Outputs non-array value in the form of hash
|
158
|
+
# For object, use to_hash. Otherwise, just return the value
|
159
|
+
# @param [Object] value Any valid value
|
160
|
+
# @return [Hash] Returns the value in the form of hash
|
161
|
+
def _to_hash(value)
|
162
|
+
if value.is_a?(Array)
|
163
|
+
value.compact.map{ |v| _to_hash(v) }
|
164
|
+
elsif value.is_a?(Hash)
|
165
|
+
{}.tap do |hash|
|
166
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
167
|
+
end
|
168
|
+
elsif value.respond_to? :to_hash
|
169
|
+
value.to_hash
|
170
|
+
else
|
171
|
+
value
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
module MParticle
|
2
|
+
class CCPAConsentState
|
3
|
+
attr_accessor :document
|
4
|
+
attr_accessor :consented
|
5
|
+
attr_accessor :timestamp_unixtime_ms
|
6
|
+
attr_accessor :location
|
7
|
+
attr_accessor :hardware_id
|
8
|
+
|
9
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
10
|
+
def self.attribute_map
|
11
|
+
{
|
12
|
+
:'document' => 'document',
|
13
|
+
:'consented' => 'consented',
|
14
|
+
:'timestamp_unixtime_ms' => 'timestamp_unixtime_ms',
|
15
|
+
:'location' => 'location',
|
16
|
+
:'hardware_id' => 'hardware_id',
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
# Attribute type mapping.
|
21
|
+
def self.swagger_types
|
22
|
+
{
|
23
|
+
:'document' => 'String',
|
24
|
+
:'consented' => 'Boolean',
|
25
|
+
:'timestamp_unixtime_ms' => 'Integer',
|
26
|
+
:'location' => 'String',
|
27
|
+
:'hardware_id' => 'String',
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Initializes the object
|
32
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
33
|
+
def initialize(attributes = {})
|
34
|
+
return unless attributes.is_a?(Hash)
|
35
|
+
|
36
|
+
# convert string to symbol for hash key
|
37
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
38
|
+
|
39
|
+
if attributes.has_key?(:'document')
|
40
|
+
self.document = attributes[:'document']
|
41
|
+
end
|
42
|
+
|
43
|
+
if attributes.has_key?(:'consented')
|
44
|
+
self.consented = attributes[:'consented']
|
45
|
+
end
|
46
|
+
|
47
|
+
if attributes.has_key?(:'timestamp_unixtime_ms')
|
48
|
+
self.timestamp_unixtime_ms = attributes[:'timestamp_unixtime_ms']
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:'location')
|
52
|
+
self.location = attributes[:'location']
|
53
|
+
end
|
54
|
+
|
55
|
+
if attributes.has_key?(:'hardware_id')
|
56
|
+
self.hardware_id = attributes[:'hardware_id']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
61
|
+
# @return Array for valid properies with the reasons
|
62
|
+
def list_invalid_properties
|
63
|
+
invalid_properties = Array.new
|
64
|
+
|
65
|
+
if @document.nil?
|
66
|
+
invalid_properties.push("invalid value for 'document', document cannot be nil.")
|
67
|
+
end
|
68
|
+
|
69
|
+
if @consented.nil?
|
70
|
+
invalid_properties.push("invalid value for 'consented', consented cannot be nil.")
|
71
|
+
end
|
72
|
+
|
73
|
+
if @timestamp_unixtime_ms.nil?
|
74
|
+
invalid_properties.push("invalid value for 'timestamp_unixtime_ms', timestamp_unixtime_ms cannot be nil.")
|
75
|
+
end
|
76
|
+
|
77
|
+
if @location.nil?
|
78
|
+
invalid_properties.push("invalid value for 'location', location cannot be nil.")
|
79
|
+
end
|
80
|
+
|
81
|
+
if @hardware_id.nil?
|
82
|
+
invalid_properties.push("invalid value for 'hardware_id', hardware_id cannot be nil.")
|
83
|
+
end
|
84
|
+
|
85
|
+
return invalid_properties
|
86
|
+
end
|
87
|
+
|
88
|
+
# Check to see if the all the properties in the model are valid
|
89
|
+
# @return true if the model is valid
|
90
|
+
def valid?
|
91
|
+
return false if @document.nil?
|
92
|
+
return false if @consented.nil?
|
93
|
+
return false if @timestamp_unixtime_ms.nil?
|
94
|
+
return false if @location.nil?
|
95
|
+
return false if @hardware_id.nil?
|
96
|
+
return true
|
97
|
+
end
|
98
|
+
|
99
|
+
# Checks equality by comparing each attribute.
|
100
|
+
# @param [Object] Object to be compared
|
101
|
+
def ==(o)
|
102
|
+
return true if self.equal?(o)
|
103
|
+
self.class == o.class &&
|
104
|
+
document == o.document &&
|
105
|
+
consented == o.consented &&
|
106
|
+
timestamp_unixtime_ms == o.timestamp_unixtime_ms &&
|
107
|
+
location == o.location &&
|
108
|
+
hardware_id == o.hardware_id
|
109
|
+
end
|
110
|
+
|
111
|
+
# @see the `==` method
|
112
|
+
# @param [Object] Object to be compared
|
113
|
+
def eql?(o)
|
114
|
+
self == o
|
115
|
+
end
|
116
|
+
|
117
|
+
# Calculates hash code according to all attributes.
|
118
|
+
# @return [Fixnum] Hash code
|
119
|
+
def hash
|
120
|
+
[
|
121
|
+
document,
|
122
|
+
consented,
|
123
|
+
timestamp_unixtime_ms,
|
124
|
+
location,
|
125
|
+
hardware_id,
|
126
|
+
].hash
|
127
|
+
end
|
128
|
+
|
129
|
+
# Builds the object from hash
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
131
|
+
# @return [Object] Returns the model itself
|
132
|
+
def build_from_hash(attributes)
|
133
|
+
return nil unless attributes.is_a?(Hash)
|
134
|
+
self.class.swagger_types.each_pair do |key, type|
|
135
|
+
if type =~ /\AArray<(.*)>/i
|
136
|
+
# check to ensure the input is an array given that the the attribute
|
137
|
+
# is documented as an array but the input is not
|
138
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
139
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
140
|
+
end
|
141
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
142
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
143
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
144
|
+
end
|
145
|
+
|
146
|
+
self
|
147
|
+
end
|
148
|
+
|
149
|
+
# Deserializes the data based on type
|
150
|
+
# @param string type Data type
|
151
|
+
# @param string value Value to be deserialized
|
152
|
+
# @return [Object] Deserialized data
|
153
|
+
def _deserialize(type, value)
|
154
|
+
case type.to_sym
|
155
|
+
when :DateTime
|
156
|
+
DateTime.parse(value)
|
157
|
+
when :Date
|
158
|
+
Date.parse(value)
|
159
|
+
when :String
|
160
|
+
value.to_s
|
161
|
+
when :Integer
|
162
|
+
value.to_i
|
163
|
+
when :Float
|
164
|
+
value.to_f
|
165
|
+
when :BOOLEAN
|
166
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
167
|
+
true
|
168
|
+
else
|
169
|
+
false
|
170
|
+
end
|
171
|
+
when :Object
|
172
|
+
# generic object (usually a Hash), return directly
|
173
|
+
value
|
174
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
175
|
+
inner_type = Regexp.last_match[:inner_type]
|
176
|
+
value.map { |v| _deserialize(inner_type, v) }
|
177
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
178
|
+
k_type = Regexp.last_match[:k_type]
|
179
|
+
v_type = Regexp.last_match[:v_type]
|
180
|
+
{}.tap do |hash|
|
181
|
+
value.each do |k, v|
|
182
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
else # model
|
186
|
+
temp_model = MParticle.const_get(type).new
|
187
|
+
temp_model.build_from_hash(value)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the string representation of the object
|
192
|
+
# @return [String] String presentation of the object
|
193
|
+
def to_s
|
194
|
+
to_hash.to_s
|
195
|
+
end
|
196
|
+
|
197
|
+
# to_body is an alias to to_hash (backward compatibility)
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_body
|
200
|
+
to_hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the object in the form of hash
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_hash
|
206
|
+
hash = {}
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
208
|
+
value = self.send(attr)
|
209
|
+
next if value.nil?
|
210
|
+
hash[param] = _to_hash(value)
|
211
|
+
end
|
212
|
+
hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Outputs non-array value in the form of hash
|
216
|
+
# For object, use to_hash. Otherwise, just return the value
|
217
|
+
# @param [Object] value Any valid value
|
218
|
+
# @return [Hash] Returns the value in the form of hash
|
219
|
+
def _to_hash(value)
|
220
|
+
if value.is_a?(Array)
|
221
|
+
value.compact.map{ |v| _to_hash(v) }
|
222
|
+
elsif value.is_a?(Hash)
|
223
|
+
{}.tap do |hash|
|
224
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
225
|
+
end
|
226
|
+
elsif value.respond_to? :to_hash
|
227
|
+
value.to_hash
|
228
|
+
else
|
229
|
+
value
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|