intercom 3.5.6 → 3.5.7

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: 770a5bf74e5b55dff642112cf3225bd3e6846223
4
- data.tar.gz: b83208f0e90d695bba729b726d02a3140158b15b
3
+ metadata.gz: 6d86ee0111c267589f1aa6def23aa09c6f809621
4
+ data.tar.gz: 111d6098366a5ddcaa614182fa53bc9319fed8c5
5
5
  SHA512:
6
- metadata.gz: 3da6f640e5770f8bea1529d263f4d0f2ef3d6c24c036aa511e2e59632792eb1dc530e919d0e7603eb56d81070dde8e9e75fcf36e8ee33ccc957f1a14eda8ba63
7
- data.tar.gz: 435db00859f1f2bb060a20130847a4c97a045a5ae9c62247e940500e21e51b96f59a769389275696b672620cf3542ba3d66cc2ee40b3014c71f8016f0f4dca5c
6
+ metadata.gz: 6beb6afb91f74bc321c165cb49018a7f1d7640934b0f38a3fa0b00efa925097f2833543f553f5456e7bc692e383b6ce0cfdaa39e5e656d26767b3ccb67427eb7
7
+ data.tar.gz: f62b9dac85b825b399c46c40f116b404d8542dc12152cecd09cd8ad77b37e38fb504c267b04a5d6b6cd4f6acace3a71bd8db0380e41cdffe7452ab0450a4e6a4
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.5"
25
+ gem 'intercom', "~> 3.5.6"
26
26
 
27
27
  ## Basic Usage
28
28
 
@@ -329,6 +329,8 @@ intercom.events.create(
329
329
  }
330
330
  )
331
331
 
332
+ # Retrieve event list for user with id:'123abc'
333
+ intercom.events.find_all("type" => "user", "intercom_user_id" => "123abc")
332
334
 
333
335
  ```
334
336
 
data/changes.txt CHANGED
@@ -1,3 +1,8 @@
1
+ 3.5.7
2
+ - Add method to find all events for a user (@reidab)
3
+
4
+ 3.5.6
5
+
1
6
  3.5.5
2
7
  - Add scroll api for contacts
3
8
  - Add extra context to IntercomError
@@ -5,6 +5,7 @@ require 'intercom/api_operations/bulk/submit'
5
5
  module Intercom
6
6
  module Service
7
7
  class Event < BaseService
8
+ include ApiOperations::FindAll
8
9
  include ApiOperations::Save
9
10
  include ApiOperations::Bulk::Submit
10
11
 
@@ -67,7 +67,7 @@ module Intercom
67
67
  end
68
68
 
69
69
  def set_property(attribute, value)
70
- if typed_value?(value) && !custom_attribute_field?(attribute) && !message_from_field?(attribute, value) && !message_to_field?(attribute, value)
70
+ if typed_property?(attribute, value)
71
71
  value_to_set = Intercom::Lib::TypedJsonDeserializer.new(value).deserialize
72
72
  elsif flat_store_attribute?(attribute)
73
73
  value_to_set = Intercom::Lib::FlatStore.new(value)
@@ -89,6 +89,14 @@ module Intercom
89
89
  attribute.to_s == 'to' && value.is_a?(Hash) && value['type']
90
90
  end
91
91
 
92
+ def typed_property?(attribute, value)
93
+ typed_value?(value) &&
94
+ !custom_attribute_field?(attribute) &&
95
+ !message_from_field?(attribute, value) &&
96
+ !message_to_field?(attribute, value) &&
97
+ attribute != 'metadata'
98
+ end
99
+
92
100
  def typed_value?(value)
93
101
  value.is_a? Hash and !!value['type']
94
102
  end
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "3.5.6"
2
+ VERSION = "3.5.7"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -549,6 +549,30 @@ def test_conversation_count
549
549
  }
550
550
  end
551
551
 
552
+ def test_event
553
+ {
554
+ "type" => "event",
555
+ "event_name" => "invited-friend",
556
+ "created_at" => 1389913941,
557
+ "user_id" => "314159",
558
+ "metadata" => {
559
+ "type" => "user",
560
+ "invitee_email" => "pi@example.org",
561
+ "invite_code" => "ADDAFRIEND"
562
+ }
563
+ }
564
+ end
565
+
566
+ def test_event_list
567
+ {
568
+ "type" => "event.list",
569
+ "events" => [ test_event ],
570
+ "pages" => {
571
+ "next" => "https =>//api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550"
572
+ }
573
+ }
574
+ end
575
+
552
576
  def error_on_modify_frozen
553
577
  RUBY_VERSION =~ /1.8/ ? TypeError : RuntimeError
554
578
  end
@@ -6,6 +6,11 @@ describe "Intercom::Event" do
6
6
  let(:created_time) {Time.now - 300}
7
7
  let (:client) { Intercom::Client.new(app_id: 'app_id', api_key: 'api_key') }
8
8
 
9
+ it 'gets events for a user' do
10
+ client.expects(:get).with('/events', type: 'user', email: 'joe@example.com').returns(test_event_list)
11
+ client.events.find_all(type: 'user', email: 'joe@example.com').first
12
+ end
13
+
9
14
  it "creates an event with metadata" do
10
15
  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)
11
16
 
@@ -11,7 +11,11 @@ describe Intercom::Traits::ApiResource do
11
11
  "remote_created_at"=>103201,
12
12
  "created_at"=>1374056196,
13
13
  "user_count"=>1,
14
- "custom_attributes"=>{}}
14
+ "custom_attributes"=>{},
15
+ "metadata"=>{
16
+ "type"=>"user",
17
+ "color"=>"cyan"
18
+ }}
15
19
  end
16
20
  let(:api_resource) { DummyClass.new.extend(Intercom::Traits::ApiResource)}
17
21
 
@@ -29,6 +33,10 @@ describe Intercom::Traits::ApiResource do
29
33
  assert_equal Time.at(1374056196), api_resource.created_at
30
34
  end
31
35
 
36
+ it "treats 'metadata' as a plain hash, not a typed object" do
37
+ assert_equal Hash, api_resource.metadata.class
38
+ end
39
+
32
40
  it "dynamically defines accessors when a non-existent property is called that looks like a setter" do
33
41
  api_resource.wont_respond_to :spiders
34
42
  api_resource.spiders = 4
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.6
4
+ version: 3.5.7
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: 2016-10-24 00:00:00.000000000 Z
18
+ date: 2016-10-26 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  version: '0'
243
243
  requirements: []
244
244
  rubyforge_project: intercom
245
- rubygems_version: 2.4.8
245
+ rubygems_version: 2.6.1
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: Ruby bindings for the Intercom API