customerio 2.1.0 → 2.2.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
  SHA1:
3
- metadata.gz: 142c5aa6d5043fbf69018fc678fc335552c46d65
4
- data.tar.gz: 15c5da49d590ac52cbc500d24e9a31b243937092
3
+ metadata.gz: 977087d789ae0127e8eef651a1546f88db71f3ce
4
+ data.tar.gz: 49fa6e8a7bf05b10c5c1c1390efcb9d21381a45b
5
5
  SHA512:
6
- metadata.gz: c612f66e9ba819f88f04659b7ea243d98c4c57e6f6733bee94ca71e85dcd7d2d5b4ecd8458623d4ad3cafa857587e47b17e74977dee302fccb2a3c879d5a53db
7
- data.tar.gz: db90752181238ad8626b2a723ae1f74230abbc6a458f39802ee25b21ac2933c653bddf2138b261e7e65b8ecb17d341d7a8234093497421a8c0b30dc811a9c0b2
6
+ metadata.gz: 84ac7dfbc050d453a25c01e66abb5262b906c73420cebad93c624221d1abf3ff0048aca072e31b2f30ec039bb86b441248ade79821973a8ec0e8dbd57511c11e
7
+ data.tar.gz: 8abcb4cfa1ba074d8c28d1f2fda6668175e13e49d8133c352a51641938b297cfcd73f39e05658650a3d5763758ff60b6355dbb1cdfc440de5753b471fc4621fa
@@ -1,3 +1,7 @@
1
+ ## Customerio 2.2.0 - Oct 18, 2018 ##
2
+
3
+ Add support for manual segments [#52](https://github.com/customerio/customerio-ruby/pull/52)
4
+
1
5
  ## Customerio 2.1.0 - May 22, 2018 ##
2
6
 
3
7
  Added support for the suppress / unsuppress methods [#49](https://github.com/customerio/customerio-ruby/pull/49)
data/README.md CHANGED
@@ -167,6 +167,38 @@ Deleting a device token will remove it from the associated customer to stop furt
167
167
  $customerio.delete_device(5, "my_device_token")
168
168
  ```
169
169
 
170
+ ### Suppress a user
171
+
172
+ Deletes the customer with the provided id if it exists and suppresses all future events and identifies for for that customer.
173
+
174
+ ```ruby
175
+ $customerio.suppress(5)
176
+ ```
177
+
178
+ ### Unsuppress a user
179
+
180
+ Start tracking events and identifies again for a previously suppressed customer. Note when a user is suppressed thier history is deleted and unsupressing them wil not recover that history.
181
+
182
+ ```ruby
183
+ $customerio.unsuppress(5)
184
+ ```
185
+
186
+ ### Add customers to a manual segment
187
+
188
+ Add the list of customer ids to the specified manual segment. If you send customer ids that don't exist yet in an add_to_segment request, we will automatically create customer profiles for the new customer ids.
189
+
190
+ ```ruby
191
+ $customerio.add_to_segment(segment_id=1,customer_ids=['1','2','3'])
192
+ ```
193
+
194
+ ### Remove customers from a manual segment
195
+
196
+ Remove the list of customer ids from the specified manual segment.
197
+
198
+ ```ruby
199
+ $customerio.remove_from_segment(segment_id=1,customer_ids=['1','2','3'])
200
+ ```
201
+
170
202
  ## Contributing
171
203
 
172
204
  1. Fork it
@@ -88,8 +88,38 @@ module Customerio
88
88
  verify_response(request(:delete, device_id_path(customer_id, device_id)))
89
89
  end
90
90
 
91
+ def add_to_segment(segment_id, customer_ids)
92
+ raise ParamError.new("segment_id must be an integer") unless segment_id.is_a? Integer
93
+ raise ParamError.new("customer_ids must be a list of values") unless customer_ids.is_a? Array
94
+
95
+ customer_ids = customer_ids.map{ |id| id.to_s }
96
+
97
+ verify_response(request(:post, add_to_segment_path(segment_id), {
98
+ :ids => customer_ids,
99
+ }))
100
+ end
101
+
102
+ def remove_from_segment(segment_id, customer_ids)
103
+ raise ParamError.new("segment_id must be an integer") unless segment_id.is_a? Integer
104
+ raise ParamError.new("customer_ids must be a list of values") unless customer_ids.is_a? Array
105
+
106
+ customer_ids = customer_ids.map{ |id| id.to_s }
107
+
108
+ verify_response(request(:post, remove_from_segment_path(segment_id), {
109
+ :ids => customer_ids,
110
+ }))
111
+ end
112
+
91
113
  private
92
114
 
115
+ def add_to_segment_path(segment_id)
116
+ "/api/v1/segments/#{segment_id}/add_customers"
117
+ end
118
+
119
+ def remove_from_segment_path(segment_id)
120
+ "/api/v1/segments/#{segment_id}/remove_customers"
121
+ end
122
+
93
123
  def device_path(customer_id)
94
124
  "/api/v1/customers/#{customer_id}/devices"
95
125
  end
@@ -1,3 +1,3 @@
1
1
  module Customerio
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -436,4 +436,50 @@ describe Customerio::Client do
436
436
  lambda { client.delete_device(5, nil) }.should raise_error(Customerio::Client::ParamError)
437
437
  end
438
438
  end
439
+
440
+ describe "#manual_segments" do
441
+
442
+ client = Customerio::Client.new("SITE_ID", "API_KEY", :json=>true)
443
+
444
+ it "allows adding customers to a manual segment" do
445
+ stub_request(:post, api_uri('/api/v1/segments/1/add_customers')).to_return(:status => 200, :body => "", :headers => {})
446
+
447
+ client.add_to_segment(1, ["customer1", "customer2", "customer3"])
448
+ end
449
+ it "requires a valid segment id when adding customers" do
450
+ stub_request(:post, api_uri('/api/v1/segments/1/add_customers')).to_return(:status => 200, :body => "", :headers => {})
451
+
452
+ lambda { client.add_to_segment("not_valid", ["customer1", "customer2", "customer3"]).should raise_error(Customerio::Client::ParamError) }
453
+ end
454
+ it "requires a valid customer list when adding customers" do
455
+ stub_request(:post, api_uri('/api/v1/segments/1/add_customers')).to_return(:status => 200, :body => "", :headers => {})
456
+
457
+ lambda { client.add_to_segment(1, "not_valid").should raise_error(Customerio::Client::ParamError) }
458
+ end
459
+ it "coerces non-string values to strings when adding customers" do
460
+ stub_request(:post, api_uri('/api/v1/segments/1/add_customers')).with(:body=>json({:ids=>["1", "2", "3"]})).to_return(:status => 200, :body => "", :headers => {})
461
+
462
+ client.add_to_segment(1, [1, 2, 3])
463
+ end
464
+ it "allows removing customers from a manual segment" do
465
+ stub_request(:post, api_uri('/api/v1/segments/1/remove_customers')).to_return(:status => 200, :body => "", :headers => {})
466
+
467
+ client.remove_from_segment(1, ["customer1", "customer2", "customer3"])
468
+ end
469
+ it "requires a valid segment id when removing customers" do
470
+ stub_request(:post, api_uri('/api/v1/segments/1/remove_customers')).to_return(:status => 200, :body => "", :headers => {})
471
+
472
+ lambda { client.remove_from_segment("not_valid", ["customer1", "customer2", "customer3"]).should raise_error(Customerio::Client::ParamError) }
473
+ end
474
+ it "requires a valid customer list when removing customers" do
475
+ stub_request(:post, api_uri('/api/v1/segments/1/remove_customers')).to_return(:status => 200, :body => "", :headers => {})
476
+
477
+ lambda { client.remove_from_segment(1, "not_valid").should raise_error(Customerio::Client::ParamError) }
478
+ end
479
+ it "coerces non-string values to strings when removing customers" do
480
+ stub_request(:post, api_uri('/api/v1/segments/1/remove_customers')).with(:body=>json({:ids=>["1", "2", "3"]})).to_return(:status => 200, :body => "", :headers => {})
481
+
482
+ client.remove_from_segment(1, [1, 2, 3])
483
+ end
484
+ end
439
485
  end
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: 2.1.0
4
+ version: 2.2.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: 2018-05-22 00:00:00.000000000 Z
11
+ date: 2018-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -141,3 +141,4 @@ summary: A ruby client for the Customer.io event API.
141
141
  test_files:
142
142
  - spec/client_spec.rb
143
143
  - spec/spec_helper.rb
144
+ has_rdoc: