mparticle 1.0.4 → 1.0.9

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.
@@ -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
@@ -33,6 +33,7 @@ module MParticle
33
33
 
34
34
  attr_accessor :is_non_interactive
35
35
 
36
+ attr_accessor :custom_flags
36
37
 
37
38
  # Attribute mapping from ruby-style variable name to JSON key.
38
39
  def self.attribute_map
@@ -51,7 +52,8 @@ module MParticle
51
52
  :'shopping_cart' => :'shopping_cart',
52
53
  :'currency_code' => :'currency_code',
53
54
  :'screen_name' => :'screen_name',
54
- :'is_non_interactive' => :'is_non_interactive'
55
+ :'is_non_interactive' => :'is_non_interactive',
56
+ :'custom_flags' => :'custom_flags',
55
57
  }
56
58
  end
57
59
 
@@ -72,7 +74,8 @@ module MParticle
72
74
  :'shopping_cart' => :'ShoppingCart',
73
75
  :'currency_code' => :'String',
74
76
  :'screen_name' => :'String',
75
- :'is_non_interactive' => :'BOOLEAN'
77
+ :'is_non_interactive' => :'BOOLEAN',
78
+ :'custom_flags' => :'Hash<String, String>',
76
79
  }
77
80
  end
78
81
 
@@ -148,6 +151,10 @@ module MParticle
148
151
  self.is_non_interactive = attributes[:'is_non_interactive']
149
152
  end
150
153
 
154
+ if attributes.has_key?(:'custom_flags')
155
+ self.custom_flags = attributes[:'custom_flags']
156
+ end
157
+
151
158
  end
152
159
 
153
160
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -182,7 +189,8 @@ module MParticle
182
189
  shopping_cart == o.shopping_cart &&
183
190
  currency_code == o.currency_code &&
184
191
  screen_name == o.screen_name &&
185
- is_non_interactive == o.is_non_interactive
192
+ is_non_interactive == o.is_non_interactive &&
193
+ custom_flags == o.custom_flags
186
194
  end
187
195
 
188
196
  # @see the `==` method
@@ -194,7 +202,7 @@ module MParticle
194
202
  # Calculates hash code according to all attributes.
195
203
  # @return [Fixnum] Hash code
196
204
  def hash
197
- [timestamp_unixtime_ms, event_id, source_message_id, session_id, session_uuid, custom_attributes, location, device_current_state, product_action, promotion_action, product_impressions, shopping_cart, currency_code, screen_name, is_non_interactive].hash
205
+ [timestamp_unixtime_ms, event_id, source_message_id, session_id, session_uuid, custom_attributes, location, device_current_state, product_action, promotion_action, product_impressions, shopping_cart, currency_code, screen_name, is_non_interactive, custom_flags].hash
198
206
  end
199
207
 
200
208
  # Builds the object from hash
@@ -3,11 +3,13 @@ require 'date'
3
3
  module MParticle
4
4
  class ConsentState
5
5
  attr_accessor :gdpr
6
+ attr_accessor :ccpa
6
7
 
7
8
  # Attribute mapping from ruby-style variable name to JSON key.
8
9
  def self.attribute_map
9
10
  {
10
11
  :'gdpr' => 'gdpr',
12
+ :'ccpa' => 'ccpa',
11
13
  }
12
14
  end
13
15
 
@@ -15,6 +17,7 @@ module MParticle
15
17
  def self.swagger_types
16
18
  {
17
19
  :'gdpr' => 'Hash',
20
+ :'ccpa' => 'Hash',
18
21
  }
19
22
  end
20
23
 
@@ -31,6 +34,12 @@ module MParticle
31
34
  else
32
35
  self.gdpr = {}
33
36
  end
37
+
38
+ if attributes.has_key?(:'ccpa')
39
+ self.ccpa = attributes[:'ccpa']
40
+ else
41
+ self.ccpa = {}
42
+ end
34
43
  end
35
44
 
