klaviyo-api-sdk 10.0.0 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +382 -136
  4. data/klaviyo-api-sdk.gemspec +1 -1
  5. data/lib/klaviyo-api-sdk/api/accounts_api.rb +2 -2
  6. data/lib/klaviyo-api-sdk/api/campaigns_api.rb +41 -23
  7. data/lib/klaviyo-api-sdk/api/catalogs_api.rb +82 -76
  8. data/lib/klaviyo-api-sdk/api/coupons_api.rb +111 -93
  9. data/lib/klaviyo-api-sdk/api/data_privacy_api.rb +1 -1
  10. data/lib/klaviyo-api-sdk/api/events_api.rb +128 -116
  11. data/lib/klaviyo-api-sdk/api/flows_api.rb +199 -169
  12. data/lib/klaviyo-api-sdk/api/forms_api.rb +19 -7
  13. data/lib/klaviyo-api-sdk/api/images_api.rb +5 -5
  14. data/lib/klaviyo-api-sdk/api/lists_api.rb +391 -337
  15. data/lib/klaviyo-api-sdk/api/metrics_api.rb +151 -115
  16. data/lib/klaviyo-api-sdk/api/profiles_api.rb +170 -119
  17. data/lib/klaviyo-api-sdk/api/reporting_api.rb +49 -7
  18. data/lib/klaviyo-api-sdk/api/reviews_api.rb +2 -2
  19. data/lib/klaviyo-api-sdk/api/segments_api.rb +170 -146
  20. data/lib/klaviyo-api-sdk/api/tags_api.rb +108 -42
  21. data/lib/klaviyo-api-sdk/api/templates_api.rb +12 -12
  22. data/lib/klaviyo-api-sdk/api/tracking_settings_api.rb +3 -3
  23. data/lib/klaviyo-api-sdk/api/webhooks_api.rb +7 -7
  24. data/lib/klaviyo-api-sdk/api_client.rb +1 -1
  25. data/lib/klaviyo-api-sdk/configuration.rb +18 -9
  26. data/lib/klaviyo-api-sdk/models/campaign_send_job_partial_update_query_resource_object_attributes.rb +34 -0
  27. data/lib/klaviyo-api-sdk/models/device_metadata.rb +2 -2
  28. data/lib/klaviyo-api-sdk/models/email_unsubscription_parameters.rb +224 -0
  29. data/lib/klaviyo-api-sdk/models/html_block_data.rb +4 -14
  30. data/lib/klaviyo-api-sdk/models/profile_subscription_delete_query_resource_object_attributes.rb +14 -5
  31. data/lib/klaviyo-api-sdk/models/sms_subscription_parameters.rb +13 -4
  32. data/lib/klaviyo-api-sdk/models/sms_unsubscription_parameters.rb +228 -0
  33. data/lib/klaviyo-api-sdk/models/template_create_query_resource_object_attributes.rb +1 -1
  34. data/lib/klaviyo-api-sdk/models/unsubscription_channels.rb +228 -0
  35. data/lib/klaviyo-api-sdk/models/unsubscription_parameters.rb +259 -0
  36. data/lib/klaviyo-api-sdk.rb +36 -19
  37. metadata +6 -2
@@ -32,7 +32,7 @@ module KlaviyoAPI
32
32
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
33
33
  def initialize(config = Configuration.default)
34
34
  @config = config
