Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

202112 docs rack updates #49

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGELOG

### 2.4.0
* Update Rack install documentation
* Update Lists API endpoint for checking list subscriptions

### 2.3.0

* Added ability to set API key in request without setting Klaviyo.private_api_key
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ To automatically insert the Klaviyo script in your Rails app, add this to your e

```ruby
require 'rack/klaviyo'
config.middleware.use "Klaviyo::Client::Middleware", "YOUR_PUBLIC_KLAVIYO_API_TOKEN"
config.middleware.use Rack::Klaviyo, "YOUR_PUBLIC_KLAVIYO_API_TOKEN"
```

This will automatically insert the Klaviyo script at the bottom on your HTML page, right before the closing `body` tag.
Expand Down
4 changes: 2 additions & 2 deletions klaviyo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ files = ['klaviyo.gemspec', '{lib}/**/**/*'].map {|f| Dir[f]}.flatten

Gem::Specification.new do |s|
s.name = 'klaviyo'
s.version = '2.3.0'
s.date = '2021-10-28'
s.version = '2.4.0'
s.date = '2021-12-06'
s.summary = 'You heard us, a Ruby wrapper for the Klaviyo API'
s.description = 'Ruby wrapper for the Klaviyo API'
s.authors = ['Klaviyo Team']
Expand Down
5 changes: 3 additions & 2 deletions lib/klaviyo/apis/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Lists < Client
LISTS = 'lists'
MEMBERS = 'members'
SUBSCRIBE = 'subscribe'
GET_LIST_SUBSCRIPTIONS = 'get-list-subscriptions'

# Creates a new list
# @param list_name [String] the list name
Expand Down Expand Up @@ -65,13 +66,13 @@ def self.delete_list(list_id, api_key: nil)
# @return A list of JSON objects of the profiles. Profiles that are
# supressed or not found are not included.
def self.check_list_subscriptions(list_id, api_key: nil, emails: [], phone_numbers: [], push_tokens: [])
path = "#{LIST}/#{list_id}/#{SUBSCRIBE}"
path = "#{LIST}/#{list_id}/#{GET_LIST_SUBSCRIPTIONS}"
params = {
:emails => emails,
:phone_numbers => phone_numbers,
:push_tokens => push_tokens
}
v2_request(HTTP_GET, path, api_key: api_key, **params)
v2_request(HTTP_POST, path, api_key: api_key, **params)
end

# Subscribe profiles to a list.
Expand Down
2 changes: 1 addition & 1 deletion lib/klaviyo/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Client
V1_API = 'v1'
V2_API = 'v2'

KL_VERSION = '2.3.0'
KL_VERSION = '2.4.0'
KL_USER_AGENT = "Ruby_Klaviyo/#{KL_VERSION}"

HTTP_DELETE = 'delete'
Expand Down
4 changes: 2 additions & 2 deletions lib/rack/klaviyo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def call(env)
def update_response!
@response.each do |part|
insert_at = part.index(@options[:insert_js_last] ? '</body' : '</head')
unless insert_at.nil?
part.insert(insert_at, render_script)
unless insert_at.nil? || part.frozen?
part.insert(insert_at, render_script.html_safe)
end
end
end
Expand Down