mparticle 1.0.3 → 1.0.4
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 +15 -1
- data/docs/Batch.md +16 -16
- data/docs/ConsentState.md +7 -0
- data/docs/GDPRConsentState.md +11 -0
- data/example/main.rb +14 -0
- data/lib/mparticle.rb +2 -0
- data/lib/mparticle/models/batch.rb +3 -0
- data/lib/mparticle/models/consent_state.rb +177 -0
- data/lib/mparticle/models/gdpr_consent_state.rb +233 -0
- data/lib/mparticle/version.rb +1 -1
- data/mparticle.gemspec +1 -1
- data/spec/models/consent_state_spec.rb +14 -0
- data/spec/models/gdpr_consent_state_spec.rb +40 -0
- data/spec/models/product_spec.rb +32 -0
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bac3ffb5b4f05c631d5c2beecbacfdc02420027
|
4
|
+
data.tar.gz: 0cf6073c991daaf5db99d34cfd3cf4eae3444bb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dd990e982b42a19a25804c8885485944cce2b04023a4c85b4d661724ee7938fa684a5b0830c904bcf596a57d568700f7eb0c41ad1abd0e2118a349d9a8b824b
|
7
|
+
data.tar.gz: 4721215db4f61185e90889cacf8b9553d00364c1392c00bca8b9c3f721d6a684096add75d015ecaf9b5be90f1cd740c3eee7e5e032ada2503b8cca388dada868
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ This is the mParticle Ruby client SDK - use it to send your data to the [mPartic
|
|
6
6
|
|
7
7
|
## Requirements
|
8
8
|
|
9
|
-
Ruby
|
9
|
+
Ruby 2.0 or later
|
10
10
|
|
11
11
|
### Installation
|
12
12
|
|
@@ -72,6 +72,20 @@ rescue MParticle::ApiError => e
|
|
72
72
|
end
|
73
73
|
```
|
74
74
|
|
75
|
+
### Running tests
|
76
|
+
|
77
|
+
Install [Rspec](https://github.com/rspec/rspec)
|
78
|
+
|
79
|
+
```sh
|
80
|
+
gem install rspec
|
81
|
+
```
|
82
|
+
|
83
|
+
Run tests
|
84
|
+
|
85
|
+
```sh
|
86
|
+
rspec
|
87
|
+
```
|
88
|
+
|
75
89
|
### License
|
76
90
|
|
77
91
|
[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
data/docs/Batch.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# mParticle::Batch
|
2
2
|
|
3
3
|
## Properties
|
4
|
-
Name | Type | Description | Notes
|
5
|
-
------------ | ------------- | ------------- | -------------
|
6
|
-
**events** | [**Array<EventBase>**](EventBase.md) | | [optional]
|
7
|
-
**source_request_id** | **String** | | [optional]
|
8
|
-
**environment** | **String** | |
|
9
|
-
**ip** | **String** | | [optional]
|
10
|
-
**schema_version** | **Integer** | | [optional]
|
11
|
-
**device_info** | [**DeviceInformation**](DeviceInformation.md) | | [optional]
|
12
|
-
**application_info** | [**ApplicationInformation**](ApplicationInformation.md) | | [optional]
|
13
|
-
**user_attributes** | **Object** | | [optional]
|
14
|
-
**deleted_user_attributes** | **Array<String>** | | [optional]
|
15
|
-
**user_identities** | [**UserIdentities**](UserIdentities.md) | | [optional]
|
16
|
-
**api_key** | **String** | | [optional]
|
17
|
-
**mpid** | **Integer** | | [optional]
|
18
|
-
**mp_deviceid** | **String** | | [optional]
|
19
|
-
|
20
4
|
|
5
|
+
| Name | Type | Description | Notes |
|
6
|
+
| --------------------------- | ------------------------------------------------------- | ----------- | ---------- |
|
7
|
+
| **events** | [**Array<EventBase>**](EventBase.md) | | [optional] |
|
8
|
+
| **source_request_id** | **String** | | [optional] |
|
9
|
+
| **environment** | **String** | |
|
10
|
+
| **ip** | **String** | | [optional] |
|
11
|
+
| **schema_version** | **Integer** | | [optional] |
|
12
|
+
| **device_info** | [**DeviceInformation**](DeviceInformation.md) | | [optional] |
|
13
|
+
| **application_info** | [**ApplicationInformation**](ApplicationInformation.md) | | [optional] |
|
14
|
+
| **user_attributes** | **Object** | | [optional] |
|
15
|
+
| **deleted_user_attributes** | **Array<String>** | | [optional] |
|
16
|
+
| Object **user_identities** | [**UserIdentities**](UserIdentities.md) | | [optional] |
|
17
|
+
| Object **consent_state** | [**ConsentState**](ConsentState.md) | | [optional] |
|
18
|
+
| **api_key** | **String** | | [optional] |
|
19
|
+
| **mpid** | **Integer** | | [optional] |
|
20
|
+
| **mp_deviceid** | **String** | | [optional] |
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# mParticle.GDPRConsentState
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
| Name | Type | Description | Notes |
|
6
|
+
| ------------------------- | ----------- | ----------- | ----- |
|
7
|
+
| **document** | **String** | | |
|
8
|
+
| **consented** | **Boolean** | | |
|
9
|
+
| **timestamp_unixtime_ms** | **Number** | | |
|
10
|
+
| **location** | **String** | | |
|
11
|
+
| **hardware_id** | **String** | | |
|
data/example/main.rb
CHANGED
@@ -23,6 +23,20 @@ app_event.custom_attributes = { 'Test key' => 'Test value' }
|
|
23
23
|
batch.events = [MParticle::SessionStartEvent.new, app_event, MParticle::SessionEndEvent.new]
|
24
24
|
batch.user_identities = user_identities
|
25
25
|
|
26
|
+
gdpr_consent_state = MParticle::GDPRConsentState.new
|
27
|
+
gdpr_consent_state.document = 'document_agreement.v2'
|
28
|
+
gdpr_consent_state.consented = true
|
29
|
+
gdpr_consent_state.timestamp_unixtime_ms = Time.now.to_i
|
30
|
+
gdpr_consent_state.location = 'dtmgbank.com/signup'
|
31
|
+
gdpr_consent_state.hardware_id = 'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'
|
32
|
+
|
33
|
+
consent_state = MParticle::ConsentState.new
|
34
|
+
# Make sure this purpose matches your consent purpose in
|
35
|
+
# Setup > GDPR Settings
|
36
|
+
# https://docs.mparticle.com/guides/consent-management/#enabling-gdpr-consent-management
|
37
|
+
consent_state.gdpr = { 'document_agreement' => gdpr_consent_state }
|
38
|
+
batch.consent_state = consent_state
|
39
|
+
|
26
40
|
batch.mpid = 600868121729048600
|
27
41
|
batch.mp_deviceid = "59780f39-d7a0-4ebe-9950-280f937c29e2"
|
28
42
|
|
data/lib/mparticle.rb
CHANGED
@@ -14,12 +14,14 @@ require 'mparticle/models/attribution_info'
|
|
14
14
|
require 'mparticle/models/batch'
|
15
15
|
require 'mparticle/models/breadcrumb_event'
|
16
16
|
require 'mparticle/models/commerce_event'
|
17
|
+
require 'mparticle/models/consent_state'
|
17
18
|
require 'mparticle/models/crash_report_event'
|
18
19
|
require 'mparticle/models/device_current_state'
|
19
20
|
require 'mparticle/models/device_information'
|
20
21
|
require 'mparticle/models/event_base'
|
21
22
|
require 'mparticle/models/event_data'
|
22
23
|
require 'mparticle/models/first_run_event'
|
24
|
+
require 'mparticle/models/gdpr_consent_state'
|
23
25
|
require 'mparticle/models/geo_location'
|
24
26
|
require 'mparticle/models/media_info'
|
25
27
|
require 'mparticle/models/network_performance_event'
|
@@ -23,6 +23,8 @@ module MParticle
|
|
23
23
|
|
24
24
|
attr_accessor :user_identities
|
25
25
|
|
26
|
+
attr_accessor :consent_state
|
27
|
+
|
26
28
|
attr_accessor :api_key
|
27
29
|
|
28
30
|
attr_accessor :mpid
|
@@ -102,6 +104,7 @@ module MParticle
|
|
102
104
|
:'device_info' => :'device_info',
|
103
105
|
:'application_info' => :'application_info',
|
104
106
|
:'user_attributes' => :'user_attributes',
|
107
|
+
:'consent_state' => :'consent_state',
|
105
108
|
:'deleted_user_attributes' => :'deleted_user_attributes',
|
106
109
|
:'user_identities' => :'user_identities',
|
107
110
|
:'api_key' => :'api_key',
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module MParticle
|
4
|
+
class ConsentState
|
5
|
+
attr_accessor :gdpr
|
6
|
+
|
7
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
8
|
+
def self.attribute_map
|
9
|
+
{
|
10
|
+
:'gdpr' => 'gdpr',
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# Attribute type mapping.
|
15
|
+
def self.swagger_types
|
16
|
+
{
|
17
|
+
:'gdpr' => 'Hash',
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Initializes the object
|
22
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
23
|
+
def initialize(attributes = {})
|
24
|
+
return unless attributes.is_a?(Hash)
|
25
|
+
|
26
|
+
# convert string to symbol for hash key
|
27
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
28
|
+
|
29
|
+
if attributes.has_key?(:'gdpr')
|
30
|
+
self.gdpr = attributes[:'gdpr']
|
31
|
+
else
|
32
|
+
self.gdpr = {}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
37
|
+
# @return Array for valid properies with the reasons
|
38
|
+
def list_invalid_properties
|
39
|
+
invalid_properties = Array.new
|
40
|
+
|
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
|
+
gdpr == o.gdpr
|
56
|
+
end
|
57
|
+
|
58
|
+
# @see the `==` method
|
59
|
+
# @param [Object] Object to be compared
|
60
|
+
def eql?(o)
|
61
|
+
self == o
|
62
|
+
end
|
63
|
+
|
64
|
+
# Calculates hash code according to all attributes.
|
65
|
+
# @return [Fixnum] Hash code
|
66
|
+
def hash
|
67
|
+
[
|
68
|
+
gdpr,
|
69
|
+
].hash
|
70
|
+
end
|
71
|
+
|
72
|
+
# Builds the object from hash
|
73
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
74
|
+
# @return [Object] Returns the model itself
|
75
|
+
def build_from_hash(attributes)
|
76
|
+
return nil unless attributes.is_a?(Hash)
|
77
|
+
self.class.swagger_types.each_pair do |key, type|
|
78
|
+
if type =~ /\AArray<(.*)>/i
|
79
|
+
# check to ensure the input is an array given that the the attribute
|
80
|
+
# is documented as an array but the input is not
|
81
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
82
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
83
|
+
end
|
84
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
85
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
86
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
87
|
+
end
|
88
|
+
|
89
|
+
self
|
90
|
+
end
|
91
|
+
|
92
|
+
# Deserializes the data based on type
|
93
|
+
# @param string type Data type
|
94
|
+
# @param string value Value to be deserialized
|
95
|
+
# @return [Object] Deserialized data
|
96
|
+
def _deserialize(type, value)
|
97
|
+
case type.to_sym
|
98
|
+
when :DateTime
|
99
|
+
DateTime.parse(value)
|
100
|
+
when :Date
|
101
|
+
Date.parse(value)
|
102
|
+
when :String
|
103
|
+
value.to_s
|
104
|
+
when :Integer
|
105
|
+
value.to_i
|
106
|
+
when :Float
|
107
|
+
value.to_f
|
108
|
+
when :BOOLEAN
|
109
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
110
|
+
true
|
111
|
+
else
|
112
|
+
false
|
113
|
+
end
|
114
|
+
when :Object
|
115
|
+
# generic object (usually a Hash), return directly
|
116
|
+
value
|
117
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
118
|
+
inner_type = Regexp.last_match[:inner_type]
|
119
|
+
value.map { |v| _deserialize(inner_type, v) }
|
120
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
121
|
+
k_type = Regexp.last_match[:k_type]
|
122
|
+
v_type = Regexp.last_match[:v_type]
|
123
|
+
{}.tap do |hash|
|
124
|
+
value.each do |k, v|
|
125
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
else # model
|
129
|
+
temp_model = MParticle.const_get(type).new
|
130
|
+
temp_model.build_from_hash(value)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Returns the string representation of the object
|
135
|
+
# @return [String] String presentation of the object
|
136
|
+
def to_s
|
137
|
+
to_hash.to_s
|
138
|
+
end
|
139
|
+
|
140
|
+
# to_body is an alias to to_hash (backward compatibility)
|
141
|
+
# @return [Hash] Returns the object in the form of hash
|
142
|
+
def to_body
|
143
|
+
to_hash
|
144
|
+
end
|
145
|
+
|
146
|
+
# Returns the object in the form of hash
|
147
|
+
# @return [Hash] Returns the object in the form of hash
|
148
|
+
def to_hash
|
149
|
+
hash = {}
|
150
|
+
self.class.attribute_map.each_pair do |attr, param|
|
151
|
+
value = self.send(attr)
|
152
|
+
next if value.nil?
|
153
|
+
hash[param] = _to_hash(value)
|
154
|
+
end
|
155
|
+
hash
|
156
|
+
end
|
157
|
+
|
158
|
+
# Outputs non-array value in the form of hash
|
159
|
+
# For object, use to_hash. Otherwise, just return the value
|
160
|
+
# @param [Object] value Any valid value
|
161
|
+
# @return [Hash] Returns the value in the form of hash
|
162
|
+
def _to_hash(value)
|
163
|
+
if value.is_a?(Array)
|
164
|
+
value.compact.map{ |v| _to_hash(v) }
|
165
|
+
elsif value.is_a?(Hash)
|
166
|
+
{}.tap do |hash|
|
167
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
168
|
+
end
|
169
|
+
elsif value.respond_to? :to_hash
|
170
|
+
value.to_hash
|
171
|
+
else
|
172
|
+
value
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
module MParticle
|
2
|
+
class GDPRConsentState
|
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
|
data/lib/mparticle/version.rb
CHANGED
data/mparticle.gemspec
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mparticle'
|
2
|
+
|
3
|
+
describe 'ConsentState' do
|
4
|
+
it 'should create an instance of ConsentState' do
|
5
|
+
model = MParticle::ConsentState.new
|
6
|
+
expect(model).to be_an_instance_of MParticle::ConsentState
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have the property gdpr (base name: "gdpr")' do
|
10
|
+
model = MParticle::ConsentState.new
|
11
|
+
expect(model).to have_attributes(:gdpr => {})
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'mparticle'
|
2
|
+
|
3
|
+
describe 'GDPRConsentState' do
|
4
|
+
it 'should create an instance of GDPRConsentState' do
|
5
|
+
model = MParticle::GDPRConsentState.new
|
6
|
+
expect(model).to be_an_instance_of MParticle::GDPRConsentState
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have the property document (base name: "document")' do
|
10
|
+
model = MParticle::GDPRConsentState.new
|
11
|
+
model.document = 'document_agreement.v2'
|
12
|
+
expect(model.document).to eq 'document_agreement.v2'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have the property consented (base name: "consented")' do
|
16
|
+
model = MParticle::GDPRConsentState.new
|
17
|
+
model.consented = true
|
18
|
+
expect(model.consented).to eq true
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have the property timestamp_unixtime_ms {base name: "timestamp_unixtime_ms" }' do
|
22
|
+
now = Time.now.to_i
|
23
|
+
model = MParticle::GDPRConsentState.new
|
24
|
+
model.timestamp_unixtime_ms = now
|
25
|
+
expect(model.timestamp_unixtime_ms).to eq now
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have the property location {base name: "location" }' do
|
29
|
+
model = MParticle::GDPRConsentState.new
|
30
|
+
model.location = 'dtmgbank.com/signup'
|
31
|
+
expect(model.location).to eq 'dtmgbank.com/signup'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have the property hardware_id {base name: "hardware_id" }' do
|
35
|
+
model = MParticle::GDPRConsentState.new
|
36
|
+
model.hardware_id = 'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'
|
37
|
+
expect(model.hardware_id).to eq 'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'mparticle'
|
2
|
+
|
3
|
+
describe 'Product' do
|
4
|
+
it 'should create an instance of Product' do
|
5
|
+
model = MParticle::Product.new
|
6
|
+
expect(model).to be_an_instance_of MParticle::Product
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have the property id (base name: "id")' do
|
10
|
+
model = MParticle::Product.new
|
11
|
+
model.id = '12345'
|
12
|
+
expect(model.id).to eq '12345'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have the property name (base name: "name")' do
|
16
|
+
model = MParticle::Product.new
|
17
|
+
model.name = 'Laserdisc'
|
18
|
+
expect(model.name).to eq 'Laserdisc'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have the property price (base name: "price")' do
|
22
|
+
model = MParticle::Product.new
|
23
|
+
model.price = 100.59
|
24
|
+
expect(model.price).to eq 100.59
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have the property totalProductAmount (base name: "total_product_amount")' do
|
28
|
+
model = MParticle::Product.new
|
29
|
+
model.total_product_amount = 40.10
|
30
|
+
expect(model.total_product_amount).to eq 40.10
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mparticle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mParticle Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- docs/Batch.md
|
68
68
|
- docs/BreadcrumbEvent.md
|
69
69
|
- docs/CommerceEvent.md
|
70
|
+
- docs/ConsentState.md
|
70
71
|
- docs/CrashReportEvent.md
|
71
72
|
- docs/DeviceCurrentState.md
|
72
73
|
- docs/DeviceInformation.md
|
@@ -74,6 +75,7 @@ files:
|
|
74
75
|
- docs/EventData.md
|
75
76
|
- docs/EventsApi.md
|
76
77
|
- docs/FirstRunEvent.md
|
78
|
+
- docs/GDPRConsentState.md
|
77
79
|
- docs/GeoLocation.md
|
78
80
|
- docs/MediaInfo.md
|
79
81
|
- docs/NetworkPerformanceEvent.md
|
@@ -107,12 +109,14 @@ files:
|
|
107
109
|
- lib/mparticle/models/batch.rb
|
108
110
|
- lib/mparticle/models/breadcrumb_event.rb
|
109
111
|
- lib/mparticle/models/commerce_event.rb
|
112
|
+
- lib/mparticle/models/consent_state.rb
|
110
113
|
- lib/mparticle/models/crash_report_event.rb
|
111
114
|
- lib/mparticle/models/device_current_state.rb
|
112
115
|
- lib/mparticle/models/device_information.rb
|
113
116
|
- lib/mparticle/models/event_base.rb
|
114
117
|
- lib/mparticle/models/event_data.rb
|
115
118
|
- lib/mparticle/models/first_run_event.rb
|
119
|
+
- lib/mparticle/models/gdpr_consent_state.rb
|
116
120
|
- lib/mparticle/models/geo_location.rb
|
117
121
|
- lib/mparticle/models/media_info.rb
|
118
122
|
- lib/mparticle/models/network_performance_event.rb
|
@@ -133,6 +137,9 @@ files:
|
|
133
137
|
- lib/mparticle/models/user_identities.rb
|
134
138
|
- lib/mparticle/version.rb
|
135
139
|
- mparticle.gemspec
|
140
|
+
- spec/models/consent_state_spec.rb
|
141
|
+
- spec/models/gdpr_consent_state_spec.rb
|
142
|
+
- spec/models/product_spec.rb
|
136
143
|
homepage: https://www.mparticle.com
|
137
144
|
licenses:
|
138
145
|
- Apache-2.0
|
@@ -153,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
160
|
version: '0'
|
154
161
|
requirements: []
|
155
162
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.6.8
|
157
164
|
signing_key:
|
158
165
|
specification_version: 4
|
159
166
|
summary: Ruby client for the mParticle platform
|