customerio 4.3.1 → 5.0.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: be14989a3ca17091869a6dc20f34341d2845fb15f8d5570b5641040edab27c39
4
- data.tar.gz: 36e35e8ce757ccf5a93c68e86af0da4c86a4026debb8d7015246606103a42c8f
3
+ metadata.gz: 558909b4f1cd8c6701f8c8fcce3796ab9d7321eb19038514ac9432f728035104
4
+ data.tar.gz: 5787b196ae97f8ded6122dbe83ccc9f9d363b86181b4e2144595a13b1772111b
5
5
  SHA512:
6
- metadata.gz: 1edc792c72b64a6141e08d8feefc41ac39541c859380c2f229cfcd958937455f71d4260c4e4828b5254c5b7d9e9cdbcc3049fdf67b7025a6566d59cc09d8864d
7
- data.tar.gz: 29baa33725a8089a340631c9b805330a89936537eb8691fd5e70ff37e5d797f2af74d4240d2551dd196c4a911c0d37ec49300d20708cb41512e0428c19fc05e5
6
+ metadata.gz: 8105a2cd41265da49055b42e9eff7db0c0548d930a4a91871edd2458db2c0389e5c5a2e095e79f1fd453994a55614c6f621960d30ab36d5c31e2cb5fc552a6b1
7
+ data.tar.gz: 74eef21394ff63ce7305a5241e23a4a74248e12a7486f268280d74bc72d8b50ec1bdf8b72717ade273b6d4dcb7d152bb49d8861c16bce5d5385eb743c899b65a
@@ -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
 
@@ -167,10 +174,20 @@ module Customerio
167
174
  )
168
175
  end
169
176
 
170
- def create_event(url:, event_name:, anonymous_id: nil, attributes: {})
177
+ def create_pageview_event(customer_id, page, attributes = {})
178
+ create_event(
179
+ url: "#{customer_path(customer_id)}/events",
180
+ event_type: "page",
181
+ event_name: page,
182
+ attributes: attributes
183
+ )
184
+ end
185
+
186
+ def create_event(url:, event_name:, anonymous_id: nil, event_type: nil, attributes: {})
171
187
  body = { :name => event_name, :data => attributes }
172
188
  body[:timestamp] = attributes[:timestamp] if valid_timestamp?(attributes[:timestamp])
173
189
  body[:anonymous_id] = anonymous_id unless is_empty?(anonymous_id)
190
+ body[:type] = event_type unless is_empty?(event_type)
174
191
 
175
192
  @client.request_and_verify_response(:post, url, body)
176
193
  end
@@ -29,8 +29,8 @@ module Customerio
29
29
  bcc
30
30
  subject
31
31
  body
32
- plaintext_body
33
- amp_body
32
+ body_plain
33
+ body_amp
34
34
  fake_bcc
35
35
  disable_message_retention
36
36
  send_to_unsubscribed
@@ -1,3 +1,3 @@
1
1
  module Customerio
2
- VERSION = "4.3.1"
2
+ VERSION = "5.0.0"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -240,6 +240,16 @@ describe Customerio::Client do
240
240
  end
241
241
  end
242
242
 
243
+ describe "#pageview" do
244
+ it "allows sending pageview event" do
245
+ stub_request(:post, api_uri('/api/v1/customers/5/events')).
246
+ with(body: json(name: "http://customer.io", data: {}, type: "page")).
247
+ to_return(status: 200, body: "", headers: {})
248
+
249
+ client.pageview(5, "http://customer.io")
250
+ end
251
+ end
252
+
243
253
  describe "#track" do
244
254
  it "raises an error if POST doesn't return a 2xx response code" do
245
255
  stub_request(:post, api_uri('/api/v1/customers/5/events')).
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.3.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-04 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubygems_version: 3.3.5
144
+ rubygems_version: 3.0.3.1
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: A ruby client for the Customer.io event API.