klaviyo_sdk 1.0.0.20220329
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +6 -0
- data/README.md +1121 -0
- data/klaviyo_sdk.gemspec +35 -0
- data/lib/klaviyo_sdk/api/campaigns_api.rb +717 -0
- data/lib/klaviyo_sdk/api/data_privacy_api.rb +86 -0
- data/lib/klaviyo_sdk/api/lists_segments_api.rb +1101 -0
- data/lib/klaviyo_sdk/api/metrics_api.rb +343 -0
- data/lib/klaviyo_sdk/api/profiles_api.rb +381 -0
- data/lib/klaviyo_sdk/api/templates_api.rb +555 -0
- data/lib/klaviyo_sdk/api/track_identify_api.rb +288 -0
- data/lib/klaviyo_sdk/api_client.rb +389 -0
- data/lib/klaviyo_sdk/api_error.rb +57 -0
- data/lib/klaviyo_sdk/configuration.rb +278 -0
- data/lib/klaviyo_sdk/models/campaign.rb +310 -0
- data/lib/klaviyo_sdk/models/check_membership_request.rb +244 -0
- data/lib/klaviyo_sdk/models/delete_email.rb +218 -0
- data/lib/klaviyo_sdk/models/delete_person.rb +218 -0
- data/lib/klaviyo_sdk/models/delete_phone.rb +219 -0
- data/lib/klaviyo_sdk/models/deprecated_get_list_response.rb +298 -0
- data/lib/klaviyo_sdk/models/deprecated_get_list_response_data.rb +263 -0
- data/lib/klaviyo_sdk/models/global_exclusion_response_data.rb +274 -0
- data/lib/klaviyo_sdk/models/identify_payload.rb +237 -0
- data/lib/klaviyo_sdk/models/identify_payload_properties.rb +327 -0
- data/lib/klaviyo_sdk/models/inline_object.rb +220 -0
- data/lib/klaviyo_sdk/models/inline_object3.rb +226 -0
- data/lib/klaviyo_sdk/models/inline_object4.rb +254 -0
- data/lib/klaviyo_sdk/models/inline_object5.rb +288 -0
- data/lib/klaviyo_sdk/models/metric.rb +265 -0
- data/lib/klaviyo_sdk/models/metric_export.rb +285 -0
- data/lib/klaviyo_sdk/models/metric_timeline.rb +271 -0
- data/lib/klaviyo_sdk/models/metric_timeline_data.rb +294 -0
- data/lib/klaviyo_sdk/models/person.rb +389 -0
- data/lib/klaviyo_sdk/models/person.rb.bak +389 -0
- data/lib/klaviyo_sdk/models/privacy_email.rb +218 -0
- data/lib/klaviyo_sdk/models/privacy_id.rb +218 -0
- data/lib/klaviyo_sdk/models/privacy_phone.rb +218 -0
- data/lib/klaviyo_sdk/models/rendered_template.rb +247 -0
- data/lib/klaviyo_sdk/models/template.rb +272 -0
- data/lib/klaviyo_sdk/models/track_payload.rb +261 -0
- data/lib/klaviyo_sdk/models/track_payload_customer_properties.rb +227 -0
- data/lib/klaviyo_sdk/models/track_payload_properties.rb +237 -0
- data/lib/klaviyo_sdk/version.rb +15 -0
- data/lib/klaviyo_sdk.rb +124 -0
- metadata +120 -0
@@ -0,0 +1,227 @@
|
|
1
|
+
=begin
|
2
|
+
#Klaviyo API
|
3
|
+
|
4
|
+
#Empowering creators to own their destiny
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2022.03.29
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Client
|
17
|
+
class TrackPayloadCustomerProperties
|
18
|
+
attr_accessor :_email
|
19
|
+
|
20
|
+
attr_accessor :_phone_number
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'_email' => :'_$email',
|
26
|
+
:'_phone_number' => :'_$phone_number'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'_email' => :'String',
|
39
|
+
:'_phone_number' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Client::TrackPayloadCustomerProperties` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Client::TrackPayloadCustomerProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'_email')
|
65
|
+
self._email = attributes[:'_email']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'_phone_number')
|
69
|
+
self._phone_number = attributes[:'_phone_number']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
true
|
84
|
+
end
|
85
|
+
|
86
|
+
# Checks equality by comparing each attribute.
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def ==(o)
|
89
|
+
return true if self.equal?(o)
|
90
|
+
self.class == o.class &&
|
91
|
+
_email == o._email &&
|
92
|
+
_phone_number == o._phone_number
|
93
|
+
end
|
94
|
+
|
95
|
+
# @see the `==` method
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def eql?(o)
|
98
|
+
self == o
|
99
|
+
end
|
100
|
+
|
101
|
+
# Calculates hash code according to all attributes.
|
102
|
+
# @return [Integer] Hash code
|
103
|
+
def hash
|
104
|
+
[_email, _phone_number].hash
|
105
|
+
end
|
106
|
+
|
107
|
+
# Builds the object from hash
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
+
# @return [Object] Returns the model itself
|
110
|
+
def self.build_from_hash(attributes)
|
111
|
+
new.build_from_hash(attributes)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Builds the object from hash
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
116
|
+
# @return [Object] Returns the model itself
|
117
|
+
def build_from_hash(attributes)
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
119
|
+
self.class.openapi_types.each_pair do |key, type|
|
120
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
121
|
+
self.send("#{key}=", nil)
|
122
|
+
elsif type =~ /\AArray<(.*)>/i
|
123
|
+
# check to ensure the input is an array given that the attribute
|
124
|
+
# is documented as an array but the input is not
|
125
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
126
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
127
|
+
end
|
128
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
129
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# Deserializes the data based on type
|
137
|
+
# @param string type Data type
|
138
|
+
# @param string value Value to be deserialized
|
139
|
+
# @return [Object] Deserialized data
|
140
|
+
def _deserialize(type, value)
|
141
|
+
case type.to_sym
|
142
|
+
when :Time
|
143
|
+
Time.parse(value)
|
144
|
+
when :Date
|
145
|
+
Date.parse(value)
|
146
|
+
when :String
|
147
|
+
value.to_s
|
148
|
+
when :Integer
|
149
|
+
value.to_i
|
150
|
+
when :Float
|
151
|
+
value.to_f
|
152
|
+
when :Boolean
|
153
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
154
|
+
true
|
155
|
+
else
|
156
|
+
false
|
157
|
+
end
|
158
|
+
when :Object
|
159
|
+
# generic object (usually a Hash), return directly
|
160
|
+
value
|
161
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
162
|
+
inner_type = Regexp.last_match[:inner_type]
|
163
|
+
value.map { |v| _deserialize(inner_type, v) }
|
164
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
165
|
+
k_type = Regexp.last_match[:k_type]
|
166
|
+
v_type = Regexp.last_match[:v_type]
|
167
|
+
{}.tap do |hash|
|
168
|
+
value.each do |k, v|
|
169
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
else # model
|
173
|
+
# models (e.g. Pet) or oneOf
|
174
|
+
klass = Client.const_get(type)
|
175
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the string representation of the object
|
180
|
+
# @return [String] String presentation of the object
|
181
|
+
def to_s
|
182
|
+
to_hash.to_s
|
183
|
+
end
|
184
|
+
|
185
|
+
# to_body is an alias to to_hash (backward compatibility)
|
186
|
+
# @return [Hash] Returns the object in the form of hash
|
187
|
+
def to_body
|
188
|
+
to_hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the object in the form of hash
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_hash
|
194
|
+
hash = {}
|
195
|
+
self.class.attribute_map.each_pair do |attr, param|
|
196
|
+
value = self.send(attr)
|
197
|
+
if value.nil?
|
198
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
199
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
200
|
+
end
|
201
|
+
|
202
|
+
hash[param] = _to_hash(value)
|
203
|
+
end
|
204
|
+
hash
|
205
|
+
end
|
206
|
+
|
207
|
+
# Outputs non-array value in the form of hash
|
208
|
+
# For object, use to_hash. Otherwise, just return the value
|
209
|
+
# @param [Object] value Any valid value
|
210
|
+
# @return [Hash] Returns the value in the form of hash
|
211
|
+
def _to_hash(value)
|
212
|
+
if value.is_a?(Array)
|
213
|
+
value.compact.map { |v| _to_hash(v) }
|
214
|
+
elsif value.is_a?(Hash)
|
215
|
+
{}.tap do |hash|
|
216
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
217
|
+
end
|
218
|
+
elsif value.respond_to? :to_hash
|
219
|
+
value.to_hash
|
220
|
+
else
|
221
|
+
value
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
=begin
|
2
|
+
#Klaviyo API
|
3
|
+
|
4
|
+
#Empowering creators to own their destiny
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2022.03.29
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Client
|
17
|
+
class TrackPayloadProperties
|
18
|
+
attr_accessor :event_id
|
19
|
+
|
20
|
+
attr_accessor :value
|
21
|
+
|
22
|
+
attr_accessor :your_custom_field
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'event_id' => :'$event_id',
|
28
|
+
:'value' => :'$value',
|
29
|
+
:'your_custom_field' => :'YOUR_CUSTOM_FIELD'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'event_id' => :'String',
|
42
|
+
:'value' => :'String',
|
43
|
+
:'your_custom_field' => :'OneOfstringintegernumberbooleanarray'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# List of attributes with nullable: true
|
48
|
+
def self.openapi_nullable
|
49
|
+
Set.new([
|
50
|
+
:'your_custom_field'
|
51
|
+
])
|
52
|
+
end
|
53
|
+
|
54
|
+
# Initializes the object
|
55
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
56
|
+
def initialize(attributes = {})
|
57
|
+
if (!attributes.is_a?(Hash))
|
58
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Client::TrackPayloadProperties` initialize method"
|
59
|
+
end
|
60
|
+
|
61
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
62
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
63
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
64
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Client::TrackPayloadProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
65
|
+
end
|
66
|
+
h[k.to_sym] = v
|
67
|
+
}
|
68
|
+
|
69
|
+
if attributes.key?(:'event_id')
|
70
|
+
self.event_id = attributes[:'event_id']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.key?(:'value')
|
74
|
+
self.value = attributes[:'value']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:'your_custom_field')
|
78
|
+
self.your_custom_field = attributes[:'your_custom_field']
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
83
|
+
# @return Array for valid properties with the reasons
|
84
|
+
def list_invalid_properties
|
85
|
+
invalid_properties = Array.new
|
86
|
+
invalid_properties
|
87
|
+
end
|
88
|
+
|
89
|
+
# Check to see if the all the properties in the model are valid
|
90
|
+
# @return true if the model is valid
|
91
|
+
def valid?
|
92
|
+
true
|
93
|
+
end
|
94
|
+
|
95
|
+
# Checks equality by comparing each attribute.
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def ==(o)
|
98
|
+
return true if self.equal?(o)
|
99
|
+
self.class == o.class &&
|
100
|
+
event_id == o.event_id &&
|
101
|
+
value == o.value &&
|
102
|
+
your_custom_field == o.your_custom_field
|
103
|
+
end
|
104
|
+
|
105
|
+
# @see the `==` method
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def eql?(o)
|
108
|
+
self == o
|
109
|
+
end
|
110
|
+
|
111
|
+
# Calculates hash code according to all attributes.
|
112
|
+
# @return [Integer] Hash code
|
113
|
+
def hash
|
114
|
+
[event_id, value, your_custom_field].hash
|
115
|
+
end
|
116
|
+
|
117
|
+
# Builds the object from hash
|
118
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
119
|
+
# @return [Object] Returns the model itself
|
120
|
+
def self.build_from_hash(attributes)
|
121
|
+
new.build_from_hash(attributes)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def build_from_hash(attributes)
|
128
|
+
return nil unless attributes.is_a?(Hash)
|
129
|
+
self.class.openapi_types.each_pair do |key, type|
|
130
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
131
|
+
self.send("#{key}=", nil)
|
132
|
+
elsif type =~ /\AArray<(.*)>/i
|
133
|
+
# check to ensure the input is an array given that the attribute
|
134
|
+
# is documented as an array but the input is not
|
135
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
136
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
137
|
+
end
|
138
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
139
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
# Deserializes the data based on type
|
147
|
+
# @param string type Data type
|
148
|
+
# @param string value Value to be deserialized
|
149
|
+
# @return [Object] Deserialized data
|
150
|
+
def _deserialize(type, value)
|
151
|
+
case type.to_sym
|
152
|
+
when :Time
|
153
|
+
Time.parse(value)
|
154
|
+
when :Date
|
155
|
+
Date.parse(value)
|
156
|
+
when :String
|
157
|
+
value.to_s
|
158
|
+
when :Integer
|
159
|
+
value.to_i
|
160
|
+
when :Float
|
161
|
+
value.to_f
|
162
|
+
when :Boolean
|
163
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
164
|
+
true
|
165
|
+
else
|
166
|
+
false
|
167
|
+
end
|
168
|
+
when :Object
|
169
|
+
# generic object (usually a Hash), return directly
|
170
|
+
value
|
171
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
172
|
+
inner_type = Regexp.last_match[:inner_type]
|
173
|
+
value.map { |v| _deserialize(inner_type, v) }
|
174
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
175
|
+
k_type = Regexp.last_match[:k_type]
|
176
|
+
v_type = Regexp.last_match[:v_type]
|
177
|
+
{}.tap do |hash|
|
178
|
+
value.each do |k, v|
|
179
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
else # model
|
183
|
+
# models (e.g. Pet) or oneOf
|
184
|
+
klass = Client.const_get(type)
|
185
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns the string representation of the object
|
190
|
+
# @return [String] String presentation of the object
|
191
|
+
def to_s
|
192
|
+
to_hash.to_s
|
193
|
+
end
|
194
|
+
|
195
|
+
# to_body is an alias to to_hash (backward compatibility)
|
196
|
+
# @return [Hash] Returns the object in the form of hash
|
197
|
+
def to_body
|
198
|
+
to_hash
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the object in the form of hash
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
203
|
+
def to_hash
|
204
|
+
hash = {}
|
205
|
+
self.class.attribute_map.each_pair do |attr, param|
|
206
|
+
value = self.send(attr)
|
207
|
+
if value.nil?
|
208
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
209
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
210
|
+
end
|
211
|
+
|
212
|
+
hash[param] = _to_hash(value)
|
213
|
+
end
|
214
|
+
hash
|
215
|
+
end
|
216
|
+
|
217
|
+
# Outputs non-array value in the form of hash
|
218
|
+
# For object, use to_hash. Otherwise, just return the value
|
219
|
+
# @param [Object] value Any valid value
|
220
|
+
# @return [Hash] Returns the value in the form of hash
|
221
|
+
def _to_hash(value)
|
222
|
+
if value.is_a?(Array)
|
223
|
+
value.compact.map { |v| _to_hash(v) }
|
224
|
+
elsif value.is_a?(Hash)
|
225
|
+
{}.tap do |hash|
|
226
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
227
|
+
end
|
228
|
+
elsif value.respond_to? :to_hash
|
229
|
+
value.to_hash
|
230
|
+
else
|
231
|
+
value
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
=begin
|
2
|
+
#Klaviyo API
|
3
|
+
|
4
|
+
#Empowering creators to own their destiny
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2022.03.29
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module Client
|
14
|
+
VERSION = '1.0.0'
|
15
|
+
end
|
data/lib/klaviyo_sdk.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
=begin
|
2
|
+
#Klaviyo API
|
3
|
+
|
4
|
+
#Empowering creators to own their destiny
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2022.03.29
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# Common files
|
14
|
+
require 'klaviyo_sdk/api_client'
|
15
|
+
require 'klaviyo_sdk/api_error'
|
16
|
+
require 'klaviyo_sdk/version'
|
17
|
+
require 'klaviyo_sdk/configuration'
|
18
|
+
|
19
|
+
# Models
|
20
|
+
require 'klaviyo_sdk/models/campaign'
|
21
|
+
require 'klaviyo_sdk/models/check_membership_request'
|
22
|
+
require 'klaviyo_sdk/models/delete_email'
|
23
|
+
require 'klaviyo_sdk/models/delete_person'
|
24
|
+
require 'klaviyo_sdk/models/delete_phone'
|
25
|
+
require 'klaviyo_sdk/models/deprecated_get_list_response'
|
26
|
+
require 'klaviyo_sdk/models/deprecated_get_list_response_data'
|
27
|
+
require 'klaviyo_sdk/models/global_exclusion_response_data'
|
28
|
+
require 'klaviyo_sdk/models/identify_payload'
|
29
|
+
require 'klaviyo_sdk/models/identify_payload_properties'
|
30
|
+
require 'klaviyo_sdk/models/inline_object'
|
31
|
+
require 'klaviyo_sdk/models/inline_object3'
|
32
|
+
require 'klaviyo_sdk/models/inline_object4'
|
33
|
+
require 'klaviyo_sdk/models/inline_object5'
|
34
|
+
require 'klaviyo_sdk/models/metric'
|
35
|
+
require 'klaviyo_sdk/models/metric_export'
|
36
|
+
require 'klaviyo_sdk/models/metric_timeline'
|
37
|
+
require 'klaviyo_sdk/models/metric_timeline_data'
|
38
|
+
require 'klaviyo_sdk/models/person'
|
39
|
+
require 'klaviyo_sdk/models/privacy_email'
|
40
|
+
require 'klaviyo_sdk/models/privacy_id'
|
41
|
+
require 'klaviyo_sdk/models/privacy_phone'
|
42
|
+
require 'klaviyo_sdk/models/rendered_template'
|
43
|
+
require 'klaviyo_sdk/models/template'
|
44
|
+
require 'klaviyo_sdk/models/track_payload'
|
45
|
+
require 'klaviyo_sdk/models/track_payload_customer_properties'
|
46
|
+
require 'klaviyo_sdk/models/track_payload_properties'
|
47
|
+
|
48
|
+
# APIs
|
49
|
+
require 'klaviyo_sdk/api/campaigns_api'
|
50
|
+
require 'klaviyo_sdk/api/data_privacy_api'
|
51
|
+
require 'klaviyo_sdk/api/lists_segments_api'
|
52
|
+
require 'klaviyo_sdk/api/metrics_api'
|
53
|
+
require 'klaviyo_sdk/api/profiles_api'
|
54
|
+
require 'klaviyo_sdk/api/templates_api'
|
55
|
+
require 'klaviyo_sdk/api/track_identify_api'
|
56
|
+
|
57
|
+
# retry logic
|
58
|
+
require 'retriable'
|
59
|
+
|
60
|
+
module Client
|
61
|
+
@is_initialized = false
|
62
|
+
|
63
|
+
class << self
|
64
|
+
# Customize default settings for the SDK using block.
|
65
|
+
# Client.configure do |config|
|
66
|
+
# config.username = "xxx"
|
67
|
+
# config.password = "xxx"
|
68
|
+
# end
|
69
|
+
# If no block given, return the default Configuration object.
|
70
|
+
|
71
|
+
|
72
|
+
# add retriable config
|
73
|
+
# todo: check how slow this is
|
74
|
+
Configuration.default.class.module_eval { attr_accessor :max_retries, :max_delay }
|
75
|
+
|
76
|
+
def configure
|
77
|
+
if block_given?
|
78
|
+
yield(Configuration.default)
|
79
|
+
else
|
80
|
+
Configuration.default
|
81
|
+
end
|
82
|
+
|
83
|
+
# create wrapper classes
|
84
|
+
if !@is_initialized # run this only once
|
85
|
+
self.constants.each do |c|
|
86
|
+
if c[-3..-1] == "Api"
|
87
|
+
attributes = [:attr1]
|
88
|
+
wrapper_class = Client.const_set(c[0..-4], Struct.new(*attributes))
|
89
|
+
original_class = Client.const_get(c)
|
90
|
+
|
91
|
+
# recreate methods
|
92
|
+
original_class.public_instance_methods(false).each do |m|
|
93
|
+
wrapper_class.class_eval {
|
94
|
+
define_singleton_method m do |*arg|
|
95
|
+
# max_delay=60, max_retries=3
|
96
|
+
# retry_codes = [429,503,504]
|
97
|
+
# only add retriable if both of these are not set
|
98
|
+
max_retries = Configuration.default.max_retries
|
99
|
+
max_delay = Configuration.default.max_delay
|
100
|
+
|
101
|
+
if (max_retries != nil && max_delay != nil)
|
102
|
+
Retriable.configure do |c|
|
103
|
+
c.tries = max_retries
|
104
|
+
c.max_elapsed_time = max_delay
|
105
|
+
c.on = {
|
106
|
+
Client::ApiError => [/400/, /503/, /504/]
|
107
|
+
}
|
108
|
+
end
|
109
|
+
Retriable.retriable do
|
110
|
+
Client.const_get(c).new.send(m, *arg)
|
111
|
+
end
|
112
|
+
else
|
113
|
+
Client.const_get(c).new.send(m, *arg)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
@is_initialized = true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|