klaviyo_sdk 1.0.0.20220329

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1121 -0
  4. data/klaviyo_sdk.gemspec +35 -0
  5. data/lib/klaviyo_sdk/api/campaigns_api.rb +717 -0
  6. data/lib/klaviyo_sdk/api/data_privacy_api.rb +86 -0
  7. data/lib/klaviyo_sdk/api/lists_segments_api.rb +1101 -0
  8. data/lib/klaviyo_sdk/api/metrics_api.rb +343 -0
  9. data/lib/klaviyo_sdk/api/profiles_api.rb +381 -0
  10. data/lib/klaviyo_sdk/api/templates_api.rb +555 -0
  11. data/lib/klaviyo_sdk/api/track_identify_api.rb +288 -0
  12. data/lib/klaviyo_sdk/api_client.rb +389 -0
  13. data/lib/klaviyo_sdk/api_error.rb +57 -0
  14. data/lib/klaviyo_sdk/configuration.rb +278 -0
  15. data/lib/klaviyo_sdk/models/campaign.rb +310 -0
  16. data/lib/klaviyo_sdk/models/check_membership_request.rb +244 -0
  17. data/lib/klaviyo_sdk/models/delete_email.rb +218 -0
  18. data/lib/klaviyo_sdk/models/delete_person.rb +218 -0
  19. data/lib/klaviyo_sdk/models/delete_phone.rb +219 -0
  20. data/lib/klaviyo_sdk/models/deprecated_get_list_response.rb +298 -0
  21. data/lib/klaviyo_sdk/models/deprecated_get_list_response_data.rb +263 -0
  22. data/lib/klaviyo_sdk/models/global_exclusion_response_data.rb +274 -0
  23. data/lib/klaviyo_sdk/models/identify_payload.rb +237 -0
  24. data/lib/klaviyo_sdk/models/identify_payload_properties.rb +327 -0
  25. data/lib/klaviyo_sdk/models/inline_object.rb +220 -0
  26. data/lib/klaviyo_sdk/models/inline_object3.rb +226 -0
  27. data/lib/klaviyo_sdk/models/inline_object4.rb +254 -0
  28. data/lib/klaviyo_sdk/models/inline_object5.rb +288 -0
  29. data/lib/klaviyo_sdk/models/metric.rb +265 -0
  30. data/lib/klaviyo_sdk/models/metric_export.rb +285 -0
  31. data/lib/klaviyo_sdk/models/metric_timeline.rb +271 -0
  32. data/lib/klaviyo_sdk/models/metric_timeline_data.rb +294 -0
  33. data/lib/klaviyo_sdk/models/person.rb +389 -0
  34. data/lib/klaviyo_sdk/models/person.rb.bak +389 -0
  35. data/lib/klaviyo_sdk/models/privacy_email.rb +218 -0
  36. data/lib/klaviyo_sdk/models/privacy_id.rb +218 -0
  37. data/lib/klaviyo_sdk/models/privacy_phone.rb +218 -0
  38. data/lib/klaviyo_sdk/models/rendered_template.rb +247 -0
  39. data/lib/klaviyo_sdk/models/template.rb +272 -0
  40. data/lib/klaviyo_sdk/models/track_payload.rb +261 -0
  41. data/lib/klaviyo_sdk/models/track_payload_customer_properties.rb +227 -0
  42. data/lib/klaviyo_sdk/models/track_payload_properties.rb +237 -0
  43. data/lib/klaviyo_sdk/version.rb +15 -0
  44. data/lib/klaviyo_sdk.rb +124 -0
  45. metadata +120 -0
@@ -0,0 +1,278 @@
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
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
+ # details will be logged with `logger.debug` (see the `logger` attribute).
67
+ # Default to false.
68
+ #
69
+ # @return [true, false]
70
+ attr_accessor :debugging
71
+
72
+ # Defines the logger used for debugging.
73
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
74
+ #
75
+ # @return [#debug]
76
+ attr_accessor :logger
77
+
78
+ # Defines the temporary folder to store downloaded files
79
+ # (for API endpoints that have file response).
80
+ # Default to use `Tempfile`.
81
+ #
82
+ # @return [String]
83
+ attr_accessor :temp_folder_path
84
+
85
+ # The time limit for HTTP request in seconds.
86
+ # Default to 0 (never times out).
87
+ attr_accessor :timeout
88
+
89
+ # Set this to false to skip client side validation in the operation.
90
+ # Default to true.
91
+ # @return [true, false]
92
+ attr_accessor :client_side_validation
93
+
94
+ ### TLS/SSL setting
95
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
96
+ # Default to true.
97
+ #
98
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
99
+ #
100
+ # @return [true, false]
101
+ attr_accessor :verify_ssl
102
+
103
+ ### TLS/SSL setting
104
+ # Set this to false to skip verifying SSL host name
105
+ # Default to true.
106
+ #
107
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
108
+ #
109
+ # @return [true, false]
110
+ attr_accessor :verify_ssl_host
111
+
112
+ ### TLS/SSL setting
113
+ # Set this to customize the certificate file to verify the peer.
114
+ #
115
+ # @return [String] the path to the certificate file
116
+ #
117
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
118
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
119
+ attr_accessor :ssl_ca_cert
120
+
121
+ ### TLS/SSL setting
122
+ # Client certificate file (for client certificate)
123
+ attr_accessor :cert_file
124
+
125
+ ### TLS/SSL setting
126
+ # Client private key file (for client certificate)
127
+ attr_accessor :key_file
128
+
129
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
130
+ # Default to nil.
131
+ #
132
+ # @see The params_encoding option of Ethon. Related source code:
133
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
134
+ attr_accessor :params_encoding
135
+
136
+ attr_accessor :inject_format
137
+
138
+ attr_accessor :force_ending_format
139
+
140
+ def initialize
141
+ @scheme = 'https'
142
+ @host = 'a.klaviyo.com'
143
+ @base_path = '/api'
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
148
+ @api_key = {}
149
+ @api_key_prefix = {}
150
+ @client_side_validation = true
151
+ @verify_ssl = true
152
+ @verify_ssl_host = true
153
+ @params_encoding = nil
154
+ @cert_file = nil
155
+ @key_file = nil
156
+ @timeout = 0
157
+ @debugging = false
158
+ @inject_format = false
159
+ @force_ending_format = false
160
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
161
+
162
+ yield(self) if block_given?
163
+ end
164
+
165
+ # The default Configuration object.
166
+ def self.default
167
+ @@default ||= Configuration.new
168
+ end
169
+
170
+ def configure
171
+ yield(self) if block_given?
172
+ end
173
+
174
+ def scheme=(scheme)
175
+ # remove :// from scheme
176
+ @scheme = scheme.sub(/:\/\//, '')
177
+ end
178
+
179
+ def host=(host)
180
+ # remove http(s):// and anything after a slash
181
+ @host = host.sub(/https?:\/\//, '').split('/').first
182
+ end
183
+
184
+ def base_path=(base_path)
185
+ # Add leading and trailing slashes to base_path
186
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
187
+ @base_path = '' if @base_path == '/'
188
+ end
189
+
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
196
+ end
197
+
198
+ # Gets API key (with prefix if set).
199
+ # @param [String] param_name the parameter name of API key auth
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
203
+ if @api_key_prefix[param_name]
204
+ "#{@api_key_prefix[param_name]} #{key}"
205
+ else
206
+ key
207
+ end
208
+ end
209
+
210
+ # Gets Basic Auth token string
211
+ def basic_auth_token
212
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
213
+ end
214
+
215
+ # Returns Auth Settings hash for api client.
216
+ def auth_settings
217
+ {
218
+ 'ApiKeyAuth' =>
219
+ {
220
+ type: 'api_key',
221
+ in: 'query',
222
+ key: 'api_key',
223
+ value: api_key_with_prefix('ApiKeyAuth')
224
+ },
225
+ }
226
+ end
227
+
228
+ # Returns an array of Server setting
229
+ def server_settings
230
+ [
231
+ {
232
+ url: "https://a.klaviyo.com/api",
233
+ description: "Production",
234
+ }
235
+ ]
236
+ end
237
+
238
+ def operation_server_settings
239
+ {
240
+ }
241
+ end
242
+
243
+ # Returns URL based on server settings
244
+ #
245
+ # @param index array index of the server settings
246
+ # @param variables hash of variable and the corresponding value
247
+ def server_url(index, variables = {}, servers = nil)
248
+ servers = server_settings if servers == nil
249
+
250
+ # check array index out of bound
251
+ if (index < 0 || index >= servers.size)
252
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
253
+ end
254
+
255
+ server = servers[index]
256
+ url = server[:url]
257
+
258
+ return url unless server.key? :variables
259
+
260
+ # go through variable and assign a value
261
+ server[:variables].each do |name, variable|
262
+ if variables.key?(name)
263
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
264
+ url.gsub! "{" + name.to_s + "}", variables[name]
265
+ else
266
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
267
+ end
268
+ else
269
+ # use default value
270
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
271
+ end
272
+ end
273
+
274
+ url
275
+ end
276
+
277
+ end
278
+ end
@@ -0,0 +1,310 @@
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 Campaign
18
+ attr_accessor :object
19
+
20
+ attr_accessor :id
21
+
22
+ attr_accessor :name
23
+
24
+ attr_accessor :subject
25
+
26
+ attr_accessor :from_email
27
+
28
+ attr_accessor :from_name
29
+
30
+ attr_accessor :list_id
31
+
32
+ attr_accessor :template
33
+
34
+ attr_accessor :status
35
+
36
+ attr_accessor :sent_at
37
+
38
+ attr_accessor :created
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'object' => :'object',
44
+ :'id' => :'id',
45
+ :'name' => :'name',
46
+ :'subject' => :'subject',
47
+ :'from_email' => :'from_email',
48
+ :'from_name' => :'from_name',
49
+ :'list_id' => :'list_id',
50
+ :'template' => :'template',
51
+ :'status' => :'status',
52
+ :'sent_at' => :'sent_at',
53
+ :'created' => :'created'
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'object' => :'String',
66
+ :'id' => :'String',
67
+ :'name' => :'String',
68
+ :'subject' => :'String',
69
+ :'from_email' => :'String',
70
+ :'from_name' => :'String',
71
+ :'list_id' => :'String',
72
+ :'template' => :'Hash<String, Object>',
73
+ :'status' => :'String',
74
+ :'sent_at' => :'String',
75
+ :'created' => :'String'
76
+ }
77
+ end
78
+
79
+ # List of attributes with nullable: true
80
+ def self.openapi_nullable
81
+ Set.new([
82
+ ])
83
+ end
84
+
85
+ # Initializes the object
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ def initialize(attributes = {})
88
+ if (!attributes.is_a?(Hash))
89
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Client::Campaign` initialize method"
90
+ end
91
+
92
+ # check to see if the attribute exists and convert string to symbol for hash key
93
+ attributes = attributes.each_with_object({}) { |(k, v), h|
94
+ if (!self.class.attribute_map.key?(k.to_sym))
95
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Client::Campaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
96
+ end
97
+ h[k.to_sym] = v
98
+ }
99
+
100
+ if attributes.key?(:'object')
101
+ self.object = attributes[:'object']
102
+ end
103
+
104
+ if attributes.key?(:'id')
105
+ self.id = attributes[:'id']
106
+ end
107
+
108
+ if attributes.key?(:'name')
109
+ self.name = attributes[:'name']
110
+ end
111
+
112
+ if attributes.key?(:'subject')
113
+ self.subject = attributes[:'subject']
114
+ end
115
+
116
+ if attributes.key?(:'from_email')
117
+ self.from_email = attributes[:'from_email']
118
+ end
119
+
120
+ if attributes.key?(:'from_name')
121
+ self.from_name = attributes[:'from_name']
122
+ end
123
+
124
+ if attributes.key?(:'list_id')
125
+ self.list_id = attributes[:'list_id']
126
+ end
127
+
128
+ if attributes.key?(:'template')
129
+ if (value = attributes[:'template']).is_a?(Hash)
130
+ self.template = value
131
+ end
132
+ end
133
+
134
+ if attributes.key?(:'status')
135
+ self.status = attributes[:'status']
136
+ end
137
+
138
+ if attributes.key?(:'sent_at')
139
+ self.sent_at = attributes[:'sent_at']
140
+ end
141
+
142
+ if attributes.key?(:'created')
143
+ self.created = attributes[:'created']
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
151
+ invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ true
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ object == o.object &&
166
+ id == o.id &&
167
+ name == o.name &&
168
+ subject == o.subject &&
169
+ from_email == o.from_email &&
170
+ from_name == o.from_name &&
171
+ list_id == o.list_id &&
172
+ template == o.template &&
173
+ status == o.status &&
174
+ sent_at == o.sent_at &&
175
+ created == o.created
176
+ end
177
+
178
+ # @see the `==` method
179
+ # @param [Object] Object to be compared
180
+ def eql?(o)
181
+ self == o
182
+ end
183
+
184
+ # Calculates hash code according to all attributes.
185
+ # @return [Integer] Hash code
186
+ def hash
187
+ [object, id, name, subject, from_email, from_name, list_id, template, status, sent_at, created].hash
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def self.build_from_hash(attributes)
194
+ new.build_from_hash(attributes)
195
+ end
196
+
197
+ # Builds the object from hash
198
+ # @param [Hash] attributes Model attributes in the form of hash
199
+ # @return [Object] Returns the model itself
200
+ def build_from_hash(attributes)
201
+ return nil unless attributes.is_a?(Hash)
202
+ self.class.openapi_types.each_pair do |key, type|
203
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
204
+ self.send("#{key}=", nil)
205
+ elsif type =~ /\AArray<(.*)>/i
206
+ # check to ensure the input is an array given that the attribute
207
+ # is documented as an array but the input is not
208
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
209
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
210
+ end
211
+ elsif !attributes[self.class.attribute_map[key]].nil?
212
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
213
+ end
214
+ end
215
+
216
+ self
217
+ end
218
+
219
+ # Deserializes the data based on type
220
+ # @param string type Data type
221
+ # @param string value Value to be deserialized
222
+ # @return [Object] Deserialized data
223
+ def _deserialize(type, value)
224
+ case type.to_sym
225
+ when :Time
226
+ Time.parse(value)
227
+ when :Date
228
+ Date.parse(value)
229
+ when :String
230
+ value.to_s
231
+ when :Integer
232
+ value.to_i
233
+ when :Float
234
+ value.to_f
235
+ when :Boolean
236
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
237
+ true
238
+ else
239
+ false
240
+ end
241
+ when :Object
242
+ # generic object (usually a Hash), return directly
243
+ value
244
+ when /\AArray<(?<inner_type>.+)>\z/
245
+ inner_type = Regexp.last_match[:inner_type]
246
+ value.map { |v| _deserialize(inner_type, v) }
247
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
248
+ k_type = Regexp.last_match[:k_type]
249
+ v_type = Regexp.last_match[:v_type]
250
+ {}.tap do |hash|
251
+ value.each do |k, v|
252
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
253
+ end
254
+ end
255
+ else # model
256
+ # models (e.g. Pet) or oneOf
257
+ klass = Client.const_get(type)
258
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
259
+ end
260
+ end
261
+
262
+ # Returns the string representation of the object
263
+ # @return [String] String presentation of the object
264
+ def to_s
265
+ to_hash.to_s
266
+ end
267
+
268
+ # to_body is an alias to to_hash (backward compatibility)
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_body
271
+ to_hash
272
+ end
273
+
274
+ # Returns the object in the form of hash
275
+ # @return [Hash] Returns the object in the form of hash
276
+ def to_hash
277
+ hash = {}
278
+ self.class.attribute_map.each_pair do |attr, param|
279
+ value = self.send(attr)
280
+ if value.nil?
281
+ is_nullable = self.class.openapi_nullable.include?(attr)
282
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
283
+ end
284
+
285
+ hash[param] = _to_hash(value)
286
+ end
287
+ hash
288
+ end
289
+
290
+ # Outputs non-array value in the form of hash
291
+ # For object, use to_hash. Otherwise, just return the value
292
+ # @param [Object] value Any valid value
293
+ # @return [Hash] Returns the value in the form of hash
294
+ def _to_hash(value)
295
+ if value.is_a?(Array)
296
+ value.compact.map { |v| _to_hash(v) }
297
+ elsif value.is_a?(Hash)
298
+ {}.tap do |hash|
299
+ value.each { |k, v| hash[k] = _to_hash(v) }
300
+ end
301
+ elsif value.respond_to? :to_hash
302
+ value.to_hash
303
+ else
304
+ value
305
+ end
306
+ end
307
+
308
+ end
309
+
310
+ end