customerio 4.3.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/CHANGELOG.markdown +21 -0
- data/README.md +89 -2
- data/customerio.gemspec +1 -1
- data/lib/customerio/api.rb +19 -0
- data/lib/customerio/client.rb +45 -3
- data/lib/customerio/param_encoder.rb +1 -1
- data/lib/customerio/requests/send_email_request.rb +5 -2
- data/lib/customerio/requests/send_push_request.rb +36 -0
- data/lib/customerio/version.rb +1 -1
- data/lib/customerio.rb +1 -0
- data/spec/api_client_spec.rb +84 -1
- data/spec/client_spec.rb +85 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d03e20b960d7934a624f045a54d3d367d35822bbe9cd7f3c39374716256e15a5
|
4
|
+
data.tar.gz: fe48ba820bb31d76d86d66dadc3dcf63dc7dc89d88b25c3b836a631a356e4fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be98051f37025cd4cf23693790663e908f6a4718ed195653fe66931c84f072fdb555ccecbe18d0d587a3ad4297fe48d84677c074edbcf1c821849cfda41fe471
|
7
|
+
data.tar.gz: a77fed86492d234f04a062fa2a0acb3c287b9f8d53601ddfcf033f0563069c705b21dc04ae8912ca22023542e198ca1980360e4885a36517b3d049e58d4e6ad7
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,24 @@
|
|
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
|
+
|
10
|
+
## Customerio 5.1.0 - May 5, 2023
|
11
|
+
### Added
|
12
|
+
- Added `send_push` to `APIClient` and `SendPushRequest` to support sending transactional push notifications.
|
13
|
+
|
14
|
+
## Customerio 4.3.1 - January 5, 2023
|
15
|
+
### Added
|
16
|
+
- Added the `disable_css_preprocessing` and `language` optional fields to send request
|
17
|
+
|
18
|
+
## Customerio 4.3.0 - April 26, 2022
|
19
|
+
### Added
|
20
|
+
- Support for [anonymous invite events](https://customer.io/docs/anonymous-invite-emails/) by setting `anonymous_id` to `nil`.
|
21
|
+
|
1
22
|
## Customerio 4.1.0 - Sep 27, 2021
|
2
23
|
### Added
|
3
24
|
- Added support for [merge customers](https://customer.io/docs/api/#operation/merge) API
|
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,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
|
@@ -217,7 +264,9 @@ $customerio.unsuppress(5)
|
|
217
264
|
|
218
265
|
### Send Transactional Messages
|
219
266
|
|
220
|
-
To use the Customer.io [Transactional API](https://customer.io/docs/transactional-api), create an instance of the API client using an [app key](https://customer.io/docs/managing-credentials#app-api-keys).
|
267
|
+
To use the Customer.io [Transactional API](https://customer.io/docs/transactional-api), create an instance of the API client using an [app key](https://customer.io/docs/managing-credentials#app-api-keys) and create a request object of your message type.
|
268
|
+
|
269
|
+
#### Email
|
221
270
|
|
222
271
|
Create a new `SendEmailRequest` object containing:
|
223
272
|
|
@@ -262,6 +311,44 @@ rescue Customerio::InvalidResponse => e
|
|
262
311
|
end
|
263
312
|
```
|
264
313
|
|
314
|
+
#### Push
|
315
|
+
|
316
|
+
Create a new `SendPushRequest` object containing:
|
317
|
+
|
318
|
+
* `transactional_message_id`: the ID or trigger name of the transactional message you want to send.
|
319
|
+
* an `identifiers` object containing the `id` or `email` of your recipient. If the profile does not exist, Customer.io creates it.
|
320
|
+
|
321
|
+
Use `send_push` referencing your request to send a transactional message. [Learn more about transactional messages and `SendPushRequest` properties](https://customer.io/docs/transactional-api).
|
322
|
+
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
require "customerio"
|
326
|
+
|
327
|
+
client = Customerio::APIClient.new("your API key", region: Customerio::Regions::US)
|
328
|
+
|
329
|
+
request = Customerio::SendPushRequest.new(
|
330
|
+
transactional_message_id: "3",
|
331
|
+
message_data: {
|
332
|
+
name: "Person",
|
333
|
+
items: {
|
334
|
+
name: "shoes",
|
335
|
+
price: "59.99",
|
336
|
+
},
|
337
|
+
products: [],
|
338
|
+
},
|
339
|
+
identifiers: {
|
340
|
+
id: "2",
|
341
|
+
},
|
342
|
+
)
|
343
|
+
|
344
|
+
begin
|
345
|
+
response = client.send_push(request)
|
346
|
+
puts response
|
347
|
+
rescue Customerio::InvalidResponse => e
|
348
|
+
puts e.code, e.message
|
349
|
+
end
|
350
|
+
```
|
351
|
+
|
265
352
|
## Contributing
|
266
353
|
|
267
354
|
1. Fork it
|
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 = "
|
9
|
+
gem.homepage = "https://customer.io"
|
10
10
|
gem.license = "MIT"
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
data/lib/customerio/api.rb
CHANGED
@@ -26,10 +26,29 @@ module Customerio
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def send_push(req)
|
30
|
+
raise "request must be an instance of Customerio::SendPushRequest" unless req.is_a?(Customerio::SendPushRequest)
|
31
|
+
response = @client.request(:post, send_push_path, req.message)
|
32
|
+
|
33
|
+
case response
|
34
|
+
when Net::HTTPSuccess then
|
35
|
+
JSON.parse(response.body)
|
36
|
+
when Net::HTTPBadRequest then
|
37
|
+
json = JSON.parse(response.body)
|
38
|
+
raise Customerio::InvalidResponse.new(response.code, json['meta']['error'], response)
|
39
|
+
else
|
40
|
+
raise InvalidResponse.new(response.code, response.body)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
29
44
|
private
|
30
45
|
|
31
46
|
def send_email_path
|
32
47
|
"/v1/send/email"
|
33
48
|
end
|
49
|
+
|
50
|
+
def send_push_path
|
51
|
+
"/v1/send/push"
|
52
|
+
end
|
34
53
|
end
|
35
54
|
end
|
data/lib/customerio/client.rb
CHANGED
@@ -51,6 +51,13 @@ module Customerio
|
|
51
51
|
create_customer_event(customer_id, event_name, attributes)
|
52
52
|
end
|
53
53
|
|
54
|
+
def pageview(customer_id, page, attributes = {})
|
55
|
+
raise ParamError.new("customer_id must be a non-empty string") if is_empty?(customer_id)
|
56
|
+
raise ParamError.new("page must be a non-empty string") if is_empty?(page)
|
57
|
+
|
58
|
+
create_pageview_event(customer_id, page, attributes)
|
59
|
+
end
|
60
|
+
|
54
61
|
def track_anonymous(anonymous_id, event_name, attributes = {})
|
55
62
|
raise ParamError.new("event_name must be a non-empty string") if is_empty?(event_name)
|
56
63
|
|
@@ -144,9 +151,34 @@ module Customerio
|
|
144
151
|
|
145
152
|
def create_or_update(attributes = {})
|
146
153
|
attributes = Hash[attributes.map { |(k,v)| [ k.to_sym, v ] }]
|
147
|
-
|
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)
|
148
180
|
|
149
|
-
url = customer_path(
|
181
|
+
url = customer_path(customer_id)
|
150
182
|
@client.request_and_verify_response(:put, url, attributes)
|
151
183
|
end
|
152
184
|
|
@@ -167,10 +199,20 @@ module Customerio
|
|
167
199
|
)
|
168
200
|
end
|
169
201
|
|
170
|
-
def
|
202
|
+
def create_pageview_event(customer_id, page, attributes = {})
|
203
|
+
create_event(
|
204
|
+
url: "#{customer_path(customer_id)}/events",
|
205
|
+
event_type: "page",
|
206
|
+
event_name: page,
|
207
|
+
attributes: attributes
|
208
|
+
)
|
209
|
+
end
|
210
|
+
|
211
|
+
def create_event(url:, event_name:, anonymous_id: nil, event_type: nil, attributes: {})
|
171
212
|
body = { :name => event_name, :data => attributes }
|
172
213
|
body[:timestamp] = attributes[:timestamp] if valid_timestamp?(attributes[:timestamp])
|
173
214
|
body[:anonymous_id] = anonymous_id unless is_empty?(anonymous_id)
|
215
|
+
body[:type] = event_type unless is_empty?(event_type)
|
174
216
|
|
175
217
|
@client.request_and_verify_response(:post, url, body)
|
176
218
|
end
|
@@ -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
|
@@ -29,13 +29,16 @@ module Customerio
|
|
29
29
|
bcc
|
30
30
|
subject
|
31
31
|
body
|
32
|
-
|
33
|
-
|
32
|
+
body_plain
|
33
|
+
body_amp
|
34
34
|
fake_bcc
|
35
35
|
disable_message_retention
|
36
36
|
send_to_unsubscribed
|
37
37
|
tracked
|
38
38
|
queue_draft
|
39
|
+
disable_css_preprocessing
|
40
|
+
send_at
|
41
|
+
language
|
39
42
|
)
|
40
43
|
|
41
44
|
def invalid_field?(field)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Customerio
|
2
|
+
class SendPushRequest
|
3
|
+
attr_reader :message
|
4
|
+
|
5
|
+
def initialize(opts)
|
6
|
+
@message = opts.delete_if { |field| invalid_field?(field) }
|
7
|
+
@message[:custom_device] = opts[:device] if opts[:device]
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
REQUIRED_FIELDS = %i(transactional_message_id identifiers)
|
13
|
+
|
14
|
+
OPTIONAL_FIELDS = %i(
|
15
|
+
to
|
16
|
+
title
|
17
|
+
message
|
18
|
+
disable_message_retention
|
19
|
+
send_to_unsubscribed
|
20
|
+
queue_draft
|
21
|
+
message_data
|
22
|
+
send_at
|
23
|
+
language
|
24
|
+
image_url
|
25
|
+
link
|
26
|
+
sound
|
27
|
+
custom_data
|
28
|
+
device
|
29
|
+
custom_device
|
30
|
+
)
|
31
|
+
|
32
|
+
def invalid_field?(field)
|
33
|
+
!REQUIRED_FIELDS.include?(field) && !OPTIONAL_FIELDS.include?(field)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/customerio/version.rb
CHANGED
data/lib/customerio.rb
CHANGED
data/spec/api_client_spec.rb
CHANGED
@@ -6,7 +6,7 @@ require 'tempfile'
|
|
6
6
|
describe Customerio::APIClient do
|
7
7
|
let(:app_key) { "appkey" }
|
8
8
|
|
9
|
-
let(:client)
|
9
|
+
let(:client) { Customerio::APIClient.new(app_key) }
|
10
10
|
let(:response) { double("Response", code: 200) }
|
11
11
|
|
12
12
|
def api_uri(path)
|
@@ -169,4 +169,87 @@ describe Customerio::APIClient do
|
|
169
169
|
req.message[:attachments].should eq({ "test" => Base64.strict_encode64("test-content") })
|
170
170
|
end
|
171
171
|
end
|
172
|
+
|
173
|
+
describe "#send_push" do
|
174
|
+
it "sends a POST request to the /api/send/push path" do
|
175
|
+
req = Customerio::SendPushRequest.new(
|
176
|
+
identifiers: {
|
177
|
+
id: 'c1',
|
178
|
+
},
|
179
|
+
transactional_message_id: 1,
|
180
|
+
)
|
181
|
+
|
182
|
+
stub_request(:post, api_uri('/v1/send/push'))
|
183
|
+
.with(headers: request_headers, body: req.message)
|
184
|
+
.to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
|
185
|
+
|
186
|
+
client.send_push(req).should eq({ "delivery_id" => 1 })
|
187
|
+
end
|
188
|
+
|
189
|
+
it "handles validation failures (400)" do
|
190
|
+
req = Customerio::SendPushRequest.new(
|
191
|
+
identifiers: {
|
192
|
+
id: 'c1',
|
193
|
+
},
|
194
|
+
transactional_message_id: 1,
|
195
|
+
)
|
196
|
+
|
197
|
+
err_json = { meta: { error: "example error" } }.to_json
|
198
|
+
|
199
|
+
stub_request(:post, api_uri('/v1/send/push'))
|
200
|
+
.with(headers: request_headers, body: req.message)
|
201
|
+
.to_return(status: 400, body: err_json, headers: {})
|
202
|
+
|
203
|
+
lambda { client.send_push(req) }.should(
|
204
|
+
raise_error(Customerio::InvalidResponse) { |error|
|
205
|
+
error.message.should eq "example error"
|
206
|
+
error.code.should eq "400"
|
207
|
+
}
|
208
|
+
)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "handles other failures (5xx)" do
|
212
|
+
req = Customerio::SendPushRequest.new(
|
213
|
+
identifiers: {
|
214
|
+
id: 'c1',
|
215
|
+
},
|
216
|
+
transactional_message_id: 1,
|
217
|
+
)
|
218
|
+
|
219
|
+
stub_request(:post, api_uri('/v1/send/push'))
|
220
|
+
.with(headers: request_headers, body: req.message)
|
221
|
+
.to_return(status: 500, body: "Server unavailable", headers: {})
|
222
|
+
|
223
|
+
lambda { client.send_push(req) }.should(
|
224
|
+
raise_error(Customerio::InvalidResponse) { |error|
|
225
|
+
error.message.should eq "Server unavailable"
|
226
|
+
error.code.should eq "500"
|
227
|
+
}
|
228
|
+
)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "sets custom_device correctly if device present in req" do
|
232
|
+
req = Customerio::SendPushRequest.new(
|
233
|
+
identifiers: {
|
234
|
+
id: 'c1',
|
235
|
+
},
|
236
|
+
transactional_message_id: 1,
|
237
|
+
device: {
|
238
|
+
platform: 'ios',
|
239
|
+
token: 'sample-token',
|
240
|
+
}
|
241
|
+
)
|
242
|
+
|
243
|
+
req.message[:custom_device].should eq({
|
244
|
+
platform: 'ios',
|
245
|
+
token: 'sample-token',
|
246
|
+
})
|
247
|
+
|
248
|
+
stub_request(:post, api_uri('/v1/send/push'))
|
249
|
+
.with(headers: request_headers, body: req.message)
|
250
|
+
.to_return(status: 200, body: { delivery_id: 2 }.to_json, headers: {})
|
251
|
+
|
252
|
+
client.send_push(req).should eq({ "delivery_id" => 2 })
|
253
|
+
end
|
254
|
+
end
|
172
255
|
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
|
@@ -240,6 +314,16 @@ describe Customerio::Client do
|
|
240
314
|
end
|
241
315
|
end
|
242
316
|
|
317
|
+
describe "#pageview" do
|
318
|
+
it "allows sending pageview event" do
|
319
|
+
stub_request(:post, api_uri('/api/v1/customers/5/events')).
|
320
|
+
with(body: json(name: "http://customer.io", data: {}, type: "page")).
|
321
|
+
to_return(status: 200, body: "", headers: {})
|
322
|
+
|
323
|
+
client.pageview(5, "http://customer.io")
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
243
327
|
describe "#track" do
|
244
328
|
it "raises an error if POST doesn't return a 2xx response code" do
|
245
329
|
stub_request(:post, api_uri('/api/v1/customers/5/events')).
|
@@ -600,7 +684,7 @@ describe Customerio::Client do
|
|
600
684
|
}.to raise_error(Customerio::Client::ParamError, 'timestamp must be a valid timestamp')
|
601
685
|
end
|
602
686
|
end
|
603
|
-
|
687
|
+
|
604
688
|
describe "#merge_customers" do
|
605
689
|
before(:each) do
|
606
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:
|
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:
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -117,16 +117,17 @@ files:
|
|
117
117
|
- lib/customerio/param_encoder.rb
|
118
118
|
- lib/customerio/regions.rb
|
119
119
|
- lib/customerio/requests/send_email_request.rb
|
120
|
+
- lib/customerio/requests/send_push_request.rb
|
120
121
|
- lib/customerio/version.rb
|
121
122
|
- spec/api_client_spec.rb
|
122
123
|
- spec/base_client_spec.rb
|
123
124
|
- spec/client_spec.rb
|
124
125
|
- spec/spec_helper.rb
|
125
|
-
homepage:
|
126
|
+
homepage: https://customer.io
|
126
127
|
licenses:
|
127
128
|
- MIT
|
128
129
|
metadata: {}
|
129
|
-
post_install_message:
|
130
|
+
post_install_message:
|
130
131
|
rdoc_options: []
|
131
132
|
require_paths:
|
132
133
|
- lib
|
@@ -141,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
|
-
rubygems_version: 3.2.
|
145
|
-
signing_key:
|
145
|
+
rubygems_version: 3.2.33
|
146
|
+
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: A ruby client for the Customer.io event API.
|
148
149
|
test_files:
|