klaviyo-api-sdk 13.0.1 → 14.0.1

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +434 -286
  4. data/klaviyo-api-sdk.gemspec +1 -1
  5. data/lib/klaviyo-api-sdk/api/accounts_api.rb +6 -6
  6. data/lib/klaviyo-api-sdk/api/campaigns_api.rb +87 -87
  7. data/lib/klaviyo-api-sdk/api/catalogs_api.rb +235 -235
  8. data/lib/klaviyo-api-sdk/api/coupons_api.rb +68 -68
  9. data/lib/klaviyo-api-sdk/api/custom_objects_api.rb +384 -0
  10. data/lib/klaviyo-api-sdk/api/data_privacy_api.rb +1 -1
  11. data/lib/klaviyo-api-sdk/api/events_api.rb +35 -35
  12. data/lib/klaviyo-api-sdk/api/flows_api.rb +93 -93
  13. data/lib/klaviyo-api-sdk/api/forms_api.rb +40 -40
  14. data/lib/klaviyo-api-sdk/api/images_api.rb +15 -15
  15. data/lib/klaviyo-api-sdk/api/lists_api.rb +60 -60
  16. data/lib/klaviyo-api-sdk/api/metrics_api.rb +643 -59
  17. data/lib/klaviyo-api-sdk/api/profiles_api.rb +134 -134
  18. data/lib/klaviyo-api-sdk/api/reporting_api.rb +13 -13
  19. data/lib/klaviyo-api-sdk/api/reviews_api.rb +21 -21
  20. data/lib/klaviyo-api-sdk/api/segments_api.rb +54 -54
  21. data/lib/klaviyo-api-sdk/api/tags_api.rb +58 -58
  22. data/lib/klaviyo-api-sdk/api/templates_api.rb +36 -36
  23. data/lib/klaviyo-api-sdk/api/tracking_settings_api.rb +15 -15
  24. data/lib/klaviyo-api-sdk/api/web_feeds_api.rb +15 -15
  25. data/lib/klaviyo-api-sdk/api/webhooks_api.rb +15 -15
  26. data/lib/klaviyo-api-sdk/api_client.rb +1 -1
  27. data/lib/klaviyo-api-sdk/models/ab_test_action_data_current_experiment.rb +2 -15
  28. data/lib/klaviyo-api-sdk/models/base_event_create_query_bulk_entry_resource_object_attributes.rb +1 -1
  29. data/lib/klaviyo-api-sdk/models/button_block.rb +247 -0
  30. data/lib/klaviyo-api-sdk/models/{custom_object_property_enum.rb → button_enum.rb} +4 -4
  31. data/lib/klaviyo-api-sdk/models/campaign_values_request_dto_resource_object_attributes_timeframe.rb +1 -1
  32. data/lib/klaviyo-api-sdk/models/condition_group_conditions_inner.rb +3 -0
  33. data/lib/klaviyo-api-sdk/models/conditional_branch_action_data_profile_filter_condition_groups_inner_conditions_inner.rb +1 -0
  34. data/lib/klaviyo-api-sdk/models/coupon_create_query_resource_object_attributes.rb +16 -5
  35. data/lib/klaviyo-api-sdk/models/coupon_update_query_resource_object_attributes.rb +16 -5
  36. data/lib/klaviyo-api-sdk/models/custom_timeframe.rb +2 -0
  37. data/lib/klaviyo-api-sdk/models/data_source_create_query.rb +223 -0
  38. data/lib/klaviyo-api-sdk/models/data_source_create_query_resource_object.rb +237 -0
  39. data/lib/klaviyo-api-sdk/models/data_source_create_query_resource_object_attributes.rb +284 -0
  40. data/lib/klaviyo-api-sdk/models/data_source_enum.rb +35 -0
  41. data/lib/klaviyo-api-sdk/models/data_source_record_bulk_create_job_create_query.rb +223 -0
  42. data/lib/klaviyo-api-sdk/models/data_source_record_bulk_create_job_create_query_resource_object.rb +246 -0
  43. data/lib/klaviyo-api-sdk/models/data_source_record_bulk_create_job_create_query_resource_object_attributes.rb +219 -0
  44. data/lib/klaviyo-api-sdk/models/data_source_record_bulk_create_job_create_query_resource_object_relationships.rb +218 -0
  45. data/lib/klaviyo-api-sdk/models/data_source_record_bulk_create_job_create_query_resource_object_relationships_data_source.rb +218 -0
  46. data/lib/klaviyo-api-sdk/models/data_source_record_bulk_create_job_enum.rb +35 -0
  47. data/lib/klaviyo-api-sdk/models/data_source_record_enum.rb +35 -0
  48. data/lib/klaviyo-api-sdk/models/data_source_record_resource_object.rb +237 -0
  49. data/lib/klaviyo-api-sdk/models/data_source_record_resource_object_attributes.rb +223 -0
  50. data/lib/klaviyo-api-sdk/models/drop_shadow_block.rb +247 -0
  51. data/lib/klaviyo-api-sdk/models/drop_shadow_enum.rb +35 -0
  52. data/lib/klaviyo-api-sdk/models/{trigger_branch_action_data_trigger_filter.rb → dsr_bulk_create_attrs_data_source_records.rb} +15 -14
  53. data/lib/klaviyo-api-sdk/models/dsr_bulk_create_rels_data_source_data.rb +238 -0
  54. data/lib/klaviyo-api-sdk/models/event_create_query_v2_resource_object_attributes.rb +1 -1
  55. data/lib/klaviyo-api-sdk/models/flow_definition_profile_filter_condition_groups_inner_conditions_inner.rb +1 -0
  56. data/lib/klaviyo-api-sdk/models/flow_email_additional_filters_condition_groups_inner_conditions_inner.rb +1 -0
  57. data/lib/klaviyo-api-sdk/models/flow_push_notification_additional_filters_condition_groups_inner_conditions_inner.rb +1 -0
  58. data/lib/klaviyo-api-sdk/models/flow_sms_additional_filters_condition_groups_inner_conditions_inner.rb +1 -0
  59. data/lib/klaviyo-api-sdk/models/has_sms_marketing_subscribed_filters_inner.rb +2 -1
  60. data/lib/klaviyo-api-sdk/models/horizontal_rule_block.rb +247 -0
  61. data/lib/klaviyo-api-sdk/models/horizontal_rule_enum.rb +35 -0
  62. data/lib/klaviyo-api-sdk/models/image_block.rb +247 -0
  63. data/lib/klaviyo-api-sdk/models/is_rcs_capable_enum.rb +35 -0
  64. data/lib/klaviyo-api-sdk/models/low_inventory_condition.rb +1 -1
  65. data/lib/klaviyo-api-sdk/models/low_inventory_condition_filter2.rb +117 -0
  66. data/lib/klaviyo-api-sdk/models/mapped_metric_enum.rb +35 -0
  67. data/lib/klaviyo-api-sdk/models/mapped_metric_partial_update_query.rb +223 -0
  68. data/lib/klaviyo-api-sdk/models/mapped_metric_partial_update_query_resource_object.rb +281 -0
  69. data/lib/klaviyo-api-sdk/models/mapped_metric_partial_update_query_resource_object_relationships.rb +227 -0
  70. data/lib/klaviyo-api-sdk/models/{trigger_branch_action_data_trigger_filter_condition_groups_inner.rb → mapped_metric_partial_update_query_resource_object_relationships_custom_metric.rb} +10 -17
  71. data/lib/klaviyo-api-sdk/models/mapped_metric_partial_update_query_resource_object_relationships_custom_metric_data.rb +238 -0
  72. data/lib/klaviyo-api-sdk/models/mapped_metric_partial_update_query_resource_object_relationships_metric.rb +218 -0
  73. data/lib/klaviyo-api-sdk/models/mapped_metric_partial_update_query_resource_object_relationships_metric_data.rb +238 -0
  74. data/lib/klaviyo-api-sdk/models/metric_property_condition.rb +1 -1
  75. data/lib/klaviyo-api-sdk/models/metric_property_condition_filter.rb +195 -87
  76. data/lib/klaviyo-api-sdk/models/metric_property_condition_filter2.rb +117 -0
  77. data/lib/klaviyo-api-sdk/models/price_drop_condition.rb +1 -1
  78. data/lib/klaviyo-api-sdk/models/{trigger_branch_action_data_trigger_filter_condition_groups_inner_conditions_inner.rb → price_drop_condition_filter2.rb} +16 -5
  79. data/lib/klaviyo-api-sdk/models/priority_enum.rb +35 -0
  80. data/lib/klaviyo-api-sdk/models/profile_predictive_analytics_channel_affinity_priority_condition.rb +327 -0
  81. data/lib/klaviyo-api-sdk/models/profile_predictive_analytics_channel_affinity_priority_filter.rb +251 -0
  82. data/lib/klaviyo-api-sdk/models/profile_predictive_analytics_channel_affinity_rank_condition.rb +327 -0
  83. data/lib/klaviyo-api-sdk/models/profile_predictive_analytics_channel_affinity_rank_filter.rb +286 -0
  84. data/lib/klaviyo-api-sdk/models/profile_predictive_analytics_date_condition.rb +286 -0
  85. data/lib/klaviyo-api-sdk/models/rank_enum.rb +35 -0
  86. data/lib/klaviyo-api-sdk/models/segment_values_request_dto_resource_object_attributes_timeframe.rb +1 -1
  87. data/lib/klaviyo-api-sdk/models/spacer_block.rb +247 -0
  88. data/lib/klaviyo-api-sdk/models/spacer_enum.rb +35 -0
  89. data/lib/klaviyo-api-sdk/models/{custom_object_property_condition.rb → subscribed_smsis_rcs_capable_filter.rb} +6 -34
  90. data/lib/klaviyo-api-sdk/models/trigger_branch_action_data.rb +6 -2
  91. data/lib/klaviyo-api-sdk/models/universal_content_create_query_resource_object_attributes_definition.rb +5 -0
  92. data/lib/klaviyo-api-sdk/models/universal_content_partial_update_query_resource_object_attributes_definition.rb +5 -0
  93. data/lib/klaviyo-api-sdk.rb +46 -6
  94. data/lib/klaviyo-api-sdk.rb.bak +979 -0
  95. metadata +48 -7
