intercom 3.3.0 → 3.4.0
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 +6 -3
- data/changes.txt +3 -0
- data/lib/intercom/client.rb +18 -5
- data/lib/intercom/service/tag.rb +1 -0
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/client_spec.rb +11 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d99183b501bb44dbe266b53e79f3f87c19598ec3
|
4
|
+
data.tar.gz: 60219b646fe7651c872bb0defc9e519538d76278
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75cf2e79bd16fbecd583c1870b88cb6434c2626049b005616b22c9702b8b55dca4eccf32dfcf080fa466b32081b6f14ae4f88156d43af865728ecbd33062ff8f
|
7
|
+
data.tar.gz: 6e70470e54a9b0c82e91ff6a598e49ace938ea7504aec800ebb0bf81cf8b710aa495d915b176d862290cf703371f2724c8a1ac967a8bf0a48755470181bde009
|
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.
|
25
|
+
gem 'intercom', "~> 3.4.0"
|
26
26
|
|
27
27
|
## Basic Usage
|
28
28
|
|
@@ -30,6 +30,9 @@ Using bundler:
|
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
intercom = Intercom::Client.new(app_id: 'my_app_id', api_key: 'my_api_key')
|
33
|
+
|
34
|
+
# With an OAuth token:
|
35
|
+
intercom = Intercom::Client.new(token: 'my_token')
|
33
36
|
```
|
34
37
|
|
35
38
|
You can get your `app_id` from the URL when you're logged into Intercom (it's the alphanumeric just after `/apps/`) and your API key from the API keys integration settings page (under your app settings - integrations in Intercom).
|
@@ -79,7 +82,7 @@ intercom.users.all.each {|user| puts %Q(#{user.email} - #{user.custom_attributes
|
|
79
82
|
intercom.users.all.map {|user| user.email }
|
80
83
|
|
81
84
|
#Bulk operations.
|
82
|
-
# Submit bulk job, to create users
|
85
|
+
# Submit bulk job, to create users, if any of the items in create_items match an existing user that user will be updated
|
83
86
|
intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@example.com"}, {user_id: 25, email: "bob@example.com"}])
|
84
87
|
# Submit bulk job, to delete users
|
85
88
|
intercom.users.submit_bulk_job(delete_items: [{user_id: 25, email: "alice@example.com"}, {user_id: 25, email: "bob@example.com"}])
|
@@ -328,7 +331,7 @@ The metadata key values in the example are treated as follows-
|
|
328
331
|
|
329
332
|
*NB:* This version of the gem reserves the field name `type` in Event data.
|
330
333
|
|
331
|
-
Bulk operations.
|
334
|
+
Bulk operations.
|
332
335
|
```ruby
|
333
336
|
# Submit bulk job, to create events
|
334
337
|
intercom.events.submit_bulk_job(create_items: [
|
data/changes.txt
CHANGED
data/lib/intercom/client.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Intercom
|
2
|
+
class MisconfiguredClientError < StandardError; end
|
2
3
|
class Client
|
3
4
|
include Options
|
4
|
-
attr_reader :base_url, :rate_limit_details
|
5
|
+
attr_reader :base_url, :rate_limit_details, :username_part, :password_part
|
5
6
|
|
6
7
|
class << self
|
7
8
|
def set_base_url(base_url)
|
@@ -13,9 +14,16 @@ module Intercom
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
def initialize(app_id: 'my_app_id', api_key: 'my_api_key')
|
17
|
-
|
18
|
-
|
17
|
+
def initialize(app_id: 'my_app_id', api_key: 'my_api_key', token: nil)
|
18
|
+
if token
|
19
|
+
@username_part = token
|
20
|
+
@password_part = ""
|
21
|
+
else
|
22
|
+
@username_part = app_id
|
23
|
+
@password_part = api_key
|
24
|
+
end
|
25
|
+
validate_credentials!
|
26
|
+
|
19
27
|
@base_url = 'https://api.intercom.io'
|
20
28
|
@rate_limit_details = {}
|
21
29
|
end
|
@@ -90,8 +98,13 @@ module Intercom
|
|
90
98
|
|
91
99
|
private
|
92
100
|
|
101
|
+
def validate_credentials!
|
102
|
+
error = MisconfiguredClientError.new("app_id and api_key must not be nil")
|
103
|
+
fail error if @username_part.nil?
|
104
|
+
end
|
105
|
+
|
93
106
|
def execute_request(request)
|
94
|
-
result = request.execute(@base_url, username: @
|
107
|
+
result = request.execute(@base_url, username: @username_part, secret: @password_part)
|
95
108
|
@rate_limit_details = request.rate_limit_details
|
96
109
|
result
|
97
110
|
end
|
data/lib/intercom/service/tag.rb
CHANGED
data/lib/intercom/version.rb
CHANGED
@@ -17,5 +17,16 @@ module Intercom
|
|
17
17
|
client.base_url.must_equal('https://api.intercom.io')
|
18
18
|
end
|
19
19
|
|
20
|
+
it 'should raise on nil credentials' do
|
21
|
+
proc { Client.new(app_id: nil, api_key: nil) }.must_raise MisconfiguredClientError
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'OAuth clients' do
|
25
|
+
it 'supports "token"' do
|
26
|
+
client = Client.new(token: 'foo')
|
27
|
+
client.username_part.must_equal('foo')
|
28
|
+
client.password_part.must_equal('')
|
29
|
+
end
|
30
|
+
end
|
20
31
|
end
|
21
32
|
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: 3.
|
4
|
+
version: 3.4.0
|
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:
|
18
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project: intercom
|
224
|
-
rubygems_version: 2.2.
|
224
|
+
rubygems_version: 2.2.5
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Ruby bindings for the Intercom API
|
@@ -246,3 +246,4 @@ test_files:
|
|
246
246
|
- spec/unit/intercom/traits/api_resource_spec.rb
|
247
247
|
- spec/unit/intercom/user_spec.rb
|
248
248
|
- spec/unit/intercom_spec.rb
|
249
|
+
has_rdoc:
|