customerio 5.1.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18279a486386052aa99a48c56652ac566bf6abc973a6428af4d5886ec2ac3b85
4
- data.tar.gz: dcaef6f328effd4cf6dc820e81b27661e440ce79d2af33b6736da544be30a0e7
3
+ metadata.gz: d03e20b960d7934a624f045a54d3d367d35822bbe9cd7f3c39374716256e15a5
4
+ data.tar.gz: fe48ba820bb31d76d86d66dadc3dcf63dc7dc89d88b25c3b836a631a356e4fb9
5
5
  SHA512:
6
- metadata.gz: bad65a5e1d2097aa9db014e71d2c1c310546ec57ce4efa002484a28d6a9031fd5db48a221659d74861ce7a7ff07489b4b8ac956ba11b7b7cadab4eabed730a98
7
- data.tar.gz: ce94e157fd6145afdaf303b1a6a91a5f2eeb9e8ea581d60acad95834e39bba788489c50e164070e83d4232bdb4c692315772bc52c0220676c216d26eeb217f1a
6
+ metadata.gz: be98051f37025cd4cf23693790663e908f6a4718ed195653fe66931c84f072fdb555ccecbe18d0d587a3ad4297fe48d84677c074edbcf1c821849cfda41fe471
7
+ data.tar.gz: a77fed86492d234f04a062fa2a0acb3c287b9f8d53601ddfcf033f0563069c705b21dc04ae8912ca22023542e198ca1980360e4885a36517b3d049e58d4e6ad7
@@ -6,7 +6,7 @@ jobs:
6
6
  test:
7
7
  strategy:
8
8
  matrix:
9
- ruby: ['2.5', '2.6', '2.7']
9
+ ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
10
10
  runs-on: ubuntu-latest
11
11
  env:
12
12
  BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,12 @@
1
+ ## Customerio 5.3.0 - December 8, 2023
2
+ ### Changed
3
+ - The `identify` method has been updated to allow the customer ID to be specified separately from the attributes, using the `customer_id` attribute. This allows a person to be updated by identifying them by e.g.: their email address. Thanks to trwalzer, jrbeck and jeremyw for the original changes that this is based on.
4
+ - It is no longer possible to set the `customer_id` attribute on a person. This is a side-effect of the changes to the `identify` method.
5
+
6
+ ## Customerio 5.2.0 - December 8, 2023
7
+ ### Changed
8
+ - 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.
9
+
1
10
  ## Customerio 5.1.0 - May 5, 2023
2
11
  ### Added
3
12
  - 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 indentify your customers when they sign up for your app and any time their
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,53 @@ $customerio.identify(
95
95
  )