36
45
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -0,0 +1,186 @@
1
+ require 'date'
2
+
3
+ module MParticle
4
+
5
+ class DataPlanContext
6
+ attr_accessor :plan_id
7
+
8
+ attr_accessor :plan_version
9
+
10
+
11
+ # Attribute mapping from ruby-style variable name to JSON key.
12
+ def self.attribute_map
13
+ {
14
+ :'plan_id' => :'plan_id',
15
+ :'plan_version' => :'plan_version'
16
+ }
17
+ end
18
+
19
+ # Attribute type mapping.
20
+ def self.swagger_types
21
+ {
22
+ :'plan_id' => :'String',
23
+ :'plan_version' => :'Integer'
24
+ }
25
+ end
26
+
27
+ # Initializes the object
28
+ # @param [Hash] attributes Model attributes in the form of hash
29
+ def initialize(attributes = {})
30
+ return unless attributes.is_a?(Hash)
31
+
32
+ # convert string to symbol for hash key
33
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
34
+
35
+ if attributes.has_key?(:'plan_id')
36
+ self.plan_id = attributes[:'plan_id']
37
+ end
38
+
39
+ if attributes.has_key?(:'plan_version')
40
+ self.plan_version = attributes[:'plan_version']
41
+ end
42
+
43
+ end
44
+
45
+ # Show invalid properties with the reasons. Usually used together with valid?
46
+ # @return Array for valid properies with the reasons
47
+ def list_invalid_properties
48
+ invalid_properties = Array.new
49
+ return invalid_properties
50
+ end
51
+
52
+ # Check to see if the all the properties in the model are valid
53
+ # @return true if the model is valid
54
+ def valid?
55
+ return true
56
+ end
57
+
58
+ # Checks equality by comparing each attribute.
59
+ # @param [Object] Object to be compared
60
+ def ==(o)
61
+ return true if self.equal?(o)
62
+ self.class == o.class &&
63
+ plan_id == o.plan_id &&
64
+ plan_version == o.plan_version
65
+
66
+ end
67
+
68
+ # @see the `==` method
69
+ # @param [Object] Object to be compared
70
+ def eql?(o)
71
+ self == o
72
+ end
73
+
74
+ # Calculates hash code according to all attributes.
75
+ # @return [Fixnum] Hash code
76
+ def hash
77
+ [plan_id, plan_version].hash
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
83
+ def build_from_hash(attributes)
84
+ return nil unless attributes.is_a?(Hash)
85
+ self.class.swagger_types.each_pair do |key, type|
86
+ if type =~ /\AArray<(.*)>/i
87
+ # check to ensure the input is an array given that the the attribute
88
+ # is documented as an array but the input is not
89
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
90
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
91
+ end
92
+ elsif !attributes[self.class.attribute_map[key]].nil?
93
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
94
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
95
+ end
96
+
97
+ self
98
+ end
99
+
100
+ # Deserializes the data based on type
101
+ # @param string type Data type
102
+ # @param string value Value to be deserialized
103
+ # @return [Object] Deserialized data
104
+ def _deserialize(type, value)
105
+ case type.to_sym
106
+ when :DateTime
107
+ DateTime.parse(value)
108
+ when :Date
109
+ Date.parse(value)
110
+ when :String
111
+ value.to_s
112
+ when :Integer
113
+ value.to_i
114
+ when :Float
115
+ value.to_f
116
+ when :BOOLEAN
117
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
118
+ true
119
+ else
120
+ false
121
+ end
122
+ when :Object
123
+ # generic object (usually a Hash), return directly
124
+ value
125
+ when /\AArray<(?<inner_type>.+)>\z/
126
+ inner_type = Regexp.last_match[:inner_type]
127
+ value.map { |v| _deserialize(inner_type, v) }
128
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
129
+ k_type = Regexp.last_match[:k_type]
130
+ v_type = Regexp.last_match[:v_type]
131
+ {}.tap do |hash|
132
+ value.each do |k, v|
133
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
134
+ end
135
+ end
136
+ else # model
137
+ temp_model = MParticle.const_get(type).new
138
+ temp_model.build_from_hash(value)
139
+ end
140
+ end
141
+
142
+ # Returns the string representation of the object
143
+ # @return [String] String presentation of the object
144
+ def to_s
145
+ to_hash.to_s
146
+ end
147
+
148
+ # to_body is an alias to to_hash (backward compatibility)
149
+ # @return [Hash] Returns the object in the form of hash
150
+ def to_body
151
+ to_hash
152
+ end
153
+
154
+ # Returns the object in the form of hash
155
+ # @return [Hash] Returns the object in the form of hash
156
+ def to_hash
157
+ hash = {}
158
+ self.class.attribute_map.each_pair do |attr, param|
159
+ value = self.send(attr)
160
+ next if value.nil?
161
+ hash[param] = _to_hash(value)
162
+ end
163
+ hash
164
+ end
165
+
166
+ # Outputs non-array value in the form of hash
167
+ # For object, use to_hash. Otherwise, just return the value
168
+ # @param [Object] value Any valid value
169
+ # @return [Hash] Returns the value in the form of hash
170
+ def _to_hash(value)
171
+ if value.is_a?(Array)
172
+ value.compact.map{ |v| _to_hash(v) }
173
+ elsif value.is_a?(Hash)
174
+ {}.tap do |hash|
175
+ value.each { |k, v| hash[k] = _to_hash(v) }
176
+ end
177
+ elsif value.respond_to? :to_hash
178
+ value.to_hash
179
+ else
180
+ value
181
+ end
182
+ end
183
+
184
+ end
185
+
186
+ end