35
- @user_agent = "klaviyo-api-ruby/10.0.0"
35
+ @user_agent = "klaviyo-api-ruby/11.1.0"
36
36
  @default_headers = {
37
37
  'Content-Type' => 'application/json',
38
38
  'User-Agent' => @user_agent
@@ -215,15 +215,24 @@ module KlaviyoAPI
215
215
 
216
216
  # Returns Auth Settings hash for api client.
217
217
  def auth_settings
218
- {
219
- 'Klaviyo-API-Key' =>
220
- {
221
- type: 'api_key',
222
- in: 'header',
223
- key: 'Authorization',
224
- value: api_key_with_prefix('Klaviyo-API-Key')
225
- },
226
- }
218
+ auth = {}
219
+ if api_key_with_prefix('Klaviyo-API-Key')
220
+ auth['Klaviyo-API-Key'] = {
221
+ type: 'api_key',
222
+ in: 'header',
223
+ key: 'Authorization',
224
+ value: api_key_with_prefix('Klaviyo-API-Key')
225
+ }
226
+ end
227
+ if access_token
228
+ auth['OAuth'] = {
229
+ type: 'oauth2',
230
+ in: 'header',
231
+ key: 'Authorization',
232
+ value: "Bearer #{access_token}"
233
+ }
234
+ end
235
+ auth
227
236
  end
228
237
 
229
238
  # Returns an array of Server setting
@@ -18,6 +18,28 @@ module KlaviyoAPI
18
18
  # The action you would like to take with this send job from among 'cancel' and 'revert'
19
19
  attr_accessor :action
20
20
 
21
+ class EnumAttributeValidator
22
+ attr_reader :datatype
23
+ attr_reader :allowable_values
24
+
25
+ def initialize(datatype, allowable_values)
26
+ @allowable_values = allowable_values.map do |value|
27
+ case datatype.to_s
28
+ when /Integer/i
29
+ value.to_i
30
+ when /Float/i
31
+ value.to_f
32
+ else
33
+ value
34
+ end
35
+ end
36
+ end
37
+
38
+ def valid?(value)
39
+ !value || allowable_values.include?(value)
40
+ end
41
+ end
42
+
21
43
  # Attribute mapping from ruby-style variable name to JSON key.
22
44
  def self.attribute_map
23
45
  {
@@ -78,9 +100,21 @@ module KlaviyoAPI
78
100
  # @return true if the model is valid
79
101
  def valid?
80
102
  return false if @action.nil?
103
+ action_validator = EnumAttributeValidator.new('String', ["cancel", "revert"])
104
+ return false unless action_validator.valid?(@action)
81
105
  true
82
106
  end
83
107
 
108
+ # Custom attribute writer method checking allowed values (enum).
109
+ # @param [Object] action Object to be assigned
110
+ def action=(action)
111
+ validator = EnumAttributeValidator.new('String', ["cancel", "revert"])
112
+ unless validator.valid?(action)
113
+ fail ArgumentError, "invalid value for \"action\", must be one of #{validator.allowable_values}."
114
+ end
115
+ @action = action
116
+ end
117
+
84
118
  # Checks equality by comparing each attribute.
85
119
  # @param [Object] Object to be compared
86
120
  def ==(o)
@@ -206,7 +206,7 @@ module KlaviyoAPI
206
206
  # Check to see if the all the properties in the model are valid
207
207
  # @return true if the model is valid
208
208
  def valid?
209
- klaviyo_sdk_validator = EnumAttributeValidator.new('String', ["android", "react_native", "swift"])
209
+ klaviyo_sdk_validator = EnumAttributeValidator.new('String', ["android", "flutter_community", "react_native", "swift"])
210
210
  return false unless klaviyo_sdk_validator.valid?(@klaviyo_sdk)
211
211
  os_name_validator = EnumAttributeValidator.new('String', ["android", "ios", "ipados", "macos", "tvos"])
212
212
  return false unless os_name_validator.valid?(@os_name)
@@ -218,7 +218,7 @@ module KlaviyoAPI
218
218
  # Custom attribute writer method checking allowed values (enum).
219
219
  # @param [Object] klaviyo_sdk Object to be assigned
220
220
  def klaviyo_sdk=(klaviyo_sdk)
221
- validator = EnumAttributeValidator.new('String', ["android", "react_native", "swift"])
221
+ validator = EnumAttributeValidator.new('String', ["android", "flutter_community", "react_native", "swift"])
222
222
  unless validator.valid?(klaviyo_sdk)
223
223
  fail ArgumentError, "invalid value for \"klaviyo_sdk\", must be one of #{validator.allowable_values}."
224
224
  end
@@ -0,0 +1,224 @@
1
+ =begin
2
+ #Klaviyo API
3
+
4
+ #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.
5
+
6
+ The version of the OpenAPI document: 2024-10-15
7
+ Contact: developers@klaviyo.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module KlaviyoAPI
17
+ class EmailUnsubscriptionParameters
18
+ attr_accessor :marketing
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'marketing' => :'marketing'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'marketing' => :'UnsubscriptionParameters'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `KlaviyoAPI::EmailUnsubscriptionParameters` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `KlaviyoAPI::EmailUnsubscriptionParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'marketing')
61
+ self.marketing = attributes[:'marketing']
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ if @marketing.nil?
70
+ invalid_properties.push('invalid value for "marketing", marketing cannot be nil.')
71
+ end
72
+
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ return false if @marketing.nil?
80
+ true
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
85
+ def ==(o)
86
+ return true if self.equal?(o)
87
+ self.class == o.class &&
88
+ marketing == o.marketing
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [marketing].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ attributes = attributes.transform_keys(&:to_sym)
116
+ self.class.openapi_types.each_pair do |key, type|
117
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
118
+ self.send("#{key}=", nil)
119
+ elsif type =~ /\AArray<(.*)>/i
120
+ # check to ensure the input is an array given that the attribute
121
+ # is documented as an array but the input is not
122
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
123
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
124
+ end
125
+ elsif !attributes[self.class.attribute_map[key]].nil?
126
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
127
+ end
128
+ end
129
+
130
+ self
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def _deserialize(type, value)
138
+ case type.to_sym
139
+ when :Time
140
+ Time.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :Boolean
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
+ end
168
+ end
169
+ else # model
170
+ # models (e.g. Pet) or oneOf
171
+ klass = KlaviyoAPI.const_get(type)
172
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
173
+ end
174
+ end
175
+
176
+ # Returns the string representation of the object
177
+ # @return [String] String presentation of the object
178
+ def to_s
179
+ to_hash.to_s
180
+ end
181
+
182
+ # to_body is an alias to to_hash (backward compatibility)
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_body
185
+ to_hash
186
+ end
187
+
188
+ # Returns the object in the form of hash
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_hash
191
+ hash = {}
192
+ self.class.attribute_map.each_pair do |attr, param|
193
+ value = self.send(attr)
194
+ if value.nil?
195
+ is_nullable = self.class.openapi_nullable.include?(attr)
196
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
197
+ end
198
+
199
+ hash[param] = _to_hash(value)
200
+ end
201
+ hash
202
+ end
203
+
204
+ # Outputs non-array value in the form of hash
205
+ # For object, use to_hash. Otherwise, just return the value
206
+ # @param [Object] value Any valid value
207
+ # @return [Hash] Returns the value in the form of hash
208
+ def _to_hash(value)
209
+ if value.is_a?(Array)
210
+ value.compact.map { |v| _to_hash(v) }
211
+ elsif value.is_a?(Hash)
212
+ {}.tap do |hash|
213
+ value.each { |k, v| hash[k] = _to_hash(v) }
214
+ end
215
+ elsif value.respond_to? :to_hash
216
+ value.to_hash
217
+ else
218
+ value
219
+ end
220
+ end
221
+
222
+ end
223
+
224
+ end
@@ -19,14 +19,11 @@ module KlaviyoAPI
19
19
 
20
20
  attr_accessor :display_options
21
21
 
22
- attr_accessor :styles
23
-
24
22
  # Attribute mapping from ruby-style variable name to JSON key.
25
23
  def self.attribute_map
26
24
  {
27
25
  :'content' => :'content',
28
- :'display_options' => :'display_options',
29
- :'styles' => :'styles'
26
+ :'display_options' => :'display_options'
30
27
  }
31
28
  end
32
29
 
@@ -39,15 +36,13 @@ module KlaviyoAPI
39
36
  def self.openapi_types
40
37
  {
41
38
  :'content' => :'String',
42
- :'display_options' => :'BlockDisplayOptions',
43
- :'styles' => :'String'
39
+ :'display_options' => :'BlockDisplayOptions'
44
40
  }
45
41
  end
46
42
 
47
43
  # List of attributes with nullable: true
48
44
  def self.openapi_nullable
49
45
  Set.new([
50
- :'styles'
51
46
  ])
52
47
  end
53
48
 
@@ -73,10 +68,6 @@ module KlaviyoAPI
73
68
  if attributes.key?(:'display_options')
74
69
  self.display_options = attributes[:'display_options']
75
70
  end
76
-
77
- if attributes.key?(:'styles')
78
- self.styles = attributes[:'styles']
79
- end
80
71
  end
81
72
 
82
73
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -108,8 +99,7 @@ module KlaviyoAPI
108
99
  return true if self.equal?(o)
109
100
  self.class == o.class &&
110
101
  content == o.content &&
111
- display_options == o.display_options &&
112
- styles == o.styles
102
+ display_options == o.display_options
113
103
  end
114
104
 
115
105
  # @see the `==` method
@@ -121,7 +111,7 @@ module KlaviyoAPI
121
111
  # Calculates hash code according to all attributes.
122
112
  # @return [Integer] Hash code
123
113
  def hash
124
- [content, display_options, styles].hash
114
+ [content, display_options].hash
125
115
  end
126
116
 
127
117
  # Builds the object from hash
@@ -21,11 +21,14 @@ module KlaviyoAPI
21
21
  # The phone number to unsubscribe. This must be in E.164 format.
22
22
  attr_accessor :phone_number
23
23
 
24
+ attr_accessor :subscriptions
25
+
24
26
  # Attribute mapping from ruby-style variable name to JSON key.
25
27
  def self.attribute_map
26
28
  {
27
29
  :'email' => :'email',
28
- :'phone_number' => :'phone_number'
30
+ :'phone_number' => :'phone_number',
31
+ :'subscriptions' => :'subscriptions'
29
32
  }
30
33
  end
31
34
 
@@ -38,7 +41,8 @@ module KlaviyoAPI
38
41
  def self.openapi_types
39
42
  {
40
43
  :'email' => :'String',
41
- :'phone_number' => :'String'
44
+ :'phone_number' => :'String',
45
+ :'subscriptions' => :'UnsubscriptionChannels'
42
46
  }
43
47
  end
44
48
 
@@ -46,7 +50,7 @@ module KlaviyoAPI
46
50
  def self.openapi_nullable
47
51
  Set.new([
48
52
  :'email',
49
- :'phone_number'
53
+ :'phone_number',
50
54
  ])
51
55
  end
52
56
 
@@ -72,6 +76,10 @@ module KlaviyoAPI
72
76
  if attributes.key?(:'phone_number')
73
77
  self.phone_number = attributes[:'phone_number']
74
78
  end
79
+
80
+ if attributes.key?(:'subscriptions')
81
+ self.subscriptions = attributes[:'subscriptions']
82
+ end
75
83
  end
76
84
 
77
85
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -93,7 +101,8 @@ module KlaviyoAPI
93
101
  return true if self.equal?(o)
94
102
  self.class == o.class &&
95
103
  email == o.email &&
96
- phone_number == o.phone_number
104
+ phone_number == o.phone_number &&
105
+ subscriptions == o.subscriptions
97
106
  end
98
107
 
99
108
  # @see the `==` method
@@ -105,7 +114,7 @@ module KlaviyoAPI
105
114
  # Calculates hash code according to all attributes.
106
115
  # @return [Integer] Hash code
107
116
  def hash
108
- [email, phone_number].hash
117
+ [email, phone_number, subscriptions].hash
109
118
  end
110
119
 
111
120
  # Builds the object from hash
@@ -17,10 +17,13 @@ module KlaviyoAPI
17
17
  class SMSSubscriptionParameters
18
18
  attr_accessor :marketing
19
19
 
20
+ attr_accessor :transactional
21
+
20
22
  # Attribute mapping from ruby-style variable name to JSON key.
21
23
  def self.attribute_map
22
24
  {
23
- :'marketing' => :'marketing'
25
+ :'marketing' => :'marketing',
26
+ :'transactional' => :'transactional'
24
27
  }
25
28
  end
26
29
 
@@ -32,7 +35,8 @@ module KlaviyoAPI
32
35
  # Attribute type mapping.
33
36
  def self.openapi_types
34
37
  {
35
- :'marketing' => :'SubscriptionParameters'
38
+ :'marketing' => :'SubscriptionParameters',
39
+ :'transactional' => :'SubscriptionParameters'
36
40
  }
37
41
  end
38
42
 
@@ -60,6 +64,10 @@ module KlaviyoAPI
60
64
  if attributes.key?(:'marketing')
61
65
  self.marketing = attributes[:'marketing']
62
66
  end
67
+
68
+ if attributes.key?(:'transactional')
69
+ self.transactional = attributes[:'transactional']
70
+ end
63
71
  end
64
72
 
65
73
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -80,7 +88,8 @@ module KlaviyoAPI
80
88
  def ==(o)
81
89
  return true if self.equal?(o)
82
90
  self.class == o.class &&
83
- marketing == o.marketing
91
+ marketing == o.marketing &&
92
+ transactional == o.transactional
84
93
  end
85
94
 
86
95
  # @see the `==` method
@@ -92,7 +101,7 @@ module KlaviyoAPI
92
101
  # Calculates hash code according to all attributes.
93
102
  # @return [Integer] Hash code
94
103
  def hash
95
- [marketing].hash
104
+ [marketing, transactional].hash
96
105
  end
97
106
 
98
107
  # Builds the object from hash