@@ -0,0 +1,327 @@
1
+ =begin
2
+ #Klaviyo API
3
+
4
+ #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.
5
+
6
+ Contact: developers@klaviyo.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 6.2.1
9
+
10
+ =end
11
+
12
+ require 'date'
13
+ require 'time'
14
+
15
+ module KlaviyoAPI
16
+ class ProfilePredictiveAnalyticsChannelAffinityPriorityCondition
17
+ attr_accessor :type
18
+
19
+ # Possible dimension for channel affinity criterion.
20
+ attr_accessor :dimension
21
+
22
+ attr_accessor :measurement
23
+
24
+ # Possible channels in a channel affinity definition.
25
+ attr_accessor :predicted_channel
26
+
27
+ attr_accessor :filter
28
+
29
+ class EnumAttributeValidator
30
+ attr_reader :datatype
31
+ attr_reader :allowable_values
32
+
33
+ def initialize(datatype, allowable_values)
34
+ @allowable_values = allowable_values.map do |value|
35
+ case datatype.to_s
36
+ when /Integer/i
37
+ value.to_i
38
+ when /Float/i
39
+ value.to_f
40
+ else
41
+ value
42
+ end
43
+ end
44
+ end
45
+
46
+ def valid?(value)
47
+ !value || allowable_values.include?(value)
48
+ end
49
+ end
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ :'type' => :'type',
55
+ :'dimension' => :'dimension',
56
+ :'measurement' => :'measurement',
57
+ :'predicted_channel' => :'predicted_channel',
58
+ :'filter' => :'filter'
59
+ }
60
+ end
61
+
62
+ # Returns all the JSON keys this model knows about
63
+ def self.acceptable_attributes
64
+ attribute_map.values
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.openapi_types
69
+ {
70
+ :'type' => :'ProfilePredictiveAnalyticsEnum',
71
+ :'dimension' => :'String',
72
+ :'measurement' => :'PriorityEnum',
73
+ :'predicted_channel' => :'String',
74
+ :'filter' => :'ProfilePredictiveAnalyticsChannelAffinityPriorityFilter'
75
+ }
76
+ end
77
+
78
+ # List of attributes with nullable: true
79
+ def self.openapi_nullable
80
+ Set.new([
81
+ ])
82
+ end
83
+
84
+ # Initializes the object
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ def initialize(attributes = {})
87
+ if (!attributes.is_a?(Hash))
88
+ fail ArgumentError, "The input argument (attributes) must be a hash in `KlaviyoAPI::ProfilePredictiveAnalyticsChannelAffinityPriorityCondition` initialize method"
89
+ end
90
+
91
+ # check to see if the attribute exists and convert string to symbol for hash key
92
+ attributes = attributes.each_with_object({}) { |(k, v), h|
93
+ if (!self.class.attribute_map.key?(k.to_sym))
94
+ fail ArgumentError, "`#{k}` is not a valid attribute in `KlaviyoAPI::ProfilePredictiveAnalyticsChannelAffinityPriorityCondition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
95
+ end
96
+ h[k.to_sym] = v
97
+ }
98
+
99
+ if attributes.key?(:'type')
100
+ self.type = attributes[:'type']
101
+ end
102
+
103
+ if attributes.key?(:'dimension')
104
+ self.dimension = attributes[:'dimension']
105
+ end
106
+
107
+ if attributes.key?(:'measurement')
108
+ self.measurement = attributes[:'measurement']
109
+ end
110
+
111
+ if attributes.key?(:'predicted_channel')
112
+ self.predicted_channel = attributes[:'predicted_channel']
113
+ end
114
+
115
+ if attributes.key?(:'filter')
116
+ self.filter = attributes[:'filter']
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ if @type.nil?
125
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
126
+ end
127
+
128
+ if @dimension.nil?
129
+ invalid_properties.push('invalid value for "dimension", dimension cannot be nil.')
130
+ end
131
+
132
+ if @measurement.nil?
133
+ invalid_properties.push('invalid value for "measurement", measurement cannot be nil.')
134
+ end
135
+
136
+ if @predicted_channel.nil?
137
+ invalid_properties.push('invalid value for "predicted_channel", predicted_channel cannot be nil.')
138
+ end
139
+
140
+ if @filter.nil?
141
+ invalid_properties.push('invalid value for "filter", filter cannot be nil.')
142
+ end
143
+
144
+ invalid_properties
145
+ end
146
+
147
+ # Check to see if the all the properties in the model are valid
148
+ # @return true if the model is valid
149
+ def valid?
150
+ return false if @type.nil?
151
+ return false if @dimension.nil?
152
+ dimension_validator = EnumAttributeValidator.new('String', ["channel_affinity"])
153
+ return false unless dimension_validator.valid?(@dimension)
154
+ return false if @measurement.nil?
155
+ return false if @predicted_channel.nil?
156
+ predicted_channel_validator = EnumAttributeValidator.new('String', ["email", "push", "sms"])
157
+ return false unless predicted_channel_validator.valid?(@predicted_channel)
158
+ return false if @filter.nil?
159
+ true
160
+ end
161
+
162
+ # Custom attribute writer method checking allowed values (enum).
163
+ # @param [Object] dimension Object to be assigned
164
+ def dimension=(dimension)
165
+ validator = EnumAttributeValidator.new('String', ["channel_affinity"])
166
+ unless validator.valid?(dimension)
167
+ fail ArgumentError, "invalid value for \"dimension\", must be one of #{validator.allowable_values}."
168
+ end
169
+ @dimension = dimension
170
+ end
171
+
172
+ # Custom attribute writer method checking allowed values (enum).
173
+ # @param [Object] predicted_channel Object to be assigned
174
+ def predicted_channel=(predicted_channel)
175
+ validator = EnumAttributeValidator.new('String', ["email", "push", "sms"])
176
+ unless validator.valid?(predicted_channel)
177
+ fail ArgumentError, "invalid value for \"predicted_channel\", must be one of #{validator.allowable_values}."
178
+ end
179
+ @predicted_channel = predicted_channel
180
+ end
181
+
182
+ # Checks equality by comparing each attribute.
183
+ # @param [Object] Object to be compared
184
+ def ==(o)
185
+ return true if self.equal?(o)
186
+ self.class == o.class &&
187
+ type == o.type &&
188
+ dimension == o.dimension &&
189
+ measurement == o.measurement &&
190
+ predicted_channel == o.predicted_channel &&
191
+ filter == o.filter
192
+ end
193
+
194
+ # @see the `==` method
195
+ # @param [Object] Object to be compared
196
+ def eql?(o)
197
+ self == o
198
+ end
199
+
200
+ # Calculates hash code according to all attributes.
201
+ # @return [Integer] Hash code
202
+ def hash
203
+ [type, dimension, measurement, predicted_channel, filter].hash
204
+ end
205
+
206
+ # Builds the object from hash
207
+ # @param [Hash] attributes Model attributes in the form of hash
208
+ # @return [Object] Returns the model itself
209
+ def self.build_from_hash(attributes)
210
+ new.build_from_hash(attributes)
211
+ end
212
+
213
+ # Builds the object from hash
214
+ # @param [Hash] attributes Model attributes in the form of hash
215
+ # @return [Object] Returns the model itself
216
+ def build_from_hash(attributes)
217
+ return nil unless attributes.is_a?(Hash)
218
+ attributes = attributes.transform_keys(&:to_sym)
219
+ self.class.openapi_types.each_pair do |key, type|
220
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
221
+ self.send("#{key}=", nil)
222
+ elsif type =~ /\AArray<(.*)>/i
223
+ # check to ensure the input is an array given that the attribute
224
+ # is documented as an array but the input is not
225
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
226
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
227
+ end
228
+ elsif !attributes[self.class.attribute_map[key]].nil?
229
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
230
+ end
231
+ end
232
+
233
+ self
234
+ end
235
+
236
+ # Deserializes the data based on type
237
+ # @param string type Data type
238
+ # @param string value Value to be deserialized
239
+ # @return [Object] Deserialized data
240
+ def _deserialize(type, value)
241
+ case type.to_sym
242
+ when :Time
243
+ Time.parse(value)
244
+ when :Date
245
+ Date.parse(value)
246
+ when :String
247
+ value.to_s
248
+ when :Integer
249
+ value.to_i
250
+ when :Float
251
+ value.to_f
252
+ when :Boolean
253
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
254
+ true
255
+ else
256
+ false
257
+ end
258
+ when :Object
259
+ # generic object (usually a Hash), return directly
260
+ value
261
+ when /\AArray<(?<inner_type>.+)>\z/
262
+ inner_type = Regexp.last_match[:inner_type]
263
+ value.map { |v| _deserialize(inner_type, v) }
264
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
265
+ k_type = Regexp.last_match[:k_type]
266
+ v_type = Regexp.last_match[:v_type]
267
+ {}.tap do |hash|
268
+ value.each do |k, v|
269
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
270
+ end
271
+ end
272
+ else # model
273
+ # models (e.g. Pet) or oneOf
274
+ klass = KlaviyoAPI.const_get(type)
275
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
276
+ end
277
+ end
278
+
279
+ # Returns the string representation of the object
280
+ # @return [String] String presentation of the object
281
+ def to_s
282
+ to_hash.to_s
283
+ end
284
+
285
+ # to_body is an alias to to_hash (backward compatibility)
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_body
288
+ to_hash
289
+ end
290
+
291
+ # Returns the object in the form of hash
292
+ # @return [Hash] Returns the object in the form of hash
293
+ def to_hash
294
+ hash = {}
295
+ self.class.attribute_map.each_pair do |attr, param|
296
+ value = self.send(attr)
297
+ if value.nil?
298
+ is_nullable = self.class.openapi_nullable.include?(attr)
299
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
300
+ end
301
+
302
+ hash[param] = _to_hash(value)
303
+ end
304
+ hash
305
+ end
306
+
307
+ # Outputs non-array value in the form of hash
308
+ # For object, use to_hash. Otherwise, just return the value
309
+ # @param [Object] value Any valid value
310
+ # @return [Hash] Returns the value in the form of hash
311
+ def _to_hash(value)
312
+ if value.is_a?(Array)
313
+ value.compact.map { |v| _to_hash(v) }
314
+ elsif value.is_a?(Hash)
315
+ {}.tap do |hash|
316
+ value.each { |k, v| hash[k] = _to_hash(v) }
317
+ end
318
+ elsif value.respond_to? :to_hash
319
+ value.to_hash
320
+ else
321
+ value
322
+ end
323
+ end
324
+
325
+ end
326
+
327
+ end
@@ -0,0 +1,251 @@
1
+ =begin
2
+ #Klaviyo API
3
+
4
+ #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.
5
+
6
+ Contact: developers@klaviyo.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 6.2.1
9
+
10
+ =end
11
+
12
+ require 'date'
13
+ require 'time'
14
+
15
+ module KlaviyoAPI
16
+ class ProfilePredictiveAnalyticsChannelAffinityPriorityFilter
17
+ attr_accessor :type
18
+
19
+ attr_accessor :operator
20
+
21
+ attr_accessor :value
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'type' => :'type',
27
+ :'operator' => :'operator',
28
+ :'value' => :'value'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'type' => :'NumericEnum',
41
+ :'operator' => :'EqualsEnum',
42
+ :'value' => :'Integer'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `KlaviyoAPI::ProfilePredictiveAnalyticsChannelAffinityPriorityFilter` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `KlaviyoAPI::ProfilePredictiveAnalyticsChannelAffinityPriorityFilter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'type')
68
+ self.type = attributes[:'type']
69
+ end
70
+
71
+ if attributes.key?(:'operator')
72
+ self.operator = attributes[:'operator']
73
+ end
74
+
75
+ if attributes.key?(:'value')
76
+ self.value = attributes[:'value']
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ invalid_properties = Array.new
84
+ if @type.nil?
85
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
86
+ end
87
+
88
+ if @operator.nil?
89
+ invalid_properties.push('invalid value for "operator", operator cannot be nil.')
90
+ end
91
+
92
+ if @value.nil?
93
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ return false if @type.nil?
103
+ return false if @operator.nil?
104
+ return false if @value.nil?
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ type == o.type &&
114
+ operator == o.operator &&
115
+ value == o.value
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Integer] Hash code
126
+ def hash
127
+ [type, operator, value].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def self.build_from_hash(attributes)
134
+ new.build_from_hash(attributes)
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def build_from_hash(attributes)
141
+ return nil unless attributes.is_a?(Hash)
142
+ attributes = attributes.transform_keys(&:to_sym)
143
+ self.class.openapi_types.each_pair do |key, type|
144
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
145
+ self.send("#{key}=", nil)
146
+ elsif type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
150
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
151
+ end
152
+ elsif !attributes[self.class.attribute_map[key]].nil?
153
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
154
+ end
155
+ end
156
+
157
+ self
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def _deserialize(type, value)
165
+ case type.to_sym
166
+ when :Time
167
+ Time.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :Boolean
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ # models (e.g. Pet) or oneOf
198
+ klass = KlaviyoAPI.const_get(type)
199
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
200
+ end
201
+ end
202
+
203
+ # Returns the string representation of the object
204
+ # @return [String] String presentation of the object
205
+ def to_s
206
+ to_hash.to_s
207
+ end
208
+
209
+ # to_body is an alias to to_hash (backward compatibility)
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_body
212
+ to_hash
213
+ end
214
+
215
+ # Returns the object in the form of hash
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_hash
218
+ hash = {}
219
+ self.class.attribute_map.each_pair do |attr, param|
220
+ value = self.send(attr)
221
+ if value.nil?
222
+ is_nullable = self.class.openapi_nullable.include?(attr)
223
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
224
+ end
225
+
226
+ hash[param] = _to_hash(value)
227
+ end
228
+ hash
229
+ end
230
+
231
+ # Outputs non-array value in the form of hash
232
+ # For object, use to_hash. Otherwise, just return the value
233
+ # @param [Object] value Any valid value
234
+ # @return [Hash] Returns the value in the form of hash
235
+ def _to_hash(value)
236
+ if value.is_a?(Array)
237
+ value.compact.map { |v| _to_hash(v) }
238
+ elsif value.is_a?(Hash)
239
+ {}.tap do |hash|
240
+ value.each { |k, v| hash[k] = _to_hash(v) }
241
+ end
242
+ elsif value.respond_to? :to_hash
243
+ value.to_hash
244
+ else
245
+ value
246
+ end
247
+ end
248
+
249
+ end
250
+
251
+ end