96
96
  ```
97
97
 
98
+ ### Updating customers: Changing identifiers
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
+
116
+ This method requires either the `id` or `cio_id` for the person. It does not work with email addresses.
117
+
118
+ You can also use this method to make other updates to the person using the `cio_id`.
119
+
120
+ ### Updating customers: Using email address
121
+
122
+ If you need to identify a person using their email address, then you can do so
123
+ by passing in a customer ID to the `identify` method. This allows you to specify
124
+ a customer ID that is different than the one used in the `id` attribute. E.g.:
125
+
126
+ ```ruby
127
+ # Arguments
128
+ # customer_id (required) - the customer ID to use for this customer, may be an id, email address, or the cio_id.
129
+ # This will be used to construct the URL but not sent in the body attributes.
130
+ # attributes (required) - a hash of information about the customer. You can pass any
131
+ # information that would be useful in your triggers. You
132
+ # must at least pass in an id, email, and created_at timestamp.
133
+
134
+ $customerio.identify(
135
+ :customer_id => "bob@example.com",
136
+ :location => "Australia"
137
+ )
138
+ ```
139
+
140
+ Note:
141
+
142
+ * If you want to use the `cio_id` in the `customer_id` field of `identify_customer_id`, you will need to prefix it with `"cio_"`. E.g.: `"cio_f000000d"` for a `cio_id` of `f000000d`.
143
+ * The `identify` method can identify the person using one of `customer_id`, `cio_id` or `id`. The order of precedence is `customer_id` > `cio_id` > `id`.
144
+
98
145
  ### Deleting customers
99
146
 
100
147
  Deleting a customer will remove them, and all their information from
data/customerio.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["john@customer.io"]
7
7
  gem.description = "A ruby client for the Customer.io event API."
8
8
  gem.summary = "A ruby client for the Customer.io event API."
9
- gem.homepage = "http://customer.io"
9
+ gem.homepage = "https://customer.io"
10
10
  gem.license = "MIT"
11
11
 
12
12
  gem.files = `git ls-files`.split($\)
@@ -151,9 +151,34 @@ module Customerio
151
151
 
152
152
  def create_or_update(attributes = {})
153
153
  attributes = Hash[attributes.map { |(k,v)| [ k.to_sym, v ] }]
154
- raise MissingIdAttributeError.new("Must provide a customer id") if is_empty?(attributes[:id])
154
+ if is_empty?(attributes[:id]) && is_empty?(attributes[:cio_id]) && is_empty?(attributes[:customer_id])
155
+ raise MissingIdAttributeError.new("Must provide a customer id")
156
+ end
157
+
158
+ # Use cio_id as the identifier, if present,
159
+ # to allow the id and email identifiers to be updated.
160
+ # The person is identified by a customer ID, which is included
161
+ # in the path to the Track v1 API. Choose the ID in this order
162
+ # from highest to lowest precedence:
163
+ #
164
+ # 1. customer_id: "id", an email address, or "cio_id" value.
165
+ # Any "cio_id" values need to be prefixed "cio_"
166
+ # so that the Track v1 API knows it's a cio_id.
167
+ #
168
+ # 2. cio_id: The cio_id value (no prefix required).
169
+ #
170
+ # 3. id: The id value.
171
+ customer_id = attributes[:id]
172
+ if !is_empty?(attributes[:cio_id])
173
+ customer_id = "cio_" + attributes[:cio_id]
174
+ end
175
+ if !is_empty?(attributes[:customer_id])
176
+ customer_id = attributes[:customer_id]
177
+ end
178
+ # customer_id is not an attribute, so remove it.
179
+ attributes.delete(:customer_id)
155
180
 
156
- url = customer_path(attributes[:id])
181
+ url = customer_path(customer_id)
157
182
  @client.request_and_verify_response(:put, url, attributes)
158
183
  end
159
184
 
@@ -55,7 +55,7 @@ module Customerio
55
55
  param
56
56
  end
57
57
 
58
- # Prefer ERB::Util.url_encode, fall baack to deprecation URI.encode for
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
@@ -1,3 +1,3 @@
1
1
  module Customerio
2
- VERSION = "5.1.0"
2
+ VERSION = "5.3.0"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -172,6 +172,8 @@ 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)
176
+ lambda { client.identify(customer_id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError)
175
177
  end
176
178
 
177
179
  it 'should not raise errors when attribute keys are strings' do
@@ -183,6 +185,78 @@ describe Customerio::Client do
183
185
 
184
186
  lambda { client.identify(attributes) }.should_not raise_error()
185
187
  end
188
+
189
+ it 'uses cio_id for customer id, when present, for id updates' do
190
+ stub_request(:put, api_uri('/api/v1/customers/cio_347f00d')).with(
191
+ body: {
192
+ cio_id: "347f00d",
193
+ id: 5
194
+ }).to_return(status: 200, body: "", headers: {})
195
+
196
+ client.identify({
197
+ cio_id: "347f00d",
198
+ id: 5
199
+ })
200
+ end
201
+
202
+ it 'uses cio_id for customer id, when present, for email updates' do
203
+ stub_request(:put, api_uri('/api/v1/customers/cio_347f00d')).with(
204
+ body: {
205
+ cio_id: "347f00d",
206
+ email: "different.customer@example.com"
207
+ }).to_return(status: 200, body: "", headers: {})
208
+
209
+ client.identify({
210
+ cio_id: "347f00d",
211
+ email: "different.customer@example.com"
212
+ })
213
+ end
214
+
215
+ it 'allows updates with cio_id as the only id' do
216
+ stub_request(:put, api_uri('/api/v1/customers/cio_347f00d')).with(
217
+ body: {
218
+ cio_id: "347f00d",
219
+ location: "here"
220
+ }).to_return(status: 200, body: "", headers: {})
221
+
222
+ client.identify({
223
+ cio_id: "347f00d",
224
+ location: "here"
225
+ })
226
+ end
227
+
228
+ it "uses provided id rather than id" do
229
+ stub_request(:put, api_uri('/api/v1/customers/1234')).
230
+ with(body: json(id: "5")).
231
+ to_return(status: 200, body: "", headers: {})
232
+
233
+ client.identify(
234
+ customer_id: "1234",
235
+ id: "5"
236
+ )
237
+ end
238
+
239
+ it "uses provided cio_id rather than id" do
240
+ stub_request(:put, api_uri('/api/v1/customers/cio_5')).
241
+ with(body: json(id: "5")).
242
+ to_return(status: 200, body: "", headers: {})
243
+
244
+ client.identify(
245
+ customer_id: "cio_5",
246
+ id: "5"
247
+ )
248
+ end
249
+
250
+ it "uses provided email rather than id" do
251
+ stub_request(:put, api_uri('/api/v1/customers/customer@example.com')).
252
+ with(body: json(id: "5")).
253
+ to_return(status: 200, body: "", headers: {})
254
+
255
+ client.identify(
256
+ customer_id: "customer@example.com",
257
+ id: "5"
258
+ )
259
+ end
186
260
  end
187
261
 
188
262
  describe "#delete" do
@@ -610,7 +684,7 @@ describe Customerio::Client do
610
684
  }.to raise_error(Customerio::Client::ParamError, 'timestamp must be a valid timestamp')
611
685
  end
612
686
  end
613
-
687
+
614
688
  describe "#merge_customers" do
615
689
  before(:each) do
616
690
  @client = Customerio::Client.new("SITE_ID", "API_KEY", :json => true)
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.1.0
4
+ version: 5.3.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-05-08 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -123,11 +123,11 @@ files:
123
123
  - spec/base_client_spec.rb
124
124
  - spec/client_spec.rb
125
125
  - spec/spec_helper.rb
126
- homepage: http://customer.io
126
+ homepage: https://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.0.3.1
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: