intercom 3.5.10 → 3.5.11

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: 0f98bf7f9725ad035949ca88859ba807a6323a83
4
- data.tar.gz: 97e46a4507500d311495e11114fb80d0715cb0a0
3
+ metadata.gz: 3017e9c7947af1ad08fba93c5d5cd16d4f491b5b
4
+ data.tar.gz: e34343229866f215a24a1888a5d10164934fe881
5
5
  SHA512:
6
- metadata.gz: 8c83c5d9c5ad9d4844b5b8f7c3602e6bf76cbbb9e9836b264acbdcfdb5e3567310c1441e23c7cd0b2dac30f0200bbea46175fe9eea5c130aa49d16e9ca5cd2d4
7
- data.tar.gz: b480c171fd98135e719c37be86b0d13f7288f65130583d863afad3dd32acdc42de3e66be8941620047ba57db9fc54548b10307cbed55bd5278563825e6728de0
6
+ metadata.gz: d54158812a58f552cf5bced5b3307d8a0297a9b31c007e29cb38503272813591787f220f613625ff2b01980243a12f5a49771e779a4e457ad4759d4e14e02c10
7
+ data.tar.gz: 912b3598890f7d1416045ca14fdb1c672cd5e46eba59f799ac09a3c5641498cea4704c826e536c630d867c3ecc377891aedeb6a4c67cf240365db65084b7fb11
data/README.md CHANGED
@@ -22,7 +22,7 @@ This version of the gem is compatible with `Ruby 2.1` and above.
22
22
 
23
23
  Using bundler:
24
24
 
25
- gem 'intercom', '~> 3.5.9'
25
+ gem 'intercom', '~> 3.5.10'
26
26
 
27
27
  ## Basic Usage
28
28
 
data/RELEASING.md ADDED
@@ -0,0 +1,9 @@
1
+ # Releasing Intercom
2
+
3
+ We use https://github.com/svenfuchs/gem-release to tag, bump, and release new versions
4
+
5
+ Please add a line to changes.txt before you release a new version.
6
+
7
+ ```
8
+ gem bump --tag --release
9
+ ```
data/changes.txt CHANGED
@@ -1,3 +1,6 @@
1
+ 3.5.10
2
+ - Add Support for find_all events pagination (@jkeyes)
3
+
1
4
  3.5.9
2
5
  - Fix event create method
3
6
 
@@ -16,7 +16,7 @@ module Intercom
16
16
  finder_details[:url] = "/#{collection_name}"
17
17
  finder_details[:params] = params
18
18
  end
19
- ClientCollectionProxy.new(collection_name, finder_details: finder_details, client: @client)
19
+ collection_proxy_class.new(collection_name, finder_details: finder_details, client: @client)
20
20
  end
21
21
 
22
22
  private
@@ -1,3 +1,5 @@
1
+ require 'intercom/client_collection_proxy'
2
+
1
3
  module Intercom
2
4
  module Service
3
5
  class BaseService
@@ -11,6 +13,10 @@ module Intercom
11
13
  raise NotImplementedError
12
14
  end
13
15
 
16
+ def collection_proxy_class
17
+ Intercom::ClientCollectionProxy
18
+ end
19
+
14
20
  def from_api(api_response)
15
21
  object = collection_class.new
16
22
  object.from_response(api_response)
@@ -1,8 +1,16 @@
1
+ require 'intercom/client_collection_proxy'
1
2
  require 'intercom/service/base_service'
2
3
  require 'intercom/api_operations/save'
3
4
  require 'intercom/api_operations/bulk/submit'
4
5
 
5
6
  module Intercom
7
+ class EventCollectionProxy < ClientCollectionProxy
8
+
9
+ def paging_info_present?(response_hash)
10
+ !!(response_hash['pages'])
11
+ end
12
+ end
13
+
6
14
  module Service
7
15
  class Event < BaseService
8
16
  include ApiOperations::FindAll
@@ -12,6 +20,10 @@ module Intercom
12
20
  def collection_class
13
21
  Intercom::Event
14
22
  end
23
+
24
+ def collection_proxy_class
25
+ Intercom::EventCollectionProxy
26
+ end
15
27
  end
16
28
  end
17
29
  end
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "3.5.10"
2
+ VERSION = "3.5.11"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -568,11 +568,23 @@ def test_event_list
568
568
  "type" => "event.list",
569
569
  "events" => [ test_event ],
570
570
  "pages" => {
571
- "next" => "https =>//api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550"
571
+ "next" => "https://api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550"
572
572
  }
573
573
  }
574
574
  end
575
575
 
576
+ def page_of_events(include_next_link=false)
577
+ {
578
+ "type" => "event.list",
579
+ "events" => [ test_event ],
580
+ "pages" =>
581
+ {
582
+ "next" => (include_next_link ? "https://api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550" : nil),
583
+ }
584
+ }
585
+ end
586
+
587
+
576
588
  def error_on_modify_frozen
577
589
  RUBY_VERSION =~ /1.8/ ? TypeError : RuntimeError
578
590
  end
@@ -11,6 +11,25 @@ describe "Intercom::Event" do
11
11
  client.events.find_all(type: 'user', email: 'joe@example.com').first
12
12
  end
13
13
 
14
+ it "has the correct collection proxy class" do
15
+ client.events.collection_proxy_class.must_equal Intercom::EventCollectionProxy
16
+ end
17
+
18
+ it "stops iterating if no next link" do
19
+ client.expects(:get).with("/events", type: 'user', email: 'joe@example.com').returns(page_of_events(false))
20
+ event_names = []
21
+ client.events.find_all(type: 'user', email: 'joe@example.com').each { |event| event_names << event.event_name }
22
+ event_names.must_equal %W(invited-friend)
23
+ end
24
+
25
+ it "keeps iterating if next link" do
26
+ client.expects(:get).with("/events", type: 'user', email: 'joe@example.com').returns(page_of_events(true))
27
+ client.expects(:get).with("https://api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550", {}).returns(page_of_events(false))
28
+ event_names = []
29
+ client.events.find_all(type: 'user', email: 'joe@example.com').each { |event| event_names << event.event_name }
30
+ event_names.must_equal %W(invited-friend invited-friend)
31
+ end
32
+
14
33
  it "creates an event with metadata" do
15
34
  client.expects(:post).with('/events', {'event_name' => 'Eventful 1', 'created_at' => created_time.to_i, 'email' => 'joe@example.com', 'metadata' => {'invitee_email' => 'pi@example.org', :invite_code => 'ADDAFRIEND', 'found_date' => 12909364407}}).returns(:status => 202)
16
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intercom
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.10
4
+ version: 3.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben McRedmond
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2017-01-10 00:00:00.000000000 Z
18
+ date: 2017-02-09 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest
@@ -137,6 +137,7 @@ files:
137
137
  - Gemfile
138
138
  - MIT-LICENSE
139
139
  - README.md
140
+ - RELEASING.md
140
141
  - Rakefile
141
142
  - changes.txt
142
143
  - intercom.gemspec
@@ -242,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
243
  version: '0'
243
244
  requirements: []
244
245
  rubyforge_project: intercom
245
- rubygems_version: 2.4.8
246
+ rubygems_version: 2.6.1
246
247
  signing_key:
247
248
  specification_version: 4
248
249
  summary: Ruby bindings for the Intercom API
@@ -269,4 +270,3 @@ test_files:
269
270
  - spec/unit/intercom/user_spec.rb
270
271
  - spec/unit/intercom/visitors_spec.rb
271
272
  - spec/unit/intercom_spec.rb
272
- has_rdoc: