klaviyo-api-sdk 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +3 -3
- data/klaviyo-api-sdk.gemspec +1 -1
- data/lib/klaviyo-api-sdk/api_client.rb +22 -1
- data/test.rb +50 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6d69c30e7ef51bcaf0cf14baa93eeb17151088e851e90534f1a987deda6078f
|
4
|
+
data.tar.gz: 31f9ffc768a778fba13c9b0619dc1257311f287dcdff61af47444d32dcebc41e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f1f8ce2bbe0b436b7f97cd7bcea5f0e79ce959c6172ae87c47f83ef360817e386efaa9559462c26c5b7ff183d1362744a41a054767fa8c8d6c4374ca099c2e6
|
7
|
+
data.tar.gz: 5edad8110899a5f21ac4f2da43698a549693feb8ea33a92a204cf30d59529c2c5f6e338c11e5eeb3f825ba0c569eb2262e8593682c7396fe11e1031be8ee3e45
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.0.1] - 2022-12-06
|
8
|
+
### Changes
|
9
|
+
- Support for cursor pagination
|
10
|
+
- Passing the `next` value from a paginated result to the following call via the `page_cursor` query string argument will now result in the cursor being parsed and set appropriately by the `ApiClient`.
|
11
|
+
|
7
12
|
## [1.0.0] - 2022-10-19
|
8
13
|
### Added
|
9
14
|
- Initial release
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Klaviyo Ruby SDK
|
2
2
|
|
3
|
-
- SDK version: 1.0.
|
3
|
+
- SDK version: 1.0.1
|
4
4
|
- API revision: 2022-10-17
|
5
5
|
|
6
6
|
## Helpful Resources
|
@@ -70,13 +70,13 @@ gem build klaviyo-api-sdk.gemspec
|
|
70
70
|
Then install the gem locally:
|
71
71
|
|
72
72
|
```shell
|
73
|
-
gem install ./klaviyo-api-sdk-1.0.
|
73
|
+
gem install ./klaviyo-api-sdk-1.0.1.gem
|
74
74
|
```
|
75
75
|
|
76
76
|
|
77
77
|
Finally add this to the Gemfile:
|
78
78
|
|
79
|
-
gem 'klaviyo-api-sdk', '~> 1.0.
|
79
|
+
gem 'klaviyo-api-sdk', '~> 1.0.1'
|
80
80
|
|
81
81
|
To install directly from rubygems:
|
82
82
|
|
data/klaviyo-api-sdk.gemspec
CHANGED
@@ -17,7 +17,7 @@ require "klaviyo-api-sdk/version"
|
|
17
17
|
|
18
18
|
Gem::Specification.new do |s|
|
19
19
|
s.name = "klaviyo-api-sdk"
|
20
|
-
s.version = "1.0.
|
20
|
+
s.version = "1.0.1"
|
21
21
|
s.authors = ['Klaviyo Team']
|
22
22
|
s.email = ['libraries@klaviyo.com']
|
23
23
|
s.summary = 'You heard us, a Ruby wrapper for the Klaviyo API'
|
@@ -15,6 +15,7 @@ require 'json'
|
|
15
15
|
require 'logger'
|
16
16
|
require 'tempfile'
|
17
17
|
require 'time'
|
18
|
+
require 'uri'
|
18
19
|
require 'typhoeus'
|
19
20
|
|
20
21
|
module KlaviyoAPI
|
@@ -31,7 +32,7 @@ module KlaviyoAPI
|
|
31
32
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
33
|
def initialize(config = Configuration.default)
|
33
34
|
@config = config
|
34
|
-
@user_agent = "klaviyo-api-ruby/1.0.
|
35
|
+
@user_agent = "klaviyo-api-ruby/1.0.1"
|
35
36
|
@default_headers = {
|
36
37
|
'Content-Type' => 'application/json',
|
37
38
|
'User-Agent' => @user_agent
|
@@ -96,6 +97,7 @@ module KlaviyoAPI
|
|
96
97
|
follow_location = opts[:follow_location] || true
|
97
98
|
|
98
99
|
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
100
|
+
update_page_cursor! header_params, query_params
|
99
101
|
|
100
102
|
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
101
103
|
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
@@ -313,6 +315,25 @@ module KlaviyoAPI
|
|
313
315
|
end
|
314
316
|
end
|
315
317
|
|
318
|
+
# Sets page[cursor] in query_params from parsed URI
|
319
|
+
#
|
320
|
+
# @param [Hash] header_params Header parameters
|
321
|
+
# @param [Hash] query_params Query parameters
|
322
|
+
def update_page_cursor!(header_params, query_params)
|
323
|
+
page_cursor_key = "page[cursor]"
|
324
|
+
page_cursor = query_params[page_cursor_key.to_sym]
|
325
|
+
|
326
|
+
return if page_cursor.nil? || page_cursor.empty?
|
327
|
+
|
328
|
+
if page_cursor.is_a?(String) && page_cursor.include?('https://')
|
329
|
+
query = CGI::parse(URI(page_cursor).query)
|
330
|
+
|
331
|
+
return if !query.keys.include?(page_cursor_key)
|
332
|
+
|
333
|
+
query_params[page_cursor_key.to_sym] = query[page_cursor_key].first
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
316
337
|
# Sets user agent in HTTP header
|
317
338
|
#
|
318
339
|
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
data/test.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Load the gem
|
2
|
+
require 'klaviyo-api-sdk'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
# Setup authorization
|
6
|
+
KlaviyoAPI.configure do |config|
|
7
|
+
config.api_key['Klaviyo-API-Key'] = 'Klaviyo-API-Key pk_51c0b2da23ca58ae5eac3d6fcfa55d6e20'
|
8
|
+
#config.max_retries = 5 # optional
|
9
|
+
#config.max_delay = 60 # optional
|
10
|
+
end
|
11
|
+
|
12
|
+
opts = {
|
13
|
+
"page%5Bcursor%5D": "bmV4dDo6aWQ6OjAxRzRKVjFIMk1NTk02NkE2MVFHWDdXVlFZ",
|
14
|
+
"another": "value"
|
15
|
+
}
|
16
|
+
|
17
|
+
begin
|
18
|
+
KlaviyoAPI::Profiles.get_profiles()
|
19
|
+
end
|
20
|
+
|
21
|
+
opts = {
|
22
|
+
"page%5Bcursor%5D": "https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6Ok43dW1iVw&another=value"
|
23
|
+
}
|
24
|
+
|
25
|
+
begin
|
26
|
+
KlaviyoAPI::Profiles.get_profiles(opts)
|
27
|
+
end
|
28
|
+
|
29
|
+
opts = {
|
30
|
+
"page_cursor": "bmV4dDo6aWQ6OjAxRzRKVjFIMk1NTk02NkE2MVFHWDdXVlFZ",
|
31
|
+
"another": "value"
|
32
|
+
}
|
33
|
+
|
34
|
+
begin
|
35
|
+
KlaviyoAPI::Profiles.get_profiles(opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
opts = {
|
39
|
+
"page_cursor": "https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6Ok43dW1iVw&another=value"
|
40
|
+
}
|
41
|
+
|
42
|
+
begin
|
43
|
+
KlaviyoAPI::Profiles.get_profiles(opts)
|
44
|
+
end
|
45
|
+
|
46
|
+
# uri = "https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6OjAxRzRKVjFIMk1NTk02NkE2MVFHWDdXVlFZ&another=value"
|
47
|
+
# query = URI(uri).query.split('&').map{|x| x.to_s.split('=')}
|
48
|
+
# # p query
|
49
|
+
# p "\n"
|
50
|
+
# print CGI::parse(URI(uri).query)["page[cursor]"]
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaviyo Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: retriable
|
@@ -555,6 +555,7 @@ files:
|
|
555
555
|
- spec/models/v2_template_render_query_as_sub_resource_spec.rb
|
556
556
|
- spec/models/v2_template_render_query_spec.rb
|
557
557
|
- spec/spec_helper.rb
|
558
|
+
- test.rb
|
558
559
|
homepage: https://www.klaviyo.com/
|
559
560
|
licenses:
|
560
561
|
- MIT
|