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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +382 -136
- data/klaviyo-api-sdk.gemspec +1 -1
- data/lib/klaviyo-api-sdk/api/accounts_api.rb +2 -2
- data/lib/klaviyo-api-sdk/api/campaigns_api.rb +41 -23
- data/lib/klaviyo-api-sdk/api/catalogs_api.rb +82 -76
- data/lib/klaviyo-api-sdk/api/coupons_api.rb +111 -93
- data/lib/klaviyo-api-sdk/api/data_privacy_api.rb +1 -1
- data/lib/klaviyo-api-sdk/api/events_api.rb +128 -116
- data/lib/klaviyo-api-sdk/api/flows_api.rb +199 -169
- data/lib/klaviyo-api-sdk/api/forms_api.rb +19 -7
- data/lib/klaviyo-api-sdk/api/images_api.rb +5 -5
- data/lib/klaviyo-api-sdk/api/lists_api.rb +391 -337
- data/lib/klaviyo-api-sdk/api/metrics_api.rb +151 -115
- data/lib/klaviyo-api-sdk/api/profiles_api.rb +170 -119
- data/lib/klaviyo-api-sdk/api/reporting_api.rb +49 -7
- data/lib/klaviyo-api-sdk/api/reviews_api.rb +2 -2
- data/lib/klaviyo-api-sdk/api/segments_api.rb +170 -146
- data/lib/klaviyo-api-sdk/api/tags_api.rb +108 -42
- data/lib/klaviyo-api-sdk/api/templates_api.rb +12 -12
- data/lib/klaviyo-api-sdk/api/tracking_settings_api.rb +3 -3
- data/lib/klaviyo-api-sdk/api/webhooks_api.rb +7 -7
- data/lib/klaviyo-api-sdk/api_client.rb +1 -1
- data/lib/klaviyo-api-sdk/configuration.rb +18 -9
- data/lib/klaviyo-api-sdk/models/campaign_send_job_partial_update_query_resource_object_attributes.rb +34 -0
- data/lib/klaviyo-api-sdk/models/device_metadata.rb +2 -2
- data/lib/klaviyo-api-sdk/models/email_unsubscription_parameters.rb +224 -0
- data/lib/klaviyo-api-sdk/models/html_block_data.rb +4 -14
- data/lib/klaviyo-api-sdk/models/profile_subscription_delete_query_resource_object_attributes.rb +14 -5
- data/lib/klaviyo-api-sdk/models/sms_subscription_parameters.rb +13 -4
- data/lib/klaviyo-api-sdk/models/sms_unsubscription_parameters.rb +228 -0
- data/lib/klaviyo-api-sdk/models/template_create_query_resource_object_attributes.rb +1 -1
- data/lib/klaviyo-api-sdk/models/unsubscription_channels.rb +228 -0
- data/lib/klaviyo-api-sdk/models/unsubscription_parameters.rb +259 -0
- data/lib/klaviyo-api-sdk.rb +36 -19
- metadata +6 -2
@@ -0,0 +1,259 @@
|
|
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 UnsubscriptionParameters
|
18
|
+
# The Consent status to be set as part of the unsubscribe call. Currently supports \"UNSUBSCRIBED\".
|
19
|
+
attr_accessor :consent
|
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
|
+
|
43
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
44
|
+
def self.attribute_map
|
45
|
+
{
|
46
|
+
:'consent' => :'consent'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns all the JSON keys this model knows about
|
51
|
+
def self.acceptable_attributes
|
52
|
+
attribute_map.values
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute type mapping.
|
56
|
+
def self.openapi_types
|
57
|
+
{
|
58
|
+
:'consent' => :'String'
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
# List of attributes with nullable: true
|
63
|
+
def self.openapi_nullable
|
64
|
+
Set.new([
|
65
|
+
])
|
66
|
+
end
|
67
|
+
|
68
|
+
# Initializes the object
|
69
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
70
|
+
def initialize(attributes = {})
|
71
|
+
if (!attributes.is_a?(Hash))
|
72
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `KlaviyoAPI::UnsubscriptionParameters` initialize method"
|
73
|
+
end
|
74
|
+
|
75
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
76
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
77
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
78
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `KlaviyoAPI::UnsubscriptionParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
79
|
+
end
|
80
|
+
h[k.to_sym] = v
|
81
|
+
}
|
82
|
+
|
83
|
+
if attributes.key?(:'consent')
|
84
|
+
self.consent = attributes[:'consent']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
89
|
+
# @return Array for valid properties with the reasons
|
90
|
+
def list_invalid_properties
|
91
|
+
invalid_properties = Array.new
|
92
|
+
if @consent.nil?
|
93
|
+
invalid_properties.push('invalid value for "consent", consent 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 @consent.nil?
|
103
|
+
consent_validator = EnumAttributeValidator.new('String', ["UNSUBSCRIBED"])
|
104
|
+
return false unless consent_validator.valid?(@consent)
|
105
|
+
true
|
106
|
+
end
|
107
|
+
|
108
|
+
# Custom attribute writer method checking allowed values (enum).
|
109
|
+
# @param [Object] consent Object to be assigned
|
110
|
+
def consent=(consent)
|
111
|
+
validator = EnumAttributeValidator.new('String', ["UNSUBSCRIBED"])
|
112
|
+
unless validator.valid?(consent)
|
113
|
+
fail ArgumentError, "invalid value for \"consent\", must be one of #{validator.allowable_values}."
|
114
|
+
end
|
115
|
+
@consent = consent
|
116
|
+
end
|
117
|
+
|
118
|
+
# Checks equality by comparing each attribute.
|
119
|
+
# @param [Object] Object to be compared
|
120
|
+
def ==(o)
|
121
|
+
return true if self.equal?(o)
|
122
|
+
self.class == o.class &&
|
123
|
+
consent == o.consent
|
124
|
+
end
|
125
|
+
|
126
|
+
# @see the `==` method
|
127
|
+
# @param [Object] Object to be compared
|
128
|
+
def eql?(o)
|
129
|
+
self == o
|
130
|
+
end
|
131
|
+
|
132
|
+
# Calculates hash code according to all attributes.
|
133
|
+
# @return [Integer] Hash code
|
134
|
+
def hash
|
135
|
+
[consent].hash
|
136
|
+
end
|
137
|
+
|
138
|
+
# Builds the object from hash
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
140
|
+
# @return [Object] Returns the model itself
|
141
|
+
def self.build_from_hash(attributes)
|
142
|
+
new.build_from_hash(attributes)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Builds the object from hash
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
147
|
+
# @return [Object] Returns the model itself
|
148
|
+
def build_from_hash(attributes)
|
149
|
+
return nil unless attributes.is_a?(Hash)
|
150
|
+
attributes = attributes.transform_keys(&:to_sym)
|
151
|
+
self.class.openapi_types.each_pair do |key, type|
|
152
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
153
|
+
self.send("#{key}=", nil)
|
154
|
+
elsif type =~ /\AArray<(.*)>/i
|
155
|
+
# check to ensure the input is an array given that the attribute
|
156
|
+
# is documented as an array but the input is not
|
157
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
158
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
159
|
+
end
|
160
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
161
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
self
|
166
|
+
end
|
167
|
+
|
168
|
+
# Deserializes the data based on type
|
169
|
+
# @param string type Data type
|
170
|
+
# @param string value Value to be deserialized
|
171
|
+
# @return [Object] Deserialized data
|
172
|
+
def _deserialize(type, value)
|
173
|
+
case type.to_sym
|
174
|
+
when :Time
|
175
|
+
Time.parse(value)
|
176
|
+
when :Date
|
177
|
+
Date.parse(value)
|
178
|
+
when :String
|
179
|
+
value.to_s
|
180
|
+
when :Integer
|
181
|
+
value.to_i
|
182
|
+
when :Float
|
183
|
+
value.to_f
|
184
|
+
when :Boolean
|
185
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
186
|
+
true
|
187
|
+
else
|
188
|
+
false
|
189
|
+
end
|
190
|
+
when :Object
|
191
|
+
# generic object (usually a Hash), return directly
|
192
|
+
value
|
193
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
194
|
+
inner_type = Regexp.last_match[:inner_type]
|
195
|
+
value.map { |v| _deserialize(inner_type, v) }
|
196
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
197
|
+
k_type = Regexp.last_match[:k_type]
|
198
|
+
v_type = Regexp.last_match[:v_type]
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each do |k, v|
|
201
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
else # model
|
205
|
+
# models (e.g. Pet) or oneOf
|
206
|
+
klass = KlaviyoAPI.const_get(type)
|
207
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the string representation of the object
|
212
|
+
# @return [String] String presentation of the object
|
213
|
+
def to_s
|
214
|
+
to_hash.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# to_body is an alias to to_hash (backward compatibility)
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the object in the form of hash
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
225
|
+
def to_hash
|
226
|
+
hash = {}
|
227
|
+
self.class.attribute_map.each_pair do |attr, param|
|
228
|
+
value = self.send(attr)
|
229
|
+
if value.nil?
|
230
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
231
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
232
|
+
end
|
233
|
+
|
234
|
+
hash[param] = _to_hash(value)
|
235
|
+
end
|
236
|
+
hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Outputs non-array value in the form of hash
|
240
|
+
# For object, use to_hash. Otherwise, just return the value
|
241
|
+
# @param [Object] value Any valid value
|
242
|
+
# @return [Hash] Returns the value in the form of hash
|
243
|
+
def _to_hash(value)
|
244
|
+
if value.is_a?(Array)
|
245
|
+
value.compact.map { |v| _to_hash(v) }
|
246
|
+
elsif value.is_a?(Hash)
|
247
|
+
{}.tap do |hash|
|
248
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
249
|
+
end
|
250
|
+
elsif value.respond_to? :to_hash
|
251
|
+
value.to_hash
|
252
|
+
else
|
253
|
+
value
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
data/lib/klaviyo-api-sdk.rb
CHANGED
@@ -213,6 +213,7 @@ require 'klaviyo-api-sdk/models/email_send_options_sub_object'
|
|
213
213
|
require 'klaviyo-api-sdk/models/email_subscription_parameters'
|
214
214
|
require 'klaviyo-api-sdk/models/email_tracking_options_sub_object'
|
215
215
|
require 'klaviyo-api-sdk/models/email_tracking_options_sub_object_custom_tracking_params_inner'
|
216
|
+
require 'klaviyo-api-sdk/models/email_unsubscription_parameters'
|
216
217
|
require 'klaviyo-api-sdk/models/equals_enum'
|
217
218
|
require 'klaviyo-api-sdk/models/equals_string_filter'
|
218
219
|
require 'klaviyo-api-sdk/models/event_bulk_create_enum'
|
@@ -447,6 +448,7 @@ require 'klaviyo-api-sdk/models/sms_content_sub_object_create'
|
|
447
448
|
require 'klaviyo-api-sdk/models/sms_send_options_sub_object'
|
448
449
|
require 'klaviyo-api-sdk/models/sms_subscription_parameters'
|
449
450
|
require 'klaviyo-api-sdk/models/sms_tracking_options_sub_object'
|
451
|
+
require 'klaviyo-api-sdk/models/sms_unsubscription_parameters'
|
450
452
|
require 'klaviyo-api-sdk/models/sto_schedule_options'
|
451
453
|
require 'klaviyo-api-sdk/models/segment_create_query'
|
452
454
|
require 'klaviyo-api-sdk/models/segment_create_query_resource_object'
|
@@ -590,6 +592,8 @@ require 'klaviyo-api-sdk/models/universal_content_partial_update_query_resource_
|
|
590
592
|
require 'klaviyo-api-sdk/models/universal_content_partial_update_query_resource_object_attributes'
|
591
593
|
require 'klaviyo-api-sdk/models/universal_content_partial_update_query_resource_object_attributes_definition'
|
592
594
|
require 'klaviyo-api-sdk/models/unsubscribed_enum'
|
595
|
+
require 'klaviyo-api-sdk/models/unsubscription_channels'
|
596
|
+
require 'klaviyo-api-sdk/models/unsubscription_parameters'
|
593
597
|
require 'klaviyo-api-sdk/models/webhook_create_query'
|
594
598
|
require 'klaviyo-api-sdk/models/webhook_create_query_resource_object'
|
595
599
|
require 'klaviyo-api-sdk/models/webhook_create_query_resource_object_attributes'
|
@@ -660,25 +664,10 @@ module KlaviyoAPI
|
|
660
664
|
# recreate methods
|
661
665
|
original_class.public_instance_methods(false).each do |m|
|
662
666
|
wrapper_class.class_eval {
|
663
|
-
define_singleton_method m do |*arg|
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
max_retries = Configuration.default.max_retries
|
668
|
-
max_delay = Configuration.default.max_delay
|
669
|
-
|
670
|
-
if (max_retries != nil && max_delay != nil)
|
671
|
-
Retriable.configure do |c|
|
672
|
-
c.tries = max_retries
|
673
|
-
c.max_elapsed_time = max_delay
|
674
|
-
c.on = {
|
675
|
-
KlaviyoAPI::ApiError => [/429/, /503/, /504/]
|
676
|
-
}
|
677
|
-
end
|
678
|
-
Retriable.retriable do
|
679
|
-
KlaviyoAPI.const_get(c).new.send(m, *arg)
|
680
|
-
end
|
681
|
-
else
|
667
|
+
define_singleton_method m do |*arg|
|
668
|
+
max_retries = Configuration.default.max_retries || 3
|
669
|
+
max_delay = Configuration.default.max_delay || 60
|
670
|
+
KlaviyoAPI.with_retry(max_retries, max_delay) do
|
682
671
|
KlaviyoAPI.const_get(c).new.send(m, *arg)
|
683
672
|
end
|
684
673
|
end
|
@@ -689,5 +678,33 @@ module KlaviyoAPI
|
|
689
678
|
@is_initialized = true
|
690
679
|
end
|
691
680
|
end
|
681
|
+
|
682
|
+
def with_retry(tries, max_elapsed_time)
|
683
|
+
start_time = Time.now
|
684
|
+
elapsed_time = -> { Time.now - start_time }
|
685
|
+
last_request_retry_after = nil
|
686
|
+
last_request_timestamp = nil
|
687
|
+
index = 0
|
688
|
+
attempt = 0
|
689
|
+
last_exception = nil
|
690
|
+
while true
|
691
|
+
begin
|
692
|
+
retry_after_value_elapsed = last_request_retry_after == nil || Time.now - last_request_timestamp > Integer(last_request_retry_after)
|
693
|
+
if retry_after_value_elapsed
|
694
|
+
attempt += 1
|
695
|
+
return yield
|
696
|
+
end
|
697
|
+
rescue KlaviyoAPI::ApiError => exception
|
698
|
+
last_exception = exception
|
699
|
+
last_request_retry_after = exception.response_headers[:'Retry-After']
|
700
|
+
last_request_timestamp = Time.now
|
701
|
+
raise unless [429, 503, 504, 524].include? exception.code
|
702
|
+
end
|
703
|
+
interval = Retriable::ExponentialBackoff.new(tries: index + 1).intervals[index]
|
704
|
+
raise last_exception if attempt >= tries || (elapsed_time.call + interval) > max_elapsed_time
|
705
|
+
sleep interval
|
706
|
+
index += 1
|
707
|
+
end
|
708
|
+
end
|
692
709
|
end
|
693
710
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klaviyo-api-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 11.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaviyo Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: retriable
|
@@ -825,6 +825,7 @@ files:
|
|
825
825
|
- lib/klaviyo-api-sdk/models/email_subscription_parameters.rb
|
826
826
|
- lib/klaviyo-api-sdk/models/email_tracking_options_sub_object.rb
|
827
827
|
- lib/klaviyo-api-sdk/models/email_tracking_options_sub_object_custom_tracking_params_inner.rb
|
828
|
+
- lib/klaviyo-api-sdk/models/email_unsubscription_parameters.rb
|
828
829
|
- lib/klaviyo-api-sdk/models/equals_enum.rb
|
829
830
|
- lib/klaviyo-api-sdk/models/equals_string_filter.rb
|
830
831
|
- lib/klaviyo-api-sdk/models/event_bulk_create_enum.rb
|
@@ -1090,6 +1091,7 @@ files:
|
|
1090
1091
|
- lib/klaviyo-api-sdk/models/sms_send_options_sub_object.rb
|
1091
1092
|
- lib/klaviyo-api-sdk/models/sms_subscription_parameters.rb
|
1092
1093
|
- lib/klaviyo-api-sdk/models/sms_tracking_options_sub_object.rb
|
1094
|
+
- lib/klaviyo-api-sdk/models/sms_unsubscription_parameters.rb
|
1093
1095
|
- lib/klaviyo-api-sdk/models/spam_complaint_enum.rb
|
1094
1096
|
- lib/klaviyo-api-sdk/models/spam_complaint_method_filter.rb
|
1095
1097
|
- lib/klaviyo-api-sdk/models/static_date_filter.rb
|
@@ -1202,6 +1204,8 @@ files:
|
|
1202
1204
|
- lib/klaviyo-api-sdk/models/universal_content_partial_update_query_resource_object_attributes.rb
|
1203
1205
|
- lib/klaviyo-api-sdk/models/universal_content_partial_update_query_resource_object_attributes_definition.rb
|
1204
1206
|
- lib/klaviyo-api-sdk/models/unsubscribed_enum.rb
|
1207
|
+
- lib/klaviyo-api-sdk/models/unsubscription_channels.rb
|
1208
|
+
- lib/klaviyo-api-sdk/models/unsubscription_parameters.rb
|
1205
1209
|
- lib/klaviyo-api-sdk/models/webhook_create_query.rb
|
1206
1210
|
- lib/klaviyo-api-sdk/models/webhook_create_query_resource_object.rb
|
1207
1211
|
- lib/klaviyo-api-sdk/models/webhook_create_query_resource_object_attributes.rb
|