customerio 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/CHANGELOG.markdown +4 -0
- data/README.md +19 -1
- data/lib/customerio/client.rb +10 -2
- data/lib/customerio/param_encoder.rb +1 -1
- data/lib/customerio/version.rb +1 -1
- data/spec/client_spec.rb +40 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad688e060a453d3f02dfcdacc1407a4376fd355deb6feb6a531d4f2b9ebbad6
|
4
|
+
data.tar.gz: ea3401fa18f031f4ecb70fc79ee8817b0278294debe53f2f78adb403873f32a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b708a8aba7b91c3a270b2829cc7ba24cad4d72e8030f04cc266dcf97adcb9de8579f0fe159eeed5c95669890dd30376f05c28b43540894feb8dd15f25a516d4
|
7
|
+
data.tar.gz: 128500f502747de7b3d4e92a201ebcf23fa2ebe731f529fb57d72f2919f95f81f3cb8e59917a621e9e475c957c234302641581415d21cfa2189d3aa994889557
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## Customerio 5.2.0 - December 8, 2023
|
2
|
+
### Changed
|
3
|
+
- The `identify` method will now automatically use the `cio_id` attribute as the customer ID when calling the track service. This allows a customer to be updated using `identify` to modify the `id` and `email` attributes.
|
4
|
+
|
1
5
|
## Customerio 5.1.0 - May 5, 2023
|
2
6
|
### Added
|
3
7
|
- Added `send_push` to `APIClient` and `SendPushRequest` to support sending transactional push notifications.
|
data/README.md
CHANGED
@@ -77,7 +77,7 @@ if you pass along the current subscription plan (free / basic / premium) for you
|
|
77
77
|
set up triggers which are only sent to customers who have subscribed to a
|
78
78
|
particular plan (e.g. "premium").
|
79
79
|
|
80
|
-
You'll want to
|
80
|
+
You'll want to identify your customers when they sign up for your app and any time their
|
81
81
|
key information changes. This keeps [Customer.io](https://customer.io) up to date with your customer information.
|
82
82
|
|
83
83
|
```ruby
|
@@ -95,6 +95,24 @@ $customerio.identify(
|
|
95
95
|
)
|
96
96
|
```
|
97
97
|
|
98
|
+
### Updating customers
|
99
|
+
|
100
|
+
You can use the identify operation to update customers.
|
101
|
+
If you need to change the `id` or `email` identifiers for a customer,
|
102
|
+
you will need to pass in the `cio_id` identifier.
|
103
|
+
`cio_id` is a unique identifier set by Customer.io, used to reference a person,
|
104
|
+
and cannot be changed.
|
105
|
+
|
106
|
+
E.g.: if the customer created in the identify operation above was given the `cio_id` of `"f000000d"`, you could change its ID and email address using:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
$customerio.identify(
|
110
|
+
:cio_id => "f000000d",
|
111
|
+
:id => 1005,
|
112
|
+
:email => "bob.fullname@example.com"
|
113
|
+
)
|
114
|
+
```
|
115
|
+
|
98
116
|
### Deleting customers
|
99
117
|
|
100
118
|
Deleting a customer will remove them, and all their information from
|
data/lib/customerio/client.rb
CHANGED
@@ -151,9 +151,17 @@ module Customerio
|
|
151
151
|
|
152
152
|
def create_or_update(attributes = {})
|
153
153
|
attributes = Hash[attributes.map { |(k,v)| [ k.to_sym, v ] }]
|
154
|
-
|
154
|
+
if is_empty?(attributes[:id]) && is_empty?(attributes[:cio_id])
|
155
|
+
raise MissingIdAttributeError.new("Must provide a customer id")
|
156
|
+
end
|
155
157
|
|
156
|
-
|
158
|
+
# Use cio_id as the identifier, if present,
|
159
|
+
# to allow the id and email identifiers to be updated.
|
160
|
+
customer_id = attributes[:id]
|
161
|
+
if !is_empty?(attributes[:cio_id])
|
162
|
+
customer_id = "cio_" + attributes[:cio_id]
|
163
|
+
end
|
164
|
+
url = customer_path(customer_id)
|
157
165
|
@client.request_and_verify_response(:put, url, attributes)
|
158
166
|
end
|
159
167
|
|
@@ -55,7 +55,7 @@ module Customerio
|
|
55
55
|
param
|
56
56
|
end
|
57
57
|
|
58
|
-
# Prefer ERB::Util.url_encode, fall
|
58
|
+
# Prefer ERB::Util.url_encode, fall back to deprecation URI.encode for
|
59
59
|
# old Ruby support
|
60
60
|
def self.escape_value(value)
|
61
61
|
if ERB::Util.respond_to? :url_encode
|
data/lib/customerio/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -172,6 +172,7 @@ describe Customerio::Client do
|
|
172
172
|
it "requires an id attribute" do
|
173
173
|
lambda { client.identify(email: "customer@example.com") }.should raise_error(Customerio::Client::MissingIdAttributeError)
|
174
174
|
lambda { client.identify(id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError)
|
175
|
+
lambda { client.identify(cio_id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError)
|
175
176
|
end
|
176
177
|
|
177
178
|
it 'should not raise errors when attribute keys are strings' do
|
@@ -183,6 +184,45 @@ describe Customerio::Client do
|
|
183
184
|
|
184
185
|
lambda { client.identify(attributes) }.should_not raise_error()
|
185
186
|
end
|
187
|
+
|
188
|
+
it 'uses cio_id for customer id, when present, for id updates' do
|
189
|
+
stub_request(:put, api_uri('/api/v1/customers/cio_347f00d')).with(
|
190
|
+
body: {
|
191
|
+
cio_id: "347f00d",
|
192
|
+
id: 5
|
193
|
+
}).to_return(status: 200, body: "", headers: {})
|
194
|
+
|
195
|
+
client.identify({
|
196
|
+
cio_id: "347f00d",
|
197
|
+
id: 5
|
198
|
+
})
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'uses cio_id for customer id, when present, for email updates' do
|
202
|
+
stub_request(:put, api_uri('/api/v1/customers/cio_347f00d')).with(
|
203
|
+
body: {
|
204
|
+
cio_id: "347f00d",
|
205
|
+
email: "different.customer@example.com"
|
206
|
+
}).to_return(status: 200, body: "", headers: {})
|
207
|
+
|
208
|
+
client.identify({
|
209
|
+
cio_id: "347f00d",
|
210
|
+
email: "different.customer@example.com"
|
211
|
+
})
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'allows updates with cio_id as the only id' do
|
215
|
+
stub_request(:put, api_uri('/api/v1/customers/cio_347f00d')).with(
|
216
|
+
body: {
|
217
|
+
cio_id: "347f00d",
|
218
|
+
location: "here"
|
219
|
+
}).to_return(status: 200, body: "", headers: {})
|
220
|
+
|
221
|
+
client.identify({
|
222
|
+
cio_id: "347f00d",
|
223
|
+
location: "here"
|
224
|
+
})
|
225
|
+
end
|
186
226
|
end
|
187
227
|
|
188
228
|
describe "#delete" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: customerio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Allison
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -127,7 +127,7 @@ homepage: http://customer.io
|
|
127
127
|
licenses:
|
128
128
|
- MIT
|
129
129
|
metadata: {}
|
130
|
-
post_install_message:
|
130
|
+
post_install_message:
|
131
131
|
rdoc_options: []
|
132
132
|
require_paths:
|
133
133
|
- lib
|
@@ -142,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
|
-
rubygems_version: 3.
|
146
|
-
signing_key:
|
145
|
+
rubygems_version: 3.2.33
|
146
|
+
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: A ruby client for the Customer.io event API.
|
149
149
|
test_files:
|