intercom 2.4.4 → 2.5.4
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/README.md +21 -1
- data/changes.txt +3 -0
- data/lib/intercom.rb +1 -0
- data/lib/intercom/api_operations/convert.rb +19 -0
- data/lib/intercom/api_operations/save.rb +12 -5
- data/lib/intercom/contact.rb +22 -0
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/contact_spec.rb +25 -0
- metadata +22 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cb2e27f3e7be79c2ad08dc54ab70fc0706dbc3c
|
4
|
+
data.tar.gz: 4ceabd2c867c299ed35cb1a38402ffa944c508fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15533df079a3388c672190e83d714d0999445f2c2d978f5905eeee01d9bad2254fe274ff5777d18047c9164e965333457e8124a1dc4062f8686c58d142ed6954
|
7
|
+
data.tar.gz: bc9d73e3c607f6052ca297330dc062e93cb521a6e8e1be8769776d129e20e717efd93b8dc09e36ab95a08fee68487f2878ed31c14fceb4673bf01edfc9a5774d
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ This version of the gem is compatible with `Ruby 2.1`, `Ruby 2.0` & `Ruby 1.9.3`
|
|
19
19
|
|
20
20
|
Using bundler:
|
21
21
|
|
22
|
-
gem 'intercom', "~> 2.
|
22
|
+
gem 'intercom', "~> 2.5.4"
|
23
23
|
|
24
24
|
## Basic Usage
|
25
25
|
|
@@ -62,6 +62,8 @@ user = Intercom::User.find(:user_id => "1")
|
|
62
62
|
user = Intercom::User.find(:id => "1")
|
63
63
|
# Create a user
|
64
64
|
user = Intercom::User.create(:email => "bob@example.com", :name => "Bob Smith", :signed_up_at => Time.now.to_i)
|
65
|
+
# Delete a user
|
66
|
+
deleted_user = Intercom::User.find(:id => "1").delete
|
65
67
|
# Update custom_attributes for a user
|
66
68
|
user.custom_attributes["average_monthly_spend"] = 1234.56; user.save
|
67
69
|
# Perform incrementing
|
@@ -296,6 +298,24 @@ The metadata key values in the example are treated as follows-
|
|
296
298
|
- order_number: a Rich Link (value contains 'url' and 'value' keys)
|
297
299
|
- price: An Amount in US Dollars (value contains 'amount' and 'currency' keys)
|
298
300
|
|
301
|
+
*NB:* This version of the gem reserves the field name `type` in Event data.
|
302
|
+
|
303
|
+
### Contacts
|
304
|
+
|
305
|
+
`Contacts` represent logged out users of your application.
|
306
|
+
|
307
|
+
```ruby
|
308
|
+
# Create a contact
|
309
|
+
contact = Intercom::Contact.create(email: "some_contact@example.com")
|
310
|
+
|
311
|
+
# Update a contact
|
312
|
+
contact.custom_attributes['foo'] = 'bar'
|
313
|
+
contact.save
|
314
|
+
|
315
|
+
# Find contacts by email
|
316
|
+
contacts = Intercom::Contact.find_all(email: "some_contact@example.com")
|
317
|
+
```
|
318
|
+
|
299
319
|
### Subscriptions
|
300
320
|
|
301
321
|
Subscribe to events in Intercom to receive webhooks.
|
data/changes.txt
CHANGED
data/lib/intercom.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'intercom/traits/api_resource'
|
2
|
+
|
3
|
+
module Intercom
|
4
|
+
module ApiOperations
|
5
|
+
module Convert
|
6
|
+
def convert(user)
|
7
|
+
from_response(
|
8
|
+
Intercom.post(
|
9
|
+
"/contacts/convert",
|
10
|
+
{
|
11
|
+
contact: { user_id: user_id },
|
12
|
+
user: user.identity_hash
|
13
|
+
}
|
14
|
+
)
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -5,7 +5,14 @@ module Intercom
|
|
5
5
|
module Save
|
6
6
|
|
7
7
|
module ClassMethods
|
8
|
-
|
8
|
+
PARAMS_NOT_PROVIDED = Object.new
|
9
|
+
def create(params = PARAMS_NOT_PROVIDED)
|
10
|
+
if self.ancestors.include?(Intercom::Contact) && params == PARAMS_NOT_PROVIDED
|
11
|
+
params = Hash.new
|
12
|
+
elsif params == PARAMS_NOT_PROVIDED
|
13
|
+
raise ArgumentError, '.create requires 1 parameter'
|
14
|
+
end
|
15
|
+
|
9
16
|
instance = self.new(params)
|
10
17
|
instance.mark_fields_as_changed!(params.keys)
|
11
18
|
instance.save
|
@@ -26,6 +33,10 @@ module Intercom
|
|
26
33
|
from_response(response) if response # may be nil we received back a 202
|
27
34
|
end
|
28
35
|
|
36
|
+
def identity_hash
|
37
|
+
respond_to?(:identity_vars) ? SliceableHash.new(to_hash).slice(*(identity_vars.map(&:to_s))) : {}
|
38
|
+
end
|
39
|
+
|
29
40
|
private
|
30
41
|
|
31
42
|
def id_present?
|
@@ -35,10 +46,6 @@ module Intercom
|
|
35
46
|
def posted_updates?
|
36
47
|
respond_to?(:update_verb) && update_verb == 'post'
|
37
48
|
end
|
38
|
-
|
39
|
-
def identity_hash
|
40
|
-
respond_to?(:identity_vars) ? SliceableHash.new(to_hash).slice(*(identity_vars.map(&:to_s))) : {}
|
41
|
-
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'intercom/api_operations/count'
|
2
|
+
require 'intercom/api_operations/load'
|
3
|
+
require 'intercom/api_operations/find'
|
4
|
+
require 'intercom/api_operations/find_all'
|
5
|
+
require 'intercom/api_operations/save'
|
6
|
+
require 'intercom/api_operations/convert'
|
7
|
+
require 'intercom/traits/api_resource'
|
8
|
+
|
9
|
+
module Intercom
|
10
|
+
class Contact
|
11
|
+
include ApiOperations::Load
|
12
|
+
include ApiOperations::Find
|
13
|
+
include ApiOperations::FindAll
|
14
|
+
include ApiOperations::Save
|
15
|
+
include ApiOperations::Convert
|
16
|
+
include Traits::ApiResource
|
17
|
+
|
18
|
+
def identity_vars ; [:email, :user_id] ; end
|
19
|
+
def flat_store_attributes ; [:custom_attributes] ; end
|
20
|
+
def update_verb; 'put' ; end
|
21
|
+
end
|
22
|
+
end
|
data/lib/intercom/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Intercom::Contact" do
|
4
|
+
it 'should not throw ArgumentErrors when there are no parameters' do
|
5
|
+
Intercom.expects(:post)
|
6
|
+
Intercom::Contact.create
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'converting' do
|
10
|
+
let(:contact) { Intercom::Contact.from_api(user_id: 'contact_id') }
|
11
|
+
let(:user) { Intercom::User.from_api(id: 'user_id') }
|
12
|
+
|
13
|
+
it do
|
14
|
+
Intercom.expects(:post).with(
|
15
|
+
"/contacts/convert",
|
16
|
+
{
|
17
|
+
contact: { user_id: contact.user_id },
|
18
|
+
user: user.identity_hash
|
19
|
+
}
|
20
|
+
).returns(test_user)
|
21
|
+
|
22
|
+
contact.convert(user)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
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: 2.
|
4
|
+
version: 2.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben McRedmond
|
@@ -15,76 +15,76 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2015-
|
18
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|
22
22
|
requirement: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.4'
|
27
27
|
type: :development
|
28
28
|
prerelease: false
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '5.4'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rake
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.3'
|
41
41
|
type: :development
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.3'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: mocha
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: fakeweb
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.3'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: json
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.8'
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '1.8'
|
90
90
|
description: 'Intercom (https://www.intercom.io) is a customer relationship management
|
@@ -103,8 +103,8 @@ executables: []
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
-
- .gitignore
|
107
|
-
- .travis.yml
|
106
|
+
- ".gitignore"
|
107
|
+
- ".travis.yml"
|
108
108
|
- Gemfile
|
109
109
|
- MIT-LICENSE
|
110
110
|
- README.md
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/ext/sliceable_hash.rb
|
116
116
|
- lib/intercom.rb
|
117
117
|
- lib/intercom/admin.rb
|
118
|
+
- lib/intercom/api_operations/convert.rb
|
118
119
|
- lib/intercom/api_operations/count.rb
|
119
120
|
- lib/intercom/api_operations/delete.rb
|
120
121
|
- lib/intercom/api_operations/find.rb
|
@@ -124,6 +125,7 @@ files:
|
|
124
125
|
- lib/intercom/api_operations/save.rb
|
125
126
|
- lib/intercom/collection_proxy.rb
|
126
127
|
- lib/intercom/company.rb
|
128
|
+
- lib/intercom/contact.rb
|
127
129
|
- lib/intercom/conversation.rb
|
128
130
|
- lib/intercom/count.rb
|
129
131
|
- lib/intercom/errors.rb
|
@@ -157,6 +159,7 @@ files:
|
|
157
159
|
- spec/unit/intercom/admin_spec.rb
|
158
160
|
- spec/unit/intercom/collection_proxy_spec.rb
|
159
161
|
- spec/unit/intercom/company_spec.rb
|
162
|
+
- spec/unit/intercom/contact_spec.rb
|
160
163
|
- spec/unit/intercom/event_spec.rb
|
161
164
|
- spec/unit/intercom/lib/flat_store_spec.rb
|
162
165
|
- spec/unit/intercom/message_spec.rb
|
@@ -178,17 +181,17 @@ require_paths:
|
|
178
181
|
- lib
|
179
182
|
required_ruby_version: !ruby/object:Gem::Requirement
|
180
183
|
requirements:
|
181
|
-
- -
|
184
|
+
- - ">="
|
182
185
|
- !ruby/object:Gem::Version
|
183
186
|
version: 1.9.3
|
184
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
188
|
requirements:
|
186
|
-
- -
|
189
|
+
- - ">="
|
187
190
|
- !ruby/object:Gem::Version
|
188
191
|
version: '0'
|
189
192
|
requirements: []
|
190
193
|
rubyforge_project: intercom
|
191
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.2.3
|
192
195
|
signing_key:
|
193
196
|
specification_version: 4
|
194
197
|
summary: Ruby bindings for the Intercom API
|
@@ -197,6 +200,7 @@ test_files:
|
|
197
200
|
- spec/unit/intercom/admin_spec.rb
|
198
201
|
- spec/unit/intercom/collection_proxy_spec.rb
|
199
202
|
- spec/unit/intercom/company_spec.rb
|
203
|
+
- spec/unit/intercom/contact_spec.rb
|
200
204
|
- spec/unit/intercom/event_spec.rb
|
201
205
|
- spec/unit/intercom/lib/flat_store_spec.rb
|
202
206
|
- spec/unit/intercom/message_spec.rb
|
@@ -208,3 +212,4 @@ test_files:
|
|
208
212
|
- spec/unit/intercom/traits/api_resource_spec.rb
|
209
213
|
- spec/unit/intercom/user_spec.rb
|
210
214
|
- spec/unit/intercom_spec.rb
|
215
|
+
has_rdoc